From: Tuukka Lehtonen Date: Wed, 5 Apr 2017 14:20:03 +0000 (+0300) Subject: Merge "Update all graph.tg files that seem to be out-of-date in git" X-Git-Tag: v1.29.0~117 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=df9a730a8e2618f5116177ede389f8f2f6c5b2ef;hp=20c44205e1ef4fbdf0e2beeb36494958d975207b Merge "Update all graph.tg files that seem to be out-of-date in git" --- diff --git a/bundles/org.simantics.utils.thread.swt/src/org/simantics/utils/threads/SWTThread.java b/bundles/org.simantics.utils.thread.swt/src/org/simantics/utils/threads/SWTThread.java index b5bb6722c..07102a102 100644 --- a/bundles/org.simantics.utils.thread.swt/src/org/simantics/utils/threads/SWTThread.java +++ b/bundles/org.simantics.utils.thread.swt/src/org/simantics/utils/threads/SWTThread.java @@ -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); } }