Plugins.ThreeGiG.ProspectDirector.BuiltIn.OpenEntityAction =
PD.Actions.ActionDefinition.extend({

    init: function (options) {

        this._super({
            id: "open-entity",
            pluginId: "builtin",
            name: "Open Entity",
            description: "Opens the specified entity.",
            parameters: [
                new PD.Actions.ActionParameterDefinition({
                    name: "Entity ID",
                    type: PD.Actions.ActionParameterType.INTEGER,
                    description: "The ID of the entity to open."
                }),
                new PD.Actions.ActionParameterDefinition({
                    name: "Folder ID",
                    type: PD.Actions.ActionParameterType.STRING,
                    description: "The Custom ID of the folder to open within the target entity.",
                    optional: true
                }),
                new PD.Actions.ActionParameterDefinition({
                    name: "New Window?",
                    type: PD.Actions.ActionParameterType.INTEGER,
                    optional: true,
                    description: "A value of '1' will open the entity in a new window."
                })
            ]
        });

    },

    method: function (entityId, folderId, newWindow) {

        var url = null;

        if (entityId == null) {
            this._showErrorDialog("Entity ID");
        }

        if (folderId != null) {
            url = PD.Path.resolve("~/explore/" + entityId + "/folder/" + folderId);
        }
        else {
            url = PD.Path.resolve("~/explore/" + entityId);
        }

        if (newWindow === 1) {
            window.open(url);
        }
        else {
            window.location = url;
        }

    },

    _showErrorDialog: function (label) {

        ProspectDirector.Web.UI.MessageDialog.warn({
            message: "Cannot complete the 'Open Entity Action' because no " + label + " has been specified."
        });

    }

});