/// class PD.Manage.Modules.ViewEditDialogCommand

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

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

    setDefaults: function () {
        this.props("id", "view/edit-dialog");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("pencil.png"));
        this.props("label", "Edit");
        this.props("tooltip", "Edit the selected View.");
        this.state("view", null);
    },

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

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

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

        this._showDialog(view.id, view.name);

    },

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

    _isEnabled: function () {
        return this.state("view") != null;
    },

    _showDialog: function (id, name) {

        ProspectDirector.Web.UI.FeatureSets.NHibTargetEditorDialog.open({
            config: {
                title: "View - " + name
            },
            data: {
                layoutType: ProspectDirector.Web.UI.FeatureSets.Layouts.TabStripLayout,
                targetArbiter: "ProspectDirector.Web.Manage.Modules.Views.ViewArbiter",
                targetType: "ProspectDirector.Web.Manage.Modules.Views.ViewUIO",
                targetId: id
            },
            callbacks: {
                ok: function (sender, e) {

                    PD.context.get_default().get_events().publish("view/edit", {
                        id: id
                    });

                }
            }
        });

    }

});
