com.extjs.gxt.ui.client.mvc
Class Dispatcher

java.lang.Object
  extended by com.extjs.gxt.ui.client.event.BaseObservable
      extended by com.extjs.gxt.ui.client.mvc.Dispatcher
All Implemented Interfaces:
Observable

public class Dispatcher
extends BaseObservable

Dispatchers are responsible for dispatching application events to controllers.

Events:
Dispatcher.BeforeDispatch : MvcEvent(dispatcher, appEvent)
Fires before an event is dispatched. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean).
Dispatcher.AfterDispatch : MvcEvent(dispatcher, appEvent)
Fires after an event has been dispatched.

See Also:
DispatcherListener

Field Summary
static EventType AfterDispatch
          Fires after an event has been dispatched.
static EventType BeforeDispatch
          Fires before an event is dispatched.
 
Method Summary
 void addController(Controller controller)
          Adds a controller.
 void addDispatcherListener(DispatcherListener listener)
          Adds a listener to receive dispatch events.
 void dispatch(AppEvent event)
          The dispatcher will query its controllers and pass the application event to any controllers that can handle the particular event type.
 void dispatch(EventType type)
          The dispatcher will query its controllers and pass the application event to controllers that can handle the particular event type.
 void dispatch(EventType type, java.lang.Object data)
          The dispatcher will query its controllers and pass the application event to controllers that can handle the particular event type.
static void forwardEvent(AppEvent event)
          Forwards an application event to the dispatcher.
static void forwardEvent(EventType eventType)
          Creates and forwards an application event to the dispatcher.
static void forwardEvent(EventType eventType, java.lang.Object data)
          Creates and forwards an application event to the dispatcher.
static void forwardEvent(EventType eventType, java.lang.Object data, boolean historyEvent)
          Creates and forwards an application event to the dispatcher.
static Dispatcher get()
          Returns the singleton instance.
 java.util.List<Controller> getControllers()
          Returns all controllers.
 java.util.Map<java.lang.String,AppEvent> getHistory()
          Returns the dispatcher's history cache.
 void removeController(Controller controller)
          Removes a controller.
 void removeDispatcherListener(DispatcherListener listener)
          Removes a previously added listener.
 
Methods inherited from class com.extjs.gxt.ui.client.event.BaseObservable
addListener, callListener, fireEvent, fireEvent, getFiresEvents, getListeners, hasActiveEvent, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BeforeDispatch

public static final EventType BeforeDispatch
Fires before an event is dispatched.


AfterDispatch

public static final EventType AfterDispatch
Fires after an event has been dispatched.

Method Detail

forwardEvent

public static void forwardEvent(AppEvent event)
Forwards an application event to the dispatcher.

Parameters:
event - the application event

forwardEvent

public static void forwardEvent(EventType eventType)
Creates and forwards an application event to the dispatcher.

Parameters:
eventType - the application event type

forwardEvent

public static void forwardEvent(EventType eventType,
                                java.lang.Object data)
Creates and forwards an application event to the dispatcher.

Parameters:
eventType - the application event type
data - the event data

forwardEvent

public static void forwardEvent(EventType eventType,
                                java.lang.Object data,
                                boolean historyEvent)
Creates and forwards an application event to the dispatcher.

Parameters:
eventType - the application event type
data - the event data
historyEvent - true to mark event as a history event

get

public static Dispatcher get()
Returns the singleton instance.

Returns:
the dispatcher

addController

public void addController(Controller controller)
Adds a controller.

Parameters:
controller - the controller to be added

addDispatcherListener

public void addDispatcherListener(DispatcherListener listener)
Adds a listener to receive dispatch events.

Parameters:
listener - the listener to add

dispatch

public void dispatch(AppEvent event)
The dispatcher will query its controllers and pass the application event to any controllers that can handle the particular event type.

Parameters:
event - the application event

dispatch

public void dispatch(EventType type)
The dispatcher will query its controllers and pass the application event to controllers that can handle the particular event type.

Parameters:
type - the event type

dispatch

public void dispatch(EventType type,
                     java.lang.Object data)
The dispatcher will query its controllers and pass the application event to controllers that can handle the particular event type.

Parameters:
type - the event type
data - the app event data

getControllers

public java.util.List<Controller> getControllers()
Returns all controllers.

Returns:
the list of controllers

getHistory

public java.util.Map<java.lang.String,AppEvent> getHistory()
Returns the dispatcher's history cache.

Returns:
the history

removeController

public void removeController(Controller controller)
Removes a controller.

Parameters:
controller - the controller to be removed

removeDispatcherListener

public void removeDispatcherListener(DispatcherListener listener)
Removes a previously added listener.

Parameters:
listener - the listener to be removed