/// class PD.Manage.Modules.Resources.FilePropertiesDialogCommand
/// using PD.Manage.Modules.Resources.ResourceCommand

PD.Manage.Modules.Resources.FilePropertiesDialogCommand =
PD.Manage.Modules.Resources.ResourceCommand.extend({

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

    setDefaults: function () {
        this._super();
        this.props("id", "file/properties-dialog");
        this.props("enabled", false);
        this.props("icon", PD.Path.to16x16("pencil.png"));
        this.props("label", "Edit");
        this.props("tooltip", "Edit the properties of the selected file.");
    },

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

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

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

    _isEnabled: function () {

        var result = false,
            resource = _.first(this.getResources());

        if (resource != null) {
            result = resource.type === "file";
        }

        return result && this.hasSelections() && !this.isMultiSelect();

    },

    _showDialog: function () {

        var that = this,
            resource = _.first(this.getResources());

        ProspectDirector.Web.UI.FeatureSets.NHibTargetEditorDialog.open({
            config: {
                title: "File Properties",
                height: "400px",
                width: "450px"
            },
            data: {
                targetArbiter: "ProspectDirector.Web.Manage.Modules.Resources.FileArbiter",
                targetType: "ProspectDirector.Web.Manage.Modules.Resources.FileUIO",
                targetId: resource.id,
                layoutType: ProspectDirector.Web.UI.FeatureSets.Layouts.TabStripLayout
            },
            callbacks: {
                ok: function (sender, e) {

                    PD.context.get_default().get_events().publish("file/edit", {
                        resourceId: resource.id,
                        resourceType: resource.type
                    });

                }
            }
        });

    }

});