Package com.iizigo.swt
Class InvokeSWTLater
- java.lang.Object
- com.iizigo.swt.InvokeSWTLater
public class InvokeSWTLater extends java.lang.Object
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 Summary
Constructors Constructor Description InvokeSWTLater()
Constructs 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, java.lang.Runnable callback)
Constructs an instance that fires the event after a while.InvokeSWTLater(int wait, java.lang.Runnable callback)
Constructs an instance that fires the event after a while.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
setCallback(java.lang.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 usingsetCallback(Runnable)
.void
trigger(java.lang.Runnable callback)
Calls the trigger function, the Runnable is the one registered usingsetCallback(Runnable)
.
Constructor Detail
InvokeSWTLater
public InvokeSWTLater()
Constructs an instance that fires the event immediately.
InvokeSWTLater
public InvokeSWTLater(int wait)
Constructs an instance that fires the event after a while.- Parameters:
wait
- How long to wait in milliseconds, (0=no wait).
InvokeSWTLater
public InvokeSWTLater(int wait, java.lang.Runnable callback)
Constructs 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.
InvokeSWTLater
public InvokeSWTLater(int wait, boolean triggerCancelPending, java.lang.Runnable callback)
Constructs 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 Detail
setCallback
public void setCallback(java.lang.Runnable callback)
Sets 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:
java.lang.NullPointerException
- If the callback is null.
trigger
public void trigger()
Calls the trigger function, the Runnable is the one registered usingsetCallback(Runnable)
.- Throws:
java.lang.NullPointerException
- If the callback is null.
trigger
public void trigger(java.lang.Runnable callback)
Calls the trigger function, the Runnable is the one registered usingsetCallback(Runnable)
.- Parameters:
callback
- The callback to notify upon event.- Throws:
java.lang.NullPointerException
- If the callback is null.