/// class PD.Manage.Modules.Resources.FolderCreateDialogCommand

PD.Manage.Modules.Resources.FolderCreateDialogCommand =
PD.Commands.Command.extend({

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

    setDefaults: function () {

        this.props("id", "folder/create-dialog");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("folder_plus.png"));
        this.props("label", "Add Folder");
        this.props("tooltip", "Create a new folder.<br/><br/>The new folder will be added<br/>to the currently selected folder.");
        this.props("canExecute", true);

        this.state("targetFolderId", null);

    },

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

    execute: function (e) {
        this._super(e);
        this._showDialog();
    },

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

    _showDialog: function () {

        ProspectDirector.Web.UI.FeatureSets.NHibTargetEditorDialog.open({
            config: {
                title: "New Folder",
                height: "400px",
                width: "450px"
            },
            data: {
                targetArbiter: "ProspectDirector.Web.Manage.Modules.Resources.FolderArbiter",
                targetType: "ProspectDirector.Web.Manage.Modules.Resources.FolderUIO",
                layoutType: ProspectDirector.Web.UI.FeatureSets.Layouts.TabStripLayout,
                properties: {
                    parentId: this.state("targetFolderId")
                }
            },
            callbacks: {
                ok: function (sender, e) {
                    PD.context.get_default().get_events().publish("folder/add", e.target);
                }
            }
        });

    },

    _enabledAndCanExecute: function (value) {
        this.props("enabled", value);
        this.props("canExecute", value);
    }

});