﻿Ext.ux.CloudMetadataGridPanel = Ext.extend(Ext.ux.MetadataGridPanel, {

    // standard initializer
    initComponent: function() {
        Ext.ux.CloudMetadataGridPanel.superclass.initComponent.apply(this, arguments);

        // args have to go here as base class initComponent doesn't get called for some reason
        var config = {
            view: new Ext.ux.CloudMetadataGridView({ scrollOffset: g_gridScrollOffset })
        };

        Ext.apply(this, config);
        Ext.apply(this.initialConfig, config);

        this.on('contextmenu', this.onContextMenu, this);
    },


    // ------ event handler functions ------ //

    // context menu
    onContextMenu: function(e) {
        var rowIndex = this.getRowIndexFromEvent(e);

        this.updateSelections(rowIndex); 
        this.contextMenu = this.createActionsContextMenu(this, rowIndex);

        Ext.ux.CloudMetadataGridPanel.superclass.onContextMenu.call(this, e);
    },


    // ------ context menu creation helper functions ------ //

    // create the context menu
    createActionsContextMenu: function(grid, rowIndex) {
        var contextMenu = this.createEmptyActionsContextMenu();

        contextMenu = this.addMetadataStreamingMenuItems(contextMenu, rowIndex);

        // add any generic menu items
        contextMenu = this.addGenericMenuItems(grid, contextMenu, rowIndex);

        return contextMenu;
    }
});

Ext.ux.CloudMetadataGridView = Ext.extend(Ext.ux.MetadataGridView, {
});

Ext.ux.CloudMetadataGridDragZone = Ext.extend(Ext.ux.MetadataGridDragZone, {  
});