/// class PD.Manage.Modules.LicenseApplyCommand

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

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

    setDefaults: function () {
        this.props("id", "license/apply");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("plus.png"));
        this.props("label", "Apply License");
        this.props("tooltip", "Apply a product license.<br/></br>The license will be applied<br/>to the appropriate product.");
    },

    execute: function (e) {

        var that = this;

        PD.Manage.Modules.ApplyLicenseDialog.open({
            callbacks: {
                ok: function (sender, e) {
                    that._callService(e.id);
                }
            }
        });

    },

    _callService: function (id) {

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

        service.apply(id, function (e) {

            PD.context
                .get_default()
                .get_events()
                .publish("license/applied", {
                    id: e.id
                });

        });

    }

});