/// class PD.Manage.Modules.SelectionListItemCreateDialogCommand

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

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

    setDefaults: function () {

        this.props("id", "selection-list-item/create-dialog");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("plus.png"));
        this.props("label", "New");
        this.props("tooltip", "Add a new Item to the selected Selection List.");

        this.state("selectionList", null);

    },

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

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

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

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

        ProspectDirector.Web.UI.FeatureSets.NHibTargetEditorDialog.open({
            config: {
                title: "New Selection List Item",
                height: "450px",
                width: "450px"
            },
            data: {
                targetArbiter: "ProspectDirector.Web.Manage.Modules.Extensions.SelectionListItemArbiter",
                targetType: "ProspectDirector.Web.Manage.Modules.Extensions.SelectionListItemUIO",
                layoutType: ProspectDirector.Web.UI.FeatureSets.Layouts.TabStripLayout,
                properties: {
                    listId: parseInt(selectionList.id)
                }
            },
            callbacks: {
                ok: function (sender, e) {
                    PD.context
                        .get_default()
                        .get_events()
                        .publish("selection-list-item/create", {
                            id: e.target.id
                        });
                }
            }
        });

    }

});