/// class PD.Manage.Modules.ExtensionColumnCreateDialogCommand

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

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

    setDefaults: function () {

        this.props("id", "extension-column/create-dialog");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("table_selection_column_plus.png"));
        this.props("label", "New");
        this.props("tooltip", "Add a new Column to the selected Extension.");

        this.state("extension", null);
        this.state("extensionColumn", null);

    },

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

        var that = this;
        var extension = this.state("extension");

        ProspectDirector.Web.UI.FeatureSets.NHibTargetEditorDialog.open({
            config: {
                title: "New Column",
                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,
                properties: {
                    extensionId: parseInt(extension.id)
                }
            },
            callbacks: {
                ok: function (sender, e) {

                    PD.context
                        .get_default()
                        .get_events()
                        .publish("extension-column/create", {
                            id: e.target.id
                        });

                }
            }
        });

    },

    isEnabled: function () {
        return this.state("extension") != null
            && this.state("extension").id != null;
    },

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

    _showExtensionColumnEditDialog: function (id) {

        ProspectDirector.Modules.Extensions.ExtensionColumnPropertiesDialog.show({
            params: {
                id: id
            },
            callbacks: {
                ok: function (sender, e) {
                    PD.context.get_default().get_events().publish("extension-column/update", {
                        id: id
                    });
                }
            }
        });

    }

});