/**
 * @class Roo.data.EventHub
 * @extends Ext.util.Observable
 *
 * EventHub relays event through the application.
 *
 * @author ssmeman
 * @version 1.0
 */

/**
 * @constructor
 * @param {Object} config Configuration options
 */
Roo.data.EventHub = Ext.extend(Ext.util.Observable, {
	constructor: function(config) {
		Roo.data.EventHub.superclass.constructor.apply(this, arguments);

		// empty addEvents() is needed to inialize the array for relaying
		this.addEvents();
	}

	,initialize: function() {

		this.registerRelays();

		// Register specific listeners
		this.registerListeners();

		// Initialize logger
		Ext.util.Observable.capture(this, function(e){
			console.debug('EventHub.capture(): %s', e);
		});
	}

	,registerRelays: function() {
		this.relayEvents(Ext.getCmp('searchLocationPanel'), ['foundLocation', 'searchedLocation', 'expandedSearchLocationPanel']);
		this.relayEvents(Ext.getCmp('searchNamePanel'), ['foundPlans', 'selectedPlan', 'searchedPlanName']);
		this.relayEvents(Ext.getCmp('searchPlanIdPanel'), ['foundPlans', 'selectedPlan', 'searchedPlanId']);
		this.relayEvents(Ext.getCmp('searchCriteriaPanel'), ['foundPlans', 'selectedPlan', 'searchedPlanCriteria', 'expandedSearchCriteriaPanel']);
		this.relayEvents(Ext.getCmp('infoPanel'), ['receivedIdentifyResult','receivedTreenodeDetails','selectedPlan','selectedPlanAuthentic']);
		this.relayEvents(Ext.getCmp('planDetailPanel'), ['highlightFeature', 'resetHighlight', 'showDocument', 'showPlan']);
		this.relayEvents(Ext.getCmp('planGridPanel'), ['highlightFeature', 'resetHighlight']);
		this.relayEvents(Ext.getCmp('designSelectPanel'), ['changedFilter']);
		this.relayEvents(Ext.getCmp('headerTabs'), ['changedTab', 'changedCard', 'changedFilter']);

		this.relayEvents(urlHandler, ['receivedUrlParameters']);
	}
	,registerListeners: function() {
		// Events that we have to take action on as a hub
		// None for now
	}
});