Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/util/ExecutionUtils.java

Issue 11364134: Merge libv1. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Reupload due to error Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/util/ExecutionUtils.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/util/ExecutionUtils.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/util/ExecutionUtils.java
index dc77250f7a46669bbbf105f1711c8a64fd452615..f4dd0a83f77cbf02b229760e9c00ff82004823ea 100644
--- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/util/ExecutionUtils.java
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/util/ExecutionUtils.java
@@ -18,6 +18,7 @@ import com.google.dart.tools.core.DartCore;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.widgets.Display;
/**
* Utilities for executing actions, such as {@link RunnableObjectEx}.
@@ -137,6 +138,21 @@ public class ExecutionUtils {
}
/**
+ * Runs given {@link RunnableEx} inside of UI thread, using {@link Display#syncExec(Runnable)}.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T runObjectUI(final RunnableObjectEx<T> runnable) {
+ final Object[] result = new Object[1];
+ runRethrowUI(new RunnableEx() {
+ @Override
+ public void run() throws Exception {
+ result[0] = runObject(runnable);
+ }
+ });
+ return (T) result[0];
+ }
+
+ /**
* Runs given {@link RunnableEx} and re-throws any exceptions without declaring it.
*/
public static void runRethrow(RunnableEx runnable) {
@@ -159,6 +175,18 @@ public class ExecutionUtils {
}
/**
+ * Runs given {@link RunnableEx} inside of UI thread, using {@link Display#syncExec(Runnable)}.
+ */
+ public static void runRethrowUI(final RunnableEx runnable) {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ ExecutionUtils.runRethrow(runnable);
+ }
+ });
+ }
+
+ /**
* Sleeps given number of milliseconds, ignoring exceptions.
*/
public static void sleep(final int millis) {

Powered by Google App Engine
This is Rietveld 408576698