Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-10-25 03:05:50 -0400
committerUwe Stieber2012-10-25 03:06:34 -0400
commitb4234af5552375c4f60ec3a158918f0b7c5a4aac (patch)
treed14ceec301b6a3c6ea791798828eb9738f1573fa /target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core
parent07b893a84d8d258bf895a2c93beac0a3d819f6c4 (diff)
downloadorg.eclipse.tcf-b4234af5552375c4f60ec3a158918f0b7c5a4aac.tar.gz
org.eclipse.tcf-b4234af5552375c4f60ec3a158918f0b7c5a4aac.tar.xz
org.eclipse.tcf-b4234af5552375c4f60ec3a158918f0b7c5a4aac.zip
Target Explorer: Fix Bug 392753 - "Detach" action is still enabled in TE after detaching the context in the Debug view
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/listener/RuntimeModelRunControlServiceListener.java117
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/services/RuntimeModelChannelService.java13
2 files changed, 130 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/listener/RuntimeModelRunControlServiceListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/listener/RuntimeModelRunControlServiceListener.java
new file mode 100644
index 000000000..6f9322a0c
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/listener/RuntimeModelRunControlServiceListener.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.processes.core.model.runtime.listener;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.tcf.services.IRunControl.RunControlContext;
+import org.eclipse.tcf.services.IRunControl.RunControlListener;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelLookupService;
+import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelRefreshService;
+import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel;
+
+/**
+ * Run control service runtime model service listener implementation.
+ */
+public class RuntimeModelRunControlServiceListener implements RunControlListener {
+ // Reference to the parent model
+ private final IRuntimeModel model;
+
+ /**
+ * Constructor.
+ */
+ public RuntimeModelRunControlServiceListener(IRuntimeModel model) {
+ Assert.isNotNull(model);
+ this.model = model;
+ }
+
+ /**
+ * Returns the parent runtime model.
+ *
+ * @return The parent runtime model.
+ */
+ public final IRuntimeModel getModel() {
+ return model;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.services.IRunControl.RunControlListener#contextAdded(org.eclipse.tcf.services.IRunControl.RunControlContext[])
+ */
+ @Override
+ public void contextAdded(RunControlContext[] contexts) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.services.IRunControl.RunControlListener#contextChanged(org.eclipse.tcf.services.IRunControl.RunControlContext[])
+ */
+ @Override
+ public void contextChanged(RunControlContext[] contexts) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.services.IRunControl.RunControlListener#contextRemoved(java.lang.String[])
+ */
+ @Override
+ public void contextRemoved(String[] context_ids) {
+ // If a run control context is removed from run control (detach),
+ // and the context is known to our model, refresh the context as
+ // we do not get events from the process service if the attach state changed.
+ if (context_ids != null && context_ids.length > 0) {
+ IModelLookupService lkupService = model.getService(IModelLookupService.class);
+ IModelRefreshService refreshService = model.getService(IModelRefreshService.class);
+ for (String contextID : context_ids) {
+ IModelNode[] candidates = lkupService.lkupModelNodesById(contextID);
+ if (candidates != null && candidates.length > 0) {
+ for (IModelNode node : candidates) {
+ refreshService.refresh(node, null);
+ }
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.services.IRunControl.RunControlListener#contextSuspended(java.lang.String, java.lang.String, java.lang.String, java.util.Map)
+ */
+ @Override
+ public void contextSuspended(String context, String pc, String reason, Map<String, Object> params) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.services.IRunControl.RunControlListener#contextResumed(java.lang.String)
+ */
+ @Override
+ public void contextResumed(String context) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.services.IRunControl.RunControlListener#containerSuspended(java.lang.String, java.lang.String, java.lang.String, java.util.Map, java.lang.String[])
+ */
+ @Override
+ public void containerSuspended(String context, String pc, String reason, Map<String, Object> params, String[] suspended_ids) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.services.IRunControl.RunControlListener#containerResumed(java.lang.String[])
+ */
+ @Override
+ public void containerResumed(String[] context_ids) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.services.IRunControl.RunControlListener#contextException(java.lang.String, java.lang.String)
+ */
+ @Override
+ public void contextException(String context, String msg) {
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/services/RuntimeModelChannelService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/services/RuntimeModelChannelService.java
index 9dc4882ab..e27ff13c0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/services/RuntimeModelChannelService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/services/RuntimeModelChannelService.java
@@ -14,6 +14,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.IProcesses;
+import org.eclipse.tcf.services.IRunControl;
import org.eclipse.tcf.te.tcf.core.Tcf;
import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager;
import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelChannelService;
@@ -21,6 +22,7 @@ import org.eclipse.tcf.te.tcf.core.model.services.AbstractModelService;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel;
import org.eclipse.tcf.te.tcf.processes.core.model.runtime.listener.RuntimeModelProcessServiceListener;
+import org.eclipse.tcf.te.tcf.processes.core.model.runtime.listener.RuntimeModelRunControlServiceListener;
/**
* Runtime model channel service implementation.
@@ -30,6 +32,8 @@ public class RuntimeModelChannelService extends AbstractModelService<IRuntimeMod
/* default */ IChannel channel;
// Reference to the process service listener
/* default */ IProcesses.ProcessesListener serviceListener;
+ // Reference to the run control service listener
+ /* default */ IRunControl.RunControlListener runControlListener;
/**
* Constructor.
@@ -80,6 +84,15 @@ public class RuntimeModelChannelService extends AbstractModelService<IRuntimeMod
service.addListener(serviceListener);
}
}
+ // Attach the run control service listener instance
+ if (error == null && runControlListener == null) {
+ IRunControl service = channel.getRemoteService(IRunControl.class);
+ if (service != null) {
+ runControlListener = new RuntimeModelRunControlServiceListener(getModel());
+ service.addListener(runControlListener);
+ }
+ }
+
done.doneOpenChannel(error, channel);
}
});

Back to the top