Package com.iizigo.swt
Class InvokeSWTLater
java.lang.Object
com.iizigo.swt.InvokeSWTLater
Helper class to invoke a Runnable in the SWT thread after a while, once. This is typically used when many events should react to a single action a little later (or that it must run in the SWT thread), and on top of that just once. There is no point in firing the event in SWT thread for every event, otherwise Display.syncExec should be used.
- Author:
- Christopher Mindus
- Constructor SummaryConstructorsConstructorDescriptionConstructs an instance that fires the event immediately.- InvokeSWTLater- (int wait) Constructs an instance that fires the event after a while.- InvokeSWTLater- (int wait, boolean triggerCancelPending, Runnable callback) Constructs an instance that fires the event after a while.- InvokeSWTLater- (int wait, Runnable callback) Constructs an instance that fires the event after a while.
- Method SummaryModifier and TypeMethodDescription- boolean- cancel()Cancels a pending run-later task.- void- dispose()Disposes of the instance.- booleanChecks if disposed of.- booleanFlag indicating the async call has been done and that it will run.- void- setCallback- (Runnable callback) Sets the callback, when it is the same one to use all the time.- void- trigger()Calls the trigger function, the Runnable is the one registered using- setCallback(Runnable).- voidCalls the trigger function, the Runnable is the one registered using- setCallback(Runnable).
- Constructor Details- InvokeSWTLaterpublic InvokeSWTLater()Constructs an instance that fires the event immediately.
- InvokeSWTLaterpublic InvokeSWTLater- (int wait) Constructs an instance that fires the event after a while.- Parameters:
- wait- How long to wait in milliseconds, (0=no wait).
 
- InvokeSWTLaterConstructs an instance that fires the event after a while.- Parameters:
- wait- How long to wait in milliseconds, (0=no wait).
- callback- The callback to use for all events in SWT.
 
- InvokeSWTLaterConstructs an instance that fires the event after a while.- Parameters:
- wait- How long to wait in milliseconds, (0=no wait).
- triggerCancelPending- Flag indicating trigger will cancel pending triggered event.
- callback- The callback to use for all events in SWT.
 
 
- Method Details- isDisposedpublic boolean isDisposed()Checks if disposed of.
- disposepublic void dispose()Disposes of the instance.
- setCallbackSets the callback, when it is the same one to use all the time.- Parameters:
- callback- The callback to use for all events in SWT.
- Throws:
- NullPointerException- If the callback is null.
 
- triggerpublic void trigger()Calls the trigger function, the Runnable is the one registered using- setCallback(Runnable).- Throws:
- NullPointerException- If the callback is null.
 
- triggerCalls the trigger function, the Runnable is the one registered using- setCallback(Runnable).- Parameters:
- callback- The callback to notify upon event.
- Throws:
- NullPointerException- If the callback is null.
 
- isTriggeredpublic boolean isTriggered()Flag indicating the async call has been done and that it will run.
- cancelpublic boolean cancel()Cancels a pending run-later task.- Returns:
- true if successfully canceled, false if disposed of or no pending task was set to run.