Bug 563459 - Enhance UISynchronize to make it more useful

upgrade to DisplayUISynchronize

Change-Id: I49128dd9ba4f072aea294dc164c81521746e6be4
Signed-off-by: Christoph Läubrich <laeubi@laeubi-soft.de>
diff --git a/bundles/org.eclipse.e4.tools.compat/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.compat/META-INF/MANIFEST.MF
index 5c84293..860638a 100644
--- a/bundles/org.eclipse.e4.tools.compat/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.tools.compat/META-INF/MANIFEST.MF
@@ -18,5 +18,6 @@
  org.eclipse.e4.tools.compat.parts;version="0.12.0.qualifier";x-internal:=true
 Bundle-ActivationPolicy: lazy
 Bundle-Vendor: %Bundle-Vendor
-Import-Package: javax.inject;version="1.0.0"
+Import-Package: javax.inject;version="1.0.0",
+ org.eclipse.e4.ui.workbench.swt
 Automatic-Module-Name: org.eclipse.e4.tools.compat
diff --git a/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/internal/ContextServiceFactory.java b/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/internal/ContextServiceFactory.java
index 525a700..75561cf 100644
--- a/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/internal/ContextServiceFactory.java
+++ b/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/internal/ContextServiceFactory.java
@@ -26,6 +26,7 @@
 import org.eclipse.e4.ui.di.UISynchronize;
 import org.eclipse.e4.ui.services.IServiceConstants;
 import org.eclipse.e4.ui.services.IStylingEngine;
+import org.eclipse.e4.ui.workbench.swt.DisplayUISynchronize;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Widget;
@@ -71,22 +72,7 @@
 			appContext.set(Realm.class, Realm.getDefault());
 
 			final Display display = Display.getCurrent();
-			appContext.set(UISynchronize.class, new UISynchronize() {
-
-				@Override
-				public void syncExec(Runnable runnable) {
-					if (display != null && !display.isDisposed()) {
-						display.syncExec(runnable);
-					}
-				}
-
-				@Override
-				public void asyncExec(Runnable runnable) {
-					if (display != null && !display.isDisposed()) {
-						display.asyncExec(runnable);
-					}
-				}
-			});
+			appContext.set(UISynchronize.class, new DisplayUISynchronize(display));
 
 			final IThemeManager manager = serviceContext.get(IThemeManager.class);
 			final IThemeEngine engine = manager.getEngineForDisplay(Display.getCurrent());