/// class PD.Manage.Modules.Resources.ExplorerContextMenu
// using PD.Web.UI.Controls.ContextMenuSegment

PD.Manage.Modules.Resources.ExplorerContextMenu =
PD.Web.UI.Controls.ContextMenuSegment.extend({

    //===================================
    // EVENT HANDLERS
    //===================================

    onRegisterItems: function (e) {

        e.registerItem(new PD.Web.UI.Controls.ContextMenuCommandItem({
            commandId: "pd/resources/context-menu:resource/delete"
        }));

        e.registerItem(new PD.Web.UI.Controls.ContextMenuCommandItem({
            commandId: "pd/resources/context-menu:folder/properties-dialog"
        }));

        e.addSeparator();

        e.registerItem(new PD.Web.UI.Controls.ContextMenuCommandItem({
            commandId: "pd/resources/context-menu:zip/download-folder"
        }));

    },

    onOpen: function (e) {

        var tree = this.get_context()["tree"],
            item = tree.dataItem(e.target);

        if (item != null) {
        
            PD.context.get_default().get_commands().setState({
                "pd/resources/context-menu": {
                    group: "pd/resources/context-menu",
                    targetFolderId: item.id,
                    resources: [
                        {
                            id: item.id,
                            name: item.name,
                            type: "folder"
                        }
                    ]
                }
            });

        }

    },

    map: function (item) {

        var result = {};

        if (item != null) {

            result = {
                id: item.id,
                name: item.name,
                type: "folder"
            };

        }

        return result;

    }

});