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:
0.9.0
Author:
jeichar

Constructor Summary
PlatformGIS()
           
 
Method Summary
static ColorBrewer getColorBrewer()
           
static void run(IRunnableWithProgress request)
          Runs the given runnable in a separate thread, providing it a progress monitor.
static void runBlockingOperation(IRunnableWithProgress runnable, IProgressMonitor monitor)
          This method runs the runnable in a separate thread.
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.


runBlockingOperation

public static void runBlockingOperation(IRunnableWithProgress runnable,
                                        IProgressMonitor monitor)
                                 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