/// class PD.Manage.Modules.ObjectModel.ProcessNodeDeleteCommand

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

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

    setDefaults: function () {

        this.props("id", "process-node/delete");
        this.props("enabled", false);
        this.props("icon", PD.Path.to16x16("delete.png"));
        this.props("label", "Delete");
        this.props("tooltip", "Delete the selected node.");

        this.state("nodeId", null);
        this.state("nodeType", null);

    },

    setState: function (state) {
        this._super(state);
        this.props("enabled", this.state("nodeId") != null && this.state("nodeType") != "Process");
    },

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

        PD.Web.UI.MessageDialog.warn({
            title: "Delete Process Node",
            message: "Delete the selected process node and all of its children?",
            ok: $.proxy(this._executeDeletion, this)
        });

    },

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

    _executeDeletion: function (e) {

        var nodeId = this.state("nodeId"),
            service = new PD.Manage.Services.ProcessModelService();

        e.close();

        service.deleteNode(nodeId, function () {
            PD.context.get_default().get_events().publish("process-node/delete", {
                nodeId: nodeId
            });
        });

    }

});