/// class PD.Manage.Modules.ExtensionColumnPropertiesDialogCommand

PD.Manage.Modules.ExtensionColumnPropertiesDialogCommand =
PD.Commands.Command.extend({

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

    init: function (options) {
        this._super(options);

        this.props("id", "extension-column/properties-dialog");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("table_selection_column_edit.png"));
        this.props("label", "Edit");
        this.props("tooltip", "Edit the selected Column.");
        this.props("visible", true);

        this.state("extensionColumns", null);

    },

    setState: function (state) {
        this._super(state);
        this.props("enabled", this.isEnabled());
    },

    execute: function (e) {
        this._super(e);

        var extensionColumn = _.first(this.state("extensionColumns"));

        ProspectDirector.Web.UI.FeatureSets.NHibTargetEditorDialog.open({
            config: {
                title: "Edit Column - " + extensionColumn.name,
                height: "550px",
                width: "550px"
            },
            data: {
                targetArbiter: "ProspectDirector.Web.Manage.Modules.Extensions.ColumnArbiter",
                targetType: "ProspectDirector.Web.Manage.Modules.Extensions.ColumnUIO",
                layoutType: ProspectDirector.Web.UI.FeatureSets.Layouts.TabStripLayout,
                targetId: extensionColumn.id
            },
            callbacks: {
                ok: function (sender, e) {
                    PD.context.get_default().get_events().publish("extension/update", {
                        id: extensionColumn.id
                    });
                }
            }
        });

    },

    isEnabled: function () {

        var extensionColumns = this.state("extensionColumns");

        return extensionColumns != null
            && _.isArray(extensionColumns)
            && extensionColumns.length === 1;

    }

});
