diff options
author | Tobias Schwarz | 2015-01-22 07:36:12 +0000 |
---|---|---|
committer | Tobias Schwarz | 2015-01-22 07:58:34 +0000 |
commit | 021f462a18b882930245c1d8046af064dc23f28e (patch) | |
tree | 7ddfd19431ad9b660b0b2f0bc33f1ef6a74cf49c | |
parent | e1ccaaee40a51f1eae7c4bff508599a2871a1739 (diff) | |
download | org.eclipse.tcf-021f462a18b882930245c1d8046af064dc23f28e.tar.gz org.eclipse.tcf-021f462a18b882930245c1d8046af064dc23f28e.tar.xz org.eclipse.tcf-021f462a18b882930245c1d8046af064dc23f28e.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 |