/// class ProspectDirector.Web.UI.FeatureSets.Editors.SelectionListEditor
/// using ProspectDirector.Web.UI.FeatureSets.Editors.CompositeEditor

/**
[NEEDS DOCUMENTATION]
@constructor
@class SelectionListEditor
@namespace Web.UI.FeatureSets.Editors
@extends Web.UI.FeatureSets.Editors.CompositeEditor
**/
ProspectDirector.Web.UI.FeatureSets.Editors.SelectionListEditor =
ProspectDirector.Web.UI.FeatureSets.Editors.CompositeEditor.extend({

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

    get_input: function () {
        return this.get_element().find("INPUT[type=text]");
    },

    get_button: function () {
        return this.get_element().find("BUTTON");
    },

    //==============================
    // EVENT HANDLERS
    //==============================
    
    _button_onClick: function () {

        var that = this;

        PD.Manage.Modules.Extensions.SelectionListSelectorDialog.open({
            callbacks: {
                ok: function (sender, e) {
                    that.setPrimaryValue(e.id);
                    that.setValue("listName", e.name);
                    that.updateUI(e.name);
                }
            }
        });

    },

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

    updateUI: function (value) {
        this.get_input().val(value);
    },

    //==============================
    // OVERRIDDEN METHODS
    //==============================

    activate: function () {
        this._super();

        this.updateUI(this.getValue("listName"));
        
    },

    render: function () {

        var definition = this.get_definition().get_data();
        var disabled = definition.disabled ? "disabled" : "";
        
        return "<div id='" + this.getId() + "' class='-pd-micro-editor-composite'>" +
            "<input type='text' style='padding-left:5px;' " + disabled + "/>" +
            "<input type='button' value='...' " + disabled + "/>" +
        "</div>";
    }

});