public class

HandlerManager

extends Object
implements HasHandlers
java.lang.Object
   ↳ com.google.gwt.event.shared.HandlerManager

Class Overview

Manager responsible for adding handlers to event sources and firing those handlers on passed in events. Primitive ancestor of EventBus, and used at the core of {com.google.gwt.user.client.ui.Widget}.

While widget authors should continue to use addDomHandler(EventHandler, com.google.gwt.event.dom.client.DomEvent.Type) and addHandler(EventHandler, Type), application developers are strongly discouraged from using a HandlerManager instance as a global event dispatch mechanism.

Summary

Public Constructors
HandlerManager(Object source)
Creates a handler manager with a source to be set on all events fired via fireEvent(GwtEvent).
HandlerManager(Object source, boolean fireInReverseOrder)
Creates a handler manager with the given source, specifying the order in which handlers are fired.
Public Methods
<H extends EventHandler> HandlerRegistration addHandler(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> H getHandler(Type<H> type, int index)
Gets the handler at the given index.
int getHandlerCount(Type<?> type)
Gets the number of handlers listening to the event type.
boolean isEventHandled(Type<?> e)
Does this handler manager handle the given event type?
<H extends EventHandler> void removeHandler(Type<H> type, H handler)
Removes the given handler from the specified event type.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.gwt.event.shared.HasHandlers

Public Constructors

public HandlerManager (Object source)

Creates a handler manager with a source to be set on all events fired via fireEvent(GwtEvent). Handlers will be fired in the order that they are added.

Parameters
source the default event source

public HandlerManager (Object source, boolean fireInReverseOrder)

Creates a handler manager with the given source, specifying the order in which handlers are fired.

Parameters
source the event source
fireInReverseOrder true to fire handlers in reverse order

Public Methods

public HandlerRegistration addHandler (Type<H> type, H handler)

Adds a handler.

Parameters
type the event type associated with this handler
handler the handler
Returns
  • the handler registration, can be stored in order to remove the handler later

public void fireEvent (GwtEvent<?> event)

Fires the given event to the handlers listening to the event's type.

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.

Parameters
event the event

public H getHandler (Type<H> type, int index)

Gets the handler at the given index.

Parameters
type the handler's event type
index the index
Returns
  • the given handler

public int getHandlerCount (Type<?> type)

Gets the number of handlers listening to the event type.

Parameters
type the event type
Returns
  • the number of registered handlers

public boolean isEventHandled (Type<?> e)

Does this handler manager handle the given event type?

Parameters
e the event type
Returns
  • whether the given event type is handled

public void removeHandler (Type<H> type, H handler)

Removes the given handler from the specified event type.

Parameters
type the event type
handler the handler