Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-09-09 06:23:46 +0000
committerUwe Stieber2013-09-09 07:26:49 +0000
commit16c957d1f5960de7040f8ce9482e4c86e29ab045 (patch)
tree8f4d27befdc44426fedd419624ca2413b975fcad /target_explorer
parentd9480f0083ddeb1fd8d67d510ae3d00ae9cbae3b (diff)
downloadorg.eclipse.tcf-16c957d1f5960de7040f8ce9482e4c86e29ab045.tar.gz
org.eclipse.tcf-16c957d1f5960de7040f8ce9482e4c86e29ab045.tar.xz
org.eclipse.tcf-16c957d1f5960de7040f8ce9482e4c86e29ab045.zip
Target Explorer: Complete path map service API by adding removePathMap
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java16
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java159
2 files changed, 127 insertions, 48 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java
index a59d77cb9..21a902795 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java
@@ -16,7 +16,8 @@ import org.eclipse.tcf.te.runtime.services.interfaces.IService;
/**
* Path map service.
* <p>
- * Allow the access to the configured path maps for a given context.
+ * Allow the access and manipulation of the configured (object) path maps
+ * for a given context.
*/
public interface IPathMapService extends IService {
@@ -51,6 +52,19 @@ public interface IPathMapService extends IService {
public IPathMap.PathMapRule addPathMap(Object context, String source, String destination);
/**
+ * Removes the given path mapping rule from the configured (object) path mappings
+ * for the given context.
+ * <p>
+ * The method auto applies the new path map to an possibly open shared channel.
+ * <p>
+ * <b>Note:</b> This method must be called from outside the TCF event dispatch thread.
+ *
+ * @param context The context. Must not be <code>null</code>.
+ * @param rule The path map rule. Must not be <code>null</code>.
+ */
+ public void removePathMap(Object context, IPathMap.PathMapRule rule);
+
+ /**
* Apply the configured (object) path mappings to the given context.
* <p>
* <b>Note:</b> This method must be called from outside the TCF event dispatch thread.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java
index 6abd028ec..9b25fd2e1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java
@@ -111,21 +111,7 @@ public class PathMapService extends AbstractService implements IPathMapService {
}
if (config != null) {
- try {
- String path_map_cfg = config.getAttribute(org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.ATTR_PATH_MAP, ""); //$NON-NLS-1$
- String path_map_cfgV1 = config.getAttribute(org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.ATTR_PATH_MAP + "V1", ""); //$NON-NLS-1$ //$NON-NLS-2$
-
- rulesList.addAll(org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.parsePathMapAttribute(path_map_cfgV1));
-
- int i = -1;
- for (PathMapRule candidate : org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.parsePathMapAttribute(path_map_cfg)) {
- if (rulesList.contains(candidate)) {
- i = rulesList.indexOf(candidate);
- } else {
- rulesList.add(++i, candidate);
- }
- }
- } catch (CoreException e) { /* ignored on purpose */ }
+ populatePathMapRulesList(config, rulesList);
// Find an existing path map rule for the given source and destination
for (PathMapRule candidate : rulesList) {
@@ -142,38 +128,7 @@ public class PathMapService extends AbstractService implements IPathMapService {
rulesList.add(rule);
// Update the launch configuration
- for (PathMapRule candidate : rulesList) {
- candidate.getProperties().remove(IPathMap.PROP_ID);
- }
-
- StringBuilder bf = new StringBuilder();
- StringBuilder bf1 = new StringBuilder();
-
- for (PathMapRule candidate : rulesList) {
- if (!(candidate instanceof org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.PathMapRule)) continue;
-
- boolean enabled = true;
- if (candidate.getProperties().containsKey("Enabled")) { //$NON-NLS-1$
- enabled = Boolean.parseBoolean(candidate.getProperties().get("Enabled").toString()); //$NON-NLS-1$
- }
- if (enabled) {
- candidate.getProperties().remove("Enabled"); //$NON-NLS-1$
- bf.append(candidate.toString());
- }
- bf1.append(candidate.toString());
- }
-
- if (bf.length() == 0) {
- config.removeAttribute(TCFLaunchDelegate.ATTR_PATH_MAP);
- } else {
- config.setAttribute(TCFLaunchDelegate.ATTR_PATH_MAP, bf.toString());
- }
-
- if (bf1.length() == 0) {
- config.removeAttribute(org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.ATTR_PATH_MAP + "V1"); //$NON-NLS-1$
- } else {
- config.setAttribute(org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.ATTR_PATH_MAP + "V1", bf1.toString()); //$NON-NLS-1$
- }
+ updateLaunchConfiguration(config, rulesList);
// Apply the path map
applyPathMap(context, new Callback() {
@@ -191,6 +146,116 @@ public class PathMapService extends AbstractService implements IPathMapService {
}
/* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService#removePathMap(java.lang.Object, org.eclipse.tcf.services.IPathMap.PathMapRule)
+ */
+ @Override
+ public void removePathMap(final Object context, final PathMapRule rule) {
+ Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+ Assert.isNotNull(context);
+ Assert.isNotNull(rule);
+
+ List<PathMapRule> rulesList = new ArrayList<PathMapRule>();
+
+ // Get the launch configuration for that peer model
+ ILaunchConfigurationWorkingCopy config = (ILaunchConfigurationWorkingCopy) Platform.getAdapterManager().getAdapter(context, ILaunchConfigurationWorkingCopy.class);
+ if (config == null) {
+ config = (ILaunchConfigurationWorkingCopy) Platform.getAdapterManager().loadAdapter(context, "org.eclipse.debug.core.ILaunchConfigurationWorkingCopy"); //$NON-NLS-1$
+ }
+
+ if (config != null) {
+ populatePathMapRulesList(config, rulesList);
+
+ // Remove the given rule from the list of present
+ if (rulesList.remove(rule)) {
+ // Update the launch configuration
+ updateLaunchConfiguration(config, rulesList);
+
+ // Apply the path map
+ applyPathMap(context, new Callback() {
+ @Override
+ protected void internalDone(Object caller, IStatus status) {
+ if (status != null && Platform.inDebugMode()) {
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
+ }
+ }
+ });
+ }
+ }
+ }
+
+ /**
+ * Populate the given path map rules list from the given launch configuration.
+ *
+ * @param config The launch configuration. Must not be <code>null</code>.
+ * @param rulesList The path map rules list. Must not be <code>null</code>.
+ */
+ private void populatePathMapRulesList(ILaunchConfiguration config, List<PathMapRule> rulesList) {
+ Assert.isNotNull(config);
+ Assert.isNotNull(rulesList);
+
+ try {
+ String path_map_cfg = config.getAttribute(org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.ATTR_PATH_MAP, ""); //$NON-NLS-1$
+ String path_map_cfgV1 = config.getAttribute(org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.ATTR_PATH_MAP + "V1", ""); //$NON-NLS-1$ //$NON-NLS-2$
+
+ rulesList.addAll(org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.parsePathMapAttribute(path_map_cfgV1));
+
+ int i = -1;
+ for (PathMapRule candidate : org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.parsePathMapAttribute(path_map_cfg)) {
+ if (rulesList.contains(candidate)) {
+ i = rulesList.indexOf(candidate);
+ } else {
+ rulesList.add(++i, candidate);
+ }
+ }
+ } catch (CoreException e) { /* ignored on purpose */ }
+ }
+
+ /**
+ * Write back the given path map rules list to the given launch configuration.
+ *
+ * @param config The launch configuration. Must not be <code>null</code>.
+ * @param rulesList The path map rules list. Must not be <code>null</code>.
+ */
+ private void updateLaunchConfiguration(ILaunchConfigurationWorkingCopy config, List<PathMapRule> rulesList) {
+ Assert.isNotNull(config);
+ Assert.isNotNull(rulesList);
+
+ // Update the launch configuration
+ for (PathMapRule candidate : rulesList) {
+ candidate.getProperties().remove(IPathMap.PROP_ID);
+ }
+
+ StringBuilder bf = new StringBuilder();
+ StringBuilder bf1 = new StringBuilder();
+
+ for (PathMapRule candidate : rulesList) {
+ if (!(candidate instanceof org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.PathMapRule)) continue;
+
+ boolean enabled = true;
+ if (candidate.getProperties().containsKey("Enabled")) { //$NON-NLS-1$
+ enabled = Boolean.parseBoolean(candidate.getProperties().get("Enabled").toString()); //$NON-NLS-1$
+ }
+ if (enabled) {
+ candidate.getProperties().remove("Enabled"); //$NON-NLS-1$
+ bf.append(candidate.toString());
+ }
+ bf1.append(candidate.toString());
+ }
+
+ if (bf.length() == 0) {
+ config.removeAttribute(TCFLaunchDelegate.ATTR_PATH_MAP);
+ } else {
+ config.setAttribute(TCFLaunchDelegate.ATTR_PATH_MAP, bf.toString());
+ }
+
+ if (bf1.length() == 0) {
+ config.removeAttribute(org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.ATTR_PATH_MAP + "V1"); //$NON-NLS-1$
+ } else {
+ config.setAttribute(org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.ATTR_PATH_MAP + "V1", bf1.toString()); //$NON-NLS-1$
+ }
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService#applyPathMap(java.lang.Object, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
*/
@Override

Back to the top