net.refractions.udig.ui
Class PlatformGIS

java.lang.Object
  extended by net.refractions.udig.ui.PlatformGIS

public class PlatformGIS
extends java.lang.Object

A facade into udig to simplify operations relating to performing platform operations.

Since:
1.1
Author:
jeichar

Constructor Summary
PlatformGIS()
           
 
Method Summary
static void asyncInDisplayThread(Display display, java.lang.Runnable runnable, boolean executeIfInDisplay)
          Runs the runnable in the display thread but asynchronously.
static void asyncInDisplayThread(java.lang.Runnable runnable, boolean executeIfInDisplay)
          Runs the runnable in the display thread but asynchronously.
static ColorBrewer getColorBrewer()
           
static void run(IRunnableWithProgress request)
          Runs the given runnable in a separate thread, providing it a progress monitor.
static void run(IRunnableWithProgress request, IProgressMonitor monitorToUse)
          Runs the given runnable in a separate thread, providing it a progress monitor.
static void runBlockingOperation(IRunnableWithProgress runnable, IProgressMonitor monitor2)
          This method runs the runnable in a separate thread.
static void runInProgressDialog(java.lang.String dialogTitle, boolean showRunInBackground, IRunnableWithProgress runnable, boolean runASync)
          Runs a blocking task in a ProgressDialog.
static void syncInDisplayThread(Display display, java.lang.Runnable runnable)
           
static void syncInDisplayThread(java.lang.Runnable runnable)
          Acts as a safer alternative to Display.syncExec().
static void wait(long interval, long timeout, WaitCondition condition, java.lang.Object mutex)
          Waits for the condition to become true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlatformGIS

public PlatformGIS()
Method Detail

run

public static void run(IRunnableWithProgress request)
Runs the given runnable in a separate thread, providing it a progress monitor. Exceptions thrown by the runnable are logged, and not rethrown.


run

public static void run(IRunnableWithProgress request,
                       IProgressMonitor monitorToUse)
Runs the given runnable in a separate thread, providing it a progress monitor. Exceptions thrown by the runnable are logged, and not rethrown.


runBlockingOperation

public static void runBlockingOperation(IRunnableWithProgress runnable,
                                        IProgressMonitor monitor2)
                                 throws java.lang.reflect.InvocationTargetException,
                                        java.lang.InterruptedException
This method runs the runnable in a separate thread. It is useful in cases where a thread must wait for a long running and potentially blocking operation (for example an IO operation). If the IO is done in the UI thread then the user interface will lock up. This allows synchronous execution of a long running thread in the UI thread without locking the UI.

Parameters:
runnable - The runnable(operation) to run
monitor - the progress monitor to update.
Throws:
java.lang.reflect.InvocationTargetException
java.lang.InterruptedException

getColorBrewer

public static ColorBrewer getColorBrewer()

syncInDisplayThread

public static void syncInDisplayThread(java.lang.Runnable runnable)
Acts as a safer alternative to Display.syncExec(). If readAndDispatch is being called from the display thread syncExec calls will not be executed only Display.asyncExec calls are executed. So this method uses Display.asyncExec and patiently waits for the result to be returned. Can be called from display thread or non-display thread. Runnable should not be blocking or it will block the display thread.

Parameters:
runnable - runnable to execute

syncInDisplayThread

public static void syncInDisplayThread(Display display,
                                       java.lang.Runnable runnable)

wait

public static void wait(long interval,
                        long timeout,
                        WaitCondition condition,
                        java.lang.Object mutex)
                 throws java.lang.InterruptedException
Waits for the condition to become true. Will call Display#readAndDispatch() if currently in the display thread.

Parameters:
interval - the time to wait between testing of condition, in milliseconds. Must be a positive number and is recommended to be larger than 50
timeout - maximum time to wait. Will throw an InterruptedException if reached. If -1 then it will not timeout.
condition - condition to wait on.
mutex - if not null mutex will be waited on so that a notify will interrupt the wait.
Throws:
java.lang.InterruptedException

runInProgressDialog

public static void runInProgressDialog(java.lang.String dialogTitle,
                                       boolean showRunInBackground,
                                       IRunnableWithProgress runnable,
                                       boolean runASync)
Runs a blocking task in a ProgressDialog. It is ran in such a way that even if the task blocks it can be cancelled. This is unlike the normal ProgressDialog.run(...) method which requires that the IProgressMonitor be checked and the task to "nicely" cancel.

Parameters:
dialogTitle - The title of the Progress dialog
showRunInBackground - if true a button added to the dialog that will make the job be ran in the background.
runnable - the task to execute.
runASync - if true the runnable will be ran asynchronously

asyncInDisplayThread

public static void asyncInDisplayThread(java.lang.Runnable runnable,
                                        boolean executeIfInDisplay)
Runs the runnable in the display thread but asynchronously.

Parameters:
runnable - the runnable to execute
executeIfInDisplay - if true and the current thread is the display thread then the runnable will just be executed.

asyncInDisplayThread

public static void asyncInDisplayThread(Display display,
                                        java.lang.Runnable runnable,
                                        boolean executeIfInDisplay)
Runs the runnable in the display thread but asynchronously.

Parameters:
display - the display in which to run the runnable
runnable - the runnable to execute
executeIfInDisplay - if true and the current thread is the display thread then the runnable will just be executed.