

Top10.Widget = Ext.extend(Ext.Panel, {
	
	widget: '',
    height: 322,
	//tabbed: false,
    gridType: 'widgetgrid',
    
    initComponent: function() {
        var config = {
        	layout: 'fit',
            tbar: {xtype: 'contexttoolbar'},
            items: {xtype: this.gridType, widget: this.widget}
        };
        
        Ext.apply(this, config);
        Ext.apply(this.initialConfig, config);

        Top10.Widget.superclass.initComponent.apply(this, arguments);
    },
    
    onRender: function(ct, position) {
        Top10.Widget.superclass.onRender.call(this, ct, position);
        
        this.ContextMgr.on('contextchange', this.loadGridStore, this);
    },
    
    loadGridStore: function(context, context_id) {
    	this.grid.context = context;
        this.grid.context_id = context_id;
        
    	this.grid.getStore().load({
            params: {
                context: context,
                context_id: context_id
            },
            callback: this.grid.showContextColumn,
            scope: this.grid
        });
    }
});

Ext.reg('widget', Top10.Widget);


Top10.BasicWidget = Ext.extend(Top10.Widget, {
    
    height: 300,
    gridType: 'widgetlistview',
    
    initComponent: function() {
        Top10.BasicWidget.superclass.initComponent.apply(this, arguments);
    },
    
    onRender: function(ct, position) {
        Top10.BasicWidget.superclass.onRender.call(this, ct, position);
        
        this.on('afterrender', function() {
            this.getTopToolbar().add('->', {
                iconCls: Top10.Icon.css('arrow_out'),
                scope: this,
                handler: function(button) {
                	new Ext.Window({
                	    title: this.title,
                        iconCls: this.iconCls,
                	    layout: 'fit',
                	    width: 850,
                        height: 330,
                        animateTarget: button.getEl().id,
                	    items: {xtype: 'widget', widget: this.widget},
                	    listeners: {
                	        scope: this,
                	        show: this.disable,
                            close: this.enable
                	    }
                	}).show();
                }
            });
        });
    }
});

Ext.reg('basicwidget', Top10.BasicWidget);