]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.utils.thread.swt/src/org/simantics/utils/threads/SWTThread.java
Merge branch 'feature/funcwrite'
[simantics/platform.git] / bundles / org.simantics.utils.thread.swt / src / org / simantics / utils / threads / SWTThread.java
index b5bb6722c43e8531dc42c80f32ac5043846752da..07102a102cd8b861210a31d9ec26de60478b8c6c 100644 (file)
@@ -22,25 +22,32 @@ import org.eclipse.swt.widgets.Widget;
 
 public class SWTThread implements IThreadWorkQueue, Executor {
 
-       final Display display;
+       private final Display display;
+       private final boolean executeAsync;
+       
+       public static IThreadWorkQueue getThreadAccess(Display display, boolean executeAsync)
+       {
+               return new SWTThread(display, executeAsync);
+       }
        
        public static IThreadWorkQueue getThreadAccess(Display display)
        {
-               return new SWTThread(display);
+               return getThreadAccess(display, false);
        }
        
        public static IThreadWorkQueue getThreadAccess(Widget widget)
        {
-               return new SWTThread(widget.getDisplay());
+               return new SWTThread(widget.getDisplay(), false);
        }
        
        public static IThreadWorkQueue getThreadAccess() {
-               return new SWTThread(Display.getDefault());
+               return new SWTThread(Display.getDefault(), false);
        }
        
-       SWTThread(Display display)
+       SWTThread(Display display, boolean executeAsync)
        {
                this.display = display;
+               this.executeAsync = executeAsync;
        }
        
        @Override
@@ -87,6 +94,7 @@ public class SWTThread implements IThreadWorkQueue, Executor {
 
        @Override
        public void execute(Runnable command) {
-               syncExec(command);
+               if (executeAsync) asyncExec(command);
+               else syncExec(command);
        }
 }