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

PD.Manage.Modules.Resources.BrowserContextMenu =
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/open"
        }));

        e.addSeparator();

        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:resource/properties-dialog"
        }));

        e.addSeparator();

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

    },

    onOpen: function (e) {

        var grid = this.get_context()["grid"];
        var currentFolderId = null;
        var selections = grid.getSelections().toArray();

        if (selections.length > 0) {
            currentFolderId = _.first(selections).id;
        }

        PD.context.get_default().get_commands().setState({
            "pd/resources/context-menu": {
                group: "pd/resources/context-menu",
                targetFolderId: currentFolderId,
                resources: selections
            }
        });

    }

});