summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2011-03-30 08:31:42 (EDT)
committerSteffen Kriese2011-03-30 08:31:42 (EDT)
commit92e8c72e298f94e5818b911fcfabdb26b99a2aeb (patch)
treebee36e0ff81c9e3175209dec419f2f8b9c8d20ae
parent594cdf4dabb5b2ee52421db6c070f078612beed3 (diff)
downloadorg.eclipse.riena-92e8c72e298f94e5818b911fcfabdb26b99a2aeb.zip
org.eclipse.riena-92e8c72e298f94e5818b911fcfabdb26b99a2aeb.tar.gz
org.eclipse.riena-92e8c72e298f94e5818b911fcfabdb26b99a2aeb.tar.bz2
removed dependency to org.eclipse.ui.swt from bundle org.eclipse.riena.navigation and moved the dispatching stuff to the UISynchronizer
-rw-r--r--org.eclipse.riena.navigation/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/AbstractSimpleNavigationNodeProvider.java14
-rw-r--r--org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/IUISynchronizer.java12
-rw-r--r--org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/uiprocess/SwtUISynchronizer.java26
4 files changed, 44 insertions, 11 deletions
diff --git a/org.eclipse.riena.navigation/META-INF/MANIFEST.MF b/org.eclipse.riena.navigation/META-INF/MANIFEST.MF
index 9a9355d..8a07427 100644
--- a/org.eclipse.riena.navigation/META-INF/MANIFEST.MF
+++ b/org.eclipse.riena.navigation/META-INF/MANIFEST.MF
@@ -7,8 +7,7 @@ Bundle-Activator: org.eclipse.riena.internal.navigation.Activator
Require-Bundle: org.eclipse.riena.core,
org.eclipse.riena.ui.core,
org.eclipse.riena.ui.ridgets,
- org.eclipse.riena.ui.filter;visibility:=reexport,
- org.eclipse.swt
+ org.eclipse.riena.ui.filter;visibility:=reexport
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.riena.internal.navigation;x-internal:=true,
org.eclipse.riena.navigation,
diff --git a/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/AbstractSimpleNavigationNodeProvider.java b/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/AbstractSimpleNavigationNodeProvider.java
index 160f5c0..add12a5 100644
--- a/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/AbstractSimpleNavigationNodeProvider.java
+++ b/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/AbstractSimpleNavigationNodeProvider.java
@@ -27,7 +27,6 @@ import org.osgi.service.log.LogService;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.log.Logger;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.riena.core.Log4r;
import org.eclipse.riena.core.util.StringUtils;
@@ -46,6 +45,7 @@ import org.eclipse.riena.navigation.extension.ICommonNavigationAssemblyExtension
import org.eclipse.riena.navigation.extension.INavigationAssembly2Extension;
import org.eclipse.riena.navigation.extension.INode2Extension;
import org.eclipse.riena.ui.core.uiprocess.UIProcess;
+import org.eclipse.riena.ui.core.uiprocess.UISynchronizer;
/**
* This class provides navigation nodes that are defined by assemlies2
@@ -171,15 +171,11 @@ public abstract class AbstractSimpleNavigationNodeProvider implements INavigatio
// Could be done with ExecutorService and Future. Using an UIProcess because of rap thread context attachment!
final NodeBuilderProcess process = new NodeBuilderProcess(callable);
process.start();
- // FIXME addeed a dependecy to org.eclipse.swt so we can use the Display for dispatching.
- // maybe we could move this code to UISynchronizer instead and get rid of the dependency
- final Display display = Display.getCurrent();
- // dispatch events
- while (!process.isFinished()) {
- if (!display.readAndDispatch()) {
- display.sleep();
+ UISynchronizer.createSynchronizer().readAndDispatch(new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ return process.isFinished();
}
- }
+ });
targetNodes = process.getResult();
} else {
targetNodes = assembler.buildNode(targetId, argument);
diff --git a/org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/IUISynchronizer.java b/org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/IUISynchronizer.java
index 1077a3a..aa80b93 100644
--- a/org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/IUISynchronizer.java
+++ b/org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/IUISynchronizer.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.riena.ui.core.uiprocess;
+import java.util.concurrent.Callable;
+
/**
* Class implementing this interface are responsible for executing a
* {@code Runnable} on the UI-Thread of the underlying widget toolkit.
@@ -33,4 +35,14 @@ public interface IUISynchronizer {
* the {@code Runnable} to be executed on the UI-thread
*/
void asyncExec(Runnable runnable);
+
+ /**
+ * Dispatches the swt-events while the given condition returns
+ * <code>true</code>
+ *
+ * @param condition
+ * the run condition
+ * @since 3.0
+ */
+ void readAndDispatch(Callable<Boolean> condition);
}
diff --git a/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/uiprocess/SwtUISynchronizer.java b/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/uiprocess/SwtUISynchronizer.java
index 0d87df1..f0d9503 100644
--- a/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/uiprocess/SwtUISynchronizer.java
+++ b/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/uiprocess/SwtUISynchronizer.java
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -262,4 +263,29 @@ public class SwtUISynchronizer implements IUISynchronizer {
public static void setWorkbenchShutdown(final boolean workbenchShutdown) {
SwtUISynchronizer.workbenchShutdown.set(workbenchShutdown);
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.riena.ui.core.uiprocess.IUISynchronizer#readAndDispatch(java
+ * .util.concurrent.Callable)
+ */
+ public void readAndDispatch(final Callable<Boolean> condition) {
+ Assert.isNotNull(condition);
+
+ final Display display = Display.getCurrent();
+
+ // dispatch events
+ try {
+ while (!condition.call()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+
+ }
}