org.eesgmbh.gimv.client.event
Class FilteredDispatchGwtEvent<H extends EventHandler>

java.lang.Object
  extended by com.google.gwt.event.shared.GwtEvent<H>
      extended by org.eesgmbh.gimv.client.event.FilteredDispatchGwtEvent<H>
Type Parameters:
H - handler type
Direct Known Subclasses:
ChangeImagePixelBoundsEvent, LoadImageDataEvent, SetDataAreaPixelBoundsEvent, SetDomainBoundsEvent, SetImageEntitiesEvent, SetImageUrlEvent, SetMaxDomainBoundsEvent, SetOverviewDomainBoundsEvent, SetViewportPixelBoundsEvent, StateChangeEvent, ViewportDragFinishedEvent, ViewportDragInProgressEvent, ViewportMouseMoveEvent, ViewportMouseOutEvent, ViewportMouseWheelEvent

public abstract class FilteredDispatchGwtEvent<H extends EventHandler>
extends GwtEvent<H>

Subclasses can optionally specify EventHandler instances, that should not be invoked when an event is dispatched, although these handlers are registered in the HandlerManager class for the particular event.

Usage: subclasss override onDispatch(EventHandler) instead of dispatch(EventHandler), which is final in this class. Usually a subclass constructor specifies only a single EventHandler. If no handler is specified no filter will be applied and the event will be dispatched to all handlers. A handler will be identified by its equals method.

Purpose: Gimv applications usually have only a single HandlerManager / event bus. In certain modules e.g. in the presenter CalendarPresenter it is necessary to fire the very same event the presenter is listening to. Without any filtering this will eventually lead to the presenter invoking its own event handling method by firing the respective event. This might not break anything but it is nevertheless a kind of behavior that ist hard to debug and error prone.

Limitation: this will only work if the event handlers which must not be called are known/accessible during event construction. On the other hand the object firing the event in Gimv is usually also the one which must not be notified of the very same event.

The filtering mechanism can't be accomplished using the GwtEvent.getSource() as this field can only be set by the HandlerManager. As there is only a single HandlerManager (an application event bus) with a single source, event sources cannot differ in a GwtEvent in an application that uses only one event bus.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.event.shared.GwtEvent
GwtEvent.Type<H>
 
Constructor Summary
protected FilteredDispatchGwtEvent(H... blockedHandlers)
          Constructor.
 
Method Summary
protected  void dispatch(H handler)
           
protected  List<H> getBlockedHandlers()
           
protected  boolean isBlockedHandler(H handler)
           
protected abstract  void onDispatch(H handler)
          Invoked when a handler is contained in the blockedHandlers list
 
Methods inherited from class com.google.gwt.event.shared.GwtEvent
assertLive, getAssociatedType, getSource, isLive, kill, revive, toDebugString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FilteredDispatchGwtEvent

protected FilteredDispatchGwtEvent(H... blockedHandlers)
Constructor.

Parameters:
blockedHandlers - Any number (0-n) of EventHandler instances that should no be invoked. An element must not null.
Method Detail

dispatch

protected final void dispatch(H handler)
Specified by:
dispatch in class GwtEvent<H extends EventHandler>

onDispatch

protected abstract void onDispatch(H handler)
Invoked when a handler is contained in the blockedHandlers list

Parameters:
handler -

isBlockedHandler

protected boolean isBlockedHandler(H handler)

getBlockedHandlers

protected List<H> getBlockedHandlers()


Copyright © 2010 - EES GmbH