Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2013-08-23 05:30:13 +0000
committerTobias Schwarz2013-08-23 05:30:13 +0000
commit46b8856d2281edfbfe534954dbdd658d699d8a0a (patch)
treebef0ee45e47ebfd6cc6679f0121129e8b703b06b /target_explorer/plugins
parent3e04f26cf1a0d3fdf2fcecd6e88aed9dc7f5f98b (diff)
downloadorg.eclipse.tcf-46b8856d2281edfbfe534954dbdd658d699d8a0a.tar.gz
org.eclipse.tcf-46b8856d2281edfbfe534954dbdd658d699d8a0a.tar.xz
org.eclipse.tcf-46b8856d2281edfbfe534954dbdd658d699d8a0a.zip
Target Explorer: add launch config type unbingding extension point
Diffstat (limited to 'target_explorer/plugins')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchConfigTypeBindings.exsd416
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java66
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java558
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeUnBinding.java158
4 files changed, 696 insertions, 502 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchConfigTypeBindings.exsd b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchConfigTypeBindings.exsd
index 544328da8..87f8eac2e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchConfigTypeBindings.exsd
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchConfigTypeBindings.exsd
@@ -1,196 +1,220 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.tcf.te.launch.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.tcf.te.launch.core" id="launchConfigTypeBindings" name="Launch Configuration Type Bindings"/>
- </appinfo>
- <documentation>
- This extension point is used to describe the bindings between a given launch configuration type, the executable steps and/or step groups and when the launch configuration type is enabled.
- </documentation>
- </annotation>
-
- <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="launchConfigTypeBinding"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="launchConfigTypeBinding">
- <annotation>
- <documentation>
- Each launch configuration type needs at least one launchConfigTypeBinding.
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <element ref="launchManagerDelegate" minOccurs="0" maxOccurs="unbounded"/>
- <element ref="stepGroup" minOccurs="0" maxOccurs="unbounded"/>
- <element ref="enablement" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="launchConfigTypeId" type="string" use="required">
- <annotation>
- <documentation>
- The launch config type id.
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.debug.core.launchConfigurationTypes/launchConfigurationType/@id"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="launchManagerDelegate">
- <annotation>
- <documentation>
- A launch manager delegate could be bound to a launch configuration type for each available launch mode. If no launch mode is specified, the launch manager delegate is used for all launch modes he supports.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- The id of the launch manager delegate to bind.
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.tcf.te.launch.core.launchManagerDelegates/delegate/@id"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="overwrites" type="string">
- <annotation>
- <documentation>
- The id of a previousely bound launch manager delegate to overwrite with the launchManagerDelegateId. A comma separated list can be specified to overwrite multiple launch manager delegates.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="modes" type="string">
- <annotation>
- <documentation>
- The launch mode to use the launch manager delegate for. If not specified, the launch manager delegate is used for all undefined launch modes, for which the launch configuration type can be used.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="stepGroup">
- <annotation>
- <documentation>
- A step group could be bound to a launch configuration type for each available launch mode. If no launch mode is specified, the step group is used for all launch modes the launch configuration type supports.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- The id of the step group to use.
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.tcf.te.runtime.stepper.stepGroups/stepGroup/@id"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="overwrites" type="string">
- <annotation>
- <documentation>
- The id of a previousely bound step group to overwrite with the id. A comma separated list can be specified to overwrite multiple step groups.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="modes" type="string">
- <annotation>
- <documentation>
- The launch mode to use the step group for. If not specified, the step group is used for all undefined launch modes, for which the launch configuration type can be used.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- Target Explorer 1.0.0
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- The following is an example of this extension point&apos;s usage:
-
-&lt;p&gt;
-&lt;pre&gt;
- &lt;extension point=&quot;org.eclipse.tcf.te.launch.core.launchConfigTypeBindings&quot;&gt;
- &lt;launchConfigTypeBinding launchConfigTypeId=&quot;org.eclipse.tcf.te.launch.linux.process&quot;&gt;
-
- &lt;launchManagerDelegate id=&quot;org.eclipse.tcf.te.launch.linux.process.launchManagerDelegate&quot;/&gt;
-
- &lt;stepper id=&quot;org.eclipse.tcf.te.runtime.stepper.multiContext&quot;/&gt;
-
- &lt;enablement&gt;
- ...
- &lt;/enablement&gt;
- &lt;/launchConfigTypeBinding&gt;
- &lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
-
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- 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.
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.tcf.te.launch.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.tcf.te.launch.core" id="launchConfigTypeBindings" name="Launch Configuration Type Bindings"/>
+ </appinfo>
+ <documentation>
+ This extension point is used to describe the bindings between a given launch configuration type, the executable steps and/or step groups and when the launch configuration type is enabled.
+ </documentation>
+ </annotation>
+
+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="launchConfigTypeBinding" minOccurs="0" maxOccurs="1"/>
+ <element ref="launchConfigTypeUnBinding" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="launchConfigTypeBinding">
+ <annotation>
+ <documentation>
+ Each launch configuration type needs at least one launchConfigTypeBinding.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="launchManagerDelegate" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="stepGroup" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="enablement" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="launchConfigTypeId" type="string" use="required">
+ <annotation>
+ <documentation>
+ The launch config type id.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.debug.core.launchConfigurationTypes/launchConfigurationType/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="launchConfigTypeUnBinding">
+ <annotation>
+ <documentation>
+ Possibility to remove a binding from a special context.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="enablement" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="launchConfigTypeId" type="string" use="required">
+ <annotation>
+ <documentation>
+ The launch config type id.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.debug.core.launchConfigurationTypes/launchConfigurationType/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="launchManagerDelegate">
+ <annotation>
+ <documentation>
+ A launch manager delegate could be bound to a launch configuration type for each available launch mode. If no launch mode is specified, the launch manager delegate is used for all launch modes he supports.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The id of the launch manager delegate to bind.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.tcf.te.launch.core.launchManagerDelegates/delegate/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="overwrites" type="string">
+ <annotation>
+ <documentation>
+ The id of a previousely bound launch manager delegate to overwrite with the launchManagerDelegateId. A comma separated list can be specified to overwrite multiple launch manager delegates.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="modes" type="string">
+ <annotation>
+ <documentation>
+ The launch mode to use the launch manager delegate for. If not specified, the launch manager delegate is used for all undefined launch modes, for which the launch configuration type can be used.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="stepGroup">
+ <annotation>
+ <documentation>
+ A step group could be bound to a launch configuration type for each available launch mode. If no launch mode is specified, the step group is used for all launch modes the launch configuration type supports.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The id of the step group to use.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.tcf.te.runtime.stepper.stepGroups/stepGroup/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="overwrites" type="string">
+ <annotation>
+ <documentation>
+ The id of a previousely bound step group to overwrite with the id. A comma separated list can be specified to overwrite multiple step groups.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="modes" type="string">
+ <annotation>
+ <documentation>
+ The launch mode to use the step group for. If not specified, the step group is used for all undefined launch modes, for which the launch configuration type can be used.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ Target Explorer 1.0.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ The following is an example of this extension point&apos;s usage:
+
+&lt;p&gt;
+&lt;pre&gt;
+ &lt;extension point=&quot;org.eclipse.tcf.te.launch.core.launchConfigTypeBindings&quot;&gt;
+ &lt;launchConfigTypeBinding launchConfigTypeId=&quot;org.eclipse.tcf.te.launch.linux.process&quot;&gt;
+
+ &lt;launchManagerDelegate id=&quot;org.eclipse.tcf.te.launch.linux.process.launchManagerDelegate&quot;/&gt;
+
+ &lt;stepper id=&quot;org.eclipse.tcf.te.runtime.stepper.multiContext&quot;/&gt;
+
+ &lt;enablement&gt;
+ ...
+ &lt;/enablement&gt;
+ &lt;/launchConfigTypeBinding&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ 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.
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java
index 0102b4af8..c2263a345 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java
@@ -28,6 +28,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.tcf.te.launch.core.bindings.internal.LaunchConfigTypeBinding;
+import org.eclipse.tcf.te.launch.core.bindings.internal.LaunchConfigTypeUnBinding;
import org.eclipse.tcf.te.launch.core.bindings.internal.OverwritableLaunchBinding;
import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate;
import org.eclipse.tcf.te.launch.core.lm.internal.ExtensionPointManager;
@@ -42,6 +43,8 @@ import org.eclipse.tcf.te.runtime.extensions.ExtensionPointComparator;
public class LaunchConfigTypeBindingsManager {
// Map of all launch configuration type bindings by id
private final Map<String, LaunchConfigTypeBinding> bindings = new Hashtable<String, LaunchConfigTypeBinding>();
+ // Map of all launch configuration type unbindings by id
+ private final Map<String, LaunchConfigTypeUnBinding> unBindings = new Hashtable<String, LaunchConfigTypeUnBinding>();
/*
* Thread save singleton instance creation.
@@ -94,10 +97,12 @@ public class LaunchConfigTypeBindingsManager {
Assert.isNotNull(selection);
LaunchConfigTypeBinding binding = bindings.get(typeId);
+ LaunchConfigTypeUnBinding unBinding = unBindings.get(typeId);
ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(typeId);
return (launchConfigType != null &&
(selection.getLaunchMode() == null || launchConfigType.supportsMode(selection.getLaunchMode())) &&
- binding != null && binding.validate(selection) == EvaluationResult.TRUE);
+ binding != null && binding.validate(selection) == EvaluationResult.TRUE &&
+ (unBinding == null || unBinding.validate(selection) == EvaluationResult.FALSE));
}
/**
@@ -112,10 +117,12 @@ public class LaunchConfigTypeBindingsManager {
Assert.isNotNull(context);
LaunchConfigTypeBinding binding = bindings.get(typeId);
+ LaunchConfigTypeUnBinding unBinding = unBindings.get(typeId);
ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(typeId);
return (launchConfigType != null &&
(mode == null || launchConfigType.supportsMode(mode)) &&
- binding != null && binding.validate(mode, context) != EvaluationResult.FALSE);
+ binding != null && binding.validate(mode, context) != EvaluationResult.FALSE &&
+ (unBinding == null || unBinding.validate(mode, context) == EvaluationResult.FALSE));
}
/**
@@ -173,7 +180,8 @@ public class LaunchConfigTypeBindingsManager {
for (IExtension binding : bindings) {
IConfigurationElement[] elements = binding.getConfigurationElements();
for (IConfigurationElement element : elements) {
- loadBinding(element);
+ if (!loadBinding(element))
+ loadUnBinding(element);
}
}
}
@@ -184,11 +192,11 @@ public class LaunchConfigTypeBindingsManager {
*
* @param element The configuration element. Must not be <code>null</code>.
*/
- private void loadBinding(IConfigurationElement element) {
+ private boolean loadBinding(IConfigurationElement element) {
Assert.isNotNull(element);
if (!element.getName().equals("launchConfigTypeBinding")) { //$NON-NLS-1$
- return;
+ return false;
}
String launchConfigTypeId = element.getAttribute("launchConfigTypeId"); //$NON-NLS-1$
@@ -206,15 +214,6 @@ public class LaunchConfigTypeBindingsManager {
binding.addLaunchManagerDelegate(new OverwritableLaunchBinding(id, overwrites, modes));
}
- IConfigurationElement[] stepperBindings = element.getChildren("stepper"); //$NON-NLS-1$
- for (IConfigurationElement stepperBinding : stepperBindings) {
- String id = stepperBinding.getAttribute("id"); //$NON-NLS-1$
- String overwrites = stepperBinding.getAttribute("overwrites"); //$NON-NLS-1$
- String modes = stepperBinding.getAttribute("modes"); //$NON-NLS-1$
-
- binding.addStepper(new OverwritableLaunchBinding(id, overwrites, modes));
- }
-
IConfigurationElement[] stepGroupBindings = element.getChildren("stepGroup"); //$NON-NLS-1$
for (IConfigurationElement stepGroupBinding : stepGroupBindings) {
String id = stepGroupBinding.getAttribute("id"); //$NON-NLS-1$
@@ -239,6 +238,45 @@ public class LaunchConfigTypeBindingsManager {
binding.addEnablement(expression);
}
}
+
+ return true;
}
+
+ /**
+ * Load a single launch configuration type unbinding.
+ *
+ * @param element The configuration element. Must not be <code>null</code>.
+ */
+ private boolean loadUnBinding(IConfigurationElement element) {
+ Assert.isNotNull(element);
+
+ if (!element.getName().equals("launchConfigTypeUnBinding")) { //$NON-NLS-1$
+ return false;
+ }
+
+ String launchConfigTypeId = element.getAttribute("launchConfigTypeId"); //$NON-NLS-1$
+ if (!unBindings.containsKey(launchConfigTypeId)) {
+ unBindings.put(launchConfigTypeId, new LaunchConfigTypeUnBinding(launchConfigTypeId));
+ }
+ LaunchConfigTypeUnBinding unBinding = unBindings.get(launchConfigTypeId);
+
+ IConfigurationElement[] enablements = element.getChildren("enablement"); //$NON-NLS-1$
+ for (IConfigurationElement enablement : enablements) {
+ Expression expression = null;
+ try {
+ expression = ExpressionConverter.getDefault().perform(enablement);
+ } catch (CoreException e) {
+ if (Platform.inDebugMode()) {
+ e.printStackTrace();
+ }
+ }
+
+ if (expression != null) {
+ unBinding.addEnablement(expression);
+ }
+ }
+
+ return true;
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java
index fb0d4ae68..dff95ce66 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java
@@ -1,292 +1,266 @@
-/*******************************************************************************
- * 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.launch.core.bindings.internal;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.launch.core.bindings.interfaces.ILaunchBinding;
-import org.eclipse.tcf.te.launch.core.bindings.interfaces.IOverwritableLaunchBinding;
-import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
-import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
-
-/**
- * Launch configuration type binding implementation.
- */
-public class LaunchConfigTypeBinding {
- // The launch configuration type id
- private final String typeId;
-
- // Lists of sub bindings
- private final List<ILaunchBinding> lmDelegateBindings = new ArrayList<ILaunchBinding>();
- private final List<ILaunchBinding> stepperBindings = new ArrayList<ILaunchBinding>();
- private final List<ILaunchBinding> stepGroupBindings = new ArrayList<ILaunchBinding>();
-
- // The list of enablement expressions
- private final List<Expression> expressions = new ArrayList<Expression>();
-
- /**
- * Constructor.
- *
- * @param typeId The launch configuration type id the binding applies to. Must not be
- * <code>null</code>.
- */
- public LaunchConfigTypeBinding(String typeId) {
- Assert.isNotNull(typeId);
- this.typeId = typeId;
- }
-
- /**
- * Returns the launch configuration type id the binding applies to.
- *
- * @return The launch configuration type id.
- */
- public String getTypeId() {
- return typeId;
- }
-
- /**
- * Returns the launch manager delegate id for the given launch mode.
- *
- * @param mode The launch mode. Must not be <code>null</code>.
- * @return The launch manager delegate id or <code>null</code>.
- */
- public String getLaunchManagerDelegate(String mode) {
- Assert.isNotNull(mode);
-
- ILaunchBinding binding = getBinding(lmDelegateBindings, mode);
- return binding != null ? binding.getId() : null;
- }
-
- /**
- * Adds the given launch manager delegate binding.
- *
- * @param binding The binding. Must not be <code>null</code>.
- */
- public void addLaunchManagerDelegate(IOverwritableLaunchBinding binding) {
- Assert.isNotNull(binding);
- if (!lmDelegateBindings.contains(binding)) {
- lmDelegateBindings.add(binding);
- }
- }
-
- /**
- * Returns the stepper id for the given launch mode.
- *
- * @param mode The launch mode. Must not be <code>null</code>.
- * @return The stepper id or <code>null</code>.
- */
- public String getStepper(String mode) {
- Assert.isNotNull(mode);
-
- ILaunchBinding binding = getBinding(stepperBindings, mode);
- return binding != null ? binding.getId() : null;
- }
-
- /**
- * Adds the given stepper binding.
- *
- * @param binding The binding. Must not be <code>null</code>.
- */
- public void addStepper(IOverwritableLaunchBinding binding) {
- Assert.isNotNull(binding);
- if (!stepperBindings.contains(binding)) {
- stepperBindings.add(binding);
- }
- }
-
- /**
- * Returns the step group id for the given launch mode.
- *
- * @param mode The launch mode. Must not be <code>null</code>.
- *
- * @return The step group id or <code>null</code>.
- */
- public String getStepGroupId(String mode) {
- ILaunchBinding binding = getBinding(stepGroupBindings, mode);
- return binding != null ? binding.getId() : null;
- }
-
- /**
- * Adds the given step group binding.
- *
- * @param binding The binding. Must not be <code>null</code>.
- */
- public void addStepGroup(ILaunchBinding binding) {
- Assert.isNotNull(binding);
- if (!stepGroupBindings.contains(binding)) {
- stepGroupBindings.add(binding);
- }
- }
-
- /**
- * Adds the given enablement expression.
- *
- * @param enablement The enablement expression. Must not be <code>null</code>.
- */
- public void addEnablement(Expression expression) {
- Assert.isNotNull(expression);
- if (!expressions.contains(expression)) {
- expressions.add(expression);
- }
- }
-
- /**
- * Evaluates the enablement expressions with the given launch selection.
- *
- * @param selection The launch selection. Must not be <code>null</code>.
- * @return The result of the enablement expression evaluation.
- */
- public EvaluationResult validate(ILaunchSelection selection) {
- Assert.isNotNull(selection);
-
- EvaluationResult result = EvaluationResult.NOT_LOADED;
-
- EvaluationResult valresult;
- for (ISelectionContext context : selection.getSelectedContexts()) {
- if (context.isPreferredContext()) {
- valresult = validate(selection.getLaunchMode(), context);
- if (valresult == EvaluationResult.FALSE) {
- return EvaluationResult.FALSE;
- }
- else if (valresult != EvaluationResult.NOT_LOADED) {
- result = valresult;
- }
- }
- }
- return result;
- }
-
- /**
- * Evaluates the enablement expressions with the given launch mode and selection context.
- *
- * @param mode The launch mode. Must not be <code>null</code>.
- * @param context The launch selection context or <code>null</code>.
- *
- * @return The result of the enablement expression evaluation.
- */
- public EvaluationResult validate(String mode, ISelectionContext context) {
- EvaluationResult result = context.isPreferredContext() ? EvaluationResult.FALSE : EvaluationResult.NOT_LOADED;
-
- if (expressions.isEmpty()) {
- return EvaluationResult.TRUE;
- }
- EvaluationResult valresult;
- for (Expression expression : expressions) {
- // Set the default variable and "selection" is the selection context
- EvaluationContext evalContext = new EvaluationContext(null, context);
- evalContext.addVariable("context", context.getContext()); //$NON-NLS-1$
- evalContext.addVariable("selection", context.getSelections() != null ? Arrays.asList(context.getSelections()) : Collections.EMPTY_LIST); //$NON-NLS-1$
- evalContext.addVariable("type", context.getType() != null ? context.getType() : ""); //$NON-NLS-1$ //$NON-NLS-2$
- evalContext.addVariable("mode", mode != null ? mode : ""); //$NON-NLS-1$ //$NON-NLS-2$
- // Allow plugin activation
- evalContext.setAllowPluginActivation(true);
- // Evaluate the expression
- try {
- valresult = expression.evaluate(evalContext);
- } catch (CoreException e) {
- valresult = EvaluationResult.FALSE;
-
- if (Platform.inDebugMode()) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), e.getLocalizedMessage(), e);
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- }
-
- if (valresult == EvaluationResult.TRUE) {
- return EvaluationResult.TRUE;
- }
- if (valresult != EvaluationResult.NOT_LOADED) {
- result = valresult;
- }
- }
-
- return result;
- }
-
- /**
- * Returns the list of bindings valid for the given launch mode.
- *
- * @param bindings The list of available bindings. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
- *
- * @return The list of valid bindings for the given launch mode or an empty list.
- */
- private List<ILaunchBinding> getBindings(List<ILaunchBinding> bindings, String mode) {
- Assert.isNotNull(bindings);
- Assert.isNotNull(mode);
-
- List<ILaunchBinding> candidates = new ArrayList<ILaunchBinding>();
- for (ILaunchBinding binding : bindings) {
- if (binding.isValidLaunchMode(mode)) {
- candidates.add(binding);
- }
- }
-
- return candidates;
- }
-
- /**
- * Returns the resolved binding in case of overwritable bindings.
- *
- * @param bindings The list of available bindings. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
- *
- * @return The resolved binding or <code>null</code>.
- */
- private ILaunchBinding getBinding(List<ILaunchBinding> bindings, String mode) {
- Assert.isNotNull(bindings);
- Assert.isNotNull(mode);
-
- ILaunchBinding binding = null;
-
- List<ILaunchBinding> candidates = getBindings(bindings, mode);
- for (int i = 0; i < candidates.size(); i++) {
- if (binding == null) {
- binding = candidates.get(i);
- }
- for (int j = 0; j < candidates.size(); j++) {
- ILaunchBinding cj = candidates.get(j);
- if (cj instanceof IOverwritableLaunchBinding
- && ((IOverwritableLaunchBinding) cj).overwrites(binding.getId())) {
- binding = cj;
- }
- }
- }
-
- return binding;
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- StringBuffer toString = new StringBuffer();
-
- toString.append("LaunchConfigTypeBinding("); //$NON-NLS-1$
- toString.append(typeId);
- toString.append(")"); //$NON-NLS-1$
-
- return toString.toString();
- }
-}
+/*******************************************************************************
+ * 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.launch.core.bindings.internal;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.launch.core.bindings.interfaces.ILaunchBinding;
+import org.eclipse.tcf.te.launch.core.bindings.interfaces.IOverwritableLaunchBinding;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
+
+/**
+ * Launch configuration type binding implementation.
+ */
+public class LaunchConfigTypeBinding {
+ // The launch configuration type id
+ private final String typeId;
+
+ // Lists of sub bindings
+ private final List<ILaunchBinding> lmDelegateBindings = new ArrayList<ILaunchBinding>();
+ private final List<ILaunchBinding> stepGroupBindings = new ArrayList<ILaunchBinding>();
+
+ // The list of enablement expressions
+ private final List<Expression> expressions = new ArrayList<Expression>();
+
+ /**
+ * Constructor.
+ *
+ * @param typeId The launch configuration type id the binding applies to. Must not be
+ * <code>null</code>.
+ */
+ public LaunchConfigTypeBinding(String typeId) {
+ Assert.isNotNull(typeId);
+ this.typeId = typeId;
+ }
+
+ /**
+ * Returns the launch configuration type id the binding applies to.
+ *
+ * @return The launch configuration type id.
+ */
+ public String getTypeId() {
+ return typeId;
+ }
+
+ /**
+ * Returns the launch manager delegate id for the given launch mode.
+ *
+ * @param mode The launch mode. Must not be <code>null</code>.
+ * @return The launch manager delegate id or <code>null</code>.
+ */
+ public String getLaunchManagerDelegate(String mode) {
+ Assert.isNotNull(mode);
+
+ ILaunchBinding binding = getBinding(lmDelegateBindings, mode);
+ return binding != null ? binding.getId() : null;
+ }
+
+ /**
+ * Adds the given launch manager delegate binding.
+ *
+ * @param binding The binding. Must not be <code>null</code>.
+ */
+ public void addLaunchManagerDelegate(IOverwritableLaunchBinding binding) {
+ Assert.isNotNull(binding);
+ if (!lmDelegateBindings.contains(binding)) {
+ lmDelegateBindings.add(binding);
+ }
+ }
+
+ /**
+ * Returns the step group id for the given launch mode.
+ *
+ * @param mode The launch mode. Must not be <code>null</code>.
+ *
+ * @return The step group id or <code>null</code>.
+ */
+ public String getStepGroupId(String mode) {
+ ILaunchBinding binding = getBinding(stepGroupBindings, mode);
+ return binding != null ? binding.getId() : null;
+ }
+
+ /**
+ * Adds the given step group binding.
+ *
+ * @param binding The binding. Must not be <code>null</code>.
+ */
+ public void addStepGroup(ILaunchBinding binding) {
+ Assert.isNotNull(binding);
+ if (!stepGroupBindings.contains(binding)) {
+ stepGroupBindings.add(binding);
+ }
+ }
+
+ /**
+ * Adds the given enablement expression.
+ *
+ * @param enablement The enablement expression. Must not be <code>null</code>.
+ */
+ public void addEnablement(Expression expression) {
+ Assert.isNotNull(expression);
+ if (!expressions.contains(expression)) {
+ expressions.add(expression);
+ }
+ }
+
+ /**
+ * Evaluates the enablement expressions with the given launch selection.
+ *
+ * @param selection The launch selection. Must not be <code>null</code>.
+ * @return The result of the enablement expression evaluation.
+ */
+ public EvaluationResult validate(ILaunchSelection selection) {
+ Assert.isNotNull(selection);
+
+ EvaluationResult result = EvaluationResult.NOT_LOADED;
+
+ EvaluationResult valresult;
+ for (ISelectionContext context : selection.getSelectedContexts()) {
+ if (context.isPreferredContext()) {
+ valresult = validate(selection.getLaunchMode(), context);
+ if (valresult == EvaluationResult.FALSE) {
+ return EvaluationResult.FALSE;
+ }
+ else if (valresult != EvaluationResult.NOT_LOADED) {
+ result = valresult;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Evaluates the enablement expressions with the given launch mode and selection context.
+ *
+ * @param mode The launch mode. Must not be <code>null</code>.
+ * @param context The launch selection context or <code>null</code>.
+ *
+ * @return The result of the enablement expression evaluation.
+ */
+ public EvaluationResult validate(String mode, ISelectionContext context) {
+ EvaluationResult result = context.isPreferredContext() ? EvaluationResult.FALSE : EvaluationResult.NOT_LOADED;
+
+ if (expressions.isEmpty()) {
+ return EvaluationResult.TRUE;
+ }
+ EvaluationResult valresult;
+ for (Expression expression : expressions) {
+ // Set the default variable and "selection" is the selection context
+ EvaluationContext evalContext = new EvaluationContext(null, context);
+ evalContext.addVariable("context", context.getContext()); //$NON-NLS-1$
+ evalContext.addVariable("selection", context.getSelections() != null ? Arrays.asList(context.getSelections()) : Collections.EMPTY_LIST); //$NON-NLS-1$
+ evalContext.addVariable("type", context.getType() != null ? context.getType() : ""); //$NON-NLS-1$ //$NON-NLS-2$
+ evalContext.addVariable("mode", mode != null ? mode : ""); //$NON-NLS-1$ //$NON-NLS-2$
+ // Allow plugin activation
+ evalContext.setAllowPluginActivation(true);
+ // Evaluate the expression
+ try {
+ valresult = expression.evaluate(evalContext);
+ } catch (CoreException e) {
+ valresult = EvaluationResult.FALSE;
+
+ if (Platform.inDebugMode()) {
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), e.getLocalizedMessage(), e);
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
+ }
+ }
+
+ if (valresult == EvaluationResult.TRUE) {
+ return EvaluationResult.TRUE;
+ }
+ if (valresult != EvaluationResult.NOT_LOADED) {
+ result = valresult;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns the list of bindings valid for the given launch mode.
+ *
+ * @param bindings The list of available bindings. Must not be <code>null</code>.
+ * @param mode The launch mode. Must not be <code>null</code>.
+ *
+ * @return The list of valid bindings for the given launch mode or an empty list.
+ */
+ private List<ILaunchBinding> getBindings(List<ILaunchBinding> bindings, String mode) {
+ Assert.isNotNull(bindings);
+ Assert.isNotNull(mode);
+
+ List<ILaunchBinding> candidates = new ArrayList<ILaunchBinding>();
+ for (ILaunchBinding binding : bindings) {
+ if (binding.isValidLaunchMode(mode)) {
+ candidates.add(binding);
+ }
+ }
+
+ return candidates;
+ }
+
+ /**
+ * Returns the resolved binding in case of overwritable bindings.
+ *
+ * @param bindings The list of available bindings. Must not be <code>null</code>.
+ * @param mode The launch mode. Must not be <code>null</code>.
+ *
+ * @return The resolved binding or <code>null</code>.
+ */
+ private ILaunchBinding getBinding(List<ILaunchBinding> bindings, String mode) {
+ Assert.isNotNull(bindings);
+ Assert.isNotNull(mode);
+
+ ILaunchBinding binding = null;
+
+ List<ILaunchBinding> candidates = getBindings(bindings, mode);
+ for (int i = 0; i < candidates.size(); i++) {
+ if (binding == null) {
+ binding = candidates.get(i);
+ }
+ for (int j = 0; j < candidates.size(); j++) {
+ ILaunchBinding cj = candidates.get(j);
+ if (cj instanceof IOverwritableLaunchBinding
+ && ((IOverwritableLaunchBinding) cj).overwrites(binding.getId())) {
+ binding = cj;
+ }
+ }
+ }
+
+ return binding;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuffer toString = new StringBuffer();
+
+ toString.append("LaunchConfigTypeBinding("); //$NON-NLS-1$
+ toString.append(typeId);
+ toString.append(")"); //$NON-NLS-1$
+
+ return toString.toString();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeUnBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeUnBinding.java
new file mode 100644
index 000000000..4597e192a
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeUnBinding.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * 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.launch.core.bindings.internal;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
+
+/**
+ * Launch configuration type unbinding implementation.
+ */
+public class LaunchConfigTypeUnBinding {
+ // The launch configuration type id
+ private final String typeId;
+
+ // The list of enablement expressions
+ private final List<Expression> expressions = new ArrayList<Expression>();
+
+ /**
+ * Constructor.
+ *
+ * @param typeId The launch configuration type id the unbinding applies to. Must not be
+ * <code>null</code>.
+ */
+ public LaunchConfigTypeUnBinding(String typeId) {
+ Assert.isNotNull(typeId);
+ this.typeId = typeId;
+ }
+
+ /**
+ * Returns the launch configuration type id the unbinding applies to.
+ *
+ * @return The launch configuration type id.
+ */
+ public String getTypeId() {
+ return typeId;
+ }
+
+ /**
+ * Adds the given enablement expression.
+ *
+ * @param enablement The enablement expression. Must not be <code>null</code>.
+ */
+ public void addEnablement(Expression expression) {
+ Assert.isNotNull(expression);
+ if (!expressions.contains(expression)) {
+ expressions.add(expression);
+ }
+ }
+
+ /**
+ * Evaluates the enablement expressions with the given launch selection.
+ *
+ * @param selection The launch selection. Must not be <code>null</code>.
+ * @return The result of the enablement expression evaluation.
+ */
+ public EvaluationResult validate(ILaunchSelection selection) {
+ Assert.isNotNull(selection);
+
+ EvaluationResult result = EvaluationResult.NOT_LOADED;
+
+ EvaluationResult valresult;
+ for (ISelectionContext context : selection.getSelectedContexts()) {
+ if (context.isPreferredContext()) {
+ valresult = validate(selection.getLaunchMode(), context);
+ if (valresult == EvaluationResult.FALSE) {
+ return EvaluationResult.FALSE;
+ }
+ else if (valresult != EvaluationResult.NOT_LOADED) {
+ result = valresult;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Evaluates the enablement expressions with the given launch mode and selection context.
+ *
+ * @param mode The launch mode. Must not be <code>null</code>.
+ * @param context The launch selection context or <code>null</code>.
+ *
+ * @return The result of the enablement expression evaluation.
+ */
+ public EvaluationResult validate(String mode, ISelectionContext context) {
+ EvaluationResult result = context.isPreferredContext() ? EvaluationResult.FALSE : EvaluationResult.NOT_LOADED;
+
+ if (expressions.isEmpty()) {
+ return EvaluationResult.TRUE;
+ }
+ EvaluationResult valresult;
+ for (Expression expression : expressions) {
+ // Set the default variable and "selection" is the selection context
+ EvaluationContext evalContext = new EvaluationContext(null, context);
+ evalContext.addVariable("context", context.getContext()); //$NON-NLS-1$
+ evalContext.addVariable("selection", context.getSelections() != null ? Arrays.asList(context.getSelections()) : Collections.EMPTY_LIST); //$NON-NLS-1$
+ evalContext.addVariable("type", context.getType() != null ? context.getType() : ""); //$NON-NLS-1$ //$NON-NLS-2$
+ evalContext.addVariable("mode", mode != null ? mode : ""); //$NON-NLS-1$ //$NON-NLS-2$
+ // Allow plugin activation
+ evalContext.setAllowPluginActivation(true);
+ // Evaluate the expression
+ try {
+ valresult = expression.evaluate(evalContext);
+ } catch (CoreException e) {
+ valresult = EvaluationResult.FALSE;
+
+ if (Platform.inDebugMode()) {
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), e.getLocalizedMessage(), e);
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
+ }
+ }
+
+ if (valresult == EvaluationResult.TRUE) {
+ return EvaluationResult.TRUE;
+ }
+ if (valresult != EvaluationResult.NOT_LOADED) {
+ result = valresult;
+ }
+ }
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuffer toString = new StringBuffer();
+
+ toString.append("LaunchConfigTypeUnBinding("); //$NON-NLS-1$
+ toString.append(typeId);
+ toString.append(")"); //$NON-NLS-1$
+
+ return toString.toString();
+ }
+}

Back to the top