public class HandlerManager extends java.lang.Object implements HasHandlers
EventBus, and
used at the core of {com.google.gwt.user.client.ui.Widget}.
While widget authors should continue to use
Widget.addDomHandler(EventHandler, com.google.gwt.event.dom.client.DomEvent.Type)
and
Widget.addHandler(EventHandler, com.google.gwt.event.shared.GwtEvent.Type)
, application developers are strongly discouraged from using a HandlerManager
instance as a global event dispatch mechanism.
| Constructor and Description |
|---|
HandlerManager(java.lang.Object source)
Creates a handler manager with a source to be set on all events fired via
fireEvent(GwtEvent). |
HandlerManager(java.lang.Object source,
boolean fireInReverseOrder)
Creates a handler manager with the given source, specifying the order in
which handlers are fired.
|
| Modifier and Type | Method and Description |
|---|---|
<H extends EventHandler> |
addHandler(GwtEvent.Type<H> type,
H handler)
Adds a handler.
|
void |
fireEvent(GwtEvent<?> event)
Fires the given event to the handlers listening to the event's type.
|
<H extends EventHandler> |
getHandler(GwtEvent.Type<H> type,
int index)
Gets the handler at the given index.
|
int |
getHandlerCount(GwtEvent.Type<?> type)
Gets the number of handlers listening to the event type.
|
boolean |
isEventHandled(GwtEvent.Type<?> e)
Does this handler manager handle the given event type?
|
<H extends EventHandler> |
removeHandler(GwtEvent.Type<H> type,
H handler)
Removes the given handler from the specified event type.
|
public HandlerManager(java.lang.Object source)
fireEvent(GwtEvent). Handlers will be fired in the order that they
are added.source - the default event sourcepublic HandlerManager(java.lang.Object source,
boolean fireInReverseOrder)
source - the event sourcefireInReverseOrder - true to fire handlers in reverse orderpublic <H extends EventHandler> HandlerRegistration addHandler(GwtEvent.Type<H> type, H handler)
H - The type of handlertype - the event type associated with this handlerhandler - the handlerpublic void fireEvent(GwtEvent<?> event)
Any exceptions thrown by handlers will be bundled into a
UmbrellaException and then re-thrown after all handlers have
completed. An exception thrown by a handler will not prevent other handlers
from executing.
Note, any subclass should be very careful about overriding this method, as adds/removes of handlers will not be safe except within this implementation.
fireEvent in interface HasHandlersevent - the eventpublic <H extends EventHandler> H getHandler(GwtEvent.Type<H> type, int index)
H - the event handler typeindex - the indextype - the handler's event typepublic int getHandlerCount(GwtEvent.Type<?> type)
type - the event typepublic boolean isEventHandled(GwtEvent.Type<?> e)
e - the event typepublic <H extends EventHandler> void removeHandler(GwtEvent.Type<H> type, H handler)
H - handler typetype - the event typehandler - the handler