summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Liebig2011-04-12 04:46:59 -0400
committerStefan Liebig2011-04-12 04:46:59 -0400
commitd3f1ab88cd98a9d8135b86187d9ab12326ce8936 (patch)
treec8b3d30eb04c8d3e069789c823ab1bf777cb51a2
parent1c094a6676518e0b57c02dccc74f4aa1a4cc3c99 (diff)
downloadorg.eclipse.riena-d3f1ab88cd98a9d8135b86187d9ab12326ce8936.zip
org.eclipse.riena-d3f1ab88cd98a9d8135b86187d9ab12326ce8936.tar.gz
org.eclipse.riena-d3f1ab88cd98a9d8135b86187d9ab12326ce8936.tar.xz
uses now UIExecutor
-rw-r--r--org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/AbstractSimpleNavigationNodeProvider.java50
1 files changed, 2 insertions, 48 deletions
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 add12a5..752a26e 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
@@ -20,12 +20,10 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicBoolean;
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.riena.core.Log4r;
@@ -44,8 +42,7 @@ import org.eclipse.riena.navigation.StartupNodeInfo.Level;
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;
+import org.eclipse.riena.ui.core.uiprocess.UIExecutor;
/**
* This class provides navigation nodes that are defined by assemlies2
@@ -162,21 +159,11 @@ public abstract class AbstractSimpleNavigationNodeProvider implements INavigatio
INavigationNode<?>[] targetNodes = null;
if ((null != argument && argument.isCreateNodesAsync()) || shouldRunAsync(assembler)) {
- final Callable<INavigationNode<?>[]> callable = new Callable<INavigationNode<?>[]>() {
-
+ targetNodes = UIExecutor.executeLively(new Callable<INavigationNode<?>[]>() {
public INavigationNode<?>[] call() throws Exception {
return assembler.buildNode(targetId, argument);
}
- };
- // Could be done with ExecutorService and Future. Using an UIProcess because of rap thread context attachment!
- final NodeBuilderProcess process = new NodeBuilderProcess(callable);
- process.start();
- UISynchronizer.createSynchronizer().readAndDispatch(new Callable<Boolean>() {
- public Boolean call() throws Exception {
- return process.isFinished();
- }
});
- targetNodes = process.getResult();
} else {
targetNodes = assembler.buildNode(targetId, argument);
}
@@ -209,39 +196,6 @@ public abstract class AbstractSimpleNavigationNodeProvider implements INavigatio
return assembler.getClass().isAnnotationPresent(RunAsync.class);
}
- private class NodeBuilderProcess extends UIProcess {
-
- private final AtomicBoolean finished = new AtomicBoolean(false);
- private final Callable<INavigationNode<?>[]> command;
- private INavigationNode<?>[] result = null;
-
- public NodeBuilderProcess(final Callable<INavigationNode<?>[]> command) {
- super("worker", false); //$NON-NLS-1$
- this.command = command;
- }
-
- @Override
- public boolean runJob(final IProgressMonitor monitor) {
- try {
- result = command.call();
- } catch (final Exception e) {
- LOGGER.log(LogService.LOG_ERROR, e.getMessage());
- } finally {
- finished.set(true);
- }
- return true;
- }
-
- private boolean isFinished() {
- return finished.get();
- }
-
- private INavigationNode<?>[] getResult() {
- return result;
- }
-
- }
-
// private void printNodeTree(final INavigationNode<?> root, final int depth) {
// final StringBuffer b = new StringBuffer();
// for (int i = 0; i < depth; i++) {