Class HandlerManager

    • Constructor Detail

      • HandlerManager

        public HandlerManager​(java.lang.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
      • HandlerManager

        public HandlerManager​(java.lang.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
    • Method Detail

      • addHandler

        public <H extends EventHandlerHandlerRegistration addHandler​(GwtEvent.Type<H> type,
                                                                       H handler)
        Adds a handler.
        Type Parameters:
        H - The type of 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
      • fireEvent

        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.

        Specified by:
        fireEvent in interface HasHandlers
        Parameters:
        event - the event
      • getHandler

        public <H extends EventHandler> H getHandler​(GwtEvent.Type<H> type,
                                                     int index)
        Gets the handler at the given index.
        Type Parameters:
        H - the event handler type
        Parameters:
        index - the index
        type - the handler's event type
        Returns:
        the given handler
      • getHandlerCount

        public int getHandlerCount​(GwtEvent.Type<?> type)
        Gets the number of handlers listening to the event type.
        Parameters:
        type - the event type
        Returns:
        the number of registered handlers
      • isEventHandled

        public boolean isEventHandled​(GwtEvent.Type<?> e)
        Does this handler manager handle the given event type?
        Parameters:
        e - the event type
        Returns:
        whether the given event type is handled
      • removeHandler

        public <H extends EventHandler> void removeHandler​(GwtEvent.Type<H> type,
                                                           H handler)
        Removes the given handler from the specified event type.
        Type Parameters:
        H - handler type
        Parameters:
        type - the event type
        handler - the handler