/// class PD.Manage.Modules.ObjectModel.ProcessDeleteCommand

PD.Manage.Modules.ObjectModel.ProcessDeleteCommand =
PD.Commands.Command.extend({

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

    setDefaults: function () {

        this.props("id", "process/delete");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("DELETE.PNG"));
        this.props("label", "Delete");
        this.props("tooltip", "Delete the selected Process.");

        this.state("processId", null);
        this.state("processName", null);

    },

    setState: function (state) {
        this._super(state);
        this.props("enabled", this.state("processId") != null)
    },

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

        var that = this,
            processId = this.state("processId"),
            processName = this.state("processName");

        PD.Web.UI.MessageDialog.warn({
            title: "Delete Process",
            message: "Delete the \"" + processName + "\" process?",
            ok: function (e) {
                that._executeDeletion(e, processId)
            }
        });

    },

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

    _executeDeletion: function (e, processId) {

        var service = new PD.Manage.Services.ProcessService();

        e.close();

        service.deleteProcess(processId, function (data) {

            PD.context.get_default().get_commands().setState({
                processId: null,
                processName: null
            });

            PD.context.get_default().get_events().publish("process/delete", {
                id: processId
            });

        });

    }

});