aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2012-02-29 01:44:31 (EST)
committerUwe Stieber2012-02-29 01:44:31 (EST)
commit7609fc7616cfe2b2e8aaf04a52ca10a34558ca13 (patch)
treea14a188f9752ff72c44752fe21593672693ae531
parentbc2bdd576dcdfe79d0dd4f4ed14d486b16853fbc (diff)
downloadorg.eclipse.tcf-7609fc7616cfe2b2e8aaf04a52ca10a34558ca13.zip
org.eclipse.tcf-7609fc7616cfe2b2e8aaf04a52ca10a34558ca13.tar.gz
org.eclipse.tcf-7609fc7616cfe2b2e8aaf04a52ca10a34558ca13.tar.bz2
Target Explorer: Cherry-Pick: Remove stepper and variant delegate extension points
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.properties1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchConfigTypeBindings.exsd77
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchModeVariantDelegates.exsd195
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java73
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IOverwritableLaunchBinding.java48
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IVaryableLaunchBinding.java30
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java59
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/OverwritableLaunchBinding.java154
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/VaryableLaunchBinding.java77
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java42
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/extensions/internal/LaunchModeVariantDelegateExtensionPointManager.java92
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java1451
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ICommonLaunchAttributes.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ILaunchManagerDelegate.java373
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/plugin.properties4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/StepperManager.java11
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepperExtensionPointManager.java83
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepper.java25
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IVariantDelegate.java31
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java1520
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/StepperTestCase.java16
24 files changed, 1810 insertions, 2563 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF
index 694deca..ba537ff 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF
@@ -25,7 +25,6 @@ Export-Package: org.eclipse.tcf.te.launch.core.activator;x-internal:=true,
org.eclipse.tcf.te.launch.core.bindings.internal;x-friends:="org.eclipse.tcf.te.launch.ui",
org.eclipse.tcf.te.launch.core.delegates,
org.eclipse.tcf.te.launch.core.exceptions,
- org.eclipse.tcf.te.launch.core.extensions.internal;x-internal:=true,
org.eclipse.tcf.te.launch.core.interfaces.tracing,
org.eclipse.tcf.te.launch.core.lm,
org.eclipse.tcf.te.launch.core.lm.delegates,
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.properties
index a2c59bb..220da8d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.properties
@@ -13,4 +13,3 @@ providerName = Eclipse.org - TCF
Extension.LaunchConfigTypeBindings.name=Launch Configuration Type Bindings
Extension.LaunchManagerDelegates.name=Launch Manager Delegates
-Extension.LaunchModeVariantDelegates.name=Launch Mode Variant Delegates
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
index 72bf67d..037f629 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
@@ -5,7 +5,6 @@
<!-- Extension points -->
<extension-point id="launchConfigTypeBindings" name="%Extension.LaunchConfigTypeBindings.name" schema="schema/launchConfigTypeBindings.exsd"/>
<extension-point id="launchManagerDelegates" name="%Extension.LaunchManagerDelegates.name" schema="schema/launchManagerDelegates.exsd"/>
- <extension-point id="launchModeVariantDelegates" name="%Extension.LaunchModeVariantDelegates.name" schema="schema/launchModeVariantDelegates.exsd"/>
<!-- Adapter factory contributions -->
<extension point="org.eclipse.core.runtime.adapters">
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 eb90083..544328d 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
@@ -58,8 +58,6 @@
<complexType>
<sequence>
<element ref="launchManagerDelegate" minOccurs="0" maxOccurs="unbounded"/>
- <element ref="launchModeVariantDelegate" minOccurs="0" maxOccurs="unbounded"/>
- <element ref="stepper" minOccurs="0" maxOccurs="unbounded"/>
<element ref="stepGroup" minOccurs="0" maxOccurs="unbounded"/>
<element ref="enablement" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
@@ -110,74 +108,6 @@
</complexType>
</element>
- <element name="launchModeVariantDelegate">
- <annotation>
- <documentation>
- A launch mode variant delegate could be bound to a launch configuration type for each available launch mode. If no launch mode is specified, the launch mode variant delegate is used for all launch modes.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- The unique id of the launch mode variant delegate.
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.tcf.te.launch.core.launchModeVariantDelegates/delegate/@id"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="overwrites" type="string">
- <annotation>
- <documentation>
- The id of a previousely bound launch mode variant delegate to overwrite with the launchModeVariantDelegateId. A comma separated list can be specified to overwrite multiple launch mode variant delegates.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="modes" type="string">
- <annotation>
- <documentation>
- The launch mode to use the launch mode varianat delegate for. If not specified, the launch mode variant delegate is used for all undefined launch modes, for which the launch configuration type can be used.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="stepper">
- <annotation>
- <documentation>
- A stepper could be bound to a launch configuration type for each available launch mode. If no launch mode is specified, the stepper 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 stepper to use.
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.tcf.te.runtime.stepper.steppers/stepper/@id"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="overwrites" type="string">
- <annotation>
- <documentation>
- The id of a previousely bound stepper to overwrite with the id. A comma separated list can be specified to overwrite multiple stepper.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="modes" type="string">
- <annotation>
- <documentation>
- The launch mode to use the stepper for. If not specified, the stepper 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>
@@ -209,13 +139,6 @@
</documentation>
</annotation>
</attribute>
- <attribute name="variants" type="string">
- <annotation>
- <documentation>
- The comma separated list of launch mode variants to use the step group for. If not specified, the step group is used for all undefined launch mode variants, for which the launch configuration type can be used.
- </documentation>
- </annotation>
- </attribute>
</complexType>
</element>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchModeVariantDelegates.exsd b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchModeVariantDelegates.exsd
deleted file mode 100644
index 2e6f9f1..0000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchModeVariantDelegates.exsd
+++ /dev/null
@@ -1,195 +0,0 @@
-<?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="launchModeVariantDelegates" name="Launch Mode Variant Delegates"/>
- </appinfo>
- <documentation>
- This extension point is used to contribute launch mode variant delegates.
-&lt;p&gt;
-The launch mode variant delegate calculates possible variants of the current launch mode. Depending on the final active launch mode variant, the executed launch steps and step groups might differ. Launch mode variant delegates are associated with launch configuration types per launch mode via the &lt;samp&gt;org.eclipse.tcf.te.launch.core.launchConfigTypeBindings&lt;/samp&gt; extension point.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="delegate" minOccurs="1" maxOccurs="unbounded"/>
- </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="delegate">
- <annotation>
- <documentation>
- Declares a launch mode variant delegate contribution.
-&lt;p&gt;
-There can be one launch mode variant delegate per launch configuration type id and launch mode active. The first read contribution will be the active one. If additional contributions are made for a specific launch configuration type/launch mode combination, and an active launch mode variant delegate already exist, the contribution will be registered but not invoked.
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <element ref="class" minOccurs="0" maxOccurs="1"/>
- </sequence>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- The unique id of the variant delegate contribution.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="label" type="string" use="required">
- <annotation>
- <documentation>
- The label representing the launch mode variant delegate within the UI.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string">
- <annotation>
- <documentation>
- The class the implements &lt;code&gt;org.eclipse.tcf.te.runtime.stepper.interfaces.IVariantDelegate&lt;/code&gt;.
-&lt;p&gt;
-The launch mode variant delegate implementation class must be specified either by the class attribute or the class child element!
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.tcf.te.runtime.stepper.interfaces.IVariantDelegate"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="class">
- <annotation>
- <documentation>
- &lt;p&gt;Used when creating an &lt;code&gt;IExecutableExtension&lt;/code&gt; with a named parameter, or more than one.&lt;/p&gt;
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <element ref="parameter" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="class" type="string">
- <annotation>
- <documentation>
- The class the implements &lt;code&gt;org.eclipse.tcf.te.runtime.stepper.interfaces.IVariantDelegate&lt;/code&gt;.
-&lt;p&gt;
-The launch mode variant delegate implementation class must be specified either by the class attribute or the class child element!
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.tcf.te.runtime.stepper.interfaces.IVariantDelegate"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="parameter">
- <annotation>
- <documentation>
- &lt;p&gt;A parameter for an &lt;code&gt;IExecutableExtension&lt;/code&gt;.&lt;/p&gt;
- </documentation>
- </annotation>
- <complexType>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
- &lt;p&gt;The parameter name.&lt;/p&gt;
- </documentation>
- </annotation>
- </attribute>
- <attribute name="value" type="string" use="required">
- <annotation>
- <documentation>
- &lt;p&gt;The parameter value.&lt;/p&gt;
- </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.launchModeVariantDelegates&quot;&gt;
- &lt;launchManagerDelegate
- class=&quot;org.eclipse.tcf.te.launch.core.delegates.CustomLaunchModeVariantDelegate&quot;
- id=&quot;org.eclipse.tcf.te.launch.variant.custom&quot;
- label=&quot;Custom Launch Mode Variant Delegate&quot;/&gt;
- &lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="apiinfo"/>
- </appinfo>
- <documentation>
- The provider of a launch mode variant delegate must implement &lt;samp&gt;org.eclipse.tcf.te.runtime.stepper.interfaces.IVariantDelegate&lt;/samp&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 1ed089a..1d55155 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
@@ -29,7 +29,6 @@ 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.OverwritableLaunchBinding;
-import org.eclipse.tcf.te.launch.core.extensions.internal.LaunchModeVariantDelegateExtensionPointManager;
import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate;
import org.eclipse.tcf.te.launch.core.lm.internal.ExtensionPointManager;
import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
@@ -38,8 +37,6 @@ import org.eclipse.tcf.te.runtime.extensions.ExtensionPointComparator;
import org.eclipse.tcf.te.runtime.stepper.StepperManager;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStep;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IVariantDelegate;
/**
@@ -148,71 +145,21 @@ public class LaunchConfigTypeBindingsManager {
}
/**
- * Get the registered launch mode variant delegate for the given launch configuration type and launch mode.
+ * Get the registered step group id for the given launch configuration type and launch mode.
*
* @param typeId The launch configuration type id. Must not be <code>null</code>.
* @param mode The launch mode. Must not be <code>null</code>.
*
- * @return The launch mode variant delegate, or a <code>null</code> if no delegate is registered for the
- * given launch configuration type id and launch mode.
- */
- public IVariantDelegate getLaunchModeVariantDelegate(String typeId, String mode) {
- Assert.isNotNull(typeId);
- Assert.isNotNull(mode);
-
- LaunchConfigTypeBinding binding = bindings.get(typeId);
- if (binding != null) {
- String id = binding.getLaunchModeVariantDelegate(mode);
- if (id != null) {
- return LaunchModeVariantDelegateExtensionPointManager.getInstance().getLaunchModeVariantDelegate(id);
- }
- }
- return null;
- }
-
- /**
- * Get the registered stepper for the given launch configuration type id and launch mode.
- *
- * @param typeId The launch configuration type id. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
-
- * @return The stepper or <code>null</code> if no stepper is registered for the
- * given launch configuration type id and launch mode.
- */
- public IStepper getStepper(String typeId, String mode) {
- Assert.isNotNull(typeId);
- Assert.isNotNull(mode);
-
- IStepper stepper = null;
-
- LaunchConfigTypeBinding binding = bindings.get(typeId);
- if (binding != null) {
- String id = binding.getStepper(mode);
- if (id != null) {
- stepper = StepperManager.getInstance().getStepperExtManager().getStepper(id, false);
- }
- }
-
- return stepper;
- }
-
- /**
- * Get the registered step group id for the given launch configuration type, launch mode and variant.
- *
- * @param typeId The launch configuration type id. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
- * @param variant The launch mode variant or <code>null</code>.
- *
* @return The launch step group id or <code>null</code> if no step group is registered for the
- * given launch configuration type id, launch mode and variant.
+ * given launch configuration type id and launch mode.
*/
- public String getStepGroupId(String typeId, String mode, String variant) {
+ public String getStepGroupId(String typeId, String mode) {
Assert.isNotNull(typeId);
Assert.isNotNull(mode);
LaunchConfigTypeBinding binding = bindings.get(typeId);
if (binding != null) {
- return binding.getStepGroupId(mode, variant);
+ return binding.getStepGroupId(mode);
}
return null;
}
@@ -284,15 +231,6 @@ public class LaunchConfigTypeBindingsManager {
binding.addLaunchManagerDelegate(new OverwritableLaunchBinding(id, overwrites, modes));
}
- IConfigurationElement[] launchModeVariantDelegateBindings = element.getChildren("launchModeVariantDelegate"); //$NON-NLS-1$
- for (IConfigurationElement launchModeVariantDelegateBinding : launchModeVariantDelegateBindings) {
- String id = launchModeVariantDelegateBinding.getAttribute("id"); //$NON-NLS-1$
- String overwrites = launchModeVariantDelegateBinding.getAttribute("overwrites"); //$NON-NLS-1$
- String modes = launchModeVariantDelegateBinding.getAttribute("modes"); //$NON-NLS-1$
-
- binding.addLaunchModeVariantDelegate(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$
@@ -307,9 +245,8 @@ public class LaunchConfigTypeBindingsManager {
String id = stepGroupBinding.getAttribute("id"); //$NON-NLS-1$
String overwrites = stepGroupBinding.getAttribute("overwrites"); //$NON-NLS-1$
String modes = stepGroupBinding.getAttribute("modes"); //$NON-NLS-1$
- String variants = stepGroupBinding.getAttribute("variants"); //$NON-NLS-1$
- binding.addStepGroup(new OverwritableLaunchBinding(id, overwrites, modes, variants));
+ binding.addStepGroup(new OverwritableLaunchBinding(id, overwrites, modes));
}
IConfigurationElement[] enablements = element.getChildren("enablement"); //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IOverwritableLaunchBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IOverwritableLaunchBinding.java
index 1b8586f..4aed764 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IOverwritableLaunchBinding.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IOverwritableLaunchBinding.java
@@ -1,24 +1,24 @@
-/*******************************************************************************
- * 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.interfaces;
-
-/**
- * Interface to be implemented by a overwritable launch configuration type binding element.
- */
-public interface IOverwritableLaunchBinding extends IVaryableLaunchBinding {
-
- /**
- * Returns if or if not this binding overwrites the given bindings id.
- *
- * @param id The id. Must not be <code>null</code>.
- * @return <code>True</code> if this binding overwrites the given bindings id, <code>false</code> if not.
- */
- public boolean overwrites(String id);
-}
+/*******************************************************************************
+ * 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.interfaces;
+
+/**
+ * Interface to be implemented by a overwritable launch configuration type binding element.
+ */
+public interface IOverwritableLaunchBinding extends ILaunchBinding {
+
+ /**
+ * Returns if or if not this binding overwrites the given bindings id.
+ *
+ * @param id The id. Must not be <code>null</code>.
+ * @return <code>True</code> if this binding overwrites the given bindings id, <code>false</code> if not.
+ */
+ public boolean overwrites(String id);
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IVaryableLaunchBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IVaryableLaunchBinding.java
deleted file mode 100644
index 89528a0..0000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IVaryableLaunchBinding.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * 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.interfaces;
-
-/**
- * Interface to be implemented by a launch configuration type binding element
- * which is supporting launch mode variants.
- */
-public interface IVaryableLaunchBinding extends ILaunchBinding {
-
- /**
- * Returns if or if not the given launch mode is handled by this binding.
- * <p>
- * <b>Note:</b> The launch mode and launch mode variant are considered valid
- * if <code>null</code> or an empty string is passed.
- *
- * @param mode The launch mode. Must not be <code>null</code>.
- * @param variant The launch mode variant to check or <code>null</code>.
- *
- * @return <code>True</code> if the launch mode is valid, <code>false</code> otherwise.
- */
- public boolean isValidLaunchMode(String mode, String variant);
-}
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 0c3998b..73df9b5 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
@@ -23,7 +23,6 @@ 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.bindings.interfaces.IVaryableLaunchBinding;
import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
@@ -38,7 +37,6 @@ public class LaunchConfigTypeBinding {
private final List<ILaunchBinding> lmDelegateBindings = new ArrayList<ILaunchBinding>();
private final List<ILaunchBinding> stepperBindings = new ArrayList<ILaunchBinding>();
private final List<ILaunchBinding> stepGroupBindings = new ArrayList<ILaunchBinding>();
- private final List<ILaunchBinding> variantDelegateBindings = new ArrayList<ILaunchBinding>();
// The list of enablement expressions
private final List<Expression> expressions = new ArrayList<Expression>();
@@ -89,31 +87,6 @@ public class LaunchConfigTypeBinding {
}
/**
- * Returns the launch mode variant delegate id for the given launch mode.
- *
- * @param mode The launch mode. Must not be <code>null</code>.
- * @return The launch mode variant delegate id or <code>null</code>.
- */
- public String getLaunchModeVariantDelegate(String mode) {
- Assert.isNotNull(mode);
-
- ILaunchBinding binding = getBinding(variantDelegateBindings, mode);
- return binding != null ? binding.getId() : null;
- }
-
- /**
- * Adds the given launch mode variant delegate binding.
- *
- * @param binding The binding. Must not be <code>null</code>.
- */
- public void addLaunchModeVariantDelegate(IOverwritableLaunchBinding binding) {
- Assert.isNotNull(binding);
- if (!variantDelegateBindings.contains(binding)) {
- variantDelegateBindings.add(binding);
- }
- }
-
- /**
* Returns the stepper id for the given launch mode.
*
* @param mode The launch mode. Must not be <code>null</code>.
@@ -139,15 +112,14 @@ public class LaunchConfigTypeBinding {
}
/**
- * Returns the step group id for the given launch mode and variant.
+ * Returns the step group id for the given launch mode.
*
* @param mode The launch mode. Must not be <code>null</code>.
- * @param variant The launch mode variant or <code>null</code>.
*
* @return The step group id or <code>null</code>.
*/
- public String getStepGroupId(String mode, String variant) {
- ILaunchBinding binding = getBinding(stepGroupBindings, mode, variant);
+ public String getStepGroupId(String mode) {
+ ILaunchBinding binding = getBinding(stepGroupBindings, mode);
return binding != null ? binding.getId() : null;
}
@@ -251,22 +223,16 @@ public class LaunchConfigTypeBinding {
*
* @param bindings The list of available bindings. Must not be <code>null</code>.
* @param mode The launch mode. Must not be <code>null</code>.
- * @param variant The launch mode variant or <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, String variant) {
+ 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 instanceof IVaryableLaunchBinding) {
- if (((IVaryableLaunchBinding) binding).isValidLaunchMode(mode, variant)) {
- candidates.add(binding);
- }
- }
- else if (binding.isValidLaunchMode(mode)) {
+ if (binding.isValidLaunchMode(mode)) {
candidates.add(binding);
}
}
@@ -283,25 +249,12 @@ public class LaunchConfigTypeBinding {
* @return The resolved binding or <code>null</code>.
*/
private ILaunchBinding getBinding(List<ILaunchBinding> bindings, String mode) {
- return getBinding(bindings, mode, null);
- }
-
- /**
- * 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>.
- * @param variant The launch mode variant or <code>null</code>.
- *
- * @return The resolved binding or <code>null</code>.
- */
- private ILaunchBinding getBinding(List<ILaunchBinding> bindings, String mode, String variant) {
Assert.isNotNull(bindings);
Assert.isNotNull(mode);
ILaunchBinding binding = null;
- List<ILaunchBinding> candidates = getBindings(bindings, mode, variant);
+ List<ILaunchBinding> candidates = getBindings(bindings, mode);
for (int i = 0; i < candidates.size(); i++) {
if (binding == null) {
binding = candidates.get(i);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/OverwritableLaunchBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/OverwritableLaunchBinding.java
index a779e19..21c73cd 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/OverwritableLaunchBinding.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/OverwritableLaunchBinding.java
@@ -1,83 +1,71 @@
-/*******************************************************************************
- * 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 org.eclipse.core.runtime.Assert;
-import org.eclipse.tcf.te.launch.core.bindings.interfaces.IOverwritableLaunchBinding;
-
-/**
- * Overwritable launch configuration type binding element implementation.
- */
-public class OverwritableLaunchBinding extends VaryableLaunchBinding implements IOverwritableLaunchBinding {
-
- private String[] overwrites;
-
- /**
- * Constructor.
- *
- * @param id The launch binding id. Must not be <code>null</code>.
- * @param overwrites The overwritten launch binding id's or <code>null</code>.
- * @param modes The launch modes or <code>null</code>
- */
- public OverwritableLaunchBinding(String id, String overwrites, String modes) {
- this(id, overwrites, modes, null);
- }
-
- /**
- * Constructor.
- *
- * @param id The launch binding id. Must not be <code>null</code>.
- * @param overwrites The overwritten launch binding id's or <code>null</code>.
- * @param modes The launch modes or <code>null</code>
- * @param variants The launch mode variants or <code>null</code>.
- */
- public OverwritableLaunchBinding(String id, String overwrites, String modes, String variants) {
- super(id, modes, variants);
-
- if (overwrites != null) this.overwrites = overwrites.trim().split("( )*,( )*"); //$NON-NLS-1$
- else this.overwrites = new String[0];
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.bindings.interfaces.IOverwritableLaunchBinding#overwrites(java.lang.String)
- */
- @Override
- public boolean overwrites(String id) {
- Assert.isNotNull(id);
- for (int i = 0; i < overwrites.length; i++) {
- if (id.equals(overwrites[i])) {
- return true;
- }
- }
- return overwrites.length == 0;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- StringBuffer toString = new StringBuffer();
-
- toString.append("OverwriteableLaunchBinding("); //$NON-NLS-1$
- toString.append(getId());
- toString.append(", launchModes"); //$NON-NLS-1$
- toString.append(toString(getModes()));
- if (getVariants().length > 0) {
- toString.append(", launchModeVariants"); //$NON-NLS-1$
- toString.append(toString(getVariants()));
- }
- toString.append(", overwrites"); //$NON-NLS-1$
- toString.append(toString(overwrites));
- 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 org.eclipse.core.runtime.Assert;
+import org.eclipse.tcf.te.launch.core.bindings.interfaces.IOverwritableLaunchBinding;
+
+/**
+ * Overwritable launch configuration type binding element implementation.
+ */
+public class OverwritableLaunchBinding extends LaunchBinding implements IOverwritableLaunchBinding {
+
+ private String[] overwrites;
+
+ /**
+ * Constructor.
+ *
+ * @param id The launch binding id. Must not be <code>null</code>.
+ * @param overwrites The overwritten launch binding id's or <code>null</code>.
+ * @param modes The launch modes or <code>null</code>
+ */
+ public OverwritableLaunchBinding(String id, String overwrites, String modes) {
+ super(id, modes);
+
+ if (overwrites != null) {
+ this.overwrites = overwrites.trim().split("( )*,( )*"); //$NON-NLS-1$
+ }
+ else {
+ this.overwrites = new String[0];
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.bindings.interfaces.IOverwritableLaunchBinding#overwrites(java.lang.String)
+ */
+ @Override
+ public boolean overwrites(String id) {
+ Assert.isNotNull(id);
+ for (String overwrite : overwrites) {
+ if (id.equals(overwrite)) {
+ return true;
+ }
+ }
+ return overwrites.length == 0;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuffer toString = new StringBuffer();
+
+ toString.append("OverwriteableLaunchBinding("); //$NON-NLS-1$
+ toString.append(getId());
+ toString.append(", launchModes"); //$NON-NLS-1$
+ toString.append(toString(getModes()));
+ toString.append(", overwrites"); //$NON-NLS-1$
+ toString.append(toString(overwrites));
+ 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/VaryableLaunchBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/VaryableLaunchBinding.java
deleted file mode 100644
index 1dc7759..0000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/VaryableLaunchBinding.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * 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 org.eclipse.tcf.te.launch.core.bindings.interfaces.IVaryableLaunchBinding;
-
-/**
- * Launch binding supporting launch mode variants.
- */
-public class VaryableLaunchBinding extends LaunchBinding implements IVaryableLaunchBinding {
- private final String[] variants;
-
- /**
- * Constructor.
- *
- * @param id The launch binding id. Must not be <code>null</code>.
- * @param modes The launch modes or <code>null</code>
- * @param variants The launch mode variants or <code>null</code>.
- */
- public VaryableLaunchBinding(String id, String modes, String variants) {
- super(id, modes);
-
- if (variants != null) this.variants = variants.trim().split("( )*,( )*"); //$NON-NLS-1$
- else this.variants = new String[0];
- }
-
- /**
- * Returns the list of handled variants.
- *
- * @return The list of handled variants or an empty list.
- */
- public final String[] getVariants() {
- return variants;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.bindings.interfaces.IVaryableLaunchBinding#isValidLaunchMode(java.lang.String, java.lang.String)
- */
- @Override
- public boolean isValidLaunchMode(String launchMode, String variant) {
- boolean valid = isValidLaunchMode(launchMode);
- if (!valid) return false;
-
- if (variant == null || variant.length() == 0)
- return true;
-
- for (String candidate : getVariants())
- if (variant.equals(candidate)) return true;
-
- return getVariants().length == 0;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- StringBuffer toString = new StringBuffer();
-
- toString.append("LaunchBinding("); //$NON-NLS-1$
- toString.append(getId());
- toString.append(", launchModes"); //$NON-NLS-1$
- toString.append(toString(getModes()));
- toString.append(", launchModeVariants"); //$NON-NLS-1$
- toString.append(toString(getVariants()));
- 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/delegates/LaunchConfigurationDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java
index 4573566..1e737fa 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java
@@ -26,7 +26,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.debug.core.model.IBreakpoint;
@@ -40,7 +39,6 @@ import org.eclipse.tcf.te.launch.core.nls.Messages;
import org.eclipse.tcf.te.launch.core.persistence.ContextSelectorPersistenceDelegate;
import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate;
import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
import org.eclipse.tcf.te.runtime.interfaces.ISharedConstants;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
@@ -50,6 +48,7 @@ import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperProperties;
import org.eclipse.tcf.te.runtime.stepper.interfaces.tracing.ITraceIds;
+import org.eclipse.tcf.te.runtime.stepper.stepper.Stepper;
/**
* Default launch configuration delegate implementation.
@@ -100,41 +99,11 @@ public class LaunchConfigurationDelegate extends AbstractLaunchConfigurationDele
launch.setAttribute(ICommonLaunchAttributes.ILAUNCH_ATTRIBUTE_LAUNCH_SEQUENCE_COMPLETED, Boolean.FALSE.toString());
// The stepper instance to be used
- IStepper stepper = null;
+ IStepper stepper = new Stepper();
IStatus status = null;
try {
- // Get the launch configuration type from the launch configuration.
- // This may throw an CoreException if the launch configuration type
- // cannot be retrieved or instantiated.
- ILaunchConfigurationType type = configuration.getType();
-
// Get the associated stepper for this launch
- stepper = LaunchConfigTypeBindingsManager.getInstance().getStepper(type.getIdentifier(), mode);
- if (stepper == null) {
- // Failed to retrieve stepper for this launch -> throw a CoreException
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- NLS.bind(Messages.LaunchConfigurationDelegate_error_failedToGetStepper, type.getIdentifier(), mode)));
- }
-
- // In case the stepper is already busy with another launch, we need a second instance
- if (stepper.isInitialized()) {
- try {
- // Create a new stepper instance
- IStepper candidate = stepper.getClass().newInstance();
- // Note: If the stepper is an instance of ExecutableExtension, the candidate has to be too.
- if (stepper instanceof ExecutableExtension) {
- ((ExecutableExtension)stepper).cloneInitializationData((ExecutableExtension)candidate);
- }
- // Force to use the newly created instance
- stepper = candidate;
- } catch (Exception e) {
- // Failed to clone already initialized stepper -> throw a CoreException
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- NLS.bind(Messages.LaunchConfigurationDelegate_error_failedToCloneStepper, type.getIdentifier(), mode)));
- }
- }
-
IFullQualifiedId fullQualifiedId = new FullQualifiedId(IStepper.ID_TYPE_STEPPER_ID, stepper.getId(), null);
// Get the launch properties container
IPropertiesContainer properties = (IPropertiesContainer)launch.getAdapter(IPropertiesContainer.class);
@@ -145,8 +114,7 @@ public class LaunchConfigurationDelegate extends AbstractLaunchConfigurationDele
properties.setProperty(IStepperProperties.PROP_STEP_GROUP_ID,
LaunchConfigTypeBindingsManager.getInstance().getStepGroupId(
launchConfig.getType().getIdentifier(),
- launch.getLaunchMode(),
- properties.getStringProperty(ICommonLaunchAttributes.ATTR_DELEGATE_VARIANT)));
+ launch.getLaunchMode()));
IModelNode[] contexts = ContextSelectorPersistenceDelegate.decodeLaunchContexts(
launchConfig.getAttribute(IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS, (String)null));
@@ -200,9 +168,7 @@ public class LaunchConfigurationDelegate extends AbstractLaunchConfigurationDele
}
// Cleanup the stepper
- if (stepper != null) {
- stepper.cleanup();
- }
+ stepper.cleanup();
// Set the launch completed here. Doesn't matter if the launch might completed with error or not.
launch.setAttribute(ICommonLaunchAttributes.ILAUNCH_ATTRIBUTE_LAUNCH_SEQUENCE_COMPLETED, Boolean.TRUE.toString());
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/extensions/internal/LaunchModeVariantDelegateExtensionPointManager.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/extensions/internal/LaunchModeVariantDelegateExtensionPointManager.java
deleted file mode 100644
index 908bd63..0000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/extensions/internal/LaunchModeVariantDelegateExtensionPointManager.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * 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.extensions.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
-import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IVariantDelegate;
-
-/**
- * Launch mode variant delegate extension point manager.
- */
-public class LaunchModeVariantDelegateExtensionPointManager extends AbstractExtensionPointManager<IVariantDelegate> {
-
- /*
- * Thread save singleton instance creation.
- */
- private static class LazyInstanceHolder {
- public static LaunchModeVariantDelegateExtensionPointManager instance = new LaunchModeVariantDelegateExtensionPointManager();
- }
-
- /**
- * Returns the singleton instance for the manager.
- */
- public static LaunchModeVariantDelegateExtensionPointManager getInstance() {
- return LazyInstanceHolder.instance;
- }
-
- /**
- * Constructor.
- */
- LaunchModeVariantDelegateExtensionPointManager() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
- */
- @Override
- protected String getConfigurationElementName() {
- return "delegate"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
- */
- @Override
- protected String getExtensionPointId() {
- return "org.eclipse.tcf.te.launch.core.launchModeVariantDelegates"; //$NON-NLS-1$
- }
-
- /**
- * Get the list of all registered launch mode variant delegates.
- */
- public IVariantDelegate[] getLaunchModeVariantDelegates() {
- List<IVariantDelegate> delegates = new ArrayList<IVariantDelegate>();
- for (ExecutableExtensionProxy<IVariantDelegate> proxy : getExtensions().values()) {
- IExecutableExtension candidate = proxy.getInstance();
- if (candidate instanceof IVariantDelegate && !delegates.contains(candidate)) {
- delegates.add((IVariantDelegate)candidate);
- }
- }
-
- return delegates.toArray(new IVariantDelegate[delegates.size()]);
- }
-
- /**
- * Returns the launch mode variant delegate with the given id.
- *
- * @param id The id of the launch mode variant delegate. Must not be <code>null</code>.
- */
- public IVariantDelegate getLaunchModeVariantDelegate(String id) {
- Assert.isNotNull(id);
- IVariantDelegate delegate = null;
- if (getExtensions().containsKey(id)) {
- delegate = getExtensions().get(id).getInstance();
- }
-
- return delegate;
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java
index 8fa98f1..9c621a2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java
@@ -1,734 +1,717 @@
-/*******************************************************************************
- * 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.lm.delegates;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.launch.core.bindings.LaunchConfigTypeBindingsManager;
-import org.eclipse.tcf.te.launch.core.exceptions.LaunchServiceException;
-import org.eclipse.tcf.te.launch.core.interfaces.tracing.ITraceIds;
-import org.eclipse.tcf.te.launch.core.lm.LaunchConfigSorter;
-import org.eclipse.tcf.te.launch.core.lm.LaunchSpecification;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.ICommonLaunchAttributes;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchAttribute;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
-import org.eclipse.tcf.te.launch.core.nls.Messages;
-import org.eclipse.tcf.te.launch.core.preferences.IPreferenceKeys;
-import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
-import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
-
-/**
- * Default launch manager delegate implementation.
- */
-public class DefaultLaunchManagerDelegate extends ExecutableExtension implements ILaunchManagerDelegate {
- protected final static int NO_MATCH = 0;
- protected final static int PARTIAL_MATCH = 1;
- protected final static int FULL_MATCH = 2;
-
- protected String errorMessage = null;
-
- /**
- * Constructor.
- */
- public DefaultLaunchManagerDelegate() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#initLaunchConfigAttributes(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy, org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification)
- */
- @Override
- public void initLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec) {
- Assert.isNotNull(wc);
- Assert.isNotNull(launchSpec);
- validateLaunchSpecification(launchSpec);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#updateLaunchConfigAttributes(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy, org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification)
- */
- @Override
- public void updateLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec) {
- Assert.isNotNull(wc);
- Assert.isNotNull(launchSpec);
- validateLaunchSpecification(launchSpec);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#isDefaultAttribute(java.lang.String, java.lang.Object, org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
- */
- @Override
- public boolean isDefaultAttribute(String attributeKey, Object attributeValue, ILaunchConfiguration launchConfig, String launchMode) {
- Assert.isNotNull(attributeKey);
- Assert.isNotNull(launchConfig);
- Assert.isNotNull(launchMode);
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getMatchingLaunchConfigurations(org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification, org.eclipse.debug.core.ILaunchConfiguration[])
- */
- @Override
- public final ILaunchConfiguration[] getMatchingLaunchConfigurations(ILaunchSpecification launchSpec, ILaunchConfiguration[] launchConfigs) throws LaunchServiceException {
- if (launchConfigs == null || launchConfigs.length == 0) {
- return new ILaunchConfiguration[0];
- }
- else if (launchSpec != null) {
- List<LaunchConfigSorter> rankedList = new ArrayList<LaunchConfigSorter>();
- for (ILaunchConfiguration launchConfig : launchConfigs) {
- if (CoreBundleActivator.getTraceHandler()
- .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
- System.out.println("\n***\n"); //$NON-NLS-1$
- }
-
- int ranking = 0;
- try {
- ranking = getLaunchConfigRanking(launchSpec, launchConfig);
- }
- catch (LaunchServiceException e) {
- switch (e.getType()) {
- case LaunchServiceException.TYPE_MISSING_LAUNCH_CONFIG_ATTR:
- ranking = 0;
- break;
- default:
- throw e;
- }
- }
-
- int fullMatchRanking = getFullMatchRanking();
-
- if (CoreBundleActivator.getTraceHandler()
- .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
- StringBuilder message = new StringBuilder("Ranking launch spec ("); //$NON-NLS-1$
- message.append(launchSpec.getLaunchConfigName());
- message.append(") vs launch configuration ("); //$NON-NLS-1$
- message.append(launchConfig.getName());
- message.append(") = "); //$NON-NLS-1$
- message.append(ranking);
- message.append(" ; full match ranking = "); //$NON-NLS-1$
- message.append(fullMatchRanking);
-
- CoreBundleActivator
- .getTraceHandler()
- .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this);
- }
-
- if (ranking >= fullMatchRanking) {
- rankedList.add(new LaunchConfigSorter(launchConfig, ranking));
- }
- }
-
- // sort results and write back into array
- Collections.sort(rankedList);
- ILaunchConfiguration[] matchingConfigs = new ILaunchConfiguration[rankedList.size()];
- for (int i = 0; i < rankedList.size(); i++) {
- matchingConfigs[i] = rankedList.get(i).getConfig();
- }
-
- return matchingConfigs;
- }
- else {
- return launchConfigs;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getLaunchSpecification(java.lang.String, org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection)
- */
- @Override
- public final ILaunchSpecification getLaunchSpecification(String launchConfigTypeId, ILaunchSelection launchSelection) {
- return getLaunchSpecification(launchConfigTypeId, launchSelection, null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getLaunchSpecification(java.lang.String, org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection, java.lang.String)
- */
- @Override
- public final ILaunchSpecification getLaunchSpecification(String launchConfigTypeId, ILaunchSelection launchSelection, String variant) {
- ILaunchSpecification spec = null;
-
- if (isValidLaunchSelection(launchSelection)) {
- spec = new LaunchSpecification(launchConfigTypeId, launchSelection.getLaunchMode());
- spec.addAttribute(ICommonLaunchAttributes.ATTR_DELEGATE_VARIANT, variant, true);
-
- for (ISelectionContext selectionContext : launchSelection.getSelectedContexts()) {
- // For launch specifications, all selection contexts needs to be set as preferred
- // for full validation.
- // otherwise "not preferred" contexts are valid even if they are not for a give
- // launch configuration type id.
- selectionContext.setIsPreferredContext(true);
- if (LaunchConfigTypeBindingsManager
- .getInstance()
- .isValidLaunchConfigType(launchConfigTypeId, launchSelection.getLaunchMode(), selectionContext)) {
- spec = addLaunchSpecAttributes(spec, launchConfigTypeId, selectionContext);
- }
- }
-
- // If the number of selected contexts is 0, we have to call addLaunchSpecAttributes
- // one time to add the selection independent attributes.
- if (launchSelection.getSelectedContexts().length == 0) {
- spec = addLaunchSpecAttributes(spec, launchConfigTypeId, null);
- }
- }
-
- return spec;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getDefaultLaunchName(org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification)
- */
- @Override
- public String getDefaultLaunchName(ILaunchSpecification launchSpec) {
- return Messages.DefaultLaunchManagerDelegate_defaultLaunchName;
- }
-
- /**
- * Add all needed selections to the launch specification.
- * <p>
- * Subclasses needs to override and super-call this method!
- * <p>
- * <b>Note:</b> The selection context can be <code>null</code>. In this case, the method
- * implementation is expected to add only selection independent attributes!
- *
- * @param launchSpec The launch specification to add selections to. Must not be
- * <code>null</code>.
- * @param launchConfigTypeId The launch configuration type id. Must not be <code>null</code>.
- * @param selectionContext The validated selection context with the selection(s) or
- * <code>null</code>
- *
- * @return The launch specification with attributes from the selection context.
- */
- protected ILaunchSpecification addLaunchSpecAttributes(ILaunchSpecification launchSpec, String launchConfigTypeId, ISelectionContext selectionContext) {
- Assert.isNotNull(launchSpec);
- Assert.isNotNull(launchConfigTypeId);
- return launchSpec;
- }
-
- /**
- * Returns the ranking of the launch configuration compared to the launch specification.
- * <p>
- * If all attributes of the launch specification matches with the corresponding attributes of
- * the launch configuration, the ranking should be at least as high as the number of attributes
- * in the launch specification. The ranking should grow with every additional attribute value
- * that is set to default.
- * <p>
- * If only a set of attributes matches, the ranking should be less than the number of attributes
- * in the launch specification.
- * <p>
- * If no attribute matches zero should be returned.
- *
- * @param launchSpec The launch specification the launch configuration should be compared to.
- * @param launchConfig The launch configuration to find a ranking for.
- * @return The ranking of the launch configuration.
- * @throws <code>LaunchServiceException</code> exception when mandatory attributes are missing
- */
- private int getLaunchConfigRanking(ILaunchSpecification launchSpec, ILaunchConfiguration launchConfig) throws LaunchServiceException {
- int ranking = 0;
- int mandatorys = 0;
- Map<?, ?> configAttributes = null;
- Set<?> configKeys = null;
- try {
- configAttributes = launchConfig.getAttributes();
- configKeys = configAttributes.keySet();
- }
- catch (Exception e) {
- return 0;
- }
-
- // Read the launch configuration matching mode from the preferences
- int mode = CoreBundleActivator.getScopedPreferences()
- .getInt(IPreferenceKeys.PREF_LAUNCH_CONFIG_FIND_CREATE_MODE);
- if (launchSpec.getAttribute(IPreferenceKeys.PREF_LAUNCH_CONFIG_FIND_CREATE_MODE, null) instanceof Integer) {
- mode = ((Integer) launchSpec
- .getAttribute(IPreferenceKeys.PREF_LAUNCH_CONFIG_FIND_CREATE_MODE, null))
- .intValue();
- }
-
- if (CoreBundleActivator.getTraceHandler()
- .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
- StringBuilder message = new StringBuilder("Ranking launch spec ("); //$NON-NLS-1$
- message.append(launchSpec.getLaunchConfigName());
- message.append(") vs launch configuration ("); //$NON-NLS-1$
- message.append(launchConfig.getName());
- message.append("): Matching mode = "); //$NON-NLS-1$
- if (mode == IPreferenceKeys.MODE_ALWAYS_NEW) {
- message.append(" ALWAYS_NEW "); //$NON-NLS-1$
- }
- else if (mode == IPreferenceKeys.MODE_FIRST_MATCHING) {
- message.append(" FIRST_MATCHING "); //$NON-NLS-1$
- }
- else if (mode == IPreferenceKeys.MODE_FULL_MATCH_TARGET) {
- message.append(" FULL_MATCH_TARGET "); //$NON-NLS-1$
- }
- else if (mode == IPreferenceKeys.MODE_FULL_MATCH_LAUNCH_CONFIG) {
- message.append(" FULL_MATCH_LAUNCH_CONFIG "); //$NON-NLS-1$
- }
-
- CoreBundleActivator
- .getTraceHandler()
- .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this);
- }
-
- for (ILaunchAttribute specAttribute : launchSpec.getAllAttributes()) {
- if (!specAttribute.isCreateOnlyAttribute()) {
- String key = specAttribute.getKey();
- Object specValue = specAttribute.getValue();
- Object configValue = configAttributes.get(key);
- int match = compareAttributeValues(key, specValue, configValue, launchSpec, launchConfig);
-
- if (CoreBundleActivator.getTraceHandler()
- .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
- StringBuilder message = new StringBuilder("Launch spec attribute '"); //$NON-NLS-1$
- message.append(specAttribute.getKey());
- message.append("': mandatory = "); //$NON-NLS-1$
- message.append(isMandatoryAttribute(key));
- message.append("; match = "); //$NON-NLS-1$
- if (match == NO_MATCH) {
- message.append("NO_MATCH"); //$NON-NLS-1$
- }
- else if (match == PARTIAL_MATCH) {
- message.append("PARTIAL_MATCH"); //$NON-NLS-1$
- }
- else if (match == FULL_MATCH) {
- message.append("FULL_MATCH"); //$NON-NLS-1$
- }
- if (match != FULL_MATCH) {
- message.append("\n\t\tspecValue = "); //$NON-NLS-1$
- message.append(specValue != null ? specValue.toString() : "null"); //$NON-NLS-1$
- message.append("\n\t\tconfigValue = "); //$NON-NLS-1$
- message.append(configValue != null ? configValue.toString() : "null"); //$NON-NLS-1$
- }
-
- CoreBundleActivator
- .getTraceHandler()
- .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this);
- }
-
- if (match == PARTIAL_MATCH && mode == IPreferenceKeys.MODE_FULL_MATCH_LAUNCH_CONFIG) {
- return 0;
- }
- if (match > NO_MATCH) {
- int attrRanking = getAttributeRanking(key);
- ranking += attrRanking * (attrRanking > 1 ? 4 : 1);
- if (match == FULL_MATCH) {
- ranking += attrRanking * (attrRanking > 1 ? 2 : 1);
- }
- configKeys.remove(key);
- if (isMandatoryAttribute(key)) {
- mandatorys++;
- }
- }
- else {
- return 0;
- }
- }
- else {
- if (CoreBundleActivator.getTraceHandler()
- .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
- StringBuilder message = new StringBuilder("Skipped launch spec attribute '"); //$NON-NLS-1$
- message.append(specAttribute.getKey());
- message.append("': is create only attribute"); //$NON-NLS-1$
-
- CoreBundleActivator
- .getTraceHandler()
- .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this);
- }
- }
- }
- if (mandatorys < getNumMandatoryAttributes()) {
- throw new LaunchServiceException("missing mandatory attribute in ILaunchSpecification", //$NON-NLS-1$
- LaunchServiceException.TYPE_MISSING_LAUNCH_SPEC_ATTR);
- }
-
- Iterator<?> configIt = configKeys.iterator();
- while (configIt.hasNext()) {
- String key = (String) configIt.next();
- Object specValue = launchSpec.getAttribute(key, null);
- Object configValue = configAttributes.get(key);
-
- int match = compareAttributeValues(key, specValue, configValue, launchSpec, launchConfig);
- if (match > NO_MATCH) {
- int attrRanking = getAttributeRanking(key);
- ranking += attrRanking * (attrRanking > 1 ? 4 : 1);
- if (match == FULL_MATCH) {
- ranking += attrRanking * (attrRanking > 1 ? 2 : 1);
- }
- }
- }
-
- return ranking;
- }
-
- /**
- * Returns the number of defined attributes for this launch manager delegate.
- *
- * @see #getAttributeRanking(String)
- */
- protected int getNumAttributes() {
- return 0;
- }
-
- /**
- * Returns the list of mandatory attributes for a launch specification handled by this launch
- * manager delegate.
- * <p>
- * The returned value must not be <code>null</code>, if no attributes are mandatory, an empty
- * list should be returned.
- *
- * @see #getAttributeRanking(String)
- */
- protected List<String> getMandatoryAttributes() {
- return Collections.emptyList();
- }
-
- private boolean validateLaunchSpecification(ILaunchSpecification launchSpec) {
- boolean valid = true;
- if (launchSpec == null || !launchSpec.isValid()) {
- return false;
- }
- for (String attribute : getMandatoryAttributes()) {
- if (!launchSpec.hasAttribute(attribute)) {
- valid = false;
- break;
- }
- }
- launchSpec.setIsValid(valid);
- return valid;
- }
-
- /**
- * Method for basic launch selection validations like checking the number of project or target
- * contexts.
- * <p>
- * The default implementation returns always <code>true</code>.
- *
- * @param launchSelection The launch selection to check.
- * @return <code>True</code> if the launch selection is valid, <code>false</code> otherwise.
- */
- protected boolean isValidLaunchSelection(ILaunchSelection launchSelection) {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#validate(java.lang.String, org.eclipse.debug.core.ILaunchConfiguration)
- */
- @Override
- public void validate(String launchMode, ILaunchConfiguration launchConfig) throws LaunchServiceException {
- String missingAttributes = null;
- for (String attribute : getMandatoryAttributes()) {
- if (!isValidAttribute(attribute, launchConfig, launchMode)) {
- missingAttributes = (missingAttributes == null) ? attribute : missingAttributes + ", " + attribute; //$NON-NLS-1$
- }
- }
- if (missingAttributes != null) {
- throw new LaunchServiceException("Missing launch configuration attributes: " + '\n' + missingAttributes, LaunchServiceException.TYPE_MISSING_LAUNCH_CONFIG_ATTR); //$NON-NLS-1$
- }
- }
-
- /**
- * Validate a single attribute for a given launch configuration and a launch mode. This method
- * needs to be overwritten when contributing new launch modes which does not need all attributes.
- *
- * @param attributeKey The attribute key.
- * @param launchConfig The launch configuration.
- * @param launchMode The launch mode.
- *
- * @return <code>True</code>, if the attribute value is valid.
- */
- protected boolean isValidAttribute(String attributeKey, ILaunchConfiguration launchConfig, String launchMode) {
- try {
- if (launchConfig == null || !launchConfig.hasAttribute(attributeKey)) {
- return false;
- }
- }
- catch (CoreException e) {
- return false;
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#validate(org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification)
- */
- @Override
- public void validate(ILaunchSpecification launchSpec) throws LaunchServiceException {
- String missingAttributes = null;
- for (String attribute : getMandatoryAttributes()) {
- if (launchSpec == null || !launchSpec.hasAttribute(attribute)) {
- // Remember the missing attribute for adding the list to the exception.
- missingAttributes = (missingAttributes == null) ? attribute : missingAttributes + ", " + attribute; //$NON-NLS-1$
- }
- }
- if (missingAttributes != null) {
- throw new LaunchServiceException("Missing launch specification attributes: " + '\n' + missingAttributes, LaunchServiceException.TYPE_MISSING_LAUNCH_SPEC_ATTR); //$NON-NLS-1$
- }
- }
-
- /**
- * Returns the number of defined mandatory attributes.
- *
- * @see #getMandatoryAttributes()
- * @see #getAttributeRanking(String)
- */
- protected final int getNumMandatoryAttributes() {
- return getMandatoryAttributes().size();
- }
-
- /**
- * Returns true if the attribute key is in the list of mandatory attributes.
- *
- * @see #getMandatoryAttributes()
- * @see #getAttributeRanking(String)
- */
- protected final boolean isMandatoryAttribute(String attributeKey) {
- return getMandatoryAttributes().contains(attributeKey);
- }
-
- /**
- * Returns the ranking for the given attribute key.
- * <p>
- * The default ranking is 1, ranking of mandatory and other fundamental attributes should be
- * coded as <code>2^n</code>.
- * <p>
- * The more important an attribute is the higher <code>n</code> should be, <code>n</code> should
- * never be less than the number of attributes with a lower ranking.
- * <p>
- * Multiple attributes can have an equal ranking when one attribute can compensate the absence
- * of an other attribute with the same ranking.
- *
- * <pre>
- * Example:
- *
- * Attributes a through f
- * Attributes a and b are mandatory, b is more important than a.
- * The attributes c and d should be higher prior than e and f, but should have equal ranking.
- *
- * The ranking looks like the following:
- * Attribute Ranking
- * b 32 (2^5)
- * a 16 (2^4)
- * c, d 4 (2^2)
- * e, f 1 (2^0)
- *
- * With this rankings it is not possible to compensate a missing higher prior attribute with
- * one or more lower prior attributes.
- *
- * Additional methods returns the following values for this example:
- *
- * getNumAttributes() == 6
- * getMandatoryAttibutes() == {a, b}
- * getNumMandatoryAttributes() == 2
- * getFullMatchRanking() >= 48 (the value can be greater than 48 depending
- * on the implementation of the launch manager delegate)
- * </pre>
- *
- * @param attributeKey The attribute key for which the ranking should be returned
- */
- protected int getAttributeRanking(String attributeKey) {
- return 1;
- }
-
- /**
- * Minimum ranking for a launch configuration to be handled as full match when comparing to a
- * launch specification.
- * <p>
- * Should be overwritten when the method {@link #getAttributeRanking(String)} was overwritten.
- *
- * @see #getAttributeRanking(String)
- */
- protected int getFullMatchRanking() {
- return 0;
- }
-
- /**
- * Compares an attribute value of launch configuration and specification.
- *
- * If both values are not null, calls {@link #equals(String, Object, Object, ILaunchSpecification, ILaunchConfiguration, String)}
- * to compare the values. If one of the values is <code>null</code>, and the not <code>null</code> value is default, <code>true</code>
- * is returned. If both values are <code>null</code>, <code>true</code> is returned.
- *
- * @param attributeKey The attribute key. Must not be <code>null</code>.
- * @param specValue The launch specification value.
- * @param confValue The launch configuration value.
- * @param launchSpec The launch specification which is the source of the <code>specValue</code>. Must not be <code>null</code>.
- * @param launchConfig The launch configuration which is the source of the <code>confValue</code>. Must not be <code>null</code>.
- * @return NO_MATCH, PARTIAL_MATCH or FULL_MATCH
- */
- protected int compareAttributeValues(String attributeKey, Object specValue, Object confValue, ILaunchSpecification launchSpec, ILaunchConfiguration launchConfig) {
- Assert.isNotNull(attributeKey);
- Assert.isNotNull(launchSpec);
- Assert.isNotNull(launchConfig);
-
- // values are equal if both are null
- if (specValue == null && confValue == null) {
- return FULL_MATCH;
- }
- // if launch specification value is null,
- // values are equal if launch configuration value is default
- else if (specValue == null) {
- Assert.isNotNull(confValue);
- return isDefaultAttribute(attributeKey, confValue, launchConfig, launchSpec.getLaunchMode()) ? FULL_MATCH : NO_MATCH;
- }
- // if launch configuration value is default,
- // values are equal if launch specification value is default too
- else if (isDefaultAttribute(attributeKey, confValue, launchConfig, launchSpec.getLaunchMode()) || confValue == null) {
- Assert.isNotNull(specValue);
- return isDefaultAttribute(attributeKey, specValue, launchConfig, launchSpec.getLaunchMode()) ? FULL_MATCH : NO_MATCH;
- }
- // use object.equals as default
- else {
- Assert.isNotNull(specValue);
- Assert.isNotNull(confValue);
- return equals(attributeKey, specValue, confValue, launchSpec, launchConfig, launchSpec.getLaunchMode());
- }
- }
-
- /**
- * Compares the attribute value of launch configuration and launch specification.
- * <p>
- * The handling of null values is implemented in the calling private method
- * {@link #compareAttributeValues(String, Object, Object, ILaunchSpecification, ILaunchConfiguration)}.
- * When overwriting this method the implementor can be certain both values are not <code>null</code>.
- *
- * @param attributeKey The attribute key
- * @param specValue The launch specification value. Must not be <code>null</code>.
- * @param confValue The launch configuration value. Must not be <code>null</code>.
- * @param launchSpec The launch specification.
- * @param launchConfig The launch configuration which is the source of the <code>confValue</code>.
- * @param launchMode The current launch mode.
- *
- * @return NO_MATCH, PARTIAL_MATCH or FULL_MATCH
- */
- protected int equals(String attributeKey, Object specValue, Object confValue, ILaunchSpecification launchSpec, ILaunchConfiguration launchConfig, String launchMode) {
- Assert.isNotNull(specValue);
- Assert.isNotNull(confValue);
-
- if (ICommonLaunchAttributes.ATTR_PROJECTS_FOR_BUILD.equals(attributeKey)) {
- // get match of list objects
- int match = specValue.equals(confValue) ? FULL_MATCH : NO_MATCH;
- // compare objects in the list when they are not already equal
- if (match != FULL_MATCH && specValue instanceof List<?> && confValue instanceof List<?>) {
- List<?> specProject = (List<?>) specValue;
- List<?> confProject = (List<?>) confValue;
- match = (specProject.isEmpty() || confProject.isEmpty()) ? PARTIAL_MATCH : NO_MATCH;
- List<?> refProjects = null;
- try {
- refProjects = launchConfig.getAttribute(ICommonLaunchAttributes.ATTR_REFERENCED_PROJECTS, (List<?>) null);
- }
- catch (CoreException e) {
- // ignore
- }
- for (int i = 0; i < specProject.size(); i++) {
- Object specObject = specProject.get(i);
- if (specObject != null && confProject.contains(specObject)) {
- // spec object can be found in the configuration
- if (match == NO_MATCH) {
- // full match on first element in the spec list,
- // otherwise partial match
- match = (i == 0) ? FULL_MATCH : PARTIAL_MATCH;
- }
- }
- else if (specObject != null && refProjects != null && refProjects.contains(specObject)) {
- // spec object can be found in the configuration
- if (match == NO_MATCH) {
- match = PARTIAL_MATCH;
- }
- }
- else if (match == FULL_MATCH) {
- // reduce full to partial match when spec object wasn't found
- match = PARTIAL_MATCH;
- }
- }
- // reduce full to partial match when list size is not equal
- // but all spec values where found in the configuration project list
- if (match == FULL_MATCH && specProject.size() != confProject.size()) {
- match = PARTIAL_MATCH;
- }
- }
- return match;
- }
-
- return specValue.equals(confValue) ? FULL_MATCH : NO_MATCH;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#showLaunchDialog(int)
- */
- @Override
- public boolean showLaunchDialog(int situation) {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#showLaunchConfigOnly()
- */
- @Override
- public boolean showLaunchConfigOnly() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#showLaunchConfigSelectionDialog(org.eclipse.debug.core.ILaunchConfigurationType, org.eclipse.debug.core.ILaunchConfiguration[])
- */
- @Override
- public boolean showLaunchConfigSelectionDialog(ILaunchConfigurationType type, ILaunchConfiguration[] launchConfigs) {
- if (type != null) {
- String key = type.getIdentifier() + ".hideLaunchConfigSelectionDialog"; //$NON-NLS-1$
- return !CoreBundleActivator.getScopedPreferences().getBoolean(key);
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getErrorMessage()
- */
- @Override
- public String getErrorMessage() {
- return errorMessage;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getVariants(org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection)
- */
- @Override
- public String[] getVariants(ILaunchSelection launchSelection) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#equals(org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext, org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext)
- */
- @Override
- public boolean equals(ISelectionContext ctx1, ISelectionContext ctx2) {
- return (ctx1 == null && ctx2 == null) || (ctx1 != null && ctx1.equals(ctx2));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#useDefaultConnection()
- */
- @Override
- public boolean useDefaultConnection() {
- return true;
- }
-}
+/*******************************************************************************
+ * 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.lm.delegates;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.launch.core.bindings.LaunchConfigTypeBindingsManager;
+import org.eclipse.tcf.te.launch.core.exceptions.LaunchServiceException;
+import org.eclipse.tcf.te.launch.core.interfaces.tracing.ITraceIds;
+import org.eclipse.tcf.te.launch.core.lm.LaunchConfigSorter;
+import org.eclipse.tcf.te.launch.core.lm.LaunchSpecification;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ICommonLaunchAttributes;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchAttribute;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
+import org.eclipse.tcf.te.launch.core.nls.Messages;
+import org.eclipse.tcf.te.launch.core.preferences.IPreferenceKeys;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
+
+/**
+ * Default launch manager delegate implementation.
+ */
+public class DefaultLaunchManagerDelegate extends ExecutableExtension implements ILaunchManagerDelegate {
+ protected final static int NO_MATCH = 0;
+ protected final static int PARTIAL_MATCH = 1;
+ protected final static int FULL_MATCH = 2;
+
+ protected String errorMessage = null;
+
+ /**
+ * Constructor.
+ */
+ public DefaultLaunchManagerDelegate() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#initLaunchConfigAttributes(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy, org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification)
+ */
+ @Override
+ public void initLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec) {
+ Assert.isNotNull(wc);
+ Assert.isNotNull(launchSpec);
+ validateLaunchSpecification(launchSpec);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#updateLaunchConfigAttributes(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy, org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification)
+ */
+ @Override
+ public void updateLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec) {
+ Assert.isNotNull(wc);
+ Assert.isNotNull(launchSpec);
+ validateLaunchSpecification(launchSpec);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#isDefaultAttribute(java.lang.String, java.lang.Object, org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
+ */
+ @Override
+ public boolean isDefaultAttribute(String attributeKey, Object attributeValue, ILaunchConfiguration launchConfig, String launchMode) {
+ Assert.isNotNull(attributeKey);
+ Assert.isNotNull(launchConfig);
+ Assert.isNotNull(launchMode);
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getMatchingLaunchConfigurations(org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification, org.eclipse.debug.core.ILaunchConfiguration[])
+ */
+ @Override
+ public final ILaunchConfiguration[] getMatchingLaunchConfigurations(ILaunchSpecification launchSpec, ILaunchConfiguration[] launchConfigs) throws LaunchServiceException {
+ if (launchConfigs == null || launchConfigs.length == 0) {
+ return new ILaunchConfiguration[0];
+ }
+ else if (launchSpec != null) {
+ List<LaunchConfigSorter> rankedList = new ArrayList<LaunchConfigSorter>();
+ for (ILaunchConfiguration launchConfig : launchConfigs) {
+ if (CoreBundleActivator.getTraceHandler()
+ .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
+ System.out.println("\n***\n"); //$NON-NLS-1$
+ }
+
+ int ranking = 0;
+ try {
+ ranking = getLaunchConfigRanking(launchSpec, launchConfig);
+ }
+ catch (LaunchServiceException e) {
+ switch (e.getType()) {
+ case LaunchServiceException.TYPE_MISSING_LAUNCH_CONFIG_ATTR:
+ ranking = 0;
+ break;
+ default:
+ throw e;
+ }
+ }
+
+ int fullMatchRanking = getFullMatchRanking();
+
+ if (CoreBundleActivator.getTraceHandler()
+ .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
+ StringBuilder message = new StringBuilder("Ranking launch spec ("); //$NON-NLS-1$
+ message.append(launchSpec.getLaunchConfigName());
+ message.append(") vs launch configuration ("); //$NON-NLS-1$
+ message.append(launchConfig.getName());
+ message.append(") = "); //$NON-NLS-1$
+ message.append(ranking);
+ message.append(" ; full match ranking = "); //$NON-NLS-1$
+ message.append(fullMatchRanking);
+
+ CoreBundleActivator
+ .getTraceHandler()
+ .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this);
+ }
+
+ if (ranking >= fullMatchRanking) {
+ rankedList.add(new LaunchConfigSorter(launchConfig, ranking));
+ }
+ }
+
+ // sort results and write back into array
+ Collections.sort(rankedList);
+ ILaunchConfiguration[] matchingConfigs = new ILaunchConfiguration[rankedList.size()];
+ for (int i = 0; i < rankedList.size(); i++) {
+ matchingConfigs[i] = rankedList.get(i).getConfig();
+ }
+
+ return matchingConfigs;
+ }
+ else {
+ return launchConfigs;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getLaunchSpecification(java.lang.String, org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection)
+ */
+ @Override
+ public final ILaunchSpecification getLaunchSpecification(String launchConfigTypeId, ILaunchSelection launchSelection) {
+ ILaunchSpecification spec = null;
+
+ if (isValidLaunchSelection(launchSelection)) {
+ spec = new LaunchSpecification(launchConfigTypeId, launchSelection.getLaunchMode());
+
+ for (ISelectionContext selectionContext : launchSelection.getSelectedContexts()) {
+ // For launch specifications, all selection contexts needs to be set as preferred
+ // for full validation.
+ // otherwise "not preferred" contexts are valid even if they are not for a give
+ // launch configuration type id.
+ selectionContext.setIsPreferredContext(true);
+ if (LaunchConfigTypeBindingsManager
+ .getInstance()
+ .isValidLaunchConfigType(launchConfigTypeId, launchSelection.getLaunchMode(), selectionContext)) {
+ spec = addLaunchSpecAttributes(spec, launchConfigTypeId, selectionContext);
+ }
+ }
+
+ // If the number of selected contexts is 0, we have to call addLaunchSpecAttributes
+ // one time to add the selection independent attributes.
+ if (launchSelection.getSelectedContexts().length == 0) {
+ spec = addLaunchSpecAttributes(spec, launchConfigTypeId, null);
+ }
+ }
+
+ return spec;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getDefaultLaunchName(org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification)
+ */
+ @Override
+ public String getDefaultLaunchName(ILaunchSpecification launchSpec) {
+ return Messages.DefaultLaunchManagerDelegate_defaultLaunchName;
+ }
+
+ /**
+ * Add all needed selections to the launch specification.
+ * <p>
+ * Subclasses needs to override and super-call this method!
+ * <p>
+ * <b>Note:</b> The selection context can be <code>null</code>. In this case, the method
+ * implementation is expected to add only selection independent attributes!
+ *
+ * @param launchSpec The launch specification to add selections to. Must not be
+ * <code>null</code>.
+ * @param launchConfigTypeId The launch configuration type id. Must not be <code>null</code>.
+ * @param selectionContext The validated selection context with the selection(s) or
+ * <code>null</code>
+ *
+ * @return The launch specification with attributes from the selection context.
+ */
+ protected ILaunchSpecification addLaunchSpecAttributes(ILaunchSpecification launchSpec, String launchConfigTypeId, ISelectionContext selectionContext) {
+ Assert.isNotNull(launchSpec);
+ Assert.isNotNull(launchConfigTypeId);
+ return launchSpec;
+ }
+
+ /**
+ * Returns the ranking of the launch configuration compared to the launch specification.
+ * <p>
+ * If all attributes of the launch specification matches with the corresponding attributes of
+ * the launch configuration, the ranking should be at least as high as the number of attributes
+ * in the launch specification. The ranking should grow with every additional attribute value
+ * that is set to default.
+ * <p>
+ * If only a set of attributes matches, the ranking should be less than the number of attributes
+ * in the launch specification.
+ * <p>
+ * If no attribute matches zero should be returned.
+ *
+ * @param launchSpec The launch specification the launch configuration should be compared to.
+ * @param launchConfig The launch configuration to find a ranking for.
+ * @return The ranking of the launch configuration.
+ * @throws <code>LaunchServiceException</code> exception when mandatory attributes are missing
+ */
+ private int getLaunchConfigRanking(ILaunchSpecification launchSpec, ILaunchConfiguration launchConfig) throws LaunchServiceException {
+ int ranking = 0;
+ int mandatorys = 0;
+ Map<?, ?> configAttributes = null;
+ Set<?> configKeys = null;
+ try {
+ configAttributes = launchConfig.getAttributes();
+ configKeys = configAttributes.keySet();
+ }
+ catch (Exception e) {
+ return 0;
+ }
+
+ // Read the launch configuration matching mode from the preferences
+ int mode = CoreBundleActivator.getScopedPreferences()
+ .getInt(IPreferenceKeys.PREF_LAUNCH_CONFIG_FIND_CREATE_MODE);
+ if (launchSpec.getAttribute(IPreferenceKeys.PREF_LAUNCH_CONFIG_FIND_CREATE_MODE, null) instanceof Integer) {
+ mode = ((Integer) launchSpec
+ .getAttribute(IPreferenceKeys.PREF_LAUNCH_CONFIG_FIND_CREATE_MODE, null))
+ .intValue();
+ }
+
+ if (CoreBundleActivator.getTraceHandler()
+ .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
+ StringBuilder message = new StringBuilder("Ranking launch spec ("); //$NON-NLS-1$
+ message.append(launchSpec.getLaunchConfigName());
+ message.append(") vs launch configuration ("); //$NON-NLS-1$
+ message.append(launchConfig.getName());
+ message.append("): Matching mode = "); //$NON-NLS-1$
+ if (mode == IPreferenceKeys.MODE_ALWAYS_NEW) {
+ message.append(" ALWAYS_NEW "); //$NON-NLS-1$
+ }
+ else if (mode == IPreferenceKeys.MODE_FIRST_MATCHING) {
+ message.append(" FIRST_MATCHING "); //$NON-NLS-1$
+ }
+ else if (mode == IPreferenceKeys.MODE_FULL_MATCH_TARGET) {
+ message.append(" FULL_MATCH_TARGET "); //$NON-NLS-1$
+ }
+ else if (mode == IPreferenceKeys.MODE_FULL_MATCH_LAUNCH_CONFIG) {
+ message.append(" FULL_MATCH_LAUNCH_CONFIG "); //$NON-NLS-1$
+ }
+
+ CoreBundleActivator
+ .getTraceHandler()
+ .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this);
+ }
+
+ for (ILaunchAttribute specAttribute : launchSpec.getAllAttributes()) {
+ if (!specAttribute.isCreateOnlyAttribute()) {
+ String key = specAttribute.getKey();
+ Object specValue = specAttribute.getValue();
+ Object configValue = configAttributes.get(key);
+ int match = compareAttributeValues(key, specValue, configValue, launchSpec, launchConfig);
+
+ if (CoreBundleActivator.getTraceHandler()
+ .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
+ StringBuilder message = new StringBuilder("Launch spec attribute '"); //$NON-NLS-1$
+ message.append(specAttribute.getKey());
+ message.append("': mandatory = "); //$NON-NLS-1$
+ message.append(isMandatoryAttribute(key));
+ message.append("; match = "); //$NON-NLS-1$
+ if (match == NO_MATCH) {
+ message.append("NO_MATCH"); //$NON-NLS-1$
+ }
+ else if (match == PARTIAL_MATCH) {
+ message.append("PARTIAL_MATCH"); //$NON-NLS-1$
+ }
+ else if (match == FULL_MATCH) {
+ message.append("FULL_MATCH"); //$NON-NLS-1$
+ }
+ if (match != FULL_MATCH) {
+ message.append("\n\t\tspecValue = "); //$NON-NLS-1$
+ message.append(specValue != null ? specValue.toString() : "null"); //$NON-NLS-1$
+ message.append("\n\t\tconfigValue = "); //$NON-NLS-1$
+ message.append(configValue != null ? configValue.toString() : "null"); //$NON-NLS-1$
+ }
+
+ CoreBundleActivator
+ .getTraceHandler()
+ .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this);
+ }
+
+ if (match == PARTIAL_MATCH && mode == IPreferenceKeys.MODE_FULL_MATCH_LAUNCH_CONFIG) {
+ return 0;
+ }
+ if (match > NO_MATCH) {
+ int attrRanking = getAttributeRanking(key);
+ ranking += attrRanking * (attrRanking > 1 ? 4 : 1);
+ if (match == FULL_MATCH) {
+ ranking += attrRanking * (attrRanking > 1 ? 2 : 1);
+ }
+ configKeys.remove(key);
+ if (isMandatoryAttribute(key)) {
+ mandatorys++;
+ }
+ }
+ else {
+ return 0;
+ }
+ }
+ else {
+ if (CoreBundleActivator.getTraceHandler()
+ .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
+ StringBuilder message = new StringBuilder("Skipped launch spec attribute '"); //$NON-NLS-1$
+ message.append(specAttribute.getKey());
+ message.append("': is create only attribute"); //$NON-NLS-1$
+
+ CoreBundleActivator
+ .getTraceHandler()
+ .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this);
+ }
+ }
+ }
+ if (mandatorys < getNumMandatoryAttributes()) {
+ throw new LaunchServiceException("missing mandatory attribute in ILaunchSpecification", //$NON-NLS-1$
+ LaunchServiceException.TYPE_MISSING_LAUNCH_SPEC_ATTR);
+ }
+
+ Iterator<?> configIt = configKeys.iterator();
+ while (configIt.hasNext()) {
+ String key = (String) configIt.next();
+ Object specValue = launchSpec.getAttribute(key, null);
+ Object configValue = configAttributes.get(key);
+
+ int match = compareAttributeValues(key, specValue, configValue, launchSpec, launchConfig);
+ if (match > NO_MATCH) {
+ int attrRanking = getAttributeRanking(key);
+ ranking += attrRanking * (attrRanking > 1 ? 4 : 1);
+ if (match == FULL_MATCH) {
+ ranking += attrRanking * (attrRanking > 1 ? 2 : 1);
+ }
+ }
+ }
+
+ return ranking;
+ }
+
+ /**
+ * Returns the number of defined attributes for this launch manager delegate.
+ *
+ * @see #getAttributeRanking(String)
+ */
+ protected int getNumAttributes() {
+ return 0;
+ }
+
+ /**
+ * Returns the list of mandatory attributes for a launch specification handled by this launch
+ * manager delegate.
+ * <p>
+ * The returned value must not be <code>null</code>, if no attributes are mandatory, an empty
+ * list should be returned.
+ *
+ * @see #getAttributeRanking(String)
+ */
+ protected List<String> getMandatoryAttributes() {
+ return Collections.emptyList();
+ }
+
+ private boolean validateLaunchSpecification(ILaunchSpecification launchSpec) {
+ boolean valid = true;
+ if (launchSpec == null || !launchSpec.isValid()) {
+ return false;
+ }
+ for (String attribute : getMandatoryAttributes()) {
+ if (!launchSpec.hasAttribute(attribute)) {
+ valid = false;
+ break;
+ }
+ }
+ launchSpec.setIsValid(valid);
+ return valid;
+ }
+
+ /**
+ * Method for basic launch selection validations like checking the number of project or target
+ * contexts.
+ * <p>
+ * The default implementation returns always <code>true</code>.
+ *
+ * @param launchSelection The launch selection to check.
+ * @return <code>True</code> if the launch selection is valid, <code>false</code> otherwise.
+ */
+ protected boolean isValidLaunchSelection(ILaunchSelection launchSelection) {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#validate(java.lang.String, org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public void validate(String launchMode, ILaunchConfiguration launchConfig) throws LaunchServiceException {
+ String missingAttributes = null;
+ for (String attribute : getMandatoryAttributes()) {
+ if (!isValidAttribute(attribute, launchConfig, launchMode)) {
+ missingAttributes = (missingAttributes == null) ? attribute : missingAttributes + ", " + attribute; //$NON-NLS-1$
+ }
+ }
+ if (missingAttributes != null) {
+ throw new LaunchServiceException("Missing launch configuration attributes: " + '\n' + missingAttributes, LaunchServiceException.TYPE_MISSING_LAUNCH_CONFIG_ATTR); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Validate a single attribute for a given launch configuration and a launch mode. This method
+ * needs to be overwritten when contributing new launch modes which does not need all attributes.
+ *
+ * @param attributeKey The attribute key.
+ * @param launchConfig The launch configuration.
+ * @param launchMode The launch mode.
+ *
+ * @return <code>True</code>, if the attribute value is valid.
+ */
+ protected boolean isValidAttribute(String attributeKey, ILaunchConfiguration launchConfig, String launchMode) {
+ try {
+ if (launchConfig == null || !launchConfig.hasAttribute(attributeKey)) {
+ return false;
+ }
+ }
+ catch (CoreException e) {
+ return false;
+ }
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#validate(org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification)
+ */
+ @Override
+ public void validate(ILaunchSpecification launchSpec) throws LaunchServiceException {
+ String missingAttributes = null;
+ for (String attribute : getMandatoryAttributes()) {
+ if (launchSpec == null || !launchSpec.hasAttribute(attribute)) {
+ // Remember the missing attribute for adding the list to the exception.
+ missingAttributes = (missingAttributes == null) ? attribute : missingAttributes + ", " + attribute; //$NON-NLS-1$
+ }
+ }
+ if (missingAttributes != null) {
+ throw new LaunchServiceException("Missing launch specification attributes: " + '\n' + missingAttributes, LaunchServiceException.TYPE_MISSING_LAUNCH_SPEC_ATTR); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Returns the number of defined mandatory attributes.
+ *
+ * @see #getMandatoryAttributes()
+ * @see #getAttributeRanking(String)
+ */
+ protected final int getNumMandatoryAttributes() {
+ return getMandatoryAttributes().size();
+ }
+
+ /**
+ * Returns true if the attribute key is in the list of mandatory attributes.
+ *
+ * @see #getMandatoryAttributes()
+ * @see #getAttributeRanking(String)
+ */
+ protected final boolean isMandatoryAttribute(String attributeKey) {
+ return getMandatoryAttributes().contains(attributeKey);
+ }
+
+ /**
+ * Returns the ranking for the given attribute key.
+ * <p>
+ * The default ranking is 1, ranking of mandatory and other fundamental attributes should be
+ * coded as <code>2^n</code>.
+ * <p>
+ * The more important an attribute is the higher <code>n</code> should be, <code>n</code> should
+ * never be less than the number of attributes with a lower ranking.
+ * <p>
+ * Multiple attributes can have an equal ranking when one attribute can compensate the absence
+ * of an other attribute with the same ranking.
+ *
+ * <pre>
+ * Example:
+ *
+ * Attributes a through f
+ * Attributes a and b are mandatory, b is more important than a.
+ * The attributes c and d should be higher prior than e and f, but should have equal ranking.
+ *
+ * The ranking looks like the following:
+ * Attribute Ranking
+ * b 32 (2^5)
+ * a 16 (2^4)
+ * c, d 4 (2^2)
+ * e, f 1 (2^0)
+ *
+ * With this rankings it is not possible to compensate a missing higher prior attribute with
+ * one or more lower prior attributes.
+ *
+ * Additional methods returns the following values for this example:
+ *
+ * getNumAttributes() == 6
+ * getMandatoryAttibutes() == {a, b}
+ * getNumMandatoryAttributes() == 2
+ * getFullMatchRanking() >= 48 (the value can be greater than 48 depending
+ * on the implementation of the launch manager delegate)
+ * </pre>
+ *
+ * @param attributeKey The attribute key for which the ranking should be returned
+ */
+ protected int getAttributeRanking(String attributeKey) {
+ return 1;
+ }
+
+ /**
+ * Minimum ranking for a launch configuration to be handled as full match when comparing to a
+ * launch specification.
+ * <p>
+ * Should be overwritten when the method {@link #getAttributeRanking(String)} was overwritten.
+ *
+ * @see #getAttributeRanking(String)
+ */
+ protected int getFullMatchRanking() {
+ return 0;
+ }
+
+ /**
+ * Compares an attribute value of launch configuration and specification.
+ *
+ * If both values are not null, calls {@link #equals(String, Object, Object, ILaunchSpecification, ILaunchConfiguration, String)}
+ * to compare the values. If one of the values is <code>null</code>, and the not <code>null</code> value is default, <code>true</code>
+ * is returned. If both values are <code>null</code>, <code>true</code> is returned.
+ *
+ * @param attributeKey The attribute key. Must not be <code>null</code>.
+ * @param specValue The launch specification value.
+ * @param confValue The launch configuration value.
+ * @param launchSpec The launch specification which is the source of the <code>specValue</code>. Must not be <code>null</code>.
+ * @param launchConfig The launch configuration which is the source of the <code>confValue</code>. Must not be <code>null</code>.
+ * @return NO_MATCH, PARTIAL_MATCH or FULL_MATCH
+ */
+ protected int compareAttributeValues(String attributeKey, Object specValue, Object confValue, ILaunchSpecification launchSpec, ILaunchConfiguration launchConfig) {
+ Assert.isNotNull(attributeKey);
+ Assert.isNotNull(launchSpec);
+ Assert.isNotNull(launchConfig);
+
+ // values are equal if both are null
+ if (specValue == null && confValue == null) {
+ return FULL_MATCH;
+ }
+ // if launch specification value is null,
+ // values are equal if launch configuration value is default
+ else if (specValue == null) {
+ Assert.isNotNull(confValue);
+ return isDefaultAttribute(attributeKey, confValue, launchConfig, launchSpec.getLaunchMode()) ? FULL_MATCH : NO_MATCH;
+ }
+ // if launch configuration value is default,
+ // values are equal if launch specification value is default too
+ else if (isDefaultAttribute(attributeKey, confValue, launchConfig, launchSpec.getLaunchMode()) || confValue == null) {
+ Assert.isNotNull(specValue);
+ return isDefaultAttribute(attributeKey, specValue, launchConfig, launchSpec.getLaunchMode()) ? FULL_MATCH : NO_MATCH;
+ }
+ // use object.equals as default
+ else {
+ Assert.isNotNull(specValue);
+ Assert.isNotNull(confValue);
+ return equals(attributeKey, specValue, confValue, launchSpec, launchConfig, launchSpec.getLaunchMode());
+ }
+ }
+
+ /**
+ * Compares the attribute value of launch configuration and launch specification.
+ * <p>
+ * The handling of null values is implemented in the calling private method
+ * {@link #compareAttributeValues(String, Object, Object, ILaunchSpecification, ILaunchConfiguration)}.
+ * When overwriting this method the implementor can be certain both values are not <code>null</code>.
+ *
+ * @param attributeKey The attribute key
+ * @param specValue The launch specification value. Must not be <code>null</code>.
+ * @param confValue The launch configuration value. Must not be <code>null</code>.
+ * @param launchSpec The launch specification.
+ * @param launchConfig The launch configuration which is the source of the <code>confValue</code>.
+ * @param launchMode The current launch mode.
+ *
+ * @return NO_MATCH, PARTIAL_MATCH or FULL_MATCH
+ */
+ protected int equals(String attributeKey, Object specValue, Object confValue, ILaunchSpecification launchSpec, ILaunchConfiguration launchConfig, String launchMode) {
+ Assert.isNotNull(specValue);
+ Assert.isNotNull(confValue);
+
+ if (ICommonLaunchAttributes.ATTR_PROJECTS_FOR_BUILD.equals(attributeKey)) {
+ // get match of list objects
+ int match = specValue.equals(confValue) ? FULL_MATCH : NO_MATCH;
+ // compare objects in the list when they are not already equal
+ if (match != FULL_MATCH && specValue instanceof List<?> && confValue instanceof List<?>) {
+ List<?> specProject = (List<?>) specValue;
+ List<?> confProject = (List<?>) confValue;
+ match = (specProject.isEmpty() || confProject.isEmpty()) ? PARTIAL_MATCH : NO_MATCH;
+ List<?> refProjects = null;
+ try {
+ refProjects = launchConfig.getAttribute(ICommonLaunchAttributes.ATTR_REFERENCED_PROJECTS, (List<?>) null);
+ }
+ catch (CoreException e) {
+ // ignore
+ }
+ for (int i = 0; i < specProject.size(); i++) {
+ Object specObject = specProject.get(i);
+ if (specObject != null && confProject.contains(specObject)) {
+ // spec object can be found in the configuration
+ if (match == NO_MATCH) {
+ // full match on first element in the spec list,
+ // otherwise partial match
+ match = (i == 0) ? FULL_MATCH : PARTIAL_MATCH;
+ }
+ }
+ else if (specObject != null && refProjects != null && refProjects.contains(specObject)) {
+ // spec object can be found in the configuration
+ if (match == NO_MATCH) {
+ match = PARTIAL_MATCH;
+ }
+ }
+ else if (match == FULL_MATCH) {
+ // reduce full to partial match when spec object wasn't found
+ match = PARTIAL_MATCH;
+ }
+ }
+ // reduce full to partial match when list size is not equal
+ // but all spec values where found in the configuration project list
+ if (match == FULL_MATCH && specProject.size() != confProject.size()) {
+ match = PARTIAL_MATCH;
+ }
+ }
+ return match;
+ }
+
+ return specValue.equals(confValue) ? FULL_MATCH : NO_MATCH;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#showLaunchDialog(int)
+ */
+ @Override
+ public boolean showLaunchDialog(int situation) {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#showLaunchConfigOnly()
+ */
+ @Override
+ public boolean showLaunchConfigOnly() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#showLaunchConfigSelectionDialog(org.eclipse.debug.core.ILaunchConfigurationType, org.eclipse.debug.core.ILaunchConfiguration[])
+ */
+ @Override
+ public boolean showLaunchConfigSelectionDialog(ILaunchConfigurationType type, ILaunchConfiguration[] launchConfigs) {
+ if (type != null) {
+ String key = type.getIdentifier() + ".hideLaunchConfigSelectionDialog"; //$NON-NLS-1$
+ return !CoreBundleActivator.getScopedPreferences().getBoolean(key);
+ }
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getErrorMessage()
+ */
+ @Override
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#equals(org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext, org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext)
+ */
+ @Override
+ public boolean equals(ISelectionContext ctx1, ISelectionContext ctx2) {
+ return (ctx1 == null && ctx2 == null) || (ctx1 != null && ctx1.equals(ctx2));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#useDefaultConnection()
+ */
+ @Override
+ public boolean useDefaultConnection() {
+ return true;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ICommonLaunchAttributes.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ICommonLaunchAttributes.java
index 63582ad..5257548 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ICommonLaunchAttributes.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ICommonLaunchAttributes.java
@@ -35,11 +35,6 @@ public interface ICommonLaunchAttributes {
public static final String ATTR_LAST_LAUNCHED = ATTR_PREFIX + ".lastLaunched"; //$NON-NLS-1$
/**
- * Launch mode variant id.
- */
- public static final String ATTR_DELEGATE_VARIANT = ATTR_PREFIX + ".delegateVariant"; //$NON-NLS-1$
-
- /**
* Attribute used exclusively with <code>ILaunch.setAttribute</code> to mark when
* then launch sequence finished. The attribute does not tell if an error occurred
* during the launch!
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ILaunchManagerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ILaunchManagerDelegate.java
index f9e1c20..658adb1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ILaunchManagerDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ILaunchManagerDelegate.java
@@ -1,196 +1,177 @@
-/*******************************************************************************
- * 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.lm.interfaces;
-
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.tcf.te.launch.core.exceptions.LaunchServiceException;
-import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
-import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
-import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
-
-/**
- * Describes the interface used by the <code>LaunchManager</code> to create
- * and manage the different types of possible launch configurations in a generalized,
- * simple and abstract way. A <code>ILaunchManagerDelegate</code> is strictly bound
- * to one specific <code>ILaunchConfigurationType</code> and is capable and responsible
- * to initializing and handling launch configurations of this type. A launch manager
- * delegate is contribute through the <code>org.eclipse.tcf.te.launch.core.launchManagerDelegates</code>
- * extension point!
- */
-public interface ILaunchManagerDelegate extends IExecutableExtension {
-
- public static final int SITUATION_BEFORE_LAUNCH = 0;
- public static final int SITUATION_AFTER_LAUNCH_FAILED = 99;
-
- // Constants for signaling the type of found matches
-
- /**
- * Constant to signal to ignore this matching.
- */
- public final static int IGNORE = -1;
-
- /**
- * Constant to signal a no match (no attributes are matching).
- */
- public final static int NO_MATCH = 0;
-
- /**
- * Constant to signal a partial match (some attributes are matching).
- */
- public final static int PARTIAL_MATCH = 1;
-
- /**
- * Constant to signal a full match (all attributes are matching).
- */
- public final static int FULL_MATCH = 2;
-
- /**
- * Initialize the launch configuration attributes based on the specified launch specification. If an launch
- * configuration attribute is not listed within the specified launch specification, the corresponding attribute is
- * initialized with an default.
- *
- * @param wc The launch configuration working copy to initialize. Must not be <code>null</code>!
- * @param launchSpec The launch specification. Must not be <code>null</code>!
- */
- public void initLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec);
-
- /**
- * Updates a found launch configuration based on the specified launch specification.
- *
- * @param wc The launch configuration working copy to initialize. Must not be <code>null</code>!
- * @param launchSpec The launch specification. Must not be <code>null</code>!
- */
- public void updateLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec);
-
- /**
- * Test the specified attribute if or if not the specified attribute value is an default value or not.
- *
- * @param attributeKey The attribute key/name. Must not be <code>null</code>.
- * @param attributeValue The attribute value to test.
- * @param launchConfig The original launch configuration. Needed to access relevant attributes for default value
- * calculation. Must not be <code>null</code>!
- * @param launchMode The launch mode. Default values may differ for different launch modes. Must not be
- * <code>null</code>!
- * @return <code>true</code> if the specified attribute value is the default value, <code>false</code> otherwise.
- */
- public boolean isDefaultAttribute(String attributeKey, Object attributeValue, ILaunchConfiguration launchConfig, String launchMode);
-
- /**
- * Returns a ranked list of launch configurations that best matches the given launch specification. In case of no
- * results or a given empty or null launch configuration list an empty list should be returned. If no launch specification
- * is given, the original list should be returned.
- *
- * @param launchSpec The launch specification the launch configurations should match.
- * @param launchConfigs A full list of launch configurations to check for best matching.
- * @return List of matching launch configurations starting with best match on first index.
- * @throws LaunchServiceException
- */
- public ILaunchConfiguration[] getMatchingLaunchConfigurations(ILaunchSpecification launchSpec, ILaunchConfiguration[] launchConfigs) throws LaunchServiceException;
-
- /**
- * Get the default launch configuration name.
- *
- * @param launchSpec The launch specification to create a default name for the launch config. Must not be <code>null</code>.
- * @return The default launch configuration name.
- */
- public String getDefaultLaunchName(ILaunchSpecification launchSpec);
-
- /**
- * Get a launch specification with all needed attributes for this delegate taken from the selection to find or create a new
- * launch configuration.
- *
- * @param launchConfigTypeId The launch configuration type id.
- * @param launchSelection The selected contexts.
- * @return Launch specification with attributes set from selected contexts.
- * @throws LaunchServiceException
- */
- public ILaunchSpecification getLaunchSpecification(String launchConfigTypeId, ILaunchSelection launchSelection);
-
- /**
- * Get a launch spec with all needed attributes for this delegate and variant taken from the selection to find or create a new
- * launch configuration.
- *
- * @param launchConfigTypeId The launch configuration type id.
- * @param launchSelection The selected contexts.
- * @param variant The delegate variant.
- * @return Launch spec with attributes set from selected contexts.
- * @throws LaunchServiceException
- */
- public ILaunchSpecification getLaunchSpecification(String launchConfigTypeId, ILaunchSelection launchSelection, String variant);
-
- /**
- * Validates a launch specification.
- *
- * @param launchSpec The launch specification to validate.
- * @throws LaunchServiceException If validation fails with further information about the reason (e.q. missing
- * attributes)
- */
- public void validate(ILaunchSpecification launchSpec) throws LaunchServiceException;
-
- /**
- * Validates a launch configuration.
- *
- * @param launchConfig The launch configuration to validate.
- * @param launchMode The launch mode.
- * @throws LaunchServiceException If validation fails with further information about the reason (e.q. missing
- * attributes)
- */
- public void validate(String launchMode, ILaunchConfiguration launchConfig) throws LaunchServiceException;
-
- /**
- * Returns true, if the launch dialog should be shown before launch.
- * @param situation The situation (before launch, after launch, ..)
- */
- public boolean showLaunchDialog(int situation);
-
- /**
- * Returns true, if the launch dialog should only show the given launch configuration (no launch configuration type tree).
- */
- public boolean showLaunchConfigOnly();
-
- /**
- * Returns <code>true</code> if a dialog should pop up when at least one matching
- * launch configuration was found.
- * If <code>false</code> is returned, the first matching launch configuration will be used.
- *
- * @param type The launch configuration type to check.
- */
- public boolean showLaunchConfigSelectionDialog(ILaunchConfigurationType type, ILaunchConfiguration[] launchConfigs);
-
- /**
- * Returns the error message when not valid, otherwise <code>null</code>.
- */
- public String getErrorMessage();
-
- /**
- * Return the list of variants or null.
- *
- * @param launchSelection The launch selection or <code>null</code>.
- */
- public String[] getVariants(ILaunchSelection launchSelection);
-
- /**
- * Return <code>true</code> if the two selection contexts are equal
- * for this launch configuration type.
- *
- * @param ctx1 The first launch selection context or <code>null</code>.
- * @param ctx2 The second launch selection context or <code>null</code>.
- *
- * @return <code>True</code> if the two selection contexts are equal for this launch configuration type, <code>false</code> otherwise.
- */
- public boolean equals(ISelectionContext ctx1, ISelectionContext ctx2);
-
- /**
- * Return <code>true</code> if a default connection should be used when the connection selection is empty.
- */
- public boolean useDefaultConnection();
-}
+/*******************************************************************************
+ * 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.lm.interfaces;
+
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.tcf.te.launch.core.exceptions.LaunchServiceException;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
+import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
+
+/**
+ * Describes the interface used by the <code>LaunchManager</code> to create
+ * and manage the different types of possible launch configurations in a generalized,
+ * simple and abstract way. A <code>ILaunchManagerDelegate</code> is strictly bound
+ * to one specific <code>ILaunchConfigurationType</code> and is capable and responsible
+ * to initializing and handling launch configurations of this type. A launch manager
+ * delegate is contribute through the <code>org.eclipse.tcf.te.launch.core.launchManagerDelegates</code>
+ * extension point!
+ */
+public interface ILaunchManagerDelegate extends IExecutableExtension {
+
+ public static final int SITUATION_BEFORE_LAUNCH = 0;
+ public static final int SITUATION_AFTER_LAUNCH_FAILED = 99;
+
+ // Constants for signaling the type of found matches
+
+ /**
+ * Constant to signal to ignore this matching.
+ */
+ public final static int IGNORE = -1;
+
+ /**
+ * Constant to signal a no match (no attributes are matching).
+ */
+ public final static int NO_MATCH = 0;
+
+ /**
+ * Constant to signal a partial match (some attributes are matching).
+ */
+ public final static int PARTIAL_MATCH = 1;
+
+ /**
+ * Constant to signal a full match (all attributes are matching).
+ */
+ public final static int FULL_MATCH = 2;
+
+ /**
+ * Initialize the launch configuration attributes based on the specified launch specification. If an launch
+ * configuration attribute is not listed within the specified launch specification, the corresponding attribute is
+ * initialized with an default.
+ *
+ * @param wc The launch configuration working copy to initialize. Must not be <code>null</code>!
+ * @param launchSpec The launch specification. Must not be <code>null</code>!
+ */
+ public void initLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec);
+
+ /**
+ * Updates a found launch configuration based on the specified launch specification.
+ *
+ * @param wc The launch configuration working copy to initialize. Must not be <code>null</code>!
+ * @param launchSpec The launch specification. Must not be <code>null</code>!
+ */
+ public void updateLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec);
+
+ /**
+ * Test the specified attribute if or if not the specified attribute value is an default value or not.
+ *
+ * @param attributeKey The attribute key/name. Must not be <code>null</code>.
+ * @param attributeValue The attribute value to test.
+ * @param launchConfig The original launch configuration. Needed to access relevant attributes for default value
+ * calculation. Must not be <code>null</code>!
+ * @param launchMode The launch mode. Default values may differ for different launch modes. Must not be
+ * <code>null</code>!
+ * @return <code>true</code> if the specified attribute value is the default value, <code>false</code> otherwise.
+ */
+ public boolean isDefaultAttribute(String attributeKey, Object attributeValue, ILaunchConfiguration launchConfig, String launchMode);
+
+ /**
+ * Returns a ranked list of launch configurations that best matches the given launch specification. In case of no
+ * results or a given empty or null launch configuration list an empty list should be returned. If no launch specification
+ * is given, the original list should be returned.
+ *
+ * @param launchSpec The launch specification the launch configurations should match.
+ * @param launchConfigs A full list of launch configurations to check for best matching.
+ * @return List of matching launch configurations starting with best match on first index.
+ * @throws LaunchServiceException
+ */
+ public ILaunchConfiguration[] getMatchingLaunchConfigurations(ILaunchSpecification launchSpec, ILaunchConfiguration[] launchConfigs) throws LaunchServiceException;
+
+ /**
+ * Get the default launch configuration name.
+ *
+ * @param launchSpec The launch specification to create a default name for the launch config. Must not be <code>null</code>.
+ * @return The default launch configuration name.
+ */
+ public String getDefaultLaunchName(ILaunchSpecification launchSpec);
+
+ /**
+ * Get a launch specification with all needed attributes for this delegate taken from the selection to find or create a new
+ * launch configuration.
+ *
+ * @param launchConfigTypeId The launch configuration type id.
+ * @param launchSelection The selected contexts.
+ * @return Launch specification with attributes set from selected contexts.
+ * @throws LaunchServiceException
+ */
+ public ILaunchSpecification getLaunchSpecification(String launchConfigTypeId, ILaunchSelection launchSelection);
+
+ /**
+ * Validates a launch specification.
+ *
+ * @param launchSpec The launch specification to validate.
+ * @throws LaunchServiceException If validation fails with further information about the reason (e.q. missing
+ * attributes)
+ */
+ public void validate(ILaunchSpecification launchSpec) throws LaunchServiceException;
+
+ /**
+ * Validates a launch configuration.
+ *
+ * @param launchConfig The launch configuration to validate.
+ * @param launchMode The launch mode.
+ * @throws LaunchServiceException If validation fails with further information about the reason (e.q. missing
+ * attributes)
+ */
+ public void validate(String launchMode, ILaunchConfiguration launchConfig) throws LaunchServiceException;
+
+ /**
+ * Returns true, if the launch dialog should be shown before launch.
+ * @param situation The situation (before launch, after launch, ..)
+ */
+ public boolean showLaunchDialog(int situation);
+
+ /**
+ * Returns true, if the launch dialog should only show the given launch configuration (no launch configuration type tree).
+ */
+ public boolean showLaunchConfigOnly();
+
+ /**
+ * Returns <code>true</code> if a dialog should pop up when at least one matching
+ * launch configuration was found.
+ * If <code>false</code> is returned, the first matching launch configuration will be used.
+ *
+ * @param type The launch configuration type to check.
+ */
+ public boolean showLaunchConfigSelectionDialog(ILaunchConfigurationType type, ILaunchConfiguration[] launchConfigs);
+
+ /**
+ * Returns the error message when not valid, otherwise <code>null</code>.
+ */
+ public String getErrorMessage();
+
+ /**
+ * Return <code>true</code> if the two selection contexts are equal
+ * for this launch configuration type.
+ *
+ * @param ctx1 The first launch selection context or <code>null</code>.
+ * @param ctx2 The second launch selection context or <code>null</code>.
+ *
+ * @return <code>True</code> if the two selection contexts are equal for this launch configuration type, <code>false</code> otherwise.
+ */
+ public boolean equals(ISelectionContext ctx1, ISelectionContext ctx2);
+
+ /**
+ * Return <code>true</code> if a default connection should be used when the connection selection is empty.
+ */
+ public boolean useDefaultConnection();
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/plugin.properties
index ea28f64..ef1a5e8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/plugin.properties
@@ -14,7 +14,3 @@ providerName = Eclipse.org - TCF
Extension.Steppers.name=Steppers
Extension.Steps.name=Steps
Extension.StepGroups.name=Step Groups
-
-# ***** Steppers *****
-
-SingleContextStepper.name=Single Context Stepper
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/StepperManager.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/StepperManager.java
index ec3aefe..5e2dcc6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/StepperManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/StepperManager.java
@@ -11,7 +11,6 @@ package org.eclipse.tcf.te.runtime.stepper;
import org.eclipse.tcf.te.runtime.stepper.extensions.manager.StepExtensionPointManager;
import org.eclipse.tcf.te.runtime.stepper.extensions.manager.StepGroupExtensionPointManager;
-import org.eclipse.tcf.te.runtime.stepper.extensions.manager.StepperExtensionPointManager;
/**
* Central manager providing access to the stepper, steps and step groups
@@ -20,7 +19,6 @@ import org.eclipse.tcf.te.runtime.stepper.extensions.manager.StepperExtensionPoi
public final class StepperManager {
// References to the extension point managers
private final StepExtensionPointManager stepExtManager = new StepExtensionPointManager();
- private final StepperExtensionPointManager stepperExtManager = new StepperExtensionPointManager();
private final StepGroupExtensionPointManager stepGroupExtManager = new StepGroupExtensionPointManager();
/*
@@ -54,15 +52,6 @@ public final class StepperManager {
}
/**
- * Returns the stepper extension point manager instance.
- *
- * @return The stepper extension point manager instance.
- */
- public StepperExtensionPointManager getStepperExtManager() {
- return stepperExtManager;
- }
-
- /**
* Returns the step group extension point manager instance.
*
* @return The step group extension point manager instance.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepperExtensionPointManager.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepperExtensionPointManager.java
deleted file mode 100644
index 730f2d9..0000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepperExtensionPointManager.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.runtime.stepper.extensions.manager;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper;
-
-/**
- * Stepper extension point manager implementation.
- */
-public final class StepperExtensionPointManager extends AbstractExtensionPointManager<IStepper> {
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
- */
- @Override
- protected String getExtensionPointId() {
- return "org.eclipse.tcf.te.runtime.stepper.steppers"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
- */
- @Override
- protected String getConfigurationElementName() {
- return "stepper"; //$NON-NLS-1$
- }
-
- /**
- * Returns the list of all contributed stepper.
- *
- * @param unique If <code>true</code>, the method returns new instances for each
- * contributed stepper.
- *
- * @return The list of contributed stepper, or an empty array.
- */
- public IStepper[] getStepper(boolean unique) {
- List<IStepper> contributions = new ArrayList<IStepper>();
- Collection<ExecutableExtensionProxy<IStepper>> delegates = getExtensions().values();
- for (ExecutableExtensionProxy<IStepper> delegate : delegates) {
- IStepper instance = unique ? delegate.newInstance() : delegate.getInstance();
- if (instance != null && !contributions.contains(instance)) {
- contributions.add(instance);
- }
- }
-
- return contributions.toArray(new IStepper[contributions.size()]);
- }
-
- /**
- * Returns the stepper identified by its unique id. If no stepper with the specified id is registered,
- * <code>null</code> is returned.
- *
- * @param id The unique id of the stepper or <code>null</code>
- * @param unique If <code>true</code>, the method returns new instances of the stepper contribution.
- *
- * @return The stepper instance or <code>null</code>.
- */
- public IStepper getStepper(String id, boolean unique) {
- Assert.isNotNull(id);
- IStepper contribution = null;
- if (getExtensions().containsKey(id)) {
- ExecutableExtensionProxy<IStepper> proxy = getExtensions().get(id);
- // Get the extension instance
- contribution = unique ? proxy.newInstance() : proxy.getInstance();
- }
-
- return contribution;
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepper.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepper.java
index b89f46f..3df1ee5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepper.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepper.java
@@ -13,7 +13,6 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.tcf.te.runtime.interfaces.IConditionTester;
-import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
@@ -27,7 +26,7 @@ import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
* <p>
* Stepper must run in worker threads.
*/
-public interface IStepper extends IExecutableExtension {
+public interface IStepper {
public static final String ID_TYPE_STEPPER_ID = "Stepper"; //$NON-NLS-1$
public static final String ID_TYPE_CONTEXT_ID = "Context"; //$NON-NLS-1$
@@ -68,6 +67,28 @@ public interface IStepper extends IExecutableExtension {
}
/**
+ * Returns the unique id of the extension. The returned
+ * id must be never <code>null</code> or an empty string.
+ *
+ * @return The unique id.
+ */
+ public String getId();
+
+ /**
+ * Returns the label or UI name of the extension.
+ *
+ * @return The label or UI name. An empty string if not set.
+ */
+ public String getLabel();
+
+ /**
+ * Returns the description of the extension.
+ *
+ * @return The description or an empty string.
+ */
+ public String getDescription();
+
+ /**
* Initialize the stepper for a run. This method must be called before <i><code>execute()</code>
* </i>. Once the stepper finished the execution, the initialization is reseted and must be
* renewed before <i><code>execute()</code></i> can be called again.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IVariantDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IVariantDelegate.java
deleted file mode 100644
index e1a5961..0000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IVariantDelegate.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.runtime.stepper.interfaces;
-
-import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-
-/**
- * The variant delegate is providing variants to the main modes. Variants can influence the executed
- * steps or step groups.
- */
-public interface IVariantDelegate extends IExecutableExtension {
-
- /**
- * Returns the valid mode variants for the current context The returned list of variants is
- * probed in the returned order.
- *
- * @param context The context. Must not be <code>null</code>.
- * @param data The data. Must not be <code>null</code>.
- *
- * @return The valid variants or an empty array.
- */
- public String[] getValidVariants(IStepContext context, IPropertiesContainer data);
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java
index 846b9ad..7c455ca 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java
@@ -1,737 +1,783 @@
-/*******************************************************************************
- * Copyright (c) 2011, 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.runtime.stepper.stepper;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.runtime.callback.Callback;
-import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
-import org.eclipse.tcf.te.runtime.interfaces.ISharedConstants;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.stepper.StepperManager;
-import org.eclipse.tcf.te.runtime.stepper.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.runtime.stepper.extensions.StepExecutor;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStep;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepExecutor;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroupIterator;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroupable;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperProperties;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.tracing.ITraceIds;
-import org.eclipse.tcf.te.runtime.stepper.nls.Messages;
-import org.eclipse.tcf.te.runtime.utils.ProgressHelper;
-import org.eclipse.tcf.te.runtime.utils.StatusHelper;
-
-/**
- * An abstract stepper implementation.
- */
-public class Stepper extends ExecutableExtension implements IStepper {
-
- private boolean initialized = false;
- private boolean finished = false;
- private IPropertiesContainer data = null;
- private IFullQualifiedId fullQualifiedId = null;
- private IProgressMonitor monitor = null;
- private IStepContext context = null;
- private boolean cancelable = true;
-
- /**
- * Internal helper describing a fully executed step.
- */
- protected final class ExecutedContextStep {
- final IFullQualifiedId id;
- final IStep step;
-
- public ExecutedContextStep(IFullQualifiedId id, IStep step) {
- this.id = id;
- this.step = step;
- }
- }
-
- /**
- * Constructor.
- */
- public Stepper() {
- super();
- }
-
- /**
- * Returns a name to describe what is executed by the stepper.
- *
- * @return A name.
- */
- protected String getName() {
- return getData() != null ? getData().getStringProperty(IStepperProperties.PROP_NAME) : null;
- }
-
- /**
- * Returns the id of the step group to execute by the stepper.
- *
- * @return The step group id.
- */
- protected String getStepGroupId() {
- return getData() != null ? getData().getStringProperty(IStepperProperties.PROP_STEP_GROUP_ID) : null;
- }
-
- /**
- * Returns the step group for the given step group id.
- *
- * @param The step group id. Must not be <code>null</code>:
- * @return The step group or <code>null</code>.
- */
- protected IStepGroup getStepGroup(String id) {
- Assert.isNotNull(id);
-
- CoreBundleActivator.getTraceHandler().trace("SingleContextStepper#getStepGroup:" //$NON-NLS-1$
- + " id = '" + id + "'", //$NON-NLS-1$ //$NON-NLS-2$
- 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
-
- return StepperManager.getInstance().getStepGroupExtManager().getStepGroup(id, false);
- }
-
- /**
- * Creates a new instance of the step executor to use for executing a step.
- *
- * @param step The step. Must not be <code>null</code>.
- * @param secondaryId The secondary id or <code>null</code>.
- * @param fullQualifiedStepId The fully qualified step id. Must not be <code>null</code>.
- *
- * @return The step executor instance.
- */
- protected IStepExecutor doCreateStepExecutor(IStep step, String secondaryId, IFullQualifiedId fullQualifiedStepId) {
- Assert.isNotNull(step);
- Assert.isNotNull(fullQualifiedStepId);
- return new StepExecutor();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#initialize(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public final void initialize(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws IllegalStateException {
- Assert.isNotNull(context);
- Assert.isNotNull(data);
- Assert.isNotNull(fullQualifiedId);
- Assert.isNotNull(monitor);
-
- // Assert stepper is not in use
- if (isInitialized()) {
- throw new IllegalStateException("Stepper instance already initialized!"); //$NON-NLS-1$
- }
-
- // set the initial stepper attributes
- this.context = context;
- this.data = data;
- this.monitor = monitor;
- this.fullQualifiedId = fullQualifiedId;
-
- // but not finished yet
- this.finished = false;
-
- // call the hook for the subclasses to initialize themselves
- onInitialize(data, fullQualifiedId, monitor);
-
- setInitialized();
-
- CoreBundleActivator.getTraceHandler().trace("Stepper#initialize:" //$NON-NLS-1$
- + " data = " + data, //$NON-NLS-1$
- 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
- }
-
- /**
- * Hook for subclasses to overwrite if subclasses wants to initialize their own state.
- *
- * @param data The data. Must not be <code>null</code>.
- * @param fullQualifiedId The full qualified id of this stepper.
- * @param monitor The progress monitor. Must not be <code>null</code>.
- */
- protected void onInitialize(IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) {
- Assert.isNotNull(data);
- Assert.isNotNull(fullQualifiedId);
- Assert.isNotNull(monitor);
- }
-
- /**
- * Marks the stepper to be fully initialized.
- */
- protected final void setInitialized() {
- initialized = true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#isInitialized()
- */
- @Override
- public final boolean isInitialized() {
- return initialized;
- }
-
- /**
- * Sets the cancelable state of the stepper.
- *
- * @param cancelable <code>True</code> if the stepper shall be cancelable, <code>false</code> if not.
- */
- protected final void setCancelable(boolean cancelable) {
- this.cancelable = cancelable;
- }
-
- /**
- * Returns the cancelable state of the stepper.
- *
- * @return <code>True</code> if the stepper is cancelable, <code>false</code> if not.
- */
- protected final boolean isCancelable() {
- return cancelable;
- }
-
- /**
- * Get the active context.
- *
- * @return The active context or <code>null</code>.
- */
- protected IStepContext getContext() {
- return context;
- }
-
- /**
- * Get the context id.
- *
- * @return The context id or <code>null</code>.
- */
- protected String getContextId() {
- return context != null ? context.getId() : null;
- }
-
- /**
- * Returns the currently associated data. The method returns <code>null</code> if the stepper is
- * not in initialized state.
- *
- * @return The data or <code>null</code>
- */
- protected final IPropertiesContainer getData() {
- return isInitialized() ? data : null;
- }
-
- /**
- * Returns the full qualified id for this stepper.
- *
- * @return The full qualified stepper id.
- */
- protected final IFullQualifiedId getFullQualifiedId() {
- return fullQualifiedId;
- }
-
- /**
- * Returns the currently associated progress monitor. The method returns
- * <code>null</code> if the stepper is not in initialized state.
- *
- * @return The progress monitor or <code>null</code>
- */
- protected final IProgressMonitor getMonitor() {
- return isInitialized() ? monitor : null;
- }
-
- /**
- * Marks the stepper to be finished.
- */
- protected final void setFinished() {
- finished = true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#isFinished()
- */
- @Override
- public final boolean isFinished() {
- return finished;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#cleanup()
- */
- @Override
- public void cleanup() {
- // Set the progress monitor done here in any case
- if (getMonitor() != null) {
- getMonitor().done();
- }
-
- // Reset the initial stepper attributes
- context = null;
- data = null;
- monitor = null;
- fullQualifiedId = null;
- finished = false;
- initialized = false;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- StringBuilder buffer = new StringBuilder(getClass().getSimpleName());
- buffer.append(" (" + getLabel() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- buffer.append(": "); //$NON-NLS-1$
- buffer.append("id = " + getId()); //$NON-NLS-1$
- return buffer.toString();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#execute()
- */
- @Override
- public final void execute() throws CoreException {
- long startTime = System.currentTimeMillis();
-
- CoreBundleActivator.getTraceHandler().trace("Stepper#execute: *** ENTERED", //$NON-NLS-1$
- 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
- CoreBundleActivator.getTraceHandler().trace(" [" + ISharedConstants.TIME_FORMAT.format(new Date(startTime)) + "]" //$NON-NLS-1$ //$NON-NLS-2$
- + " ***", //$NON-NLS-1$
- 0, ITraceIds.PROFILE_STEPPING, IStatus.WARNING, this);
-
- try {
- // stepper must be initialized before executing
- if (!isInitialized()) {
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- Messages.Stepper_error_initializeNotCalled));
- }
-
- // Create a container for collecting the non-severe status objects
- // during the step execution. Non-severe status objects will
- // be hold back till the execution completed or stopped with an error.
- // Severe status objects are errors or cancellation.
- List<IStatus> statusContainer = new ArrayList<IStatus>();
-
- // start execution
- internalExecute(statusContainer);
-
- // If the warnings container is not empty, create a new status and
- // throw a core exception
- if (!statusContainer.isEmpty()) {
- IStatus status = null;
-
- // Check if we need a multi status
- if (statusContainer.size() > 1) {
- MultiStatus multiStatus =
- new MultiStatus(CoreBundleActivator.getUniqueIdentifier(), 0,
- NLS.bind(Messages.Stepper_multiStatus_finishedWithWarnings, getName()), null);
- for (IStatus subStatus : statusContainer) {
- multiStatus.merge(subStatus);
- }
- status = multiStatus;
- }
- else {
- status = statusContainer.get(0);
- }
-
- throw new CoreException(status);
- }
- }
- finally {
- // Mark the stepper finished
- setFinished();
-
- long endTime = System.currentTimeMillis();
- CoreBundleActivator.getTraceHandler().trace("Stepper#execute: *** DONE", //$NON-NLS-1$
- 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
- CoreBundleActivator.getTraceHandler().trace(" [" + ISharedConstants.TIME_FORMAT.format(new Date(endTime)) //$NON-NLS-1$
- + " , delay = " + (endTime - startTime) + " ms]" //$NON-NLS-1$ //$NON-NLS-2$
- + " ***", //$NON-NLS-1$
- 0, ITraceIds.PROFILE_STEPPING, IStatus.WARNING, this);
- }
- }
-
- /**
- * Executes a step or step group.
- *
- * @param statusContainer The status container. Must not be <code>null</code>.
- * @throws CoreException If the execution fails.
- */
- protected void internalExecute(List<IStatus> statusContainer) throws CoreException {
- Assert.isNotNull(statusContainer);
-
- // Get the step group id
- String stepGroupId = getStepGroupId();
-
- // If no step group id is available, throw an exception
- if (stepGroupId == null) {
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- NLS.bind(Messages.Stepper_error_missingStepGroupId, getName())));
- }
-
- // Get the step group
- IStepGroup stepGroup = getStepGroup(stepGroupId);
-
- // If no step group could be found for any of the valid variants, throw an exception
- if (stepGroup == null) {
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- NLS.bind(Messages.Stepper_error_missingStepGroup, stepGroupId)));
- }
-
- // Initialize the progress monitor
- getMonitor().beginTask(stepGroup.getLabel(), calculateTotalWork(stepGroup));
-
- IFullQualifiedId fullQualifiedId = getFullQualifiedId().createChildId(ID_TYPE_CONTEXT_ID, getContextId(), null);
- fullQualifiedId = fullQualifiedId.createChildId(ID_TYPE_STEP_GROUP_ID, stepGroup.getId(), null);
- // Execute the step group
- executeStepGroup(stepGroup, statusContainer, new ArrayList<ExecutedContextStep>(), fullQualifiedId);
- }
-
- /**
- * Executes a step group.
- *
- * @param stepGroup The step group. Must not be <code>null</code>.
- * @param statusContainer A list holding the warnings occurred during the execution. Must not be <code>null</code>.
- * @param executedSteps A list holding the id's of the steps executed before. Must not be <code>null</code>.
- * @param fullQualifiedGroupId The hierarchy of all parent step group id's separated by "::". Must not be <code>null</code>.
- *
- * @throws CoreException If the execution fails.
- */
- private void executeStepGroup(IStepGroup stepGroup, List<IStatus> statusContainer, List<ExecutedContextStep> executedSteps, IFullQualifiedId fullQualifiedGroupId) throws CoreException {
- Assert.isNotNull(stepGroup);
- Assert.isNotNull(statusContainer);
- Assert.isNotNull(executedSteps);
- Assert.isNotNull(fullQualifiedGroupId);
-
- // Return immediately if the user canceled the monitor in the meanwhile
- if (isCancelable() && getMonitor().isCanceled()) {
- rollback(executedSteps, Status.CANCEL_STATUS, getMonitor());
- throw new CoreException(StatusHelper.getStatus(new OperationCanceledException()));
- }
-
- CoreBundleActivator.getTraceHandler().trace("Stepper#executeStepGroup: step group: '" + stepGroup.getLabel() + "'", //$NON-NLS-1$ //$NON-NLS-2$
- 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
-
- // Resolve the steps to execute
- IStepGroupable[] groupables = stepGroup.getSteps(getContext());
-
- IStepGroupIterator iterator = stepGroup.getStepGroupIterator();
- IFullQualifiedId fullQualifiedIterationId = fullQualifiedGroupId;
- int iteration = 0;
-
- if (iterator != null) {
- iterator.initialize(getContext(), getData(), fullQualifiedGroupId, getMonitor());
- }
- boolean next = iterator == null || iterator.hasNext(getContext(), getData(), fullQualifiedGroupId, getMonitor());
-
- while (next) {
- if (iterator != null) {
- fullQualifiedIterationId = fullQualifiedGroupId.createChildId(ID_TYPE_STEP_GROUP_ITERATION_ID, iterator.getId(), ""+iteration); //$NON-NLS-1$
- iterator.next(getContext(), getData(), fullQualifiedIterationId, getMonitor());
- }
- // Execute the steps or step groups.
- for (IStepGroupable groupable : groupables) {
- executeGroupable(groupable, statusContainer, executedSteps, fullQualifiedIterationId);
- }
- iteration++;
- next = iterator != null && iterator.hasNext(getContext(), getData(), fullQualifiedGroupId, getMonitor());
- }
- }
-
- /**
- * Executes a step groupable. The groupable might encapsulate a
- * step or a step group.
- *
- * @param step The step groupable. Must not be <code>null</code>.
- * @param statusContainer A list holding the warnings occurred during the execution. Must not be <code>null</code>.
- * @param executedSteps A list holding the id's of the steps executed before. Must not be <code>null</code>.
- * @param fullQualifiedParentId The hierarchy of all parent step group id's separated by "::". Must not be <code>null</code>.
- *
- * @throws CoreException If the execution failed.
- */
- private void executeGroupable(IStepGroupable groupable, List<IStatus> statusContainer, List<ExecutedContextStep> executedSteps, IFullQualifiedId fullQualifiedParentId) throws CoreException {
- Assert.isNotNull(groupable);
- Assert.isNotNull(statusContainer);
- Assert.isNotNull(executedSteps);
- Assert.isNotNull(fullQualifiedParentId);
-
- // Return immediately if the user canceled the monitor in the meanwhile
- if (isCancelable() && getMonitor() != null && getMonitor().isCanceled()) {
- rollback(executedSteps, Status.CANCEL_STATUS, getMonitor());
- throw new CoreException(StatusHelper.getStatus(new OperationCanceledException()));
- }
-
- // If the passed in groupable is disabled -> we are done immediately
- if (groupable.isDisabled()) {
- CoreBundleActivator.getTraceHandler().trace("Stepper#executeGroupable: DROPPED DISABLED groupable: id = '" + groupable.getExtension().getId() + "'" //$NON-NLS-1$ //$NON-NLS-2$
- + ", secondaryId = '" + groupable.getSecondaryId() + "'", //$NON-NLS-1$ //$NON-NLS-2$
- 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
- return;
- }
-
- // Check if all dependencies of the groupable have been executed before
- checkForDependenciesExecuted(groupable, executedSteps);
-
- if (groupable.getExtension() instanceof IStepGroup) {
- IFullQualifiedId id = fullQualifiedParentId.createChildId(ID_TYPE_STEP_GROUP_ID, groupable.getExtension().getId(), groupable.getSecondaryId());
- // If the passed in groupable is associated with a step group
- // -> get the groupable from that group and execute them
- executeStepGroup((IStepGroup)groupable.getExtension(), statusContainer, executedSteps, id);
- }
- else if (groupable.getExtension() instanceof IStep) {
- // If the passed in groupable is associated with a step
- // -> check if the required steps have been executed before,
- // create a step executor and invoke the executor.
- IStep step = (IStep)groupable.getExtension();
-
- IFullQualifiedId id = fullQualifiedParentId.createChildId(ID_TYPE_STEP_ID, step.getId(), groupable.getSecondaryId());
-
- // Create the step executor now
- IStepExecutor executor = doCreateStepExecutor(step, groupable.getSecondaryId(), id);
- Assert.isNotNull(executor);
-
- try {
- executedSteps.add(new ExecutedContextStep(id, step));
- // Invoke the executor now
- executor.execute(step, id, getContext(), getData(), getMonitor());
- }
- catch (Exception e) {
- // Catch the CoreException first hand as we need to continue the
- // stepping if the step returned with warnings or information only.
- CoreException coreException = normalizeStatus(e, statusContainer);
- // If the exception has been not eaten, rollback previously executed
- // steps and re-throw the exception.
- if (coreException != null) {
- // Rollback everything, if the step(s) are supporting this and
- // the cleanup hasn't been done already.
- if (isInitialized()) {
- rollback(executedSteps, coreException.getStatus(), getMonitor());
- }
-
- // Re-throw the exception
- throw coreException;
- }
- }
- }
- }
-
- /**
- * Checks if all required dependencies have been executed before. If not, the method
- * will throw an error status.
- *
- * @param groupable The groupable. Must not be <code>null</code>.
- * @param executedSteps A list holding the id's of the steps executed before. Must not be <code>null</code>.
- *
- * @throws CoreException If a dependency has not been executed before.
- */
- protected void checkForDependenciesExecuted(IStepGroupable groupable, List<ExecutedContextStep> executedSteps) throws CoreException {
- Assert.isNotNull(groupable);
- Assert.isNotNull(executedSteps);
-
- // Build up the complete list of dependencies.
- List<String> dependencies = new ArrayList<String>(Arrays.asList(groupable.getDependencies()));
- // If the groupable wraps a step, the step can have additional dependencies to check
- if (groupable.getExtension() instanceof IStep) {
- dependencies.addAll(Arrays.asList(((IStep)groupable.getExtension()).getDependencies()));
- }
-
- // Check each dependency now.
- for (String dependency : dependencies) {
- // The dependencies might be fully qualified. Split out the primary id.
- String[] splitted = dependency.split("##", 2); //$NON-NLS-1$
- String primaryId = splitted.length == 2 ? splitted[0] : dependency;
-
- // Check if the id is in the list of executed steps. As the list contains
- // the fully qualified id's, we cannot just check for contained
- boolean requiredStepExecuted = false;
- for (ExecutedContextStep step : executedSteps) {
- if (step.step.getId().equals(primaryId)) {
- requiredStepExecuted = true;
- break;
- }
- }
-
- if (!requiredStepExecuted) {
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- MessageFormat.format(Messages.Stepper_error_requiredStepNotExecuted,
- NLS.bind(groupable.getExtension() instanceof IStep ? Messages.Stepper_error_step : Messages.Stepper_error_step, groupable.getExtension().getId()),
- NLS.bind(Messages.Stepper_error_requiredStepOrGroup, dependency), ""))); //$NON-NLS-1$
- }
-
- // Recursive checking is not necessary here as the step or step group
- // id's would have made it the executed steps list of they missed required
- // steps or step groups.
- }
-
- }
-
- /**
- * Rollback the steps previously executed to the failed step. The rollback
- * is executed in reverse order and the step must be of type {@link IExtendedStep}
- * to participate in the rollback.
- *
- * @param executedSteps
- * @param progress
- */
- protected final void rollback(final List<ExecutedContextStep> executedSteps, final IStatus rollBackStatus, IProgressMonitor progress) {
- Assert.isNotNull(executedSteps);
-
- final IProgressMonitor rollbackProgress = ProgressHelper.getProgressMonitor(progress, 1);
- ProgressHelper.beginTask(rollbackProgress, "Cancel", executedSteps.size()); //$NON-NLS-1$
- final Callback finalCallback = new Callback();
- final Callback rollbackCallback = new Callback() {
- @Override
- protected void internalDone(Object caller, IStatus status) {
- if (!executedSteps.isEmpty()) {
- setProperty(PROPERTY_IS_DONE, false);
- ExecutedContextStep executedStep = executedSteps.remove(executedSteps.size()-1);
- if (executedStep.step instanceof IExtendedStep) {
- IExtendedStep step = (IExtendedStep)executedStep.step;
- step.rollback(getContext(), getData(), rollBackStatus, executedStep.id, rollbackProgress, this);
- }
- else {
- this.done(this, status);
- }
- }
- else {
- finalCallback.done(this, Status.OK_STATUS);
- }
- }
- };
-
- rollbackCallback.done(this, rollBackStatus);
- ExecutorsUtil.waitAndExecute(0, finalCallback.getDoneConditionTester(null));
- }
-
- /**
- * Calculates the total work required for the step group. The total
- * work is the sum of the total work of each sub step. If one of the
- * steps returns {@link IProgressMonitor#UNKNOWN}, the total work will
- * be unknown for the whole step group.
- *
- * @param stepGroup The step group. Must not be <code>null</code>.
- * @return The total work required or {@link IProgressMonitor#UNKNOWN}.
- *
- * @throws CoreException If the total work of the step group cannot be determined.
- */
- protected int calculateTotalWork(IStepGroup stepGroup) throws CoreException {
- Assert.isNotNull(stepGroup);
-
- int totalWork = 0;
-
- // Loop the group steps and summarize the returned total work
- IStepGroupable[] groupables = stepGroup.getSteps(getContext());
- for (IStepGroupable groupable : groupables) {
- int work = groupable.getExtension() instanceof IStep
- ? ((IStep)groupable.getExtension()).getTotalWork(getContext(), getData())
- : groupable.getExtension() instanceof IStepGroup
- ? calculateTotalWork((IStepGroup)groupable.getExtension())
- : IProgressMonitor.UNKNOWN;
-
- if (work == IProgressMonitor.UNKNOWN) {
- totalWork = IProgressMonitor.UNKNOWN;
- break;
- }
-
- totalWork += work;
- }
-
- return totalWork;
- }
-
- /**
- * Normalize the associated status object of the given {@link CoreException}.
- * <p>
- * If the associated status contains only WARNING or INFORMATION status objects,
- * the objects are added to the passed in status container. The passed in exception
- * is dropped and the method will return <code>null</code>.
- * <p>
- * If the associated status contains only OK status objects, the passed in
- * exception and the associated status are dropped and the method will return
- * <code>null</code>.
- * <p>
- * If the associated status contain ERROR status objects, the passed in exception
- * and the associated status objects are returned if the passed in status container
- * is empty. If the status container is not empty, a new exception and multi status
- * object is created and returned. The multi status object will contain all status
- * objects from the status container and all objects of the originally associated
- * status.
- * <p>
- * If the associated status contains a CANCEL status object, the passed in
- * exception and the associated status objects are returned unmodified.
- *
- * @param e The core exception. Must not be <code>null</code>.
- * @param statusContainer The list of non-severe status objects. Must not be <code>null</code>.
- * @return The exception to re-throw or <code>null</code>.
- */
- private CoreException normalizeStatus(Exception e, List<IStatus> statusContainer) {
- Assert.isNotNull(statusContainer);
-
- CoreException coreException = null;
-
- IStatus status = Status.OK_STATUS;
- // Get the associated status from the exception
- if (e instanceof CoreException) {
- status = ((CoreException)e).getStatus();
- coreException = (CoreException)e;
- }
- else if (e instanceof OperationCanceledException) {
- status = new Status(IStatus.CANCEL, CoreBundleActivator.getUniqueIdentifier(), e.getLocalizedMessage(), e);
- coreException = new CoreException(status);
- }
- else if (e != null) {
- status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), e.getLocalizedMessage(), e);
- coreException = new CoreException(status);
- }
-
- // Check the severity
- // PS: MultiStatus.getSeverity() returns always the highest severity.
- if (status.getSeverity() == IStatus.OK) {
- // OK -> drop completely and return null
- coreException = null;
- }
- else if (status.getSeverity() == IStatus.CANCEL) {
- // CANCEL -> Check monitor to be canceled.
- if (isCancelable()) {
- if (getMonitor() != null && !getMonitor().isCanceled()) {
- getMonitor().setCanceled(true);
- }
- }
- }
- else if (status.getSeverity() == IStatus.WARNING || status.getSeverity() == IStatus.INFO) {
- // WARNING or INFORMATION -> add to the list and return null
- statusContainer.add(status);
- coreException = null;
- }
- else if (status.getSeverity() == IStatus.ERROR) {
- // Error -> If the warnings container not empty, create
- // a new MultiStatus.
- if (!statusContainer.isEmpty()) {
- MultiStatus multiStatus = new MultiStatus(status.getPlugin(), status.getCode(),
- NLS.bind(Messages.Stepper_multiStatus_finishedWithErrors, getName()), null);
- for (IStatus stat : statusContainer) {
- multiStatus.merge(stat);
- }
- // Re-throw via a new CoreException
- coreException = new CoreException(multiStatus);
- }
- }
-
- return coreException;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 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.runtime.stepper.stepper;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.te.runtime.callback.Callback;
+import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
+import org.eclipse.tcf.te.runtime.interfaces.ISharedConstants;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.stepper.StepperManager;
+import org.eclipse.tcf.te.runtime.stepper.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.runtime.stepper.extensions.StepExecutor;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStep;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepExecutor;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroupIterator;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroupable;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperProperties;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.tracing.ITraceIds;
+import org.eclipse.tcf.te.runtime.stepper.nls.Messages;
+import org.eclipse.tcf.te.runtime.utils.ProgressHelper;
+import org.eclipse.tcf.te.runtime.utils.StatusHelper;
+
+/**
+ * An abstract stepper implementation.
+ */
+public class Stepper implements IStepper {
+
+ private boolean initialized = false;
+ private boolean finished = false;
+ private IPropertiesContainer data = null;
+ private IFullQualifiedId fullQualifiedId = null;
+ private IProgressMonitor monitor = null;
+ private IStepContext context = null;
+ private boolean cancelable = true;
+
+ /**
+ * Internal helper describing a fully executed step.
+ */
+ protected final class ExecutedContextStep {
+ final IFullQualifiedId id;
+ final IStep step;
+
+ public ExecutedContextStep(IFullQualifiedId id, IStep step) {
+ this.id = id;
+ this.step = step;
+ }
+ }
+
+ /**
+ * Constructor.
+ */
+ public Stepper() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#getId()
+ */
+ @Override
+ public String getId() {
+ return getClass().getName();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#getLabel()
+ */
+ @Override
+ public String getLabel() {
+ return getClass().getName();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#getDescription()
+ */
+ @Override
+ public String getDescription() {
+ return null;
+ }
+
+ /**
+ * Returns the id of the step group to execute by the stepper.
+ *
+ * @return The step group id.
+ */
+ protected String getStepGroupId() {
+ return getData() != null ? getData()
+ .getStringProperty(IStepperProperties.PROP_STEP_GROUP_ID) : null;
+ }
+
+ /**
+ * Returns the step group for the given step group id.
+ *
+ * @param The step group id. Must not be <code>null</code>:
+ * @return The step group or <code>null</code>.
+ */
+ protected IStepGroup getStepGroup(String id) {
+ Assert.isNotNull(id);
+
+ CoreBundleActivator.getTraceHandler().trace("SingleContextStepper#getStepGroup:" //$NON-NLS-1$
+ + " id = '" + id + "'", //$NON-NLS-1$ //$NON-NLS-2$
+ 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
+
+ return StepperManager.getInstance().getStepGroupExtManager().getStepGroup(id, false);
+ }
+
+ /**
+ * Creates a new instance of the step executor to use for executing a step.
+ *
+ * @param step The step. Must not be <code>null</code>.
+ * @param secondaryId The secondary id or <code>null</code>.
+ * @param fullQualifiedStepId The fully qualified step id. Must not be <code>null</code>.
+ *
+ * @return The step executor instance.
+ */
+ protected IStepExecutor doCreateStepExecutor(IStep step, String secondaryId, IFullQualifiedId fullQualifiedStepId) {
+ Assert.isNotNull(step);
+ Assert.isNotNull(fullQualifiedStepId);
+ return new StepExecutor();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#initialize(org.eclipse.tcf.te.runtime
+ * .interfaces.properties.IPropertiesContainer,
+ * org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public final void initialize(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws IllegalStateException {
+ Assert.isNotNull(context);
+ Assert.isNotNull(data);
+ Assert.isNotNull(fullQualifiedId);
+ Assert.isNotNull(monitor);
+
+ // Assert stepper is not in use
+ if (isInitialized()) {
+ throw new IllegalStateException("Stepper instance already initialized!"); //$NON-NLS-1$
+ }
+
+ // set the initial stepper attributes
+ this.context = context;
+ this.data = data;
+ this.monitor = monitor;
+ this.fullQualifiedId = fullQualifiedId;
+
+ // but not finished yet
+ this.finished = false;
+
+ // call the hook for the subclasses to initialize themselves
+ onInitialize(data, fullQualifiedId, monitor);
+
+ setInitialized();
+
+ CoreBundleActivator.getTraceHandler().trace("Stepper#initialize:" //$NON-NLS-1$
+ + " data = " + data, //$NON-NLS-1$
+ 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
+ }
+
+ /**
+ * Hook for subclasses to overwrite if subclasses wants to initialize their own state.
+ *
+ * @param data The data. Must not be <code>null</code>.
+ * @param fullQualifiedId The full qualified id of this stepper.
+ * @param monitor The progress monitor. Must not be <code>null</code>.
+ */
+ protected void onInitialize(IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) {
+ Assert.isNotNull(data);
+ Assert.isNotNull(fullQualifiedId);
+ Assert.isNotNull(monitor);
+ }
+
+ /**
+ * Marks the stepper to be fully initialized.
+ */
+ protected final void setInitialized() {
+ initialized = true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#isInitialized()
+ */
+ @Override
+ public final boolean isInitialized() {
+ return initialized;
+ }
+
+ /**
+ * Sets the cancelable state of the stepper.
+ *
+ * @param cancelable <code>True</code> if the stepper shall be cancelable, <code>false</code> if
+ * not.
+ */
+ protected final void setCancelable(boolean cancelable) {
+ this.cancelable = cancelable;
+ }
+
+ /**
+ * Returns the cancelable state of the stepper.
+ *
+ * @return <code>True</code> if the stepper is cancelable, <code>false</code> if not.
+ */
+ protected final boolean isCancelable() {
+ return cancelable;
+ }
+
+ /**
+ * Get the active context.
+ *
+ * @return The active context or <code>null</code>.
+ */
+ protected IStepContext getContext() {
+ return context;
+ }
+
+ /**
+ * Get the context id.
+ *
+ * @return The context id or <code>null</code>.
+ */
+ protected String getContextId() {
+ return context != null ? context.getId() : null;
+ }
+
+ /**
+ * Returns the currently associated data. The method returns <code>null</code> if the stepper is
+ * not in initialized state.
+ *
+ * @return The data or <code>null</code>
+ */
+ protected final IPropertiesContainer getData() {
+ return isInitialized() ? data : null;
+ }
+
+ /**
+ * Returns the full qualified id for this stepper.
+ *
+ * @return The full qualified stepper id.
+ */
+ protected final IFullQualifiedId getFullQualifiedId() {
+ return fullQualifiedId;
+ }
+
+ /**
+ * Returns the currently associated progress monitor. The method returns <code>null</code> if
+ * the stepper is not in initialized state.
+ *
+ * @return The progress monitor or <code>null</code>
+ */
+ protected final IProgressMonitor getMonitor() {
+ return isInitialized() ? monitor : null;
+ }
+
+ /**
+ * Marks the stepper to be finished.
+ */
+ protected final void setFinished() {
+ finished = true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#isFinished()
+ */
+ @Override
+ public final boolean isFinished() {
+ return finished;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#cleanup()
+ */
+ @Override
+ public void cleanup() {
+ // Set the progress monitor done here in any case
+ if (getMonitor() != null) {
+ getMonitor().done();
+ }
+
+ // Reset the initial stepper attributes
+ context = null;
+ data = null;
+ monitor = null;
+ fullQualifiedId = null;
+ finished = false;
+ initialized = false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder buffer = new StringBuilder(getClass().getSimpleName());
+ buffer.append(" (" + getLabel() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append(": "); //$NON-NLS-1$
+ buffer.append("id = " + getId()); //$NON-NLS-1$
+ return buffer.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#execute()
+ */
+ @Override
+ public final void execute() throws CoreException {
+ long startTime = System.currentTimeMillis();
+
+ CoreBundleActivator.getTraceHandler().trace("Stepper#execute: *** ENTERED", //$NON-NLS-1$
+ 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
+ CoreBundleActivator
+ .getTraceHandler()
+ .trace(" [" + ISharedConstants.TIME_FORMAT.format(new Date(startTime)) + "]" //$NON-NLS-1$ //$NON-NLS-2$
+ + " ***", //$NON-NLS-1$
+ 0, ITraceIds.PROFILE_STEPPING, IStatus.WARNING, this);
+
+ try {
+ // stepper must be initialized before executing
+ if (!isInitialized()) {
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), Messages.Stepper_error_initializeNotCalled));
+ }
+
+ // Create a container for collecting the non-severe status objects
+ // during the step execution. Non-severe status objects will
+ // be hold back till the execution completed or stopped with an error.
+ // Severe status objects are errors or cancellation.
+ List<IStatus> statusContainer = new ArrayList<IStatus>();
+
+ // start execution
+ internalExecute(statusContainer);
+
+ // If the warnings container is not empty, create a new status and
+ // throw a core exception
+ if (!statusContainer.isEmpty()) {
+ IStatus status = null;
+
+ // Check if we need a multi status
+ if (statusContainer.size() > 1) {
+ MultiStatus multiStatus = new MultiStatus(CoreBundleActivator.getUniqueIdentifier(), 0, NLS
+ .bind(Messages.Stepper_multiStatus_finishedWithWarnings, getLabel()), null);
+ for (IStatus subStatus : statusContainer) {
+ multiStatus.merge(subStatus);
+ }
+ status = multiStatus;
+ }
+ else {
+ status = statusContainer.get(0);
+ }
+
+ throw new CoreException(status);
+ }
+ }
+ finally {
+ // Mark the stepper finished
+ setFinished();
+
+ long endTime = System.currentTimeMillis();
+ CoreBundleActivator.getTraceHandler().trace("Stepper#execute: *** DONE", //$NON-NLS-1$
+ 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
+ CoreBundleActivator.getTraceHandler()
+ .trace(" [" + ISharedConstants.TIME_FORMAT.format(new Date(endTime)) //$NON-NLS-1$
+ + " , delay = " + (endTime - startTime) + " ms]" //$NON-NLS-1$ //$NON-NLS-2$
+ + " ***", //$NON-NLS-1$
+ 0, ITraceIds.PROFILE_STEPPING, IStatus.WARNING, this);
+ }
+ }
+
+ /**
+ * Executes a step or step group.
+ *
+ * @param statusContainer The status container. Must not be <code>null</code>.
+ * @throws CoreException If the execution fails.
+ */
+ protected void internalExecute(List<IStatus> statusContainer) throws CoreException {
+ Assert.isNotNull(statusContainer);
+
+ // Get the step group id
+ String stepGroupId = getStepGroupId();
+
+ // If no step group id is available, throw an exception
+ if (stepGroupId == null) {
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), NLS
+ .bind(Messages.Stepper_error_missingStepGroupId, getLabel())));
+ }
+
+ // Get the step group
+ IStepGroup stepGroup = getStepGroup(stepGroupId);
+
+ // If no step group could be found, throw an exception
+ if (stepGroup == null) {
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), NLS
+ .bind(Messages.Stepper_error_missingStepGroup, stepGroupId)));
+ }
+
+ // Initialize the progress monitor
+ getMonitor().beginTask(stepGroup.getLabel(), calculateTotalWork(stepGroup));
+
+ IFullQualifiedId fullQualifiedId = getFullQualifiedId()
+ .createChildId(ID_TYPE_CONTEXT_ID, getContextId(), null);
+ fullQualifiedId = fullQualifiedId
+ .createChildId(ID_TYPE_STEP_GROUP_ID, stepGroup.getId(), null);
+ // Execute the step group
+ executeStepGroup(stepGroup, statusContainer, new ArrayList<ExecutedContextStep>(), fullQualifiedId);
+ }
+
+ /**
+ * Executes a step group.
+ *
+ * @param stepGroup The step group. Must not be <code>null</code>.
+ * @param statusContainer A list holding the warnings occurred during the execution. Must not be
+ * <code>null</code>.
+ * @param executedSteps A list holding the id's of the steps executed before. Must not be
+ * <code>null</code>.
+ * @param fullQualifiedGroupId The hierarchy of all parent step group id's separated by "::".
+ * Must not be <code>null</code>.
+ *
+ * @throws CoreException If the execution fails.
+ */
+ private void executeStepGroup(IStepGroup stepGroup, List<IStatus> statusContainer, List<ExecutedContextStep> executedSteps, IFullQualifiedId fullQualifiedGroupId) throws CoreException {
+ Assert.isNotNull(stepGroup);
+ Assert.isNotNull(statusContainer);
+ Assert.isNotNull(executedSteps);
+ Assert.isNotNull(fullQualifiedGroupId);
+
+ // Return immediately if the user canceled the monitor in the meanwhile
+ if (isCancelable() && getMonitor().isCanceled()) {
+ rollback(executedSteps, Status.CANCEL_STATUS, getMonitor());
+ throw new CoreException(StatusHelper.getStatus(new OperationCanceledException()));
+ }
+
+ CoreBundleActivator
+ .getTraceHandler()
+ .trace("Stepper#executeStepGroup: step group: '" + stepGroup.getLabel() + "'", //$NON-NLS-1$ //$NON-NLS-2$
+ 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
+
+ // Resolve the steps to execute
+ IStepGroupable[] groupables = stepGroup.getSteps(getContext());
+
+ IStepGroupIterator iterator = stepGroup.getStepGroupIterator();
+ IFullQualifiedId fullQualifiedIterationId = fullQualifiedGroupId;
+ int iteration = 0;
+
+ if (iterator != null) {
+ iterator.initialize(getContext(), getData(), fullQualifiedGroupId, getMonitor());
+ }
+ boolean next = iterator == null || iterator
+ .hasNext(getContext(), getData(), fullQualifiedGroupId, getMonitor());
+
+ while (next) {
+ if (iterator != null) {
+ fullQualifiedIterationId = fullQualifiedGroupId
+ .createChildId(ID_TYPE_STEP_GROUP_ITERATION_ID, iterator.getId(), "" + iteration); //$NON-NLS-1$
+ iterator.next(getContext(), getData(), fullQualifiedIterationId, getMonitor());
+ }
+ // Execute the steps or step groups.
+ for (IStepGroupable groupable : groupables) {
+ executeGroupable(groupable, statusContainer, executedSteps, fullQualifiedIterationId);
+ }
+ iteration++;
+ next = iterator != null && iterator
+ .hasNext(getContext(), getData(), fullQualifiedGroupId, getMonitor());
+ }
+ }
+
+ /**
+ * Executes a step groupable. The groupable might encapsulate a step or a step group.
+ *
+ * @param step The step groupable. Must not be <code>null</code>.
+ * @param statusContainer A list holding the warnings occurred during the execution. Must not be
+ * <code>null</code>.
+ * @param executedSteps A list holding the id's of the steps executed before. Must not be
+ * <code>null</code>.
+ * @param fullQualifiedParentId The hierarchy of all parent step group id's separated by "::".
+ * Must not be <code>null</code>.
+ *
+ * @throws CoreException If the execution failed.
+ */
+ private void executeGroupable(IStepGroupable groupable, List<IStatus> statusContainer, List<ExecutedContextStep> executedSteps, IFullQualifiedId fullQualifiedParentId) throws CoreException {
+ Assert.isNotNull(groupable);
+ Assert.isNotNull(statusContainer);
+ Assert.isNotNull(executedSteps);
+ Assert.isNotNull(fullQualifiedParentId);
+
+ // Return immediately if the user canceled the monitor in the meanwhile
+ if (isCancelable() && getMonitor() != null && getMonitor().isCanceled()) {
+ rollback(executedSteps, Status.CANCEL_STATUS, getMonitor());
+ throw new CoreException(StatusHelper.getStatus(new OperationCanceledException()));
+ }
+
+ // If the passed in groupable is disabled -> we are done immediately
+ if (groupable.isDisabled()) {
+ CoreBundleActivator
+ .getTraceHandler()
+ .trace("Stepper#executeGroupable: DROPPED DISABLED groupable: id = '" + groupable.getExtension().getId() + "'" //$NON-NLS-1$ //$NON-NLS-2$
+ + ", secondaryId = '" + groupable.getSecondaryId() + "'", //$NON-NLS-1$ //$NON-NLS-2$
+ 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
+ return;
+ }
+
+ // Check if all dependencies of the groupable have been executed before
+ checkForDependenciesExecuted(groupable, executedSteps);
+
+ if (groupable.getExtension() instanceof IStepGroup) {
+ IFullQualifiedId id = fullQualifiedParentId
+ .createChildId(ID_TYPE_STEP_GROUP_ID, groupable.getExtension().getId(), groupable
+ .getSecondaryId());
+ // If the passed in groupable is associated with a step group
+ // -> get the groupable from that group and execute them
+ executeStepGroup((IStepGroup) groupable.getExtension(), statusContainer, executedSteps, id);
+ }
+ else if (groupable.getExtension() instanceof IStep) {
+ // If the passed in groupable is associated with a step
+ // -> check if the required steps have been executed before,
+ // create a step executor and invoke the executor.
+ IStep step = (IStep) groupable.getExtension();
+
+ IFullQualifiedId id = fullQualifiedParentId
+ .createChildId(ID_TYPE_STEP_ID, step.getId(), groupable
+ .getSecondaryId());
+
+ // Create the step executor now
+ IStepExecutor executor = doCreateStepExecutor(step, groupable.getSecondaryId(), id);
+ Assert.isNotNull(executor);
+
+ try {
+ executedSteps.add(new ExecutedContextStep(id, step));
+ // Invoke the executor now
+ executor.execute(step, id, getContext(), getData(), getMonitor());
+ }
+ catch (Exception e) {
+ // Catch the CoreException first hand as we need to continue the
+ // stepping if the step returned with warnings or information only.
+ CoreException coreException = normalizeStatus(e, statusContainer);
+ // If the exception has been not eaten, rollback previously executed
+ // steps and re-throw the exception.
+ if (coreException != null) {
+ // Rollback everything, if the step(s) are supporting this and
+ // the cleanup hasn't been done already.
+ if (isInitialized()) {
+ rollback(executedSteps, coreException.getStatus(), getMonitor());
+ }
+
+ // Re-throw the exception
+ throw coreException;
+ }
+ }
+ }
+ }
+
+ /**
+ * Checks if all required dependencies have been executed before. If not, the method will throw
+ * an error status.
+ *
+ * @param groupable The groupable. Must not be <code>null</code>.
+ * @param executedSteps A list holding the id's of the steps executed before. Must not be
+ * <code>null</code>.
+ *
+ * @throws CoreException If a dependency has not been executed before.
+ */
+ protected void checkForDependenciesExecuted(IStepGroupable groupable, List<ExecutedContextStep> executedSteps) throws CoreException {
+ Assert.isNotNull(groupable);
+ Assert.isNotNull(executedSteps);
+
+ // Build up the complete list of dependencies.
+ List<String> dependencies = new ArrayList<String>(Arrays.asList(groupable.getDependencies()));
+ // If the groupable wraps a step, the step can have additional dependencies to check
+ if (groupable.getExtension() instanceof IStep) {
+ dependencies.addAll(Arrays.asList(((IStep) groupable.getExtension()).getDependencies()));
+ }
+
+ // Check each dependency now.
+ for (String dependency : dependencies) {
+ // The dependencies might be fully qualified. Split out the primary id.
+ String[] splitted = dependency.split("##", 2); //$NON-NLS-1$
+ String primaryId = splitted.length == 2 ? splitted[0] : dependency;
+
+ // Check if the id is in the list of executed steps. As the list contains
+ // the fully qualified id's, we cannot just check for contained
+ boolean requiredStepExecuted = false;
+ for (ExecutedContextStep step : executedSteps) {
+ if (step.step.getId().equals(primaryId)) {
+ requiredStepExecuted = true;
+ break;
+ }
+ }
+
+ if (!requiredStepExecuted) {
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), MessageFormat
+ .format(Messages.Stepper_error_requiredStepNotExecuted, NLS.bind(groupable
+ .getExtension() instanceof IStep ? Messages.Stepper_error_step : Messages.Stepper_error_step, groupable
+ .getExtension().getId()), NLS
+ .bind(Messages.Stepper_error_requiredStepOrGroup, dependency), ""))); //$NON-NLS-1$
+ }
+
+ // Recursive checking is not necessary here as the step or step group
+ // id's would have made it the executed steps list of they missed required
+ // steps or step groups.
+ }
+
+ }
+
+ /**
+ * Rollback the steps previously executed to the failed step. The rollback is executed in
+ * reverse order and the step must be of type {@link IExtendedStep} to participate in the
+ * rollback.
+ *
+ * @param executedSteps
+ * @param progress
+ */
+ protected final void rollback(final List<ExecutedContextStep> executedSteps, final IStatus rollBackStatus, IProgressMonitor progress) {
+ Assert.isNotNull(executedSteps);
+
+ final IProgressMonitor rollbackProgress = ProgressHelper.getProgressMonitor(progress, 1);
+ ProgressHelper.beginTask(rollbackProgress, "Cancel", executedSteps.size()); //$NON-NLS-1$
+ final Callback finalCallback = new Callback();
+ final Callback rollbackCallback = new Callback() {
+ @Override
+ protected void internalDone(Object caller, IStatus status) {
+ if (!executedSteps.isEmpty()) {
+ setProperty(PROPERTY_IS_DONE, false);
+ ExecutedContextStep executedStep = executedSteps
+ .remove(executedSteps.size() - 1);
+ if (executedStep.step instanceof IExtendedStep) {
+ IExtendedStep step = (IExtendedStep) executedStep.step;
+ step.rollback(getContext(), getData(), rollBackStatus, executedStep.id, rollbackProgress, this);
+ }
+ else {
+ this.done(this, status);
+ }
+ }
+ else {
+ finalCallback.done(this, Status.OK_STATUS);
+ }
+ }
+ };
+
+ rollbackCallback.done(this, rollBackStatus);
+ ExecutorsUtil.waitAndExecute(0, finalCallback.getDoneConditionTester(null));
+ }
+
+ /**
+ * Calculates the total work required for the step group. The total work is the sum of the total
+ * work of each sub step. If one of the steps returns {@link IProgressMonitor#UNKNOWN}, the
+ * total work will be unknown for the whole step group.
+ *
+ * @param stepGroup The step group. Must not be <code>null</code>.
+ * @return The total work required or {@link IProgressMonitor#UNKNOWN}.
+ *
+ * @throws CoreException If the total work of the step group cannot be determined.
+ */
+ protected int calculateTotalWork(IStepGroup stepGroup) throws CoreException {
+ Assert.isNotNull(stepGroup);
+
+ int totalWork = 0;
+
+ // Loop the group steps and summarize the returned total work
+ IStepGroupable[] groupables = stepGroup.getSteps(getContext());
+ for (IStepGroupable groupable : groupables) {
+ int work = groupable.getExtension() instanceof IStep ? ((IStep) groupable
+ .getExtension()).getTotalWork(getContext(), getData()) : groupable
+ .getExtension() instanceof IStepGroup ? calculateTotalWork((IStepGroup) groupable
+ .getExtension()) : IProgressMonitor.UNKNOWN;
+
+ if (work == IProgressMonitor.UNKNOWN) {
+ totalWork = IProgressMonitor.UNKNOWN;
+ break;
+ }
+
+ totalWork += work;
+ }
+
+ return totalWork;
+ }
+
+ /**
+ * Normalize the associated status object of the given {@link CoreException}.
+ * <p>
+ * If the associated status contains only WARNING or INFORMATION status objects, the objects are
+ * added to the passed in status container. The passed in exception is dropped and the method
+ * will return <code>null</code>.
+ * <p>
+ * If the associated status contains only OK status objects, the passed in exception and the
+ * associated status are dropped and the method will return <code>null</code>.
+ * <p>
+ * If the associated status contain ERROR status objects, the passed in exception and the
+ * associated status objects are returned if the passed in status container is empty. If the
+ * status container is not empty, a new exception and multi status object is created and
+ * returned. The multi status object will contain all status objects from the status container
+ * and all objects of the originally associated status.
+ * <p>
+ * If the associated status contains a CANCEL status object, the passed in exception and the
+ * associated status objects are returned unmodified.
+ *
+ * @param e The core exception. Must not be <code>null</code>.
+ * @param statusContainer The list of non-severe status objects. Must not be <code>null</code>.
+ * @return The exception to re-throw or <code>null</code>.
+ */
+ private CoreException normalizeStatus(Exception e, List<IStatus> statusContainer) {
+ Assert.isNotNull(statusContainer);
+
+ CoreException coreException = null;
+
+ IStatus status = Status.OK_STATUS;
+ // Get the associated status from the exception
+ if (e instanceof CoreException) {
+ status = ((CoreException) e).getStatus();
+ coreException = (CoreException) e;
+ }
+ else if (e instanceof OperationCanceledException) {
+ status = new Status(IStatus.CANCEL, CoreBundleActivator.getUniqueIdentifier(), e.getLocalizedMessage(), e);
+ coreException = new CoreException(status);
+ }
+ else if (e != null) {
+ status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), e.getLocalizedMessage(), e);
+ coreException = new CoreException(status);
+ }
+
+ // Check the severity
+ // PS: MultiStatus.getSeverity() returns always the highest severity.
+ if (status.getSeverity() == IStatus.OK) {
+ // OK -> drop completely and return null
+ coreException = null;
+ }
+ else if (status.getSeverity() == IStatus.CANCEL) {
+ // CANCEL -> Check monitor to be canceled.
+ if (isCancelable()) {
+ if (getMonitor() != null && !getMonitor().isCanceled()) {
+ getMonitor().setCanceled(true);
+ }
+ }
+ }
+ else if (status.getSeverity() == IStatus.WARNING || status.getSeverity() == IStatus.INFO) {
+ // WARNING or INFORMATION -> add to the list and return null
+ statusContainer.add(status);
+ coreException = null;
+ }
+ else if (status.getSeverity() == IStatus.ERROR) {
+ // Error -> If the warnings container not empty, create
+ // a new MultiStatus.
+ if (!statusContainer.isEmpty()) {
+ MultiStatus multiStatus = new MultiStatus(status.getPlugin(), status.getCode(), NLS.bind(Messages.Stepper_multiStatus_finishedWithErrors, getLabel()), null);
+ for (IStatus stat : statusContainer) {
+ multiStatus.merge(stat);
+ }
+ // Re-throw via a new CoreException
+ coreException = new CoreException(multiStatus);
+ }
+ }
+
+ return coreException;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
index 2ae1a69..89eed92 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
@@ -43,10 +43,6 @@
<extension point="org.eclipse.tcf.te.launch.core.launchConfigTypeBindings">
<launchConfigTypeBinding
launchConfigTypeId="org.eclipse.tcf.te.tcf.launch.type.linux.app">
- <stepper
- id="org.eclipse.tcf.te.runtime.stepper"
- modes="run,debug">
- </stepper>
<launchManagerDelegate
id="org.eclipse.tcf.te.tcf.launch.type.linux.app.launchManagerDelegate"
modes="run,debug">
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/StepperTestCase.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/StepperTestCase.java
index b28e1f2..e4419a8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/StepperTestCase.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/StepperTestCase.java
@@ -21,7 +21,6 @@ import org.eclipse.tcf.te.runtime.stepper.interfaces.IStep;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroupable;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper;
import org.eclipse.tcf.te.tests.CoreTestCase;
/**
@@ -78,21 +77,6 @@ public class StepperTestCase extends CoreTestCase {
*/
public void testStepperContributions() {
assertNotNull("Unexpected return value 'null'.", StepperManager.getInstance()); //$NON-NLS-1$
- assertNotNull("Unexpected return value 'null'.", StepperManager.getInstance().getStepperExtManager()); //$NON-NLS-1$
-
- // Lookup the default single-context stepper contributions
- boolean singleContext = false;
-
- IStepper[] steppers = StepperManager.getInstance().getStepperExtManager().getStepper(false);
- for (IStepper stepper : steppers) {
- if (stepper.getId().equals("org.eclipse.tcf.te.runtime.stepper")) { //$NON-NLS-1$
- singleContext = true;
- }
- if (singleContext) {
- break;
- }
- }
- assertTrue("Default single context stepper contribution not found.", singleContext); //$NON-NLS-1$
}
/**