org.eclipse.swtbot.swt.finder.finders
Class UIThreadRunnable

java.lang.Object
  extended by org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable
All Implemented Interfaces:
Runnable

public abstract class UIThreadRunnable
extends Object
implements Runnable

Performs operations in the UI thread. If the run() method of this class is called from an non-UI thread, the instance ensures that it runs in the UI thread by invoking Display.syncExec(Runnable), else it executes in the UI thread. All operations are blocking operations.

Version:
$Id$
Author:
Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>

Field Summary
protected  Display display
          the display on which runnables must be executed.
 
Method Summary
static void asyncExec(Display display, VoidResult toExecute)
          Executes the toExecute on the UI thread asynchronously, and does not block the calling thread.
static void asyncExec(VoidResult toExecute)
          Executes the toExecute on the UI thread asynchronously, and does not block the calling thread.
protected abstract  void doRun()
          Performs the run in the UI Thread.
 void run()
          This method is intelligent to execute in the UI thread.
static
<T> T[]
syncExec(ArrayResult<T> toExecute)
          Executes the toExecute on the display thread, and blocks the calling thread.
static
<T> T[]
syncExec(Display display, ArrayResult<T> toExecute)
          Executes the toExecute on the display thread, and blocks the calling thread.
static
<T> T
syncExec(Display display, Result<T> toExecute)
          Executes the toExecute on the display thread, and blocks the calling thread.
static void syncExec(Display display, VoidResult toExecute)
          Executes the toExecute on the display thread, and blocks the calling thread.
static
<T> T
syncExec(Result<T> toExecute)
          Executes the toExecute on the UI thread, and blocks the calling thread.
static void syncExec(VoidResult toExecute)
          Executes the toExecute on the UI thread, and blocks the calling thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

display

protected final Display display
the display on which runnables must be executed.

Method Detail

run

public void run()
This method is intelligent to execute in the UI thread.

Specified by:
run in interface Runnable

doRun

protected abstract void doRun()
Performs the run in the UI Thread.

This MUST be invoked in the UI thread.


syncExec

public static <T> T syncExec(Result<T> toExecute)
Executes the toExecute on the UI thread, and blocks the calling thread.

Type Parameters:
T - the type of the result.
Parameters:
toExecute - the runnable to execute.
Returns:
the result of executing result on the UI thread.

syncExec

public static <T> T syncExec(Display display,
                             Result<T> toExecute)
Executes the toExecute on the display thread, and blocks the calling thread.

Type Parameters:
T - the type of the result.
Parameters:
display - the display on which toExecute must be executed.
toExecute - the runnable to execute.
Returns:
the object result of execution on the UI thread.

syncExec

public static <T> T[] syncExec(ArrayResult<T> toExecute)
Executes the toExecute on the display thread, and blocks the calling thread.

Type Parameters:
T - the type of the result.
Parameters:
toExecute - the runnable to execute.
Returns:
the object result of execution on the UI thread.

syncExec

public static <T> T[] syncExec(Display display,
                               ArrayResult<T> toExecute)
Executes the toExecute on the display thread, and blocks the calling thread.

Type Parameters:
T - the type of the result.
Parameters:
display - the display on which toExecute must be executed.
toExecute - the runnable to execute.
Returns:
the object result of execution on the UI thread.

syncExec

public static void syncExec(VoidResult toExecute)
Executes the toExecute on the UI thread, and blocks the calling thread.

Parameters:
toExecute - the runnable to execute.
Since:
1.0

syncExec

public static void syncExec(Display display,
                            VoidResult toExecute)
Executes the toExecute on the display thread, and blocks the calling thread.

Parameters:
display - the display on which toExecute must be executed.
toExecute - the runnable to execute.

asyncExec

public static void asyncExec(VoidResult toExecute)
Executes the toExecute on the UI thread asynchronously, and does not block the calling thread.

Parameters:
toExecute - the runnable to execute.
Since:
1.0

asyncExec

public static void asyncExec(Display display,
                             VoidResult toExecute)
Executes the toExecute on the UI thread asynchronously, and does not block the calling thread.

Parameters:
display - the display on which toExecute must be executed.
toExecute - the runnable to execute.