org.eesgmbh.gimv.client.util
Class EventAccumulator

java.lang.Object
  extended by org.eesgmbh.gimv.client.util.EventAccumulator

public class EventAccumulator
extends Object

A utility class which cumulates GwtEvent instances until for a specified time no further events were added to the accumulator. If e.g. 100 ms is specified as the accumulation period, the callback's execute method is invoked 100ms after the last event was added.

A List of GwtEvent instances is passed into the EventAccumulator.Callback that was specified in the constructor after the accumulation time elapsed.

This helps to reduce server load e.g. if mouse wheel events are 'summed up' during the accumulation period.


Nested Class Summary
static interface EventAccumulator.Callback
           
 
Constructor Summary
EventAccumulator(int callbackExecutionDelay, EventAccumulator.Callback callback)
          Constructor.
 
Method Summary
 void addEvent(GwtEvent<? extends EventHandler> gwtEvent)
          Adds an event that will be passed into the EventAccumulator.Callback execute-method after the accumulation period elapsed.
 void setCallbackExecutionDelay(int callbackExecutionDelay)
          How long to wait in milliseconds before invoking the callback's execute method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventAccumulator

public EventAccumulator(int callbackExecutionDelay,
                        EventAccumulator.Callback callback)
Constructor.

Parameters:
callbackExecutionDelay - How long to wait in milliseconds before invoking the callback's execute method. If 0, GwtEvents are immediately passed to the Callback, thus there is no delay (and no internal use of Timer).

callback - A EventAccumulator.Callback implementation whose execute-method will be invoked after the specified delay
Method Detail

addEvent

public void addEvent(GwtEvent<? extends EventHandler> gwtEvent)
Adds an event that will be passed into the EventAccumulator.Callback execute-method after the accumulation period elapsed.

Parameters:
gwtEvent - The GwtEvent

setCallbackExecutionDelay

public void setCallbackExecutionDelay(int callbackExecutionDelay)
How long to wait in milliseconds before invoking the callback's execute method. If 0, GwtEvents are immediately passed to the Callback, thus there is no delay (and no internal use of Timer).

Parameters:
callbackExecutionDelay - Delay in milliseconds


Copyright © 2010 - EES GmbH