/// class ProspectDirector.Web.UI.FeatureSets.EditorBase

/**
[NEEDS DOCUMENTATION]
@class EditorBase
@namespace Web.UI.FeatureSets
@constructor
**/
ProspectDirector.Web.UI.FeatureSets.EditorBase = Class.extend({

    //==============================
    // FIELDS
    //==============================

    _id: null,
    _options: null,

    //==============================
    // CONSTRUCTOR
    //==============================

    init: function (options) {
        this._options = options;
        this._id = uuid.v4();
        this.get_feature().get_featureSet().on("change", $.proxy(this._featureSet_onChange, this));
    },

    //==============================
    // PROPERTIES
    //==============================

    /**
    @public
    @property get_container
    @type {jQuery}
    **/
    get_container: function () {
        return $("#" + this.getId());
    },

    /**
    @public
    @property get_definition
    @type {Web.UI.FeatureSets.EditorDefinition}
    **/
    get_definition: function () {
        return this.get_options().definition;
    },

    /**
    @public
    @property get_domNode
    @type {jQuery}
    **/
    get_domNode: function () {
        return $("#" + this.getId());
    },

    /**
    @public
    @property get_feature
    @type {Web.UI.FeatureSets.Feature}
    **/
    get_feature: function () {
        return this.get_definition().get_feature();
    },

    /**
    @public
    @property get_featureSet
    @type {Web.UI.FeatureSets.FeatureSet}
    **/
    get_featureSet: function () {
        return this.get_feature().get_featureSet();
    },

    /**
    @public
    @property get_data
    @type {Object}
    **/
    get_data: function () {
        return this.get_definition().get_feature().get_data();
    },

    /**
    @public
    @property get_init
    @type {Object}
    **/
    get_init: function () {
        return this.get_options().init;
    },

    /**
    @public
    @property get_options
    @type {Object}
    **/
    get_options: function () {
        return this._options;
    },

    /**
    @public
    @property get_eventBus
    @type Web.UI.EventBus
    **/
    get_eventBus: function () {
        return this.get_options().eventBus;
    },

    get_input: function () {
        return $("#" + this.getId());
    },

    //==============================
    // EVENT HANDLERS
    //==============================

    /**
    @protected
    @method _featureSet_onChange
    **/
    _featureSet_onChange: function (e, data) {
        //overridable
    },

    //==============================
    // PUBLIC METHODS
    //==============================

    /**
    @public
    @method setValue
    @param key {String}
    @param value {Object}
    **/
    setValue: function (key, value) {
        this.get_feature().setValue(key, value);
    },

    /**
    @public
    @method getValue
    @param key {String}
    @return {Object}
    **/
    getValue: function (key) {
        return this.get_feature().getValue(key);
    },

    /**
    @public
    @method setRemoteValue
    @param key {String}
    @return {Boolean}
    **/
    setRemoteValue: function (key, value) {
        return this.get_featureSet().setValue(key, value);
    },

    /**
    @public
    @method getRemoteValue
    @param key {String}
    @return {Object}
    **/
    getRemoteValue: function (key) {
        return this.get_featureSet().getValue(key);
    },

    /**
    @public
    @method validateValue
    @param key {String}
    @param validators {Array}
    **/
    validateValue: function (key, validators) {
        
    },

    /**
    @public
    @method activate
    **/
    activate: function () {
        //must override
    },

    /**
    @public
    @method focus
    **/
    focus: function () {
        //must override
    },

    getId: function () {
        return this._formatId();
    },

    /**
    @public
    @method render
    **/
    render: function () {
        return "";
    },

    /**
    @public
    @method commit
    **/
    commit: function () {

    },

    /**
    @public
    @method setValidationErrors
    @param validationErrors {Web.UI.FeatureSets.ValidationErrorCollection}
    **/
    setValidationErrors: function (validationErrors) {
        //overridable
    },

    onValidationError: function (validationError) {
        //overridable
    },

    onValidationErrors: function (validationErrors) {
        //overridable
    },

    destroy: function () {
        
    },

    //==============================
    // PRIVATE METHODS
    //==============================

    _formatId: function () {
        return this._id.replace(/-/g, "_")
    }

});
