javauis/coreui_qt/javasrc/com/nokia/mj/impl/coreuiqt/CoreUiImpl.java
changeset 80 d6dafc5d983f
parent 72 1f0034e370aa
--- a/javauis/coreui_qt/javasrc/com/nokia/mj/impl/coreuiqt/CoreUiImpl.java	Mon Oct 04 11:29:25 2010 +0300
+++ b/javauis/coreui_qt/javasrc/com/nokia/mj/impl/coreuiqt/CoreUiImpl.java	Fri Oct 15 12:29:39 2010 +0300
@@ -22,6 +22,8 @@
 import com.nokia.mj.impl.rt.support.ApplicationInfo;
 import com.nokia.mj.impl.coreui.CoreUi;
 
+import org.eclipse.swt.internal.extension.Toolkit;
+
 
 /**
  * A gate to CoreUi Qt implementation.
@@ -92,5 +94,43 @@
         _hideApplication(!hide);
     }
 
+    /**
+     * Executes given Runnable synchronously in UI thread.
+     * <br>
+     * This method should only be used in cases where it
+     * is absolutely needed. Before using this method,
+     * consider carefully if the use case really requires
+     * code to be executed in UI thread.
+     * <br>
+     * This method is only supported in Qt based runtimes.
+     * <br>
+     * @param runnable Runnable to be executed
+     * @throws RuntimeException if execution in UI thread
+     * is not supported
+     */
+    protected void runInSyncUiThreadImpl(Runnable runnable)
+    {
+        Toolkit.getInternalDisplay().syncExec(runnable);
+    }
+
+    /**
+     * Executes given Runnable asynchronously in UI thread.
+     * <br>
+     * This method should only be used in cases where it
+     * is absolutely needed. Before using this method,
+     * consider carefully if the use case really requires
+     * code to be executed in UI thread.
+     * <br>
+     * This method is only supported in Qt based runtimes.
+     * <br>
+     * @param runnable Runnable to be executed
+     * @throws RuntimeException if execution in UI thread
+     * is not supported
+     */
+    protected void runInAsyncUiThreadImpl(Runnable runnable)
+    {
+        Toolkit.getInternalDisplay().asyncExec(runnable);
+    }
+
     private native void _hideApplication(boolean hide);
 }