Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2014-05-03 10:31:35 -0400
committerUwe Stieber2014-05-03 10:31:35 -0400
commit632b4de66f5866d3f37507d9a325468b515194d0 (patch)
tree0abd41ecda7bbbcce435279d6acce5797bbfa680
parente0fb3ebd7890acc042742ac622a0f3d63e49353f (diff)
downloadorg.eclipse.tcf-632b4de66f5866d3f37507d9a325468b515194d0.tar.gz
org.eclipse.tcf-632b4de66f5866d3f37507d9a325468b515194d0.tar.xz
org.eclipse.tcf-632b4de66f5866d3f37507d9a325468b515194d0.zip
Target Explorer: Simplify simulator utils implementation
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java58
1 files changed, 25 insertions, 33 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java
index 157529342..7ada3d342 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java
@@ -11,12 +11,12 @@
package org.eclipse.tcf.te.tcf.locator.utils;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.callback.Callback;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
@@ -78,43 +78,35 @@ public final class SimulatorUtils {
public static Result getSimulatorService(final IPeerNode peerNode) {
Assert.isNotNull(peerNode);
- final AtomicBoolean isEnabled = new AtomicBoolean(false);
- final AtomicReference<String> type = new AtomicReference<String>();
- final AtomicReference<String> properties = new AtomicReference<String>();
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- String value = peerNode.getPeer().getAttributes().get(IPeerNodeProperties.PROP_SIM_ENABLED);
- if (value != null) {
- isEnabled.set(Boolean.parseBoolean(value));
- }
-
- type.set(peerNode.getPeer().getAttributes().get(IPeerNodeProperties.PROP_SIM_TYPE));
- properties.set(peerNode.getPeer().getAttributes().get(IPeerNodeProperties.PROP_SIM_PROPERTIES));
- }
- };
-
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
-
Result result = null;
- if (isEnabled.get()) {
- IService[] services = ServiceManager.getInstance().getServices(peerNode, ISimulatorService.class, false);
- for (IService service : services) {
- Assert.isTrue(service instanceof ISimulatorService);
- // Get the UI service which is associated with the simulator service
- String id = service.getId();
- if (id != null && id.equals(type.get())) {
- result = new Result();
- result.service = (ISimulatorService)service;
- result.id = id;
- result.settings = properties.get();
- break;
+ IPeer peer = peerNode.getPeer();
+ if (peer != null) {
+ boolean isEnabled = false;
+
+ String value = peer.getAttributes().get(IPeerNodeProperties.PROP_SIM_ENABLED);
+ if (value != null) isEnabled = Boolean.parseBoolean(value);
+
+ String type = peer.getAttributes().get(IPeerNodeProperties.PROP_SIM_TYPE);
+ String properties = peer.getAttributes().get(IPeerNodeProperties.PROP_SIM_PROPERTIES);
+
+ if (isEnabled) {
+ IService[] services = ServiceManager.getInstance().getServices(peerNode, ISimulatorService.class, false);
+ for (IService service : services) {
+ Assert.isTrue(service instanceof ISimulatorService);
+ // Get the UI service which is associated with the simulator service
+ String id = service.getId();
+ if (id != null && id.equals(type)) {
+ result = new Result();
+ result.service = (ISimulatorService)service;
+ result.id = id;
+ result.settings = properties;
+ break;
+ }
}
}
}
+
return result;
}

Back to the top