/// class PD.Manage.Modules.ReportEditDialogCommand

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

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

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

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

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

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

        this._showDialog(report.id);

    },

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

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

    _showDialog: function (id) {

        ProspectDirector.Web.UI.FeatureSets.NHibTargetEditorDialog.open({
            config: {
                title: "Report Properties"
            },
            data: {
                targetArbiter: "ProspectDirector.Web.Manage.Modules.Reports.ReportArbiter",
                targetType: "ProspectDirector.Web.Manage.Modules.Reports.ReportUIO",
                layoutType: ProspectDirector.Web.UI.FeatureSets.Layouts.TabStripLayout,
                targetId: id
            },
            callbacks: {
                ok: function (sender, e) {
                    PD.context.get_default().get_events().publish("report/edit", {
                        id: e.target.id
                    });
                }
            }
        });

    }

});