diff options
author | Tobias Schwarz | 2015-01-22 07:36:12 +0000 |
---|---|---|
committer | Tobias Schwarz | 2015-01-22 10:34:42 +0000 |
commit | 494b32de5a621e4d2b2e34e1039b78f150790533 (patch) | |
tree | 1e1bd46602cd18cfd7f9dcee625a88f54dc07099 | |
parent | f4fa9be4c8406cee92f09d2dd654f8b76efe68b4 (diff) | |
download | org.eclipse.tcf-494b32de5a621e4d2b2e34e1039b78f150790533.tar.gz org.eclipse.tcf-494b32de5a621e4d2b2e34e1039b78f150790533.tar.xz org.eclipse.tcf-494b32de5a621e4d2b2e34e1039b78f150790533.zip |
SM: add method to use already running simulator instead of starting new
one.
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java | 27 |
1 files changed, 25 insertions, 2 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 97f984229..7c31b3f15 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 @@ -152,15 +152,17 @@ public final class SimulatorUtils { result.service.start(peerNode, result.settings, new Callback() { @Override protected void internalDone(Object caller, IStatus status) { + setUsedRunningSimulator(peerNode, false); callback.setResult(new Boolean(status.isOK())); callback.done(caller, status); } }, monitor); } else { - // Start the simulator + // Try to use running simulator result.service.useRunning(peerNode, result.settings, new Callback() { @Override protected void internalDone(Object caller, IStatus status) { + setUsedRunningSimulator(peerNode, status.isOK()); callback.setResult(new Boolean(status.isOK())); callback.done(caller, status); } @@ -169,11 +171,32 @@ public final class SimulatorUtils { } }, monitor); } else { + setUsedRunningSimulator(peerNode, false); callback.setResult(Boolean.FALSE); callback.done(null, Status.OK_STATUS); } } + protected static void setUsedRunningSimulator(final IPeerNode peerNode, final boolean usedRunning) { + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + peerNode.setProperty(SimulatorUtils.class.getSimpleName() + ".usedRunning", usedRunning ? new Boolean(usedRunning) : null); //$NON-NLS-1$ + } + }); + } + + protected static boolean getUsedRunningSimulator(final IPeerNode peerNode) { + final AtomicBoolean usedRunning = new AtomicBoolean(false); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + usedRunning.set(peerNode.getBooleanProperty(SimulatorUtils.class.getSimpleName() + ".usedRunning")); //$NON-NLS-1$ + } + }); + return usedRunning.get(); + } + /** * Stops the simulator if the simulator launch is enabled for the given peer * model node and the configured simulator service type is available. In any @@ -189,7 +212,7 @@ public final class SimulatorUtils { // Get the associated simulator service final Result result = getSimulatorService(peerNode); - if (result != null && result.service != null) { + if (result != null && result.service != null && !getUsedRunningSimulator(peerNode)) { // Determine if the simulator is at all running result.service.isRunning(peerNode, result.settings, new Callback() { @Override |