Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2012-02-28 10:10:22 +0000
committerUwe Stieber2012-02-28 10:10:22 +0000
commit81c55237f6fc3a63726fbae7617eb0a28043bedb (patch)
tree095789911ae3bda7c5b9749891ab498f7354d58e /target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper
parentf7516341dac4f8d0dbbef730c9d633a4287ce1b3 (diff)
downloadorg.eclipse.tcf-81c55237f6fc3a63726fbae7617eb0a28043bedb.tar.gz
org.eclipse.tcf-81c55237f6fc3a63726fbae7617eb0a28043bedb.tar.xz
org.eclipse.tcf-81c55237f6fc3a63726fbae7617eb0a28043bedb.zip
Target Explorer: Cherry-pick: REWORK stepper framework and ADD minimal launch stepping
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/plugin.properties37
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/plugin.xml15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/schema/stepBindings.exsd129
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/StepperAttributeUtil.java466
-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/AbstractStepGroup.java71
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/StepExecutor.java532
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/StepGroup.java1686
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepBinding.java66
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepBindingsExtensionPointManager.java187
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepGroupExtensionPointManager.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IContextManipulator.java29
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepContext.java47
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepGroup.java92
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepper.java239
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepperProperties.java7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/nls/Messages.java134
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/nls/Messages.properties94
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/MultiContextStepper.java126
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/SingleContextStepper.java107
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/AbstractStepper.java)285
21 files changed, 1783 insertions, 2579 deletions
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 1932f01b8..ea28f6439 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
@@ -1,17 +1,20 @@
-##################################################################################
-# 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
-##################################################################################
-
-pluginName = Target Explorer, Stepper plug-in
-providerName = Eclipse.org - TCF
-
-# ***** Steppers *****
-
-MultiContextStepper.name=Multi Context Stepper
-SingleContextStepper.name=Single Context Stepper
+##################################################################################
+# 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
+##################################################################################
+
+pluginName = Target Explorer, Stepper plug-in
+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/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/plugin.xml
index e9191deca..a3b4221e7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/plugin.xml
@@ -3,20 +3,15 @@
<plugin>
<!-- Extension Points -->
- <extension-point id="steppers" name="Steppers" schema="schema/steppers.exsd"/>
- <extension-point id="steps" name="Steps" schema="schema/steps.exsd"/>
- <extension-point id="stepGroups" name="Step Groups" schema="schema/stepGroups.exsd"/>
- <extension-point id="stepBindings" name="Step Bindings" schema="schema/stepBindings.exsd"/>
+ <extension-point id="steppers" name="%Extension.Steppers.name" schema="schema/steppers.exsd"/>
+ <extension-point id="steps" name="%Extension.Steps.name" schema="schema/steps.exsd"/>
+ <extension-point id="stepGroups" name="%Extension.StepGroups.name" schema="schema/stepGroups.exsd"/>
<!-- Stepper contributions -->
<extension point="org.eclipse.tcf.te.runtime.stepper.steppers">
<stepper
- id="org.eclipse.tcf.te.runtime.stepper.multiContext"
- class="org.eclipse.tcf.te.runtime.stepper.stepper.MultiContextStepper"
- label="%MultiContextStepper.name"/>
- <stepper
- id="org.eclipse.tcf.te.runtime.stepper.singleContext"
- class="org.eclipse.tcf.te.runtime.stepper.stepper.SingleContextStepper"
+ id="org.eclipse.tcf.te.runtime.stepper"
+ class="org.eclipse.tcf.te.runtime.stepper.stepper.Stepper"
label="%SingleContextStepper.name"/>
</extension>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/schema/stepBindings.exsd b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/schema/stepBindings.exsd
deleted file mode 100644
index fcb6b1ff4..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/schema/stepBindings.exsd
+++ /dev/null
@@ -1,129 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.tcf.te.runtime.stepper" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.tcf.te.runtime.stepper" id="stepBindings" name="Step Bindings Extension Point"/>
- </appinfo>
- <documentation>
- This extension point is used to declare step bindings.
-&lt;p&gt;
-&lt;b&gt;Note:&lt;/b&gt; For the enablement expression evaluation, the default variable is the same as &quot;activeContexts&quot;, and the variable is iterable. The variable is set to the list of contexts the executing stepper is associated with.
- </documentation>
- </annotation>
-
- <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="binding" 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="binding">
- <annotation>
- <documentation>
- Declares a step binding.
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <element ref="enablement" minOccurs="0" maxOccurs="1"/>
- </sequence>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- The unique id of the step binding contribution.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="stepId" type="string" use="required">
- <annotation>
- <documentation>
- The unique id of the referenced step.
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.tcf.te.runtime.stepper.steps/step/@id"/>
- </appinfo>
- </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>
- &lt;pre&gt;
- &lt;extension point=&quot;org.eclipse.tcf.te.runtime.stepper.stepBindings&quot;&gt;
- &lt;binding
- id=&quot;org.eclipse.tcf.te.ui.stepper.step.binding.OpenChannelStep&quot;
- stepId=&quot;org.eclipse.tcf.te.ui.stepper.step.OpenChannelStep&quot;&gt;
- &lt;enablement&gt;
- ...
- &lt;/enablement&gt;
- &lt;/binding&gt;
- &lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
-
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- 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.
- </documentation>
- </annotation>
-
-</schema>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/StepperAttributeUtil.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/StepperAttributeUtil.java
index 12603c153..9c3cfc189 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/StepperAttributeUtil.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/StepperAttributeUtil.java
@@ -1,233 +1,233 @@
-/*******************************************************************************
- * 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;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-
-/**
- * A stepper attributes utility provides a set of static methods
- * to access the attributes of a step.
- */
-public class StepperAttributeUtil {
- /**
- * Get the full qualified key to get or set data in the data.
- *
- * @param key The key for the value.
- * @param fullQualifiedId The full qualified id for this step.
- * @param data The data.
- * @return The full qualified key.
- */
- protected final static String getFullQualifiedKey(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data) {
- Assert.isNotNull(key);
- Assert.isNotNull(data);
-
- return (fullQualifiedId != null ? fullQualifiedId.toString() : "") + key; //$NON-NLS-1$
- }
-
- /**
- * Get a property from the data. If the value is not stored within the full qualified id, the
- * value stored within the parent id will be returned.
- *
- * @param key The key for the value.
- * @param fullQualifiedId The full qualified id for this step.
- * @param data The data.
- * @return The property value or <code>null</code> if either the data has no property container
- * or the property is not set.
- */
- public final static Object getProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data) {
- Assert.isNotNull(key);
- Assert.isNotNull(data);
-
- if (fullQualifiedId == null || data.getProperty(getFullQualifiedKey(key, fullQualifiedId, data)) != null) {
- return data.getProperty(getFullQualifiedKey(key, fullQualifiedId, data));
- }
- return data.getProperty(getFullQualifiedKey(key, fullQualifiedId.getParentId(), data));
- }
-
- /**
- * Get a string property from the data. If the value is not stored within the full qualified id,
- * the value stored within the parent id will be returned.
- *
- * @param key The key for the value.
- * @param fullQualifiedId The full qualified id for this step.
- * @param data The data.
- * @return The string property value or <code>null</code> if either the data has no property
- * container or the property is not set.
- */
- public final static String getStringProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data) {
- Assert.isNotNull(key);
- Assert.isNotNull(data);
-
- if (fullQualifiedId == null || data.getProperty(getFullQualifiedKey(key, fullQualifiedId, data)) != null) {
- return data.getStringProperty(getFullQualifiedKey(key, fullQualifiedId, data));
- }
- return data.getStringProperty(getFullQualifiedKey(key, fullQualifiedId.getParentId(), data));
- }
-
- /**
- * Get a boolean property from the data. If the value is not stored within the full qualified
- * id, the value stored within the parent id will be returned.
- *
- * @param key The key for the value.
- * @param fullQualifiedId The full qualified id for this step.
- * @param data The data.
- * @return The boolean property value or <code>false</code> if either the data has no property
- * container or the property is not set.
- */
- public final static boolean getBooleanProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data) {
- Assert.isNotNull(key);
- Assert.isNotNull(data);
-
- if (fullQualifiedId == null || data.getProperty(getFullQualifiedKey(key, fullQualifiedId, data)) != null) {
- return data.getBooleanProperty(getFullQualifiedKey(key, fullQualifiedId, data));
- }
- return data.getBooleanProperty(getFullQualifiedKey(key, fullQualifiedId.getParentId(), data));
- }
-
- /**
- * Get a int property from the data.
- *
- * @param key The key for the value.
- * @param fullQualifiedId The full qualified id for this step.
- * @param data The data.
- * @return The int property value or <code>-1</code> if either the data has no property
- * container or the property is not set.
- */
- public final static int getIntProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data) {
- Assert.isNotNull(key);
- Assert.isNotNull(data);
-
- if (fullQualifiedId == null || data.getProperty(getFullQualifiedKey(key, fullQualifiedId, data)) != null) {
- return data.getIntProperty(getFullQualifiedKey(key, fullQualifiedId, data));
- }
- return data.getIntProperty(getFullQualifiedKey(key, fullQualifiedId.getParentId(), data));
- }
-
- /**
- * Check if a property is set.
- *
- * @param key The key for the value.
- * @param fullQualifiedId The full qualified id for this step.
- * @param data The data.
- * @return <code>true</code> if a property value is set.
- */
- public final static boolean isPropertySet(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data) {
- Assert.isNotNull(key);
- Assert.isNotNull(data);
-
- return data.getProperty(getFullQualifiedKey(key, fullQualifiedId, data)) != null;
- }
-
- /**
- * Set a property value to the data.
- *
- * @param key The key for the value.
- * @param fullQualifiedId The full qualified id for this step.
- * @param data The data.
- * @param value The new value.
- * @return <code>true</code> if the value was set.
- */
- public final static boolean setProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data, Object value) {
- return setProperty(key, fullQualifiedId, data, value, false);
- }
-
- /**
- * Set a property value to the data and optional share it through the parent full qualified id.
- *
- * @param key The key for the value.
- * @param fullQualifiedId The full qualified id for this step.
- * @param data The data.
- * @param value The new value.
- * @param share When <code>true</code>, the value is also stored within the parent full
- * qualified id to share the value with other steps within the same parent (group).
- * @return <code>true</code> if the value was set.
- */
- public final static boolean setProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data, Object value, boolean share) {
- Assert.isNotNull(key);
- Assert.isNotNull(data);
-
- if (share && fullQualifiedId != null) {
- data.setProperty(getFullQualifiedKey(key, fullQualifiedId.getParentId(), data), value);
- }
- return data.setProperty(getFullQualifiedKey(key, fullQualifiedId, data), value);
- }
-
- /**
- * Set a boolean property value to the data.
- *
- * @param key The key for the value.
- * @param fullQualifiedId The full qualified id for this step.
- * @param data The data.
- * @param value The new boolean value.
- * @return <code>true</code> if the value was set.
- */
- public final static boolean setProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data, boolean value) {
- return setProperty(key, fullQualifiedId, data, value, false);
- }
-
- /**
- * Set a boolean property value to the data and optional share it through the parent full
- * qualified id.
- *
- * @param key The key for the value.
- * @param fullQualifiedId The full qualified id for this step.
- * @param data The data.
- * @param value The new boolean value.
- * @param share When <code>true</code>, the value is also stored within the parent full
- * qualified id to share the value with other steps within the same parent (group).
- * @return <code>true</code> if the value was set.
- */
- public final static boolean setProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data, boolean value, boolean share) {
- Assert.isNotNull(key);
- Assert.isNotNull(data);
-
- if (share && fullQualifiedId != null) {
- data.setProperty(getFullQualifiedKey(key, fullQualifiedId.getParentId(), data), value);
- }
- return data.setProperty(getFullQualifiedKey(key, fullQualifiedId, data), value);
- }
-
- /**
- * Set a int property value to the data.
- *
- * @param key The key for the value.
- * @param fullQualifiedId The full qualified id for this step.
- * @param data The data.
- * @param value The new int value.
- * @return <code>true</code> if the value was set.
- */
- public final static boolean setProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data, int value) {
- return setProperty(key, fullQualifiedId, data, value, false);
- }
-
- /**
- * Set an int property value to the data and optional share it through the parent full qualified
- * id.
- *
- * @param key The key for the value.
- * @param fullQualifiedId The full qualified id for this step.
- * @param data The data.
- * @param value The new int value.
- * @param share When <code>true</code>, the value is also stored within the parent full
- * qualified id to share the value with other steps within the same parent (group).
- * @return <code>true</code> if the value was set.
- */
- public final static boolean setProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data, int value, boolean share) {
- Assert.isNotNull(key);
- Assert.isNotNull(data);
-
- if (share && fullQualifiedId != null) {
- data.setProperty(getFullQualifiedKey(key, fullQualifiedId.getParentId(), data), value);
- }
- return data.setProperty(getFullQualifiedKey(key, fullQualifiedId, data), value);
- }
-}
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+
+/**
+ * A stepper attributes utility provides a set of static methods
+ * to access the attributes of a step.
+ */
+public class StepperAttributeUtil {
+ /**
+ * Get the full qualified key to get or set data in the data.
+ *
+ * @param key The key for the value.
+ * @param fullQualifiedId The full qualified id for this step.
+ * @param data The data.
+ * @return The full qualified key.
+ */
+ protected final static String getFullQualifiedKey(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data) {
+ Assert.isNotNull(key);
+ Assert.isNotNull(data);
+
+ return (fullQualifiedId != null ? fullQualifiedId.toString() : "") + key; //$NON-NLS-1$
+ }
+
+ /**
+ * Get a property from the data. If the value is not stored within the full qualified id, the
+ * value stored within the parent id will be returned.
+ *
+ * @param key The key for the value.
+ * @param fullQualifiedId The full qualified id for this step.
+ * @param data The data.
+ * @return The property value or <code>null</code> if either the data has no property container
+ * or the property is not set.
+ */
+ public final static Object getProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data) {
+ Assert.isNotNull(key);
+ Assert.isNotNull(data);
+
+ if (fullQualifiedId == null || data.getProperty(getFullQualifiedKey(key, fullQualifiedId, data)) != null) {
+ return data.getProperty(getFullQualifiedKey(key, fullQualifiedId, data));
+ }
+ return getProperty(key, fullQualifiedId.getParentId(), data);
+ }
+
+ /**
+ * Get a string property from the data. If the value is not stored within the full qualified id,
+ * the value stored within the parent id will be returned.
+ *
+ * @param key The key for the value.
+ * @param fullQualifiedId The full qualified id for this step.
+ * @param data The data.
+ * @return The string property value or <code>null</code> if either the data has no property
+ * container or the property is not set.
+ */
+ public final static String getStringProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data) {
+ Assert.isNotNull(key);
+ Assert.isNotNull(data);
+
+ if (fullQualifiedId == null || data.getProperty(getFullQualifiedKey(key, fullQualifiedId, data)) != null) {
+ return data.getStringProperty(getFullQualifiedKey(key, fullQualifiedId, data));
+ }
+ return getStringProperty(key, fullQualifiedId.getParentId(), data);
+ }
+
+ /**
+ * Get a boolean property from the data. If the value is not stored within the full qualified
+ * id, the value stored within the parent id will be returned.
+ *
+ * @param key The key for the value.
+ * @param fullQualifiedId The full qualified id for this step.
+ * @param data The data.
+ * @return The boolean property value or <code>false</code> if either the data has no property
+ * container or the property is not set.
+ */
+ public final static boolean getBooleanProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data) {
+ Assert.isNotNull(key);
+ Assert.isNotNull(data);
+
+ if (fullQualifiedId == null || data.getProperty(getFullQualifiedKey(key, fullQualifiedId, data)) != null) {
+ return data.getBooleanProperty(getFullQualifiedKey(key, fullQualifiedId, data));
+ }
+ return getBooleanProperty(key, fullQualifiedId.getParentId(), data);
+ }
+
+ /**
+ * Get a int property from the data.
+ *
+ * @param key The key for the value.
+ * @param fullQualifiedId The full qualified id for this step.
+ * @param data The data.
+ * @return The int property value or <code>-1</code> if either the data has no property
+ * container or the property is not set.
+ */
+ public final static int getIntProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data) {
+ Assert.isNotNull(key);
+ Assert.isNotNull(data);
+
+ if (fullQualifiedId == null || data.getProperty(getFullQualifiedKey(key, fullQualifiedId, data)) != null) {
+ return data.getIntProperty(getFullQualifiedKey(key, fullQualifiedId, data));
+ }
+ return getIntProperty(key, fullQualifiedId.getParentId(), data);
+ }
+
+ /**
+ * Check if a property is set.
+ *
+ * @param key The key for the value.
+ * @param fullQualifiedId The full qualified id for this step.
+ * @param data The data.
+ * @return <code>true</code> if a property value is set.
+ */
+ public final static boolean isPropertySet(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data) {
+ Assert.isNotNull(key);
+ Assert.isNotNull(data);
+
+ return data.getProperty(getFullQualifiedKey(key, fullQualifiedId, data)) != null;
+ }
+
+ /**
+ * Set a property value to the data.
+ *
+ * @param key The key for the value.
+ * @param fullQualifiedId The full qualified id for this step.
+ * @param data The data.
+ * @param value The new value.
+ * @return <code>true</code> if the value was set.
+ */
+ public final static boolean setProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data, Object value) {
+ return setProperty(key, fullQualifiedId, data, value, false);
+ }
+
+ /**
+ * Set a property value to the data and optional share it through the parent full qualified id.
+ *
+ * @param key The key for the value.
+ * @param fullQualifiedId The full qualified id for this step.
+ * @param data The data.
+ * @param value The new value.
+ * @param share When <code>true</code>, the value is also stored within the parent full
+ * qualified id to share the value with other steps within the same parent (group).
+ * @return <code>true</code> if the value was set.
+ */
+ public final static boolean setProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data, Object value, boolean share) {
+ Assert.isNotNull(key);
+ Assert.isNotNull(data);
+
+ if (share && fullQualifiedId != null) {
+ data.setProperty(getFullQualifiedKey(key, fullQualifiedId.getParentId(), data), value);
+ }
+ return data.setProperty(getFullQualifiedKey(key, fullQualifiedId, data), value);
+ }
+
+ /**
+ * Set a boolean property value to the data.
+ *
+ * @param key The key for the value.
+ * @param fullQualifiedId The full qualified id for this step.
+ * @param data The data.
+ * @param value The new boolean value.
+ * @return <code>true</code> if the value was set.
+ */
+ public final static boolean setProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data, boolean value) {
+ return setProperty(key, fullQualifiedId, data, value, false);
+ }
+
+ /**
+ * Set a boolean property value to the data and optional share it through the parent full
+ * qualified id.
+ *
+ * @param key The key for the value.
+ * @param fullQualifiedId The full qualified id for this step.
+ * @param data The data.
+ * @param value The new boolean value.
+ * @param share When <code>true</code>, the value is also stored within the parent full
+ * qualified id to share the value with other steps within the same parent (group).
+ * @return <code>true</code> if the value was set.
+ */
+ public final static boolean setProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data, boolean value, boolean share) {
+ Assert.isNotNull(key);
+ Assert.isNotNull(data);
+
+ if (share && fullQualifiedId != null) {
+ data.setProperty(getFullQualifiedKey(key, fullQualifiedId.getParentId(), data), value);
+ }
+ return data.setProperty(getFullQualifiedKey(key, fullQualifiedId, data), value);
+ }
+
+ /**
+ * Set a int property value to the data.
+ *
+ * @param key The key for the value.
+ * @param fullQualifiedId The full qualified id for this step.
+ * @param data The data.
+ * @param value The new int value.
+ * @return <code>true</code> if the value was set.
+ */
+ public final static boolean setProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data, int value) {
+ return setProperty(key, fullQualifiedId, data, value, false);
+ }
+
+ /**
+ * Set an int property value to the data and optional share it through the parent full qualified
+ * id.
+ *
+ * @param key The key for the value.
+ * @param fullQualifiedId The full qualified id for this step.
+ * @param data The data.
+ * @param value The new int value.
+ * @param share When <code>true</code>, the value is also stored within the parent full
+ * qualified id to share the value with other steps within the same parent (group).
+ * @return <code>true</code> if the value was set.
+ */
+ public final static boolean setProperty(String key, IFullQualifiedId fullQualifiedId, IPropertiesContainer data, int value, boolean share) {
+ Assert.isNotNull(key);
+ Assert.isNotNull(data);
+
+ if (share && fullQualifiedId != null) {
+ data.setProperty(getFullQualifiedKey(key, fullQualifiedId.getParentId(), data), value);
+ }
+ return data.setProperty(getFullQualifiedKey(key, fullQualifiedId, data), value);
+ }
+}
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 9789297d4..ec3aefe2b 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
@@ -9,7 +9,6 @@
*******************************************************************************/
package org.eclipse.tcf.te.runtime.stepper;
-import org.eclipse.tcf.te.runtime.stepper.extensions.manager.StepBindingsExtensionPointManager;
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;
@@ -21,7 +20,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 StepBindingsExtensionPointManager stepBindingsExtManager = new StepBindingsExtensionPointManager();
private final StepperExtensionPointManager stepperExtManager = new StepperExtensionPointManager();
private final StepGroupExtensionPointManager stepGroupExtManager = new StepGroupExtensionPointManager();
@@ -72,13 +70,4 @@ public final class StepperManager {
public StepGroupExtensionPointManager getStepGroupExtManager() {
return stepGroupExtManager;
}
-
- /**
- * Returns the step bindings extension point manager instance.
- *
- * @return The step bindings extension point manager instance.
- */
- public StepBindingsExtensionPointManager getStepBindingsExtManager() {
- return stepBindingsExtManager;
- }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/AbstractStepGroup.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/AbstractStepGroup.java
deleted file mode 100644
index 568eccf59..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/AbstractStepGroup.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * 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.extensions;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
-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;
-
-/**
- * Abstract step group implementation.
- */
-public abstract class AbstractStepGroup extends ExecutableExtension implements IStepGroup {
-
- private ExecutableExtensionProxy<IStepGroupIterator> iteratorProxy = null;
-
- /**
- * Constant to be returned in case the step group contains no steps.
- */
- protected final static IStepGroupable[] NO_STEPS = new IStepGroupable[0];
-
- /**
- * Constructor.
- */
- public AbstractStepGroup() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup#isLocked()
- */
- @Override
- public boolean isLocked() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.ExecutableExtension#doSetInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
- */
- @Override
- public void doSetInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- super.doSetInitializationData(config, propertyName, data);
-
- if (iteratorProxy == null) {
- iteratorProxy = new ExecutableExtensionProxy<IStepGroupIterator>(config) {
- @Override
- protected String getExecutableExtensionAttributeName() {
- return "iterator"; //$NON-NLS-1$
- }
- };
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup#getStepGroupIterator()
- */
- @Override
- public IStepGroupIterator getStepGroupIterator() {
- return iteratorProxy != null ? iteratorProxy.newInstance() : null;
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/StepExecutor.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/StepExecutor.java
index 54916ddcc..590c56e73 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/StepExecutor.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/StepExecutor.java
@@ -1,266 +1,266 @@
-/*******************************************************************************
- * 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.extensions;
-
-import java.util.Date;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Platform;
-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.activator.CoreBundleActivator;
-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.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;
-
-/**
- * Step executor implementation.
- * <p>
- * The step executor is responsible for initiating the execution of a single step. The executor
- * creates and associated the step callback and blocks the execution till the executed step invoked
- * the callback.
- * <p>
- * The step executor is passing any status thrown by the executed step to the parent stepper
- * instance for handling.
- * <p>
- * If the step to execute is of type {@link IExtendedStep}, the step executor is calling
- * {@link IExtendedStep#initializeFrom(IAdaptable, IPropertiesContainer, IFullQualifiedId, IProgressMonitor)} and
- * {@link IExtendedStep#validateExecute(IAdaptable, IPropertiesContainer, IFullQualifiedId, IProgressMonitor)} before calling
- * {@link IStep#execute(IAdaptable, IPropertiesContainer, IFullQualifiedId, IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)}.
- * <p>
- * The methods will be called within the current step executor thread.
- * <p>
- * The stepper implementation can be traced and profiled by setting the debug options:
- * <ul>
- * <li><i>org.eclipse.tcf.te.runtime.stepper/trace/stepping</i></li>
- * <li><i>org.eclipse.tcf.te.runtime.stepper/profile/stepping</i></li>
- * </ul>
- */
-public class StepExecutor implements IStepExecutor {
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepExecutor#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStep, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public final void execute(IStep step, IFullQualifiedId id, final IStepContext context, final IPropertiesContainer data, IProgressMonitor progress) throws CoreException {
- Assert.isNotNull(step);
- Assert.isNotNull(id);
- Assert.isNotNull(context);
- Assert.isNotNull(data);
- Assert.isNotNull(progress);
-
- long startTime = System.currentTimeMillis();
-
- CoreBundleActivator.getTraceHandler().trace("StepExecutor#execute: *** START (" + step.getLabel() + ")", //$NON-NLS-1$ //$NON-NLS-2$
- 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);
-
- int ticksToUse = (step instanceof IExtendedStep) ? ((IExtendedStep)step).getTotalWork(context, data) : IProgressMonitor.UNKNOWN;
- progress = ProgressHelper.getProgressMonitor(progress, ticksToUse);
- ProgressHelper.beginTask(progress, step.getLabel(), ticksToUse);
-
- // Create the handler (and the callback) for the current step
- final Callback callback = new Callback();
-
- // Catch any exception that might occur during execution.
- // Errors are passed through by definition.
- try {
- // Execute the step. Spawn to the dispatch thread if necessary.
- if (step instanceof IExtendedStep) {
- IExtendedStep extendedStep = (IExtendedStep)step;
-
- // IExtendedStep provides protocol for initialization and validation.
- extendedStep.initializeFrom(context, data, id, progress);
-
- // step is initialized -> now validate for execution.
- // If the step if not valid for execution, validateExecute is throwing an exception.
- extendedStep.validateExecute(context, data, id, progress);
- }
-
- step.execute(context, data, id, progress, callback);
-
- // Wait till the step finished, an execution occurred or the
- // user hit cancel on the progress monitor.
- ExecutorsUtil.waitAndExecute(0, callback.getDoneConditionTester(null));
-
- // Check the status of the step
- normalizeStatus(step, id, context, data, callback.getStatus());
- }
- catch (Exception e) {
- CoreBundleActivator.getTraceHandler().trace("StepExecutor#execute: Exception catched: class ='" + e.getClass().getName() + "'" //$NON-NLS-1$ //$NON-NLS-2$
- + ", message = '" + e.getLocalizedMessage() + "'" //$NON-NLS-1$ //$NON-NLS-2$
- + ", cause = " //$NON-NLS-1$
- + (e instanceof CoreException ? ((CoreException)e).getStatus().getException() : e.getCause()),
- 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
-
- // If the exception is a CoreException by itself, just re-throw
- if (e instanceof CoreException) {
- // Check if the message does need normalization
- if (isExceptionMessageFormatted(e.getLocalizedMessage())) {
- throw (CoreException)e;
- }
- // We have to normalize the status message first
- normalizeStatus(step, id, context, data, ((CoreException)e).getStatus());
- } else {
- // all other exceptions are repackaged within a CoreException
- normalizeStatus(step, id, context, data, StatusHelper.getStatus(e));
- }
- }
- finally {
- if (!progress.isCanceled()) {
- progress.done();
- }
-
- // Give the step a chance for cleanup
- if (step instanceof IExtendedStep) {
- ((IExtendedStep)step).cleanup(context, data, id, progress);
- }
-
- long endTime = System.currentTimeMillis();
- CoreBundleActivator.getTraceHandler().trace("StepExecutor#execute: *** DONE (" + step.getLabel() + ")", //$NON-NLS-1$ //$NON-NLS-2$
- 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);
- }
- }
-
- /**
- * Normalize the given status.
- *
- * @param step The step.
- * @param id The fully qualified id.
- * @param context The context.
- * @param data The step data.
- * @param status The status.
- *
- * @throws CoreException - if the operation fails
- */
- private void normalizeStatus(IStep step, IFullQualifiedId id, IStepContext context , IPropertiesContainer data, IStatus status) throws CoreException {
- Assert.isNotNull(context);
- Assert.isNotNull(data);
- Assert.isNotNull(id);
- Assert.isNotNull(step);
-
- if (status == null || status.isOK()) {
- return;
- }
-
- switch (status.getSeverity()) {
- case IStatus.CANCEL:
- throw new OperationCanceledException(status.getMessage());
- default:
- String message = formatMessage(status.getMessage(), status.getSeverity(), step, id, context, data);
- status = new Status(status.getSeverity(), status.getPlugin(), status.getCode(), message != null ? message : status.getMessage(), status.getException());
- throw new CoreException(status);
- }
- }
-
- /**
- * Checks if the given message is already formatted to get displayed to the user.
- *
- * @param message The message. Must not be <code>null</code>.
- * @return <code>True</code> if the message is already formatted to get displayed to the user, <code>false</code> otherwise.
- */
- protected boolean isExceptionMessageFormatted(String message) {
- Assert.isNotNull(message);
- return message.startsWith(Messages.StepExecutor_checkPoint_normalizationNeeded);
- }
-
- /**
- * Format the message depending on the severity.
- *
- * @param message The message to format.
- * @param severity The message severity.
- * @param step The step.
- * @param id The full qualified step id.
- * @param context The target context.
- * @param data The step data.
- *
- * @return Formatted message.
- */
- protected String formatMessage(String message, int severity, IStep step, IFullQualifiedId id, IStepContext context, IPropertiesContainer data) {
- String template = null;
-
- switch (severity) {
- case IStatus.INFO:
- template = Messages.StepExecutor_info_stepFailed;
- break;
- case IStatus.WARNING:
- template = Messages.StepExecutor_warning_stepFailed;
- break;
- case IStatus.ERROR:
- template = Messages.StepExecutor_error_stepFailed;
- break;
- }
-
- // If we cannot determine the formatted message template, just return the message as is
- if (template == null) {
- return message;
- }
-
- // Check the message for additions
- message = checkMessage(message);
-
- // Split the message. The first sentence is shown more prominent on the top,
- // the rest as additional information below the step information.
- String[] splittedMsg = message != null ? message.split("[\t\n\r\f]+", 2) : new String[] { null, null }; //$NON-NLS-1$
-
- // Format the core message
- String formattedMessage = NLS.bind(template,
- new String[] { splittedMsg[0],
- context.getName(),
- context.getInfo(data),
- (step.getLabel() != null && step.getLabel().trim().length() > 0 ? step.getLabel() : step.getId())
- });
-
- // If we have more information available, append them
- if (splittedMsg.length > 1 && splittedMsg[1] != null && !"".equals(splittedMsg[1])) { //$NON-NLS-1$
- formattedMessage += "\n\n" + splittedMsg[1]; //$NON-NLS-1$
- }
-
- // In debug mode, there is even more information to add
- if (Platform.inDebugMode()) {
- formattedMessage += "\n\n" + NLS.bind(Messages.StepExecutor_stepFailed_debugInfo, id.toString()); //$NON-NLS-1$
- }
-
- return formattedMessage;
- }
-
- /**
- * Check for additions to add to the message.
- * <p>
- * <i>Reserved for future use. Currently returns the message unmodified.</i>
- *
- * @param message The message or <code>null</code>.
- * @return The checked message.
- */
- protected String checkMessage(String message) {
- return message;
- }
-}
+/*******************************************************************************
+ * 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.extensions;
+
+import java.util.Date;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Platform;
+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.activator.CoreBundleActivator;
+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.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;
+
+/**
+ * Step executor implementation.
+ * <p>
+ * The step executor is responsible for initiating the execution of a single step. The executor
+ * creates and associated the step callback and blocks the execution till the executed step invoked
+ * the callback.
+ * <p>
+ * The step executor is passing any status thrown by the executed step to the parent stepper
+ * instance for handling.
+ * <p>
+ * If the step to execute is of type {@link IExtendedStep}, the step executor is calling
+ * {@link IExtendedStep#initializeFrom(IAdaptable, IPropertiesContainer, IFullQualifiedId, IProgressMonitor)} and
+ * {@link IExtendedStep#validateExecute(IAdaptable, IPropertiesContainer, IFullQualifiedId, IProgressMonitor)} before calling
+ * {@link IStep#execute(IAdaptable, IPropertiesContainer, IFullQualifiedId, IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)}.
+ * <p>
+ * The methods will be called within the current step executor thread.
+ * <p>
+ * The stepper implementation can be traced and profiled by setting the debug options:
+ * <ul>
+ * <li><i>org.eclipse.tcf.te.runtime.stepper/trace/stepping</i></li>
+ * <li><i>org.eclipse.tcf.te.runtime.stepper/profile/stepping</i></li>
+ * </ul>
+ */
+public class StepExecutor implements IStepExecutor {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepExecutor#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStep, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public final void execute(IStep step, IFullQualifiedId id, final IStepContext context, final IPropertiesContainer data, IProgressMonitor progress) throws CoreException {
+ Assert.isNotNull(step);
+ Assert.isNotNull(id);
+ // Assert.isNotNull(context);
+ Assert.isNotNull(data);
+ Assert.isNotNull(progress);
+
+ long startTime = System.currentTimeMillis();
+
+ CoreBundleActivator.getTraceHandler().trace("StepExecutor#execute: *** START (" + step.getLabel() + ")", //$NON-NLS-1$ //$NON-NLS-2$
+ 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);
+
+ int ticksToUse = (step instanceof IExtendedStep) ? ((IExtendedStep)step).getTotalWork(context, data) : IProgressMonitor.UNKNOWN;
+ progress = ProgressHelper.getProgressMonitor(progress, ticksToUse);
+ ProgressHelper.beginTask(progress, step.getLabel(), ticksToUse);
+
+ // Create the handler (and the callback) for the current step
+ final Callback callback = new Callback();
+
+ // Catch any exception that might occur during execution.
+ // Errors are passed through by definition.
+ try {
+ // Execute the step. Spawn to the dispatch thread if necessary.
+ if (step instanceof IExtendedStep) {
+ IExtendedStep extendedStep = (IExtendedStep)step;
+
+ // IExtendedStep provides protocol for initialization and validation.
+ extendedStep.initializeFrom(context, data, id, progress);
+
+ // step is initialized -> now validate for execution.
+ // If the step if not valid for execution, validateExecute is throwing an exception.
+ extendedStep.validateExecute(context, data, id, progress);
+ }
+
+ step.execute(context, data, id, progress, callback);
+
+ // Wait till the step finished, an execution occurred or the
+ // user hit cancel on the progress monitor.
+ ExecutorsUtil.waitAndExecute(0, callback.getDoneConditionTester(null));
+
+ // Check the status of the step
+ normalizeStatus(step, id, context, data, callback.getStatus());
+ }
+ catch (Exception e) {
+ CoreBundleActivator.getTraceHandler().trace("StepExecutor#execute: Exception catched: class ='" + e.getClass().getName() + "'" //$NON-NLS-1$ //$NON-NLS-2$
+ + ", message = '" + e.getLocalizedMessage() + "'" //$NON-NLS-1$ //$NON-NLS-2$
+ + ", cause = " //$NON-NLS-1$
+ + (e instanceof CoreException ? ((CoreException)e).getStatus().getException() : e.getCause()),
+ 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
+
+ // If the exception is a CoreException by itself, just re-throw
+ if (e instanceof CoreException) {
+ // Check if the message does need normalization
+ if (isExceptionMessageFormatted(e.getLocalizedMessage())) {
+ throw (CoreException)e;
+ }
+ // We have to normalize the status message first
+ normalizeStatus(step, id, context, data, ((CoreException)e).getStatus());
+ } else {
+ // all other exceptions are repackaged within a CoreException
+ normalizeStatus(step, id, context, data, StatusHelper.getStatus(e));
+ }
+ }
+ finally {
+ if (!progress.isCanceled()) {
+ progress.done();
+ }
+
+ // Give the step a chance for cleanup
+ if (step instanceof IExtendedStep) {
+ ((IExtendedStep)step).cleanup(context, data, id, progress);
+ }
+
+ long endTime = System.currentTimeMillis();
+ CoreBundleActivator.getTraceHandler().trace("StepExecutor#execute: *** DONE (" + step.getLabel() + ")", //$NON-NLS-1$ //$NON-NLS-2$
+ 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);
+ }
+ }
+
+ /**
+ * Normalize the given status.
+ *
+ * @param step The step.
+ * @param id The fully qualified id.
+ * @param context The context.
+ * @param data The step data.
+ * @param status The status.
+ *
+ * @throws CoreException - if the operation fails
+ */
+ private void normalizeStatus(IStep step, IFullQualifiedId id, IStepContext context , IPropertiesContainer data, IStatus status) throws CoreException {
+ Assert.isNotNull(context);
+ Assert.isNotNull(data);
+ Assert.isNotNull(id);
+ Assert.isNotNull(step);
+
+ if (status == null || status.isOK()) {
+ return;
+ }
+
+ switch (status.getSeverity()) {
+ case IStatus.CANCEL:
+ throw new OperationCanceledException(status.getMessage());
+ default:
+ String message = formatMessage(status.getMessage(), status.getSeverity(), step, id, context, data);
+ status = new Status(status.getSeverity(), status.getPlugin(), status.getCode(), message != null ? message : status.getMessage(), status.getException());
+ throw new CoreException(status);
+ }
+ }
+
+ /**
+ * Checks if the given message is already formatted to get displayed to the user.
+ *
+ * @param message The message. Must not be <code>null</code>.
+ * @return <code>True</code> if the message is already formatted to get displayed to the user, <code>false</code> otherwise.
+ */
+ protected boolean isExceptionMessageFormatted(String message) {
+ Assert.isNotNull(message);
+ return message.startsWith(Messages.StepExecutor_checkPoint_normalizationNeeded);
+ }
+
+ /**
+ * Format the message depending on the severity.
+ *
+ * @param message The message to format.
+ * @param severity The message severity.
+ * @param step The step.
+ * @param id The full qualified step id.
+ * @param context The target context.
+ * @param data The step data.
+ *
+ * @return Formatted message.
+ */
+ protected String formatMessage(String message, int severity, IStep step, IFullQualifiedId id, IStepContext context, IPropertiesContainer data) {
+ String template = null;
+
+ switch (severity) {
+ case IStatus.INFO:
+ template = Messages.StepExecutor_info_stepFailed;
+ break;
+ case IStatus.WARNING:
+ template = Messages.StepExecutor_warning_stepFailed;
+ break;
+ case IStatus.ERROR:
+ template = Messages.StepExecutor_error_stepFailed;
+ break;
+ }
+
+ // If we cannot determine the formatted message template, just return the message as is
+ if (template == null) {
+ return message;
+ }
+
+ // Check the message for additions
+ message = checkMessage(message);
+
+ // Split the message. The first sentence is shown more prominent on the top,
+ // the rest as additional information below the step information.
+ String[] splittedMsg = message != null ? message.split("[\t\n\r\f]+", 2) : new String[] { null, null }; //$NON-NLS-1$
+
+ // Format the core message
+ String formattedMessage = NLS.bind(template,
+ new String[] { splittedMsg[0],
+ context.getName(),
+ context.getInfo(data),
+ (step.getLabel() != null && step.getLabel().trim().length() > 0 ? step.getLabel() : step.getId())
+ });
+
+ // If we have more information available, append them
+ if (splittedMsg.length > 1 && splittedMsg[1] != null && !"".equals(splittedMsg[1])) { //$NON-NLS-1$
+ formattedMessage += "\n\n" + splittedMsg[1]; //$NON-NLS-1$
+ }
+
+ // In debug mode, there is even more information to add
+ if (Platform.inDebugMode()) {
+ formattedMessage += "\n\n" + NLS.bind(Messages.StepExecutor_stepFailed_debugInfo, id.toString()); //$NON-NLS-1$
+ }
+
+ return formattedMessage;
+ }
+
+ /**
+ * Check for additions to add to the message.
+ * <p>
+ * <i>Reserved for future use. Currently returns the message unmodified.</i>
+ *
+ * @param message The message or <code>null</code>.
+ * @return The checked message.
+ */
+ protected String checkMessage(String message) {
+ return message;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/StepGroup.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/StepGroup.java
index f9eda4695..bc27d5458 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/StepGroup.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/StepGroup.java
@@ -1,817 +1,869 @@
-/*******************************************************************************
- * 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.extensions;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
-import org.eclipse.tcf.te.runtime.stepper.StepperManager;
-import org.eclipse.tcf.te.runtime.stepper.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep;
-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.tracing.ITraceIds;
-import org.eclipse.tcf.te.runtime.stepper.nls.Messages;
-
-/**
- * A default step group implementation.
- */
-public class StepGroup extends AbstractStepGroup {
-
- private boolean locked;
- private String baseOn;
-
- private final List<ReferenceSubElement> references = new ArrayList<ReferenceSubElement>();
-
- /**
- * Step group reference sub element.
- */
- protected final static class ReferenceSubElement implements org.eclipse.core.runtime.IExecutableExtension {
- private String id;
- private String secondaryId;
- private String insertBefore;
- private String insertAfter;
- private String overwrite;
- private boolean removable;
- private boolean hidden;
- private boolean disable;
- private boolean singleton;
- private final List<String> dependencies = new ArrayList<String>();
-
-
- /**
- * Returns the id of the referenced step or step group.
- *
- * @return The id of the referenced step or step group.
- */
- public String getId() {
- return id;
- }
-
- /**
- * Returns the secondary id of the referenced step or step group.
- *
- * @return The secondary id or <code>null</code>.
- */
- public String getSecondaryId() {
- return secondaryId;
- }
-
- /**
- * Sets the secondary id of the referenced step or step group.
- *
- * @return The secondary id or <code>null</code>.
- */
- public void setSecondardId(String secondaryId) {
- this.secondaryId = secondaryId;
- }
-
- /**
- * Returns the id of the step or step group the referenced
- * step or group shall be inserted before.
- *
- * @return The id or <code>null</code>.
- */
- public String getInsertBefore() {
- return insertBefore;
- }
-
- /**
- * Returns the id of the step or step group the referenced
- * step or group shall be inserted after.
- *
- * @return The id or <code>null</code>.
- */
- public String getInsertAfter() {
- return insertAfter;
- }
-
- /**
- * Returns the id of the step or step group the referenced
- * step or group do overwrite.
- *
- * @return The id or <code>null</code>.
- */
- public String getOverwrite() {
- return overwrite;
- }
-
- /**
- * Returns if or if not the referenced step or step group
- * can be removed by the user from the group.
- *
- * @return <code>True</code> if removable, <code>false</code> otherwise.
- */
- public boolean isRemovable() {
- return removable;
- }
-
- /**
- * Returns if or if not the referenced step or step group
- * is hidden.
- *
- * @return <code>True</code> if hidden, <code>false</code> otherwise.
- */
- public boolean isHidden() {
- return hidden;
- }
-
- /**
- * Returns if or if not to disable the referenced step or step group.
- *
- * @return <code>True</code> if to disable, <code>false</code> otherwise.
- */
- public boolean isDisable() {
- return disable;
- }
-
- /**
- * Returns if or if not the referenced step or step group is a singleton.
- *
- * @return <code>True</code> if singleton, <code>false</code> otherwise.
- */
- public boolean isSingleton() {
- return singleton;
- }
-
- /**
- * Returns the list of dependencies.
- * <p>
- * The step or step group id might be fully qualified using the form
- * <code>&quot;primaryId##secondaryId</code>. The <code>secondaryId</code> is optional.
- *
- * @return The list of dependencies or an empty list.
- */
- public String[] getDependencies() {
- return dependencies.toArray(new String[dependencies.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
- */
- @Override
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- if (config == null) {
- return;
- }
-
- String value = config.getAttribute("id"); //$NON-NLS-1$
- if (value != null && value.trim().length() > 0) {
- this.id = value.trim();
- }
-
- value = config.getAttribute("secondaryId"); //$NON-NLS-1$
- setSecondardId(value != null && value.trim().length() > 0 ? value.trim() : null);
-
- value = config.getAttribute("insertBefore"); //$NON-NLS-1$
- if (value != null && value.trim().length() > 0) {
- this.insertBefore = value.trim();
- }
-
- value = config.getAttribute("insertAfter"); //$NON-NLS-1$
- if (value != null && value.trim().length() > 0) {
- this.insertAfter = value.trim();
- }
-
- value = config.getAttribute("overwrite"); //$NON-NLS-1$
- if (value != null && value.trim().length() > 0) {
- this.overwrite = value.trim();
- }
-
- value = config.getAttribute("removable"); //$NON-NLS-1$
- if (value != null && value.trim().length() > 0) {
- this.removable = Boolean.parseBoolean(value.trim());
- }
-
- value = config.getAttribute("hidden"); //$NON-NLS-1$
- if (value != null && value.trim().length() > 0) {
- this.hidden = Boolean.parseBoolean(value.trim());
- }
-
- value = config.getAttribute("disable"); //$NON-NLS-1$
- if (value != null && value.trim().length() > 0) {
- this.disable = Boolean.parseBoolean(value.trim());
- }
-
- value = config.getAttribute("singleton"); //$NON-NLS-1$
- if (value != null && value.trim().length() > 0) {
- this.singleton = Boolean.parseBoolean(value.trim());
- }
-
- // Read in the list of dependencies if specified.
- dependencies.clear();
- IConfigurationElement[] requires = config.getChildren("requires"); //$NON-NLS-1$
- for (IConfigurationElement require : requires) {
- value = require.getAttribute("id"); //$NON-NLS-1$
- if (value == null || value.trim().length() == 0) {
- throw new CoreException(new Status(IStatus.ERROR,
- CoreBundleActivator.getUniqueIdentifier(),
- 0,
- NLS.bind(Messages.AbstractStep_error_missingRequiredAttribute,
- "dependency id (requires)", //$NON-NLS-1$
- config.getName()),
- null));
- }
- if (!dependencies.contains(value.trim())) {
- dependencies.add(value.trim());
- }
- }
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (getId() != null && obj instanceof ReferenceSubElement) {
- boolean secondaryIdEquals = false;
- if (getSecondaryId() == null) {
- secondaryIdEquals = ((ReferenceSubElement)obj).getSecondaryId() == null;
- }
- else {
- secondaryIdEquals = getSecondaryId().equals(((ReferenceSubElement)obj).getSecondaryId());
- }
-
- return getId().equals(((ReferenceSubElement)obj).getId()) && secondaryIdEquals;
- }
- return super.equals(obj);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return getId() != null ? getId().hashCode() + (getSecondaryId() != null ? getSecondaryId().hashCode() : 0) : super.hashCode();
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- StringBuffer buffer = new StringBuffer(getClass().getSimpleName());
- buffer.append(": "); //$NON-NLS-1$
- buffer.append("id = " + getId()); //$NON-NLS-1$
- buffer.append(", secondaryId = " + getSecondaryId()); //$NON-NLS-1$
- buffer.append(", insertBefore = " + getInsertBefore()); //$NON-NLS-1$
- buffer.append(", insertAfter = " + getInsertAfter()); //$NON-NLS-1$
- buffer.append(", overwrite = " + getOverwrite()); //$NON-NLS-1$
- buffer.append(", removable = " + isRemovable()); //$NON-NLS-1$
- buffer.append(", hidden = " + isHidden()); //$NON-NLS-1$
- buffer.append(", disable = " + isDisable()); //$NON-NLS-1$
- buffer.append(", singleton = " + isSingleton()); //$NON-NLS-1$
- return buffer.toString();
- }
- }
-
- /**
- * Constructor.
- */
- public StepGroup() {
- super();
- locked = false;
- baseOn = null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.AbstractContextStepGroup#isLocked()
- */
- @Override
- public boolean isLocked() {
- return locked;
- }
-
- /**
- * Returns the id of the step group this step group is
- * initially based on.
- *
- * @return The id or <code>null</code>.
- */
- protected String getBaseOn() {
- return baseOn;
- }
-
- /**
- * Returns the references.
- */
- protected List<ReferenceSubElement> getReferences() {
- return references;
- }
-
- /**
- * Check for duplicates of the referenced step or step group. The check will fail if multiple
- * occurrence of a step or step group are found and the step or step group is supposed to be a
- * singleton.
- *
- * @param steps The list of steps. Must not be <code>null</code>.
- * @param reference The reference. Must not be <code>null</code>.
- *
- * @throws CoreException If multiple occurrences of singleton references are found.
- */
- protected void checkForDuplicates(List<IStepGroupable> steps, ReferenceSubElement reference) throws CoreException {
- Assert.isNotNull(steps);
- Assert.isNotNull(reference);
-
- // If the reference overwrites another reference, it is not a duplicate
- String overwrite = reference.getOverwrite();
- if (overwrite != null && overwrite.length() > 0) {
- return;
- }
-
- boolean checkFailed = false;
-
- for (IStepGroupable step : steps) {
- if (step.getExtension().getId().equals(reference.getId())) {
- // We've found an existing groupable with the reference id.
- // If either the groupable, the reference or the extension is
- // marked singleton, than this is an failure.
- checkFailed = step.isSingleton() || reference.isSingleton()
- || (step.getExtension() instanceof IExtendedStep
- && ((IExtendedStep)step.getExtension()).isSingleton());
- if (checkFailed) {
- break;
- }
- }
- }
-
- if (checkFailed) {
- throw new CoreException(new Status(IStatus.ERROR,
- CoreBundleActivator.getUniqueIdentifier(),
- MessageFormat.format(Messages.StepGroup_error_multipleSingletonOccurrences,
- NLS.bind(Messages.StepGroup_error_stepGroup, getLabel()),
- NLS.bind(Messages.StepGroup_error_referencedStepOrGroup, reference.getId()))
- ));
- }
- }
-
- /**
- * Replace all references to a given step or step group with another one.
- *
- * @param steps The list of steps. Must not be <code>null</code>.
- * @param oldId The id of the step or step group to replace. Must not be <code>null</code>.
- * @param replacement The replacement. Must not be <code>null</code>.
- * @param reference The reference sub element. Must not be <code>null</code>.
- *
- * @return The list of affected groupable's or an empty list.
- */
- protected List<IStepGroupable> onOverwrite(List<IStepGroupable> steps, String oldId, IExecutableExtension replacement, ReferenceSubElement reference) {
- Assert.isNotNull(steps);
- Assert.isNotNull(oldId);
- Assert.isNotNull(replacement);
- Assert.isNotNull(reference);
-
- List<IStepGroupable> affected = new ArrayList<IStepGroupable>();
-
- // Isolate primary and secondary id
- String primaryId = oldId;
- String secondaryId = null;
-
- String[] splitted = oldId.split("##", 2); //$NON-NLS-1$
- if (splitted.length == 2) {
- primaryId = splitted[0];
- secondaryId = splitted[1];
- }
-
- for (IStepGroupable step : steps) {
- // A step is clearly affected if the primary id and the secondary
- // id (if any) matches the overwritten id
- if (step.getExtension().getId().equals(primaryId)
- && (secondaryId == null || secondaryId.equals(step.getSecondaryId()))) {
- if (step instanceof StepGroupable) {
- StepGroupable groupable = ((StepGroupable)step);
- // Update the grouped extension
- groupable.setExtension(replacement);
- // Update the groupable secondary id
- groupable.setSecondaryId(reference.getSecondaryId());
- // Add the groupable to the list of affected steps
- affected.add(step);
- }
- }
-
- // A step is affected as well if the step depends on the overwritten step
- // In this case we have to update the dependencies.
- List<String> dependencies = new ArrayList<String>(Arrays.asList(step.getDependencies()));
- if (dependencies.contains(oldId)) {
- String fullId = replacement.getId() + (reference.getSecondaryId() != null ? "##" + reference.getSecondaryId() : ""); //$NON-NLS-1$ //$NON-NLS-2$
- // We have to replace the dependency at the exact position within the list
- dependencies.set(dependencies.indexOf(oldId), fullId);
- if (step instanceof StepGroupable) {
- ((StepGroupable)step).setDependencies(dependencies.toArray(new String[dependencies.size()]));
- }
- }
- }
-
- return affected;
- }
-
- /**
- * Insert the step before the specified step or step group. If no step or
- * step group with the given id exist, the step is added to the end.
- *
- * @param steps The list of steps. Must not be <code>null</code>.
- * @param id The id of the step or step group where to insert the new step before. Must not be <code>null</code>.
- * @param newStep The step to add. Must not be <code>null</code>.
- * @param reference The reference sub element. Must not be <code>null</code>.
- *
- * @return The list of affected groupable's or an empty list.
- */
- protected List<IStepGroupable> onInsertBefore(List<IStepGroupable> steps, String id, IExecutableExtension newStep, ReferenceSubElement reference) {
- Assert.isNotNull(steps);
- Assert.isNotNull(id);
- Assert.isNotNull(newStep);
- Assert.isNotNull(reference);
-
- List<IStepGroupable> affected = new ArrayList<IStepGroupable>();
-
- // Isolate primary and secondary id
- String primaryId = id;
- String secondaryId = null;
-
- String[] splitted = id.split("##", 2); //$NON-NLS-1$
- if (splitted.length == 2) {
- primaryId = splitted[0];
- secondaryId = splitted[1];
- }
-
- // Always loop over all steps in case the anchor step is available
- // multiple times. In such case, the new step is inserted at all
- // occurrences.
- for (int i = 0; i < steps.size(); i++) {
- IStepGroupable step = steps.get(i);
- if (!step.getExtension().getId().equals(primaryId)) {
- continue;
- }
- if (secondaryId != null && !secondaryId.equals(step.getSecondaryId())) {
- continue;
- }
-
- // Create a new groupable object for inserting
- IStepGroupable groupable = new StepGroupable(newStep, reference.getSecondaryId());
- // Insert the new step at the current position
- steps.add(i, groupable);
- // And increase the counter --> Otherwise we would see the
- // same step we want to insert before again!
- i++;
- // Add the new groupable to the list of affected steps
- affected.add(groupable);
- }
-
- // If the step could not be added, add to the end of the list
- if (affected.isEmpty()) {
- IStepGroupable groupable = new StepGroupable(newStep, reference.getSecondaryId());
- steps.add(groupable);
- }
-
- return affected;
- }
-
- /**
- * Insert the step after the specified step or step group. If no step or
- * step group with the given id exist, the step is added to the end.
- *
- * @param steps The list of steps. Must not be <code>null</code>.
- * @param id The id of the step or step group where to insert the new step after. Must not be <code>null</code>.
- * @param newStep The step to add. Must not be <code>null</code>.
- * @param reference The reference sub element. Must not be <code>null</code>.
- *
- * @return The list of affected groupable's or an empty list.
- */
- protected List<IStepGroupable> onInsertAfter(List<IStepGroupable> steps, String id, IExecutableExtension newStep, ReferenceSubElement reference) {
- Assert.isNotNull(steps);
- Assert.isNotNull(id);
- Assert.isNotNull(newStep);
- Assert.isNotNull(reference);
-
- List<IStepGroupable> affected = new ArrayList<IStepGroupable>();
-
- // Isolate primary and secondary id
- String primaryId = id;
- String secondaryId = null;
-
- String[] splitted = id.split("##", 2); //$NON-NLS-1$
- if (splitted.length == 2) {
- primaryId = splitted[0];
- secondaryId = splitted[1];
- }
-
- // Always loop over all steps in case the anchor step is available
- // multiple times. In such case, the new step is inserted at all
- // occurrences.
- for (int i = 0; i < steps.size(); i++) {
- IStepGroupable step = steps.get(i);
- if (!step.getExtension().getId().equals(primaryId)) {
- continue;
- }
- if (secondaryId != null && !secondaryId.equals(step.getSecondaryId())) {
- continue;
- }
-
- // Create a new groupable object for inserting
- IStepGroupable groupable = new StepGroupable(newStep, reference.getSecondaryId());
- // Insert the new groupable after the current step or at the end (if i + 1 == steps.size())
- steps.add(i + 1, groupable);
- // Add the new groupable to the list of affected steps
- affected.add(groupable);
- }
-
- // If the step could not be added, add to the end of the list
- if (affected.isEmpty()) {
- IStepGroupable groupable = new StepGroupable(newStep, reference.getSecondaryId());
- steps.add(groupable);
- }
-
- return affected;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup#getSteps(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext[])
- */
- @Override
- public IStepGroupable[] getSteps(IStepContext[] contexts) throws CoreException {
- Assert.isNotNull(contexts);
-
- // The list of resolved steps for the specified type and mode
- List<IStepGroupable> steps = new ArrayList<IStepGroupable>();
-
- // If this step group is based on another step group, we have to get the resolved
- // steps from there first.
- if (getBaseOn() != null) {
- IStepGroup baseStepGroup = getStepGroup(getBaseOn());
- // If the base step group cannot be found, that's an error. We cannot continue
- // without the base group.
- if (baseStepGroup == null) {
- throw new CoreException(new Status(IStatus.ERROR,
- CoreBundleActivator.getUniqueIdentifier(),
- MessageFormat.format(Messages.StepGroup_error_missingBaseStepGroup,
- NLS.bind(Messages.StepGroup_error_stepGroup, getLabel()),
- NLS.bind(Messages.StepGroup_error_referencedBaseGroup, getBaseOn()))
- ));
- }
-
- // Add all the steps from the base step group now to the list
- steps.addAll(Arrays.asList(baseStepGroup.getSteps(contexts)));
- }
-
- // Now process the references and modify the steps list accordingly
- for (ReferenceSubElement reference : getReferences()) {
- // Get the step or step group for the referenced id. Try the steps first.
- IExecutableExtension candidate = getStep(reference.getId());
- if (candidate == null) {
- candidate = getStepGroup(reference.getId());
- }
-
- // If the candidate is null here, that's an error as a referenced step is missing.
- if (candidate == null) {
- throw new CoreException(new Status(IStatus.ERROR,
- CoreBundleActivator.getUniqueIdentifier(),
- MessageFormat.format(Messages.StepGroup_error_missingReferencedStep,
- NLS.bind(Messages.StepGroup_error_stepGroup, getLabel()),
- NLS.bind(Messages.StepGroup_error_referencedStepOrGroup, reference.getId()))
- ));
- }
-
- // Check if the step is valid for the current contexts.
- if (candidate instanceof IStep) {
- boolean valid = isValidStep(candidate.getId(), contexts);
-
- if (!valid) {
- CoreBundleActivator.getTraceHandler().trace(
- "StepGroup#getSteps: SKIPPED step = '" + candidate.getLabel() + "'." //$NON-NLS-1$ //$NON-NLS-2$
- + " Not valid for contexts '" + Arrays.deepToString(contexts), //$NON-NLS-1$
- 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
- continue;
- }
- }
-
- // Check for duplicates of singleton references.
- checkForDuplicates(steps, reference);
-
- // Check for the steps own dependencies to be valid for the current type id and mode
- if (candidate instanceof IStep) {
- checkForDependenciesValid((IStep)candidate, contexts);
- }
-
- // Will contain the list of affected groupables from the whole list
- List<IStepGroupable> affectedGroupables = new ArrayList<IStepGroupable>();
-
- // Check first for overwriting groupables
- String overwrite = reference.getOverwrite();
- if (overwrite != null && overwrite.length() > 0) {
- affectedGroupables.addAll(onOverwrite(steps, overwrite, candidate, reference));
- } else {
- // overwrite is not set -> process insertBefore or insertAfter
- String insertBefore = reference.getInsertBefore();
- String insertAfter = reference.getInsertAfter();
-
- // If neither one is specified, the step or step group will be to the end of the list
- if ((insertBefore == null || insertBefore.length() == 0)
- && (insertAfter == null || insertAfter.length() == 0)) {
- IStepGroupable groupable = new StepGroupable(candidate, reference.getSecondaryId());
- steps.add(groupable);
- affectedGroupables.add(groupable);
- } else {
- // insertBefore comes first
- if (insertBefore != null && insertBefore.length() > 0) {
- affectedGroupables.addAll(onInsertBefore(steps, insertBefore, candidate, reference));
- } else {
- affectedGroupables.addAll(onInsertAfter(steps, insertAfter, candidate, reference));
- }
- }
- }
-
- // Process the groupable attributes on all affected groupables
- for (IStepGroupable step : affectedGroupables) {
- if (!(step instanceof StepGroupable)) {
- continue;
- }
-
- StepGroupable groupable = (StepGroupable)step;
- groupable.setDependencies(reference.getDependencies());
-
- if (!reference.isRemovable() && groupable.isRemovable()) {
- groupable.setRemovable(reference.isRemovable());
- }
- if (reference.isHidden() && !groupable.isHidden()) {
- groupable.setHidden(reference.isHidden());
- }
- if (reference.isDisable() && !groupable.isDisabled()) {
- groupable.setDisabled(reference.isDisable());
- }
- if (reference.isSingleton() && !groupable.isSingleton()) {
- groupable.setSingleton(reference.isSingleton());
- }
- }
- }
-
- return !steps.isEmpty() ? steps.toArray(new IStepGroupable[steps.size()]) : NO_STEPS;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.ExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
- */
- @Override
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- references.clear();
- super.setInitializationData(config, propertyName, data);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.extensions.AbstractStepGroup#doSetInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
- */
- @Override
- public void doSetInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- super.doSetInitializationData(config, propertyName, data);
-
- if (!locked) {
- String lockedAttribute = config.getAttribute("locked"); //$NON-NLS-1$
- if (lockedAttribute != null) {
- this.locked = Boolean.parseBoolean(lockedAttribute);
- }
- }
-
- if (baseOn == null || baseOn.trim().length() == 0) {
- String baseOnAttribute = config.getAttribute("baseOn"); //$NON-NLS-1$
- if (baseOnAttribute != null && baseOnAttribute.trim().length() > 0) {
- this.baseOn = baseOnAttribute.trim();
- }
- }
-
- Map<String, Integer> occurrences = new HashMap<String, Integer>();
- IConfigurationElement[] childElements = config.getChildren("references"); //$NON-NLS-1$
- for (IConfigurationElement childElement : childElements) {
- IConfigurationElement[] references = childElement.getChildren("reference"); //$NON-NLS-1$
- for (IConfigurationElement reference : references) {
- ReferenceSubElement candidate = new ReferenceSubElement();
- candidate.setInitializationData(reference, reference.getName(), null);
- // If multiple references to the same step or step group exist, check
- // for the secondaryId
- if (occurrences.containsKey(candidate.getId())) {
- // Occurrences are counted up always
- int number = occurrences.get(candidate.getId()).intValue() + 1;
- occurrences.put(candidate.getId(), Integer.valueOf(number));
-
- if (candidate.getSecondaryId() == null) {
- // secondaryId not explicitly set -> auto set
- candidate.setSecondardId(Integer.toString(number));
- }
- } else {
- // remember the occurrence of the reference
- occurrences.put(candidate.getId(), Integer.valueOf(1));
- }
-
- // References are not sorted out here. That's the task of the resolver.
- this.references.add(candidate);
- }
- }
- }
-
-
- /**
- * Checks is all dependencies of the given step are available
- * and valid for the given type id and mode.
- *
- * @param step The step. Must not be <code>null</code>.
- * @param contexts The array of context objects. Must not be <code>null</code>.
- *
- * @throws CoreException If a required step or step group is not available or not valid.
- */
- protected void checkForDependenciesValid(IStep step, IStepContext[] contexts) throws CoreException {
- Assert.isNotNull(step);
- Assert.isNotNull(contexts);
-
- String[] dependencies = step.getDependencies();
- for (String dependency : dependencies) {
- // Get the step or step group. Try the steps first.
- IExecutableExtension candidate = getStep(dependency);
- if (candidate == null) {
- candidate = getStepGroup(dependency);
- }
-
- // If the candidate is null here, that's an error as a required step or step group is missing.
- if (candidate == null) {
- throw new CoreException(new Status(IStatus.ERROR,
- CoreBundleActivator.getUniqueIdentifier(),
- MessageFormat.format(Messages.StepGroup_error_missingRequiredStep,
- NLS.bind(Messages.StepGroup_error_step, step.getLabel()),
- NLS.bind(Messages.StepGroup_error_requiredStepOrGroup, dependency))
- ));
- }
-
- // If the candidate a step, validate the step
- if (candidate instanceof IStep) {
- IStep candidateStep = (IStep)candidate;
- boolean valid = isValidStep(candidateStep.getId(), contexts);
- if (!valid) {
- throw new CoreException(new Status(IStatus.ERROR,
- CoreBundleActivator.getUniqueIdentifier(),
- MessageFormat.format(Messages.StepGroup_error_invalidRequiredStep,
- NLS.bind(Messages.StepGroup_error_step, step.getLabel()),
- NLS.bind(Messages.StepGroup_error_requiredStep, dependency))
- ));
- }
-
- // Step is valid -> recursively check required steps.
- checkForDependenciesValid(candidateStep, contexts);
- }
- }
- }
-
- /**
- * Convenience method returning a unique instance of the step
- * identified by the given id.
- *
- * @param id The step id. Must not be <code>null</code>.
- * @return The step instance or <code>null</code>.
- */
- protected IStep getStep(String id) {
- Assert.isNotNull(id);
- return StepperManager.getInstance().getStepExtManager().getStep(id, true);
- }
-
- /**
- * Convenience method returning a unique instance of the step
- * group identified by the given id.
- *
- * @param id The step id. Must not be <code>null</code>.
- * @return The step group instance or <code>null</code>.
- */
- protected IStepGroup getStepGroup(String id) {
- Assert.isNotNull(id);
- return StepperManager.getInstance().getStepGroupExtManager().getStepGroup(id, true);
- }
-
- /**
- * Returns if or if not the step identified by the given id is valid for
- * the given contexts.
- *
- * @param id The step id. Must not be <code>null</code>.
- * @param contexts The array of context objects or <code>null</code>.
- *
- * @return <code>True</code> if the step is valid, <code>false</code> otherwise.
- */
- protected boolean isValidStep(String id, IStepContext[] contexts) {
- Assert.isNotNull(id);
- return StepperManager.getInstance().getStepBindingsExtManager().isStepEnabled(id, contexts);
- }
-}
+/*******************************************************************************
+ * 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.extensions;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.expressions.ExpressionConverter;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
+import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
+import org.eclipse.tcf.te.runtime.stepper.StepperManager;
+import org.eclipse.tcf.te.runtime.stepper.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep;
+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.IStepGroupIterator;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroupable;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.tracing.ITraceIds;
+import org.eclipse.tcf.te.runtime.stepper.nls.Messages;
+
+/**
+ * A default step group implementation.
+ */
+public class StepGroup extends ExecutableExtension implements IStepGroup {
+
+ private boolean locked;
+ private String baseOn;
+
+ private final List<ReferenceSubElement> references = new ArrayList<ReferenceSubElement>();
+
+ private ExecutableExtensionProxy<IStepGroupIterator> iteratorProxy = null;
+
+ /**
+ * Constant to be returned in case the step group contains no steps.
+ */
+ protected final static IStepGroupable[] NO_STEPS = new IStepGroupable[0];
+
+ /**
+ * Step group reference sub element.
+ */
+ protected final static class ReferenceSubElement implements org.eclipse.core.runtime.IExecutableExtension {
+ private String id;
+ private String secondaryId;
+ private String insertBefore;
+ private String insertAfter;
+ private String overwrite;
+ private boolean removable;
+ private boolean hidden;
+ private boolean disable;
+ private boolean singleton;
+ private final List<String> dependencies = new ArrayList<String>();
+ private Expression expression;
+
+ /**
+ * Returns the id of the referenced step or step group.
+ *
+ * @return The id of the referenced step or step group.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Returns the secondary id of the referenced step or step group.
+ *
+ * @return The secondary id or <code>null</code>.
+ */
+ public String getSecondaryId() {
+ return secondaryId;
+ }
+
+ /**
+ * Sets the secondary id of the referenced step or step group.
+ *
+ * @return The secondary id or <code>null</code>.
+ */
+ public void setSecondardId(String secondaryId) {
+ this.secondaryId = secondaryId;
+ }
+
+ /**
+ * Returns the id of the step or step group the referenced
+ * step or group shall be inserted before.
+ *
+ * @return The id or <code>null</code>.
+ */
+ public String getInsertBefore() {
+ return insertBefore;
+ }
+
+ /**
+ * Returns the id of the step or step group the referenced
+ * step or group shall be inserted after.
+ *
+ * @return The id or <code>null</code>.
+ */
+ public String getInsertAfter() {
+ return insertAfter;
+ }
+
+ /**
+ * Returns the id of the step or step group the referenced
+ * step or group do overwrite.
+ *
+ * @return The id or <code>null</code>.
+ */
+ public String getOverwrite() {
+ return overwrite;
+ }
+
+ /**
+ * Returns if or if not the referenced step or step group
+ * can be removed by the user from the group.
+ *
+ * @return <code>True</code> if removable, <code>false</code> otherwise.
+ */
+ public boolean isRemovable() {
+ return removable;
+ }
+
+ /**
+ * Returns if or if not the referenced step or step group
+ * is hidden.
+ *
+ * @return <code>True</code> if hidden, <code>false</code> otherwise.
+ */
+ public boolean isHidden() {
+ return hidden;
+ }
+
+ /**
+ * Returns if or if not to disable the referenced step or step group.
+ *
+ * @return <code>True</code> if to disable, <code>false</code> otherwise.
+ */
+ public boolean isDisable() {
+ return disable;
+ }
+
+ /**
+ * Returns if or if not the referenced step or step group is a singleton.
+ *
+ * @return <code>True</code> if singleton, <code>false</code> otherwise.
+ */
+ public boolean isSingleton() {
+ return singleton;
+ }
+
+ /**
+ * Returns the list of dependencies.
+ * <p>
+ * The step or step group id might be fully qualified using the form
+ * <code>&quot;primaryId##secondaryId</code>. The <code>secondaryId</code> is optional.
+ *
+ * @return The list of dependencies or an empty list.
+ */
+ public String[] getDependencies() {
+ return dependencies.toArray(new String[dependencies.size()]);
+ }
+
+ /**
+ * Returns the enablement expression which is associated with this reference.
+ *
+ * @return The enablement expression or <code>null</code>.
+ */
+ public Expression getEnablement() {
+ return expression;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
+ */
+ @Override
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ if (config == null) {
+ return;
+ }
+
+ String value = config.getAttribute("id"); //$NON-NLS-1$
+ if (value != null && value.trim().length() > 0) {
+ this.id = value.trim();
+ }
+
+ value = config.getAttribute("secondaryId"); //$NON-NLS-1$
+ setSecondardId(value != null && value.trim().length() > 0 ? value.trim() : null);
+
+ value = config.getAttribute("insertBefore"); //$NON-NLS-1$
+ if (value != null && value.trim().length() > 0) {
+ this.insertBefore = value.trim();
+ }
+
+ value = config.getAttribute("insertAfter"); //$NON-NLS-1$
+ if (value != null && value.trim().length() > 0) {
+ this.insertAfter = value.trim();
+ }
+
+ value = config.getAttribute("overwrite"); //$NON-NLS-1$
+ if (value != null && value.trim().length() > 0) {
+ this.overwrite = value.trim();
+ }
+
+ value = config.getAttribute("removable"); //$NON-NLS-1$
+ if (value != null && value.trim().length() > 0) {
+ this.removable = Boolean.parseBoolean(value.trim());
+ }
+
+ value = config.getAttribute("hidden"); //$NON-NLS-1$
+ if (value != null && value.trim().length() > 0) {
+ this.hidden = Boolean.parseBoolean(value.trim());
+ }
+
+ value = config.getAttribute("disable"); //$NON-NLS-1$
+ if (value != null && value.trim().length() > 0) {
+ this.disable = Boolean.parseBoolean(value.trim());
+ }
+
+ value = config.getAttribute("singleton"); //$NON-NLS-1$
+ if (value != null && value.trim().length() > 0) {
+ this.singleton = Boolean.parseBoolean(value.trim());
+ }
+
+ // Read in the list of dependencies if specified.
+ dependencies.clear();
+ IConfigurationElement[] requires = config.getChildren("requires"); //$NON-NLS-1$
+ for (IConfigurationElement require : requires) {
+ value = require.getAttribute("id"); //$NON-NLS-1$
+ if (value == null || value.trim().length() == 0) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ CoreBundleActivator.getUniqueIdentifier(),
+ 0,
+ NLS.bind(Messages.AbstractStep_error_missingRequiredAttribute,
+ "dependency id (requires)", //$NON-NLS-1$
+ config.getName()),
+ null));
+ }
+ if (!dependencies.contains(value.trim())) {
+ dependencies.add(value.trim());
+ }
+ }
+
+ // Read the sub elements of the extension
+ IConfigurationElement[] enablements = config.getChildren("enablement"); //$NON-NLS-1$
+ // The "enablement" element is the only expected one
+ if (enablements != null && enablements.length > 0) {
+ expression = ExpressionConverter.getDefault().perform(enablements[0]);
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (getId() != null && obj instanceof ReferenceSubElement) {
+ boolean secondaryIdEquals = false;
+ if (getSecondaryId() == null) {
+ secondaryIdEquals = ((ReferenceSubElement)obj).getSecondaryId() == null;
+ }
+ else {
+ secondaryIdEquals = getSecondaryId().equals(((ReferenceSubElement)obj).getSecondaryId());
+ }
+
+ return getId().equals(((ReferenceSubElement)obj).getId()) && secondaryIdEquals;
+ }
+ return super.equals(obj);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return getId() != null ? getId().hashCode() + (getSecondaryId() != null ? getSecondaryId().hashCode() : 0) : super.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuffer buffer = new StringBuffer(getClass().getSimpleName());
+ buffer.append(": "); //$NON-NLS-1$
+ buffer.append("id = " + getId()); //$NON-NLS-1$
+ buffer.append(", secondaryId = " + getSecondaryId()); //$NON-NLS-1$
+ buffer.append(", insertBefore = " + getInsertBefore()); //$NON-NLS-1$
+ buffer.append(", insertAfter = " + getInsertAfter()); //$NON-NLS-1$
+ buffer.append(", overwrite = " + getOverwrite()); //$NON-NLS-1$
+ buffer.append(", removable = " + isRemovable()); //$NON-NLS-1$
+ buffer.append(", hidden = " + isHidden()); //$NON-NLS-1$
+ buffer.append(", disable = " + isDisable()); //$NON-NLS-1$
+ buffer.append(", singleton = " + isSingleton()); //$NON-NLS-1$
+ return buffer.toString();
+ }
+ }
+
+ /**
+ * Constructor.
+ */
+ public StepGroup() {
+ super();
+ locked = false;
+ baseOn = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.AbstractContextStepGroup#isLocked()
+ */
+ @Override
+ public boolean isLocked() {
+ return locked;
+ }
+
+ /**
+ * Returns the id of the step group this step group is
+ * initially based on.
+ *
+ * @return The id or <code>null</code>.
+ */
+ protected String getBaseOn() {
+ return baseOn;
+ }
+
+ /**
+ * Returns the references.
+ */
+ protected List<ReferenceSubElement> getReferences() {
+ return references;
+ }
+
+ /**
+ * Check for duplicates of the referenced step or step group. The check will fail if multiple
+ * occurrence of a step or step group are found and the step or step group is supposed to be a
+ * singleton.
+ *
+ * @param steps The list of steps. Must not be <code>null</code>.
+ * @param reference The reference. Must not be <code>null</code>.
+ *
+ * @throws CoreException If multiple occurrences of singleton references are found.
+ */
+ protected void checkForDuplicates(List<IStepGroupable> steps, ReferenceSubElement reference) throws CoreException {
+ Assert.isNotNull(steps);
+ Assert.isNotNull(reference);
+
+ // If the reference overwrites another reference, it is not a duplicate
+ String overwrite = reference.getOverwrite();
+ if (overwrite != null && overwrite.length() > 0) {
+ return;
+ }
+
+ boolean checkFailed = false;
+
+ for (IStepGroupable step : steps) {
+ if (step.getExtension().getId().equals(reference.getId())) {
+ // We've found an existing groupable with the reference id.
+ // If either the groupable, the reference or the extension is
+ // marked singleton, than this is an failure.
+ checkFailed = step.isSingleton() || reference.isSingleton()
+ || (step.getExtension() instanceof IExtendedStep
+ && ((IExtendedStep)step.getExtension()).isSingleton());
+ if (checkFailed) {
+ break;
+ }
+ }
+ }
+
+ if (checkFailed) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ CoreBundleActivator.getUniqueIdentifier(),
+ MessageFormat.format(Messages.StepGroup_error_multipleSingletonOccurrences,
+ NLS.bind(Messages.StepGroup_error_stepGroup, getLabel()),
+ NLS.bind(Messages.StepGroup_error_referencedStepOrGroup, reference.getId()))
+ ));
+ }
+ }
+
+ /**
+ * Replace all references to a given step or step group with another one.
+ *
+ * @param steps The list of steps. Must not be <code>null</code>.
+ * @param oldId The id of the step or step group to replace. Must not be <code>null</code>.
+ * @param replacement The replacement. Must not be <code>null</code>.
+ * @param reference The reference sub element. Must not be <code>null</code>.
+ *
+ * @return The list of affected groupable's or an empty list.
+ */
+ protected List<IStepGroupable> onOverwrite(List<IStepGroupable> steps, String oldId, IExecutableExtension replacement, ReferenceSubElement reference) {
+ Assert.isNotNull(steps);
+ Assert.isNotNull(oldId);
+ Assert.isNotNull(replacement);
+ Assert.isNotNull(reference);
+
+ List<IStepGroupable> affected = new ArrayList<IStepGroupable>();
+
+ // Isolate primary and secondary id
+ String primaryId = oldId;
+ String secondaryId = null;
+
+ String[] splitted = oldId.split("##", 2); //$NON-NLS-1$
+ if (splitted.length == 2) {
+ primaryId = splitted[0];
+ secondaryId = splitted[1];
+ }
+
+ for (IStepGroupable step : steps) {
+ // A step is clearly affected if the primary id and the secondary
+ // id (if any) matches the overwritten id
+ if (step.getExtension().getId().equals(primaryId)
+ && (secondaryId == null || secondaryId.equals(step.getSecondaryId()))) {
+ if (step instanceof StepGroupable) {
+ StepGroupable groupable = ((StepGroupable)step);
+ // Update the grouped extension
+ groupable.setExtension(replacement);
+ // Update the groupable secondary id
+ groupable.setSecondaryId(reference.getSecondaryId());
+ // Add the groupable to the list of affected steps
+ affected.add(step);
+ }
+ }
+
+ // A step is affected as well if the step depends on the overwritten step
+ // In this case we have to update the dependencies.
+ List<String> dependencies = new ArrayList<String>(Arrays.asList(step.getDependencies()));
+ if (dependencies.contains(oldId)) {
+ String fullId = replacement.getId() + (reference.getSecondaryId() != null ? "##" + reference.getSecondaryId() : ""); //$NON-NLS-1$ //$NON-NLS-2$
+ // We have to replace the dependency at the exact position within the list
+ dependencies.set(dependencies.indexOf(oldId), fullId);
+ if (step instanceof StepGroupable) {
+ ((StepGroupable)step).setDependencies(dependencies.toArray(new String[dependencies.size()]));
+ }
+ }
+ }
+
+ return affected;
+ }
+
+ /**
+ * Insert the step before the specified step or step group. If no step or
+ * step group with the given id exist, the step is added to the end.
+ *
+ * @param steps The list of steps. Must not be <code>null</code>.
+ * @param id The id of the step or step group where to insert the new step before. Must not be <code>null</code>.
+ * @param newStep The step to add. Must not be <code>null</code>.
+ * @param reference The reference sub element. Must not be <code>null</code>.
+ *
+ * @return The list of affected groupable's or an empty list.
+ */
+ protected List<IStepGroupable> onInsertBefore(List<IStepGroupable> steps, String id, IExecutableExtension newStep, ReferenceSubElement reference) {
+ Assert.isNotNull(steps);
+ Assert.isNotNull(id);
+ Assert.isNotNull(newStep);
+ Assert.isNotNull(reference);
+
+ List<IStepGroupable> affected = new ArrayList<IStepGroupable>();
+
+ // Isolate primary and secondary id
+ String primaryId = id;
+ String secondaryId = null;
+
+ String[] splitted = id.split("##", 2); //$NON-NLS-1$
+ if (splitted.length == 2) {
+ primaryId = splitted[0];
+ secondaryId = splitted[1];
+ }
+
+ // Always loop over all steps in case the anchor step is available
+ // multiple times. In such case, the new step is inserted at all
+ // occurrences.
+ for (int i = 0; i < steps.size(); i++) {
+ IStepGroupable step = steps.get(i);
+ if (!step.getExtension().getId().equals(primaryId)) {
+ continue;
+ }
+ if (secondaryId != null && !secondaryId.equals(step.getSecondaryId())) {
+ continue;
+ }
+
+ // Create a new groupable object for inserting
+ IStepGroupable groupable = new StepGroupable(newStep, reference.getSecondaryId());
+ // Insert the new step at the current position
+ steps.add(i, groupable);
+ // And increase the counter --> Otherwise we would see the
+ // same step we want to insert before again!
+ i++;
+ // Add the new groupable to the list of affected steps
+ affected.add(groupable);
+ }
+
+ // If the step could not be added, add to the end of the list
+ if (affected.isEmpty()) {
+ IStepGroupable groupable = new StepGroupable(newStep, reference.getSecondaryId());
+ steps.add(groupable);
+ }
+
+ return affected;
+ }
+
+ /**
+ * Insert the step after the specified step or step group. If no step or
+ * step group with the given id exist, the step is added to the end.
+ *
+ * @param steps The list of steps. Must not be <code>null</code>.
+ * @param id The id of the step or step group where to insert the new step after. Must not be <code>null</code>.
+ * @param newStep The step to add. Must not be <code>null</code>.
+ * @param reference The reference sub element. Must not be <code>null</code>.
+ *
+ * @return The list of affected groupable's or an empty list.
+ */
+ protected List<IStepGroupable> onInsertAfter(List<IStepGroupable> steps, String id, IExecutableExtension newStep, ReferenceSubElement reference) {
+ Assert.isNotNull(steps);
+ Assert.isNotNull(id);
+ Assert.isNotNull(newStep);
+ Assert.isNotNull(reference);
+
+ List<IStepGroupable> affected = new ArrayList<IStepGroupable>();
+
+ // Isolate primary and secondary id
+ String primaryId = id;
+ String secondaryId = null;
+
+ String[] splitted = id.split("##", 2); //$NON-NLS-1$
+ if (splitted.length == 2) {
+ primaryId = splitted[0];
+ secondaryId = splitted[1];
+ }
+
+ // Always loop over all steps in case the anchor step is available
+ // multiple times. In such case, the new step is inserted at all
+ // occurrences.
+ for (int i = 0; i < steps.size(); i++) {
+ IStepGroupable step = steps.get(i);
+ if (!step.getExtension().getId().equals(primaryId)) {
+ continue;
+ }
+ if (secondaryId != null && !secondaryId.equals(step.getSecondaryId())) {
+ continue;
+ }
+
+ // Create a new groupable object for inserting
+ IStepGroupable groupable = new StepGroupable(newStep, reference.getSecondaryId());
+ // Insert the new groupable after the current step or at the end (if i + 1 == steps.size())
+ steps.add(i + 1, groupable);
+ // Add the new groupable to the list of affected steps
+ affected.add(groupable);
+ }
+
+ // If the step could not be added, add to the end of the list
+ if (affected.isEmpty()) {
+ IStepGroupable groupable = new StepGroupable(newStep, reference.getSecondaryId());
+ steps.add(groupable);
+ }
+
+ return affected;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup#getSteps(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext)
+ */
+ @Override
+ public IStepGroupable[] getSteps(IStepContext context) throws CoreException {
+ Assert.isNotNull(context);
+
+ // The list of resolved steps for the specified type and mode
+ List<IStepGroupable> steps = new ArrayList<IStepGroupable>();
+
+ // If this step group is based on another step group, we have to get the resolved
+ // steps from there first.
+ if (getBaseOn() != null) {
+ IStepGroup baseStepGroup = getStepGroup(getBaseOn());
+ // If the base step group cannot be found, that's an error. We cannot continue
+ // without the base group.
+ if (baseStepGroup == null) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ CoreBundleActivator.getUniqueIdentifier(),
+ MessageFormat.format(Messages.StepGroup_error_missingBaseStepGroup,
+ NLS.bind(Messages.StepGroup_error_stepGroup, getLabel()),
+ NLS.bind(Messages.StepGroup_error_referencedBaseGroup, getBaseOn()))
+ ));
+ }
+
+ // Add all the steps from the base step group now to the list
+ steps.addAll(Arrays.asList(baseStepGroup.getSteps(context)));
+ }
+
+ // Now process the references and modify the steps list accordingly
+ for (ReferenceSubElement reference : getReferences()) {
+ // Get the step or step group for the referenced id. Try the steps first.
+ IExecutableExtension candidate = getStep(reference.getId());
+ if (candidate == null) {
+ candidate = getStepGroup(reference.getId());
+ }
+
+ // If the candidate is null here, that's an error as a referenced step is missing.
+ if (candidate == null) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ CoreBundleActivator.getUniqueIdentifier(),
+ MessageFormat.format(Messages.StepGroup_error_missingReferencedStep,
+ NLS.bind(Messages.StepGroup_error_stepGroup, getLabel()),
+ NLS.bind(Messages.StepGroup_error_referencedStepOrGroup, reference.getId()))
+ ));
+ }
+
+ // Check if the step is valid for the current contexts.
+ boolean valid = isValidReference(reference, context);
+
+ if (!valid) {
+ CoreBundleActivator.getTraceHandler().trace(
+ "StepGroup#getSteps: SKIPPED reference = '" + candidate.getLabel() + "'." //$NON-NLS-1$ //$NON-NLS-2$
+ + " Not valid for contexts '" + context, //$NON-NLS-1$
+ 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
+ continue;
+ }
+
+ // Check for duplicates of singleton references.
+ checkForDuplicates(steps, reference);
+
+ // Check for the steps own dependencies to be valid for the current type id and mode
+ if (candidate instanceof IStep) {
+ checkForDependenciesValid((IStep)candidate, context);
+ }
+
+ // Will contain the list of affected groupables from the whole list
+ List<IStepGroupable> affectedGroupables = new ArrayList<IStepGroupable>();
+
+ // Check first for overwriting groupables
+ String overwrite = reference.getOverwrite();
+ if (overwrite != null && overwrite.length() > 0) {
+ affectedGroupables.addAll(onOverwrite(steps, overwrite, candidate, reference));
+ } else {
+ // overwrite is not set -> process insertBefore or insertAfter
+ String insertBefore = reference.getInsertBefore();
+ String insertAfter = reference.getInsertAfter();
+
+ // If neither one is specified, the step or step group will be to the end of the list
+ if ((insertBefore == null || insertBefore.length() == 0)
+ && (insertAfter == null || insertAfter.length() == 0)) {
+ IStepGroupable groupable = new StepGroupable(candidate, reference.getSecondaryId());
+ steps.add(groupable);
+ affectedGroupables.add(groupable);
+ } else {
+ // insertBefore comes first
+ if (insertBefore != null && insertBefore.length() > 0) {
+ affectedGroupables.addAll(onInsertBefore(steps, insertBefore, candidate, reference));
+ } else {
+ affectedGroupables.addAll(onInsertAfter(steps, insertAfter, candidate, reference));
+ }
+ }
+ }
+
+ // Process the groupable attributes on all affected groupables
+ for (IStepGroupable step : affectedGroupables) {
+ if (!(step instanceof StepGroupable)) {
+ continue;
+ }
+
+ StepGroupable groupable = (StepGroupable)step;
+ groupable.setDependencies(reference.getDependencies());
+
+ if (!reference.isRemovable() && groupable.isRemovable()) {
+ groupable.setRemovable(reference.isRemovable());
+ }
+ if (reference.isHidden() && !groupable.isHidden()) {
+ groupable.setHidden(reference.isHidden());
+ }
+ if (reference.isDisable() && !groupable.isDisabled()) {
+ groupable.setDisabled(reference.isDisable());
+ }
+ if (reference.isSingleton() && !groupable.isSingleton()) {
+ groupable.setSingleton(reference.isSingleton());
+ }
+ }
+ }
+
+ return !steps.isEmpty() ? steps.toArray(new IStepGroupable[steps.size()]) : NO_STEPS;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.ExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
+ */
+ @Override
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ references.clear();
+ super.setInitializationData(config, propertyName, data);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.extensions.AbstractStepGroup#doSetInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
+ */
+ @Override
+ public void doSetInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ super.doSetInitializationData(config, propertyName, data);
+
+ if (iteratorProxy == null) {
+ iteratorProxy = new ExecutableExtensionProxy<IStepGroupIterator>(config) {
+ @Override
+ protected String getExecutableExtensionAttributeName() {
+ return "iterator"; //$NON-NLS-1$
+ }
+ };
+ }
+
+ if (!locked) {
+ String lockedAttribute = config.getAttribute("locked"); //$NON-NLS-1$
+ if (lockedAttribute != null) {
+ this.locked = Boolean.parseBoolean(lockedAttribute);
+ }
+ }
+
+ if (baseOn == null || baseOn.trim().length() == 0) {
+ String baseOnAttribute = config.getAttribute("baseOn"); //$NON-NLS-1$
+ if (baseOnAttribute != null && baseOnAttribute.trim().length() > 0) {
+ this.baseOn = baseOnAttribute.trim();
+ }
+ }
+
+ Map<String, Integer> occurrences = new HashMap<String, Integer>();
+ IConfigurationElement[] childElements = config.getChildren("references"); //$NON-NLS-1$
+ for (IConfigurationElement childElement : childElements) {
+ IConfigurationElement[] references = childElement.getChildren("reference"); //$NON-NLS-1$
+ for (IConfigurationElement reference : references) {
+ ReferenceSubElement candidate = new ReferenceSubElement();
+ candidate.setInitializationData(reference, reference.getName(), null);
+ // If multiple references to the same step or step group exist, check
+ // for the secondaryId
+ if (occurrences.containsKey(candidate.getId())) {
+ // Occurrences are counted up always
+ int number = occurrences.get(candidate.getId()).intValue() + 1;
+ occurrences.put(candidate.getId(), Integer.valueOf(number));
+
+ if (candidate.getSecondaryId() == null) {
+ // secondaryId not explicitly set -> auto set
+ candidate.setSecondardId(Integer.toString(number));
+ }
+ } else {
+ // remember the occurrence of the reference
+ occurrences.put(candidate.getId(), Integer.valueOf(1));
+ }
+
+ // References are not sorted out here. That's the task of the resolver.
+ this.references.add(candidate);
+ }
+ }
+ }
+
+
+ /**
+ * Checks if all dependencies of the given step are available
+ * and valid for the given type id and mode.
+ *
+ * @param step The step. Must not be <code>null</code>.
+ * @param context The context. Must not be <code>null</code>.
+ *
+ * @throws CoreException If a required step or step group is not available or not valid.
+ */
+ protected void checkForDependenciesValid(IStep step, IStepContext context) throws CoreException {
+ Assert.isNotNull(step);
+ Assert.isNotNull(context);
+
+ String[] dependencies = step.getDependencies();
+ for (String dependency : dependencies) {
+ // Get the step or step group. Try the steps first.
+ IExecutableExtension candidate = getStep(dependency);
+ if (candidate == null) {
+ candidate = getStepGroup(dependency);
+ }
+
+ // If the candidate is null here, that's an error as a required step or step group is missing.
+ if (candidate == null) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ CoreBundleActivator.getUniqueIdentifier(),
+ MessageFormat.format(Messages.StepGroup_error_missingRequiredStep,
+ NLS.bind(Messages.StepGroup_error_step, step.getLabel()),
+ NLS.bind(Messages.StepGroup_error_requiredStepOrGroup, dependency))
+ ));
+ }
+ }
+ }
+
+ /**
+ * Convenience method returning a unique instance of the step
+ * identified by the given id.
+ *
+ * @param id The step id. Must not be <code>null</code>.
+ * @return The step instance or <code>null</code>.
+ */
+ protected IStep getStep(String id) {
+ Assert.isNotNull(id);
+ return StepperManager.getInstance().getStepExtManager().getStep(id, true);
+ }
+
+ /**
+ * Convenience method returning a unique instance of the step
+ * group identified by the given id.
+ *
+ * @param id The step id. Must not be <code>null</code>.
+ * @return The step group instance or <code>null</code>.
+ */
+ protected IStepGroup getStepGroup(String id) {
+ Assert.isNotNull(id);
+ return StepperManager.getInstance().getStepGroupExtManager().getStepGroup(id, true);
+ }
+
+ /**
+ * Returns if or if not the reference is valid for the given contexts.
+ *
+ * @param reference The reference. Must not be <code>null</code>.
+ * @param context The context or <code>null</code>.
+ *
+ * @return <code>True</code> if the step is valid, <code>false</code> otherwise.
+ */
+ protected boolean isValidReference(ReferenceSubElement reference, IStepContext context) {
+ Assert.isNotNull(reference);
+ // Get the enablement.
+ Expression enablement = reference.getEnablement();
+
+ if (enablement != null) {
+ if (context != null) {
+ // Set the default variable to the context.
+ EvaluationContext evalContext = new EvaluationContext(null, context);
+ // Initialize the evaluation context named variables
+ evalContext.addVariable("context", context.getContextObject()); //$NON-NLS-1$
+ evalContext.addVariable("id", context.getId()); //$NON-NLS-1$
+ // Allow plugin activation
+ evalContext.setAllowPluginActivation(true);
+ // Evaluate the expression
+ try {
+ return enablement.evaluate(evalContext).equals(EvaluationResult.TRUE);
+ } catch (CoreException e) {
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
+ e.getLocalizedMessage(), e);
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup#getStepGroupIterator()
+ */
+ @Override
+ public IStepGroupIterator getStepGroupIterator() {
+ return iteratorProxy != null ? iteratorProxy.newInstance() : null;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepBinding.java
deleted file mode 100644
index 575602d27..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepBinding.java
+++ /dev/null
@@ -1,66 +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 org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.ExpressionConverter;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
-
-/**
- * Step binding implementation.
- */
-public final class StepBinding extends ExecutableExtension {
- // The mandatory step identifier
- private String stepId;
- // The converted expression
- private Expression expression;
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.ExecutableExtension#doSetInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
- */
- @Override
- public void doSetInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- super.doSetInitializationData(config, propertyName, data);
-
- // Initialize the step id field.
- // Throws an exception if the step id is empty or null.
- stepId = config != null ? config.getAttribute("stepId") : null; //$NON-NLS-1$
- if (stepId == null || (stepId != null && "".equals(stepId.trim()))) { //$NON-NLS-1$
- throw createMissingMandatoryAttributeException("stepId", config.getContributor().getName()); //$NON-NLS-1$
- }
-
- // Read the sub elements of the extension
- IConfigurationElement[] children = config != null ? config.getChildren() : null;
- // The "enablement" element is the only expected one
- if (children != null && children.length > 0) {
- expression = ExpressionConverter.getDefault().perform(children[0]);
- }
- }
-
- /**
- * Returns the step id which is associated with this binding.
- *
- * @return The step id.
- */
- public String getStepId() {
- return stepId;
- }
-
- /**
- * Returns the enablement expression which is associated with this binding.
- *
- * @return The enablement expression or <code>null</code>.
- */
- public Expression getEnablement() {
- return expression;
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepBindingsExtensionPointManager.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepBindingsExtensionPointManager.java
deleted file mode 100644
index 1847dca50..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepBindingsExtensionPointManager.java
+++ /dev/null
@@ -1,187 +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.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
-import org.eclipse.tcf.te.runtime.stepper.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-
-
-/**
- * Step bindings extension point manager implementation.
- */
-public final class StepBindingsExtensionPointManager extends AbstractExtensionPointManager<StepBinding> {
-
- /**
- * Constructor.
- */
- public StepBindingsExtensionPointManager() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
- */
- @Override
- protected String getExtensionPointId() {
- return "org.eclipse.tcf.te.runtime.stepper.stepBindings"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
- */
- @Override
- protected String getConfigurationElementName() {
- return "binding"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#doCreateExtensionProxy(org.eclipse.core.runtime.IConfigurationElement)
- */
- @Override
- protected ExecutableExtensionProxy<StepBinding> doCreateExtensionProxy(IConfigurationElement element) throws CoreException {
- return new ExecutableExtensionProxy<StepBinding>(element) {
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy#newInstance()
- */
- @Override
- public StepBinding newInstance() {
- StepBinding instance = new StepBinding();
- try {
- instance.setInitializationData(getConfigurationElement(), null, null);
- } catch (CoreException e) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- e.getLocalizedMessage(), e);
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- return instance;
- }
- };
- }
-
- /**
- * Returns if or if not the step identified by the given step id is enabled for the
- * given context.
- * <p>
- * <b>Note:</b> A step is considered enabled if
- * <ul>
- * <li>There is no step binding contribution for the given step id. Or</li>
- * <li>At least one of the bindings has not enablement sub element. Or</li>
- * <li>At least one of the bindings enablement sub element evaluates to <code>true</code>.</li>
- * </ul>
- *
- * @param stepId The step id. Must not be <code>null</code>.
- * @param contexts The context objects or <code>null</code>.
- * @return The list of applicable editor page bindings or an empty array.
- */
- public boolean isStepEnabled(String stepId, IStepContext[] contexts) {
- Assert.isNotNull(stepId);
-
- // Flag is set to true at the first binding matching the given step id
- boolean hasStepBinding = false;
- boolean enabled = false;
-
- for (StepBinding binding : getStepBindings()) {
- // Ignore all bindings not matching the given step id.
- if (!stepId.equals(binding.getStepId())) continue;
-
- // OK. There is at least one binding contribution for the given step id.
- hasStepBinding = true;
-
- // Get the enablement.
- Expression enablement = binding.getEnablement();
-
- // The binding is applicable by default if no expression is specified.
- enabled = enablement == null;
-
- if (enablement != null) {
- if (contexts != null) {
- // To satisfy the "isIterable" and "isCountable" needs of the expression
- // evaluator, pass on the contexts as collection.
- List<IStepContext> variableValue = Arrays.asList(contexts);
- // Set the default variable to the context.
- EvaluationContext evalContext = new EvaluationContext(null, variableValue);
- // Initialize the evaluation context named variables
- evalContext.addVariable("activeContexts", variableValue); //$NON-NLS-1$
- // Allow plugin activation
- evalContext.setAllowPluginActivation(true);
- // Evaluate the expression
- try {
- enabled = enablement.evaluate(evalContext).equals(EvaluationResult.TRUE);
- } catch (CoreException e) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- e.getLocalizedMessage(), e);
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- } else {
- // The enablement is false by definition if no context is given.
- enabled = false;
- }
- }
-
- // Break the loop if the step is found enabled
- if (enabled) break;
- }
-
- return !hasStepBinding || enabled;
- }
-
- /**
- * Returns the list of all contributed step bindings.
- *
- * @return The list of contributed step bindings, or an empty array.
- */
- public StepBinding[] getStepBindings() {
- List<StepBinding> contributions = new ArrayList<StepBinding>();
- Collection<ExecutableExtensionProxy<StepBinding>> statusHandlerBindings = getExtensions().values();
- for (ExecutableExtensionProxy<StepBinding> statusHandlerBinding : statusHandlerBindings) {
- StepBinding instance = statusHandlerBinding.getInstance();
- if (instance != null && !contributions.contains(instance)) {
- contributions.add(instance);
- }
- }
-
- return contributions.toArray(new StepBinding[contributions.size()]);
- }
-
- /**
- * Returns the step binding identified by its unique id. If no step
- * binding with the specified id is registered, <code>null</code> is returned.
- *
- * @param id The unique id of the step binding or <code>null</code>
- *
- * @return The step binding instance or <code>null</code>.
- */
- public StepBinding getBinding(String id) {
- StepBinding contribution = null;
- if (getExtensions().containsKey(id)) {
- ExecutableExtensionProxy<StepBinding> proxy = getExtensions().get(id);
- // Get the extension instance
- contribution = proxy.getInstance();
- }
-
- return contribution;
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepGroupExtensionPointManager.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepGroupExtensionPointManager.java
index 9b851a3a8..747751a14 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepGroupExtensionPointManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/manager/StepGroupExtensionPointManager.java
@@ -112,7 +112,5 @@ public final class StepGroupExtensionPointManager extends AbstractExtensionPoint
else {
super.doStoreExtensionTo(extensions, candidate, element);
}
-
- super.doStoreExtensionTo(extensions, candidate, element);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IContextManipulator.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IContextManipulator.java
deleted file mode 100644
index 61bb81817..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IContextManipulator.java
+++ /dev/null
@@ -1,29 +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;
-
-/**
- * A step or step group capable of modifying the context the steps or step
- * groups are operating on.
- */
-public interface IContextManipulator {
-
- /**
- * The suffix to append to the full qualified step id to
- * get the delayed status object.
- */
- public final static String CONTEXT_ID = "contextId"; //$NON-NLS-1$
-
- /**
- * The suffix to append to the full qualified step id to
- * get the delayed status object.
- */
- public final static String CONTEXT = "context"; //$NON-NLS-1$
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepContext.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepContext.java
index 95afe26aa..6386de407 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepContext.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepContext.java
@@ -9,15 +9,13 @@
*******************************************************************************/
package org.eclipse.tcf.te.runtime.stepper.interfaces;
-import java.io.IOException;
-
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.model.interfaces.IModelNodeProvider;
/**
* Interface to be implemented by objects representing a context for a step.
*/
-public interface IStepContext extends IModelNodeProvider {
+public interface IStepContext extends IAdaptable {
/**
* Returns the context id.
@@ -35,6 +33,13 @@ public interface IStepContext extends IModelNodeProvider {
public String getName();
/**
+ * Returns the context object.
+ *
+ * @return The context Object. Must not be <code>null</code>.
+ */
+ public Object getContextObject();
+
+ /**
* Returns a possible multi-line string providing detail information
* about the context which shall be included in failure messages.
*
@@ -42,38 +47,4 @@ public interface IStepContext extends IModelNodeProvider {
* @return The context information or <code>null</code>.
*/
public String getInfo(IPropertiesContainer data);
-
- /**
- * Returns if or if not the associated model node really exist.
- *
- * @return <code>True</code> if the associated model node really exists, <code>false</code> otherwise.
- */
- public boolean exists();
-
- /**
- * Encodes the context to an persistable representation.
- * <p>
- * <b>Note:</b> The persistable representation is expected to be a single line.
- *
- * @return The persistable representation of the context.
- */
- public String encode();
-
- /**
- * Returns the class name of the encoded context.
- * <p>
- * The class name is used to load the correct class to decode the persistable representation.
- *
- * @return The class name of the encoded context.
- */
- public String getEncodedClassName();
-
- /**
- * Decodes the given persistable representation and store the result
- * in the context.
- *
- * @param value The persistable representation of the context. Must not be <code>null</code>.
- * @throws IOException - if the decode operation fails
- */
- public void decode(String value) throws IOException;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepGroup.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepGroup.java
index f9b544acc..7ac8e26b1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepGroup.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepGroup.java
@@ -1,46 +1,46 @@
-/*******************************************************************************
- * 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.interfaces;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
-
-
-/**
- * A step group.
- * <p>
- * A step group is a set of single steps or other step groups.
- */
-public interface IStepGroup extends IExecutableExtension {
-
- /**
- * Returns if or if not the step group is locked for user modifications.
- *
- * @return <code>True</code> if locked for user modifications, <code>false</code> otherwise.
- */
- public boolean isLocked();
-
- /**
- * Returns the list of steps or step groups enlisted and enabled in the group for the
- * given contexts.
- *
- * @param contexts The array of context objects. Must not be <code>null</code>.
- * @return The list of steps and step groups or an empty array.
- *
- * @throws CoreException If the steps cannot be determined.
- */
- public IStepGroupable[] getSteps(IStepContext[] contexts) throws CoreException;
-
- /**
- * Return the step group iterator or <code>null</code>. The step group iterator can be used to
- * generate loops and conditions for a step group.
- */
- public IStepGroupIterator getStepGroupIterator();
-}
+/*******************************************************************************
+ * 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.interfaces;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
+
+
+/**
+ * A step group.
+ * <p>
+ * A step group is a set of single steps or other step groups.
+ */
+public interface IStepGroup extends IExecutableExtension {
+
+ /**
+ * Returns if or if not the step group is locked for user modifications.
+ *
+ * @return <code>True</code> if locked for user modifications, <code>false</code> otherwise.
+ */
+ public boolean isLocked();
+
+ /**
+ * Returns the list of steps or step groups enlisted and enabled in the group for the
+ * given context.
+ *
+ * @param context The step context object. Must not be <code>null</code>.
+ * @return The list of steps and step groups or an empty array.
+ *
+ * @throws CoreException If the steps cannot be determined.
+ */
+ public IStepGroupable[] getSteps(IStepContext context) throws CoreException;
+
+ /**
+ * Return the step group iterator or <code>null</code>. The step group iterator can be used to
+ * generate loops and conditions for a step group.
+ */
+ public IStepGroupIterator getStepGroupIterator();
+}
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 3ca20c146..b89f46ff8 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
@@ -1,119 +1,120 @@
-/*******************************************************************************
- * 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.interfaces;
-
-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;
-
-
-/**
- * A stepper.
- * <p>
- * Stepper are executing a set of steps and/or step groups for the given context(s). The stepper is
- * responsible for handling any exceptions which occurred during step execution.
- * <p>
- * <b>Note:</b> Stepper are synchronous where steps are asynchronous.
- * <p>
- * Stepper must run in worker threads.
- */
-public interface IStepper extends IExecutableExtension {
-
- public static final String ID_TYPE_STEPPER_ID = "Stepper"; //$NON-NLS-1$
- public static final String ID_TYPE_CONTEXT_ID = "Context"; //$NON-NLS-1$
- public static final String ID_TYPE_STEP_GROUP_ID = "StepGroup"; //$NON-NLS-1$
- public static final String ID_TYPE_STEP_GROUP_ITERATION_ID = "StepGroupIteration"; //$NON-NLS-1$
- public static final String ID_TYPE_STEP_ID = "Step"; //$NON-NLS-1$
-
- /**
- * Condition Tester to test for finished execution of the associated stepper.
- */
- public static class ExecutionFinishedConditionTester implements IConditionTester {
- private final IStepper stepper;
-
- /**
- * Constructor.
- *
- * @param stepper The stepper. Must not be <code>null</code>.
- */
- public ExecutionFinishedConditionTester(IStepper stepper) {
- Assert.isNotNull(stepper);
- this.stepper = stepper;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.IConditionTester#cleanup()
- */
- @Override
- public void cleanup() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.IConditionTester#isConditionFulfilled()
- */
- @Override
- public boolean isConditionFulfilled() {
- return stepper.isFinished();
- }
- }
-
- /**
- * 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.
- *
- * @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>.
- *
- * @throws IllegalStateException If called if the stepper is in initialized state already.
- */
- public void initialize(IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws IllegalStateException;
-
- /**
- * Returns if or if not the stepper got initialized for a new run.
- * <p>
- * The <i><code>execute()</code></i> method cannot be called if the stepper is not correctly
- * initialized for each run. The initialized state can be set only by calling the <i>
- * <code>initialize(...)</code></i> method. <i> <code>cleanup()</code></i> will reset the
- * initialized state back to uninitialized.
- *
- * @return <code>True</code> if initialized, <code>false</code> otherwise.
- */
- public boolean isInitialized();
-
- /**
- * Executes the configured steps. The method is synchronous and must return only if all steps
- * finished or an exception occurred.
- * <p>
- * Steps are assumed to be asynchronous. The stepper implementor must wait for callback(s) to be
- * invoked by the step implementor(s) before the sequence can continue.
- * <p>
- * <b>Note:</b> Waiting for the step callback must not block the UI thread.
- *
- * @throws CoreException In case the execution fails or is canceled.
- */
- public void execute() throws CoreException;
-
- /**
- * Returns if or if not the stepper finished the execution.
- *
- * @return <code>True</code> if the execution is finished, <code>false</code> otherwise.
- */
- public boolean isFinished();
-
- /**
- * Cleanup and reset the stepper into a defined state.
- */
- public void cleanup();
-}
+/*******************************************************************************
+ * 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.interfaces;
+
+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;
+
+
+/**
+ * A stepper.
+ * <p>
+ * Stepper are executing a set of steps and/or step groups for the given context(s). The stepper is
+ * responsible for handling any exceptions which occurred during step execution.
+ * <p>
+ * <b>Note:</b> Stepper are synchronous where steps are asynchronous.
+ * <p>
+ * Stepper must run in worker threads.
+ */
+public interface IStepper extends IExecutableExtension {
+
+ public static final String ID_TYPE_STEPPER_ID = "Stepper"; //$NON-NLS-1$
+ public static final String ID_TYPE_CONTEXT_ID = "Context"; //$NON-NLS-1$
+ public static final String ID_TYPE_STEP_GROUP_ID = "StepGroup"; //$NON-NLS-1$
+ public static final String ID_TYPE_STEP_GROUP_ITERATION_ID = "StepGroupIteration"; //$NON-NLS-1$
+ public static final String ID_TYPE_STEP_ID = "Step"; //$NON-NLS-1$
+
+ /**
+ * Condition Tester to test for finished execution of the associated stepper.
+ */
+ public static class ExecutionFinishedConditionTester implements IConditionTester {
+ private final IStepper stepper;
+
+ /**
+ * Constructor.
+ *
+ * @param stepper The stepper. Must not be <code>null</code>.
+ */
+ public ExecutionFinishedConditionTester(IStepper stepper) {
+ Assert.isNotNull(stepper);
+ this.stepper = stepper;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.interfaces.IConditionTester#cleanup()
+ */
+ @Override
+ public void cleanup() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.interfaces.IConditionTester#isConditionFulfilled()
+ */
+ @Override
+ public boolean isConditionFulfilled() {
+ return stepper.isFinished();
+ }
+ }
+
+ /**
+ * 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.
+ *
+ * @param context The step context. Must not be <code>null</code>.
+ * @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>.
+ *
+ * @throws IllegalStateException If called if the stepper is in initialized state already.
+ */
+ public void initialize(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws IllegalStateException;
+
+ /**
+ * Returns if or if not the stepper got initialized for a new run.
+ * <p>
+ * The <i><code>execute()</code></i> method cannot be called if the stepper is not correctly
+ * initialized for each run. The initialized state can be set only by calling the <i>
+ * <code>initialize(...)</code></i> method. <i> <code>cleanup()</code></i> will reset the
+ * initialized state back to uninitialized.
+ *
+ * @return <code>True</code> if initialized, <code>false</code> otherwise.
+ */
+ public boolean isInitialized();
+
+ /**
+ * Executes the configured steps. The method is synchronous and must return only if all steps
+ * finished or an exception occurred.
+ * <p>
+ * Steps are assumed to be asynchronous. The stepper implementor must wait for callback(s) to be
+ * invoked by the step implementor(s) before the sequence can continue.
+ * <p>
+ * <b>Note:</b> Waiting for the step callback must not block the UI thread.
+ *
+ * @throws CoreException In case the execution fails or is canceled.
+ */
+ public void execute() throws CoreException;
+
+ /**
+ * Returns if or if not the stepper finished the execution.
+ *
+ * @return <code>True</code> if the execution is finished, <code>false</code> otherwise.
+ */
+ public boolean isFinished();
+
+ /**
+ * Cleanup and reset the stepper into a defined state.
+ */
+ public void cleanup();
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepperProperties.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepperProperties.java
index 7a92a023c..e834644a4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepperProperties.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepperProperties.java
@@ -31,11 +31,4 @@ public interface IStepperProperties {
* Type: String
*/
public static final String PROP_NAME = "name"; //$NON-NLS-1$
-
- /**
- * The context objects the stepper is working on.
- * <p>
- * Type: Array of {@link IStepContext}
- */
- public static final String PROP_CONTEXTS = "contexts"; //$NON-NLS-1$
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/nls/Messages.java
index 1111c6912..b80750d0f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/nls/Messages.java
@@ -1,67 +1,67 @@
-/*******************************************************************************
- * 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.nls;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Stepper Runtime plugin externalized strings management.
- */
-public class Messages extends NLS {
-
- // The plug-in resource bundle name
- private static final String BUNDLE_NAME = "org.eclipse.tcf.te.runtime.stepper.nls.Messages"; //$NON-NLS-1$
-
- /**
- * Static constructor.
- */
- static {
- // Load message values from bundle file
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- // **** Declare externalized string id's down here *****
-
- public static String AbstractStep_error_missingRequiredAttribute;
- public static String AbstractStep_warning_stepFinishedWithWarnings;
-
- public static String AbstractStepper_error_stepGroup;
- public static String AbstractStepper_error_step;
- public static String AbstractStepper_error_referencedBaseGroup;
- public static String AbstractStepper_error_referencedStepOrGroup;
- public static String AbstractStepper_error_requiredStepOrGroup;
- public static String AbstractStepper_error_requiredStep;
- public static String AbstractStepper_error_initializeNotCalled;
- public static String AbstractStepper_error_missingStepGroupId;
- public static String AbstractStepper_error_missingStepGroup;
- public static String AbstractStepper_error_missingSteps;
- public static String AbstractStepper_multiStatus_finishedWithWarnings;
- public static String AbstractStepper_multiStatus_finishedWithErrors;
- public static String AbstractStepper_error_missingRequiredStep;
- public static String AbstractStepper_error_requiredStepNotExecuted;
-
- public static String StepGroup_error_missingBaseStepGroup;
- public static String StepGroup_error_missingReferencedStep;
- public static String StepGroup_error_missingRequiredStep;
- public static String StepGroup_error_invalidRequiredStep;
- public static String StepGroup_error_multipleSingletonOccurrences;
- public static String StepGroup_error_step;
- public static String StepGroup_error_stepGroup;
- public static String StepGroup_error_requiredStep;
- public static String StepGroup_error_referencedBaseGroup;
- public static String StepGroup_error_referencedStepOrGroup;
- public static String StepGroup_error_requiredStepOrGroup;
-
- public static String StepExecutor_checkPoint_normalizationNeeded;
- public static String StepExecutor_info_stepFailed;
- public static String StepExecutor_warning_stepFailed;
- public static String StepExecutor_error_stepFailed;
- public static String StepExecutor_stepFailed_debugInfo;
-}
+/*******************************************************************************
+ * 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.nls;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Stepper Runtime plugin externalized strings management.
+ */
+public class Messages extends NLS {
+
+ // The plug-in resource bundle name
+ private static final String BUNDLE_NAME = "org.eclipse.tcf.te.runtime.stepper.nls.Messages"; //$NON-NLS-1$
+
+ /**
+ * Static constructor.
+ */
+ static {
+ // Load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ // **** Declare externalized string id's down here *****
+
+ public static String AbstractStep_error_missingRequiredAttribute;
+ public static String AbstractStep_warning_stepFinishedWithWarnings;
+
+ public static String Stepper_error_stepGroup;
+ public static String Stepper_error_step;
+ public static String Stepper_error_referencedBaseGroup;
+ public static String Stepper_error_referencedStepOrGroup;
+ public static String Stepper_error_requiredStepOrGroup;
+ public static String Stepper_error_requiredStep;
+ public static String Stepper_error_initializeNotCalled;
+ public static String Stepper_error_missingStepGroupId;
+ public static String Stepper_error_missingStepGroup;
+ public static String Stepper_error_missingSteps;
+ public static String Stepper_multiStatus_finishedWithWarnings;
+ public static String Stepper_multiStatus_finishedWithErrors;
+ public static String Stepper_error_missingRequiredStep;
+ public static String Stepper_error_requiredStepNotExecuted;
+
+ public static String StepGroup_error_missingBaseStepGroup;
+ public static String StepGroup_error_missingReferencedStep;
+ public static String StepGroup_error_missingRequiredStep;
+ public static String StepGroup_error_invalidRequiredStep;
+ public static String StepGroup_error_multipleSingletonOccurrences;
+ public static String StepGroup_error_step;
+ public static String StepGroup_error_stepGroup;
+ public static String StepGroup_error_requiredStep;
+ public static String StepGroup_error_referencedBaseGroup;
+ public static String StepGroup_error_referencedStepOrGroup;
+ public static String StepGroup_error_requiredStepOrGroup;
+
+ public static String StepExecutor_checkPoint_normalizationNeeded;
+ public static String StepExecutor_info_stepFailed;
+ public static String StepExecutor_warning_stepFailed;
+ public static String StepExecutor_error_stepFailed;
+ public static String StepExecutor_stepFailed_debugInfo;
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/nls/Messages.properties
index e727d67f5..06a153ef3 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/nls/Messages.properties
@@ -1,48 +1,46 @@
-#
-# org.eclipse.tcf.te.runtime.stepper
-# Externalized Strings.
-#
-
-AbstractStep_error_missingRequiredAttribute=Required attribute "{0}" missing for extension "{1}"!
-AbstractStep_warning_stepFinishedWithWarnings=Step ''{0}'' finished with warnings.
-
-AbstractStepper_error_stepGroup=Step group:\n\t{0}
-AbstractStepper_error_step=Step:\n\t{0}
-AbstractStepper_error_referencedBaseGroup=Referenced Base Step Group:\n\t{0}
-AbstractStepper_error_referencedStepOrGroup=Referenced Step or Step Group:\n\t{0}
-AbstractStepper_error_requiredStepOrGroup=Required Step or Step Group:\n\t{0}
-AbstractStepper_error_requiredStep=Required Step:\n\t{0}
-AbstractStepper_error_initializeNotCalled=initialize(...) must be called before execute()!
-AbstractStepper_error_missingStepGroupId=Execution failed. Missing step group id for ''{0}''.
-AbstractStepper_error_missingStepGroup=Execution failed. Missing step group for id ''{0}''.
-AbstractStepper_error_missingSteps=Execution failed. No steps enabled for ''{0}''.
-AbstractStepper_multiStatus_finishedWithWarnings=''{0}'' completed with warnings or information.
-AbstractStepper_multiStatus_finishedWithErrors=''{0}'' failed.
-AbstractStepper_error_missingRequiredStep=Step execution failed. \
-Required step or step group does not exist.\n\n{0}\n{1}\n\n{2}
-AbstractStepper_error_requiredStepNotExecuted=Step execution failed. \
-Required step or step group not executed before.\n\n{0}\n{1}\n\n{2}
-
-StepGroup_error_missingBaseStepGroup=Cannot determine steps for execution. Referenced base step group does not exist.\n\n{0}\n{1}\n\n{2}
-StepGroup_error_missingReferencedStep=Cannot determine steps for execution. Referenced step or step group does not exist.\n\n{0}\n{1}\n\n{2}
-StepGroup_error_missingRequiredStep=Invalid step. Required step or step group does not exist.\n\n{0}\n{1}\n\n{2}
-StepGroup_error_invalidRequiredStep=Invalid step. Required step is invalid.\n\n{0}\n{1}\n\n{2}
-StepGroup_error_multipleSingletonOccurrences=Cannot determine steps for execution. Only one reference allowed.\n\n{0}\n{1}\n\n{2}
-StepGroup_error_step=Step:\n\t{0}
-StepGroup_error_stepGroup=Step group:\n\t{0}
-StepGroup_error_requiredStep=Required Step:\n\t{0}
-StepGroup_error_referencedBaseGroup=Referenced Base Step Group:\n\t{0}
-StepGroup_error_referencedStepOrGroup=Referenced Step or Step Group:\n\t{0}
-StepGroup_error_requiredStepOrGroup=Required Step or Step Group:\n\t{0}
-
-StepExecutor_checkPoint_normalizationNeeded=Step finished with this
-StepExecutor_info_stepFailed=Step finished with this information: {0}\n\n\
-Context: {1}\n\{2}\n\
-Step: {3}
-StepExecutor_warning_stepFailed=Step finished with this warning: {0}\n\n\
-Context: {1}\n\{2}\n\
-Step: {3}
-StepExecutor_error_stepFailed=Step finished with this error: {0}\n\n\
-Context: {1}\n\{2}\n\
-Step: {3}
-StepExecutor_stepFailed_debugInfo=Debug info:\n{0}
+#
+# org.eclipse.tcf.te.runtime.stepper
+# Externalized Strings.
+#
+
+AbstractStep_error_missingRequiredAttribute=Required attribute "{0}" missing for extension "{1}"!
+AbstractStep_warning_stepFinishedWithWarnings=Step ''{0}'' finished with warnings.
+
+Stepper_error_stepGroup=Step group:\n\t{0}
+Stepper_error_step=Step:\n\t{0}
+Stepper_error_referencedBaseGroup=Referenced Base Step Group:\n\t{0}
+Stepper_error_referencedStepOrGroup=Referenced Step or Step Group:\n\t{0}
+Stepper_error_requiredStepOrGroup=Required Step or Step Group:\n\t{0}
+Stepper_error_requiredStep=Required Step:\n\t{0}
+Stepper_error_initializeNotCalled=initialize(...) must be called before execute()!
+Stepper_error_missingStepGroupId=Execution failed. Missing step group id for ''{0}''.
+Stepper_error_missingStepGroup=Execution failed. Missing step group for id ''{0}''.
+Stepper_error_missingSteps=Execution failed. No steps enabled for ''{0}''.
+Stepper_multiStatus_finishedWithWarnings=''{0}'' completed with warnings or information.
+Stepper_multiStatus_finishedWithErrors=''{0}'' failed.
+Stepper_error_missingRequiredStep=Step execution failed. Required step or step group does not exist.\n\n{0}\n{1}\n\n{2}
+Stepper_error_requiredStepNotExecuted=Step execution failed. Required step or step group not executed before.\n\n{0}\n{1}\n\n{2}
+
+StepGroup_error_missingBaseStepGroup=Cannot determine steps for execution. Referenced base step group does not exist.\n\n{0}\n{1}\n\n{2}
+StepGroup_error_missingReferencedStep=Cannot determine steps for execution. Referenced step or step group does not exist.\n\n{0}\n{1}\n\n{2}
+StepGroup_error_missingRequiredStep=Invalid step. Required step or step group does not exist.\n\n{0}\n{1}\n\n{2}
+StepGroup_error_invalidRequiredStep=Invalid step. Required step is invalid.\n\n{0}\n{1}\n\n{2}
+StepGroup_error_multipleSingletonOccurrences=Cannot determine steps for execution. Only one reference allowed.\n\n{0}\n{1}\n\n{2}
+StepGroup_error_step=Step:\n\t{0}
+StepGroup_error_stepGroup=Step group:\n\t{0}
+StepGroup_error_requiredStep=Required Step:\n\t{0}
+StepGroup_error_referencedBaseGroup=Referenced Base Step Group:\n\t{0}
+StepGroup_error_referencedStepOrGroup=Referenced Step or Step Group:\n\t{0}
+StepGroup_error_requiredStepOrGroup=Required Step or Step Group:\n\t{0}
+
+StepExecutor_checkPoint_normalizationNeeded=Step finished with this
+StepExecutor_info_stepFailed=Step finished with this information: {0}\n\n\
+Context: {1}\n\{2}\n\
+Step: {3}
+StepExecutor_warning_stepFailed=Step finished with this warning: {0}\n\n\
+Context: {1}\n\{2}\n\
+Step: {3}
+StepExecutor_error_stepFailed=Step finished with this error: {0}\n\n\
+Context: {1}\n\{2}\n\
+Step: {3}
+StepExecutor_stepFailed_debugInfo=Debug info:\n{0}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/MultiContextStepper.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/MultiContextStepper.java
deleted file mode 100644
index 43ee484a9..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/MultiContextStepper.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * 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.util.ArrayList;
-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.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IContextManipulator;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-
-/**
- * A stepper implementation capable of handling multiple contexts.
- * <p>
- * The multi context stepper will sequential loop all configured contexts and invoke a single
- * context stepper for each context.
- */
-public class MultiContextStepper extends SingleContextStepper {
-
- private List<IStepper> steppers = new ArrayList<IStepper>();
-
- public static final String CONTEXT_COUNT = "contextCount"; //$NON-NLS-1$
- public static final String CONTEXT_INDEX = "contextIndex"; //$NON-NLS-1$
-
- /**
- * Constructor.
- */
- public MultiContextStepper() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.extensions.AbstractStepper#onInitialize(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected void onInitialize(IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) {
- super.onInitialize(data, fullQualifiedId, monitor);
-
- IStepContext[] contexts = getContexts();
- for (IStepContext context : contexts) {
- if (context == null) continue;
-
- // Get the stepper to be used for this context object
- IStepper stepper = getStepper(context);
- Assert.isNotNull(stepper);
-
- // Build up a new fully qualified id
- IFullQualifiedId id = fullQualifiedId.createChildId(ID_TYPE_STEPPER_ID,
- (stepper.getId() != null ? stepper.getId() : "org.eclipse.tcf.te.runtime.stepper.singleContext"), //$NON-NLS-1$
- "" + steppers.size()); //$NON-NLS-1$
-
- // Initialize the stepper
- stepper.initialize(data, id, monitor);
-
- // Associate the context and context id with the calculated id
- StepperAttributeUtil.setProperty(IContextManipulator.CONTEXT, id, data, context);
- StepperAttributeUtil.setProperty(IContextManipulator.CONTEXT_ID, id, data, context.getId());
-
- // Add the stepper to the list
- steppers.add(stepper);
- }
- data.setProperty("MULTI_CONTEXT", Boolean.toString(steppers.size() > 1)); //$NON-NLS-1$
- }
-
- /**
- * Returns the stepper to be used for the given target context.
- * <p>
- * <b>Note:</b> The default implementation does always return a new single context stepper
- * instance.
- *
- * @param context The context. Must not be <code>null</code>.
- * @return The stepper instance.
- */
- protected IStepper getStepper(IStepContext context) {
- Assert.isNotNull(context);
- return new SingleContextStepper();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.extensions.AbstractStepper#internalExecute(java.util.List)
- */
- @Override
- protected void internalExecute(List<IStatus> statusContainer) throws CoreException {
- int i = 0;
- StepperAttributeUtil.setProperty(CONTEXT_COUNT, null, getData(), steppers.size());
- for (IStepper stepper : steppers) {
- StepperAttributeUtil.setProperty(CONTEXT_INDEX, null, getData(), i++);
- try {
- stepper.execute();
- }
- catch (CoreException e) {
- if (isCancelable() && getMonitor() != null && getMonitor().isCanceled()) {
- throw e;
- }
- statusContainer.add(e.getStatus());
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.extensions.AbstractStepper#cleanup()
- */
- @Override
- public void cleanup() {
- super.cleanup();
-
- for (IStepper stepper : steppers) {
- stepper.cleanup();
- }
- steppers.clear();
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/SingleContextStepper.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/SingleContextStepper.java
deleted file mode 100644
index bed7b8456..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/SingleContextStepper.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * 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 org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-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.AbstractStepper;
-import org.eclipse.tcf.te.runtime.stepper.extensions.StepExecutor;
-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.IStepperProperties;
-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.IStepExecutor;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.tracing.ITraceIds;
-
-/**
- * A single context stepper implementation.
- * <p>
- * The single context stepper implementation applies following assumptions:
- * <ul>
- * <li>The step group to execute needs to be passed to the stepper via the properties container
- * given by the {@link #onInitialize(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)}
- * call.</li>
- * <li>The stepper executes single steps through {@link DefaultStepExecutor}.
- * <li>The stepper stops the step group execution if the progress monitor is set to canceled
- * or a status with severity {@link IStatus#CANCEL} is thrown by a single step.
- * <li>The stepper stops the step group execution on first error.</li>
- * <li>The stepper collect warnings and information thrown by the single steps till the
- * end of the step group execution. Warnings and information are not stopping the execution.</li>
- * <li>The stepper ignores any status thrown by the single steps with severity {@link IStatus#OK}.</li>
- * <li>A single stepper instance can execute only one step group at a time.</li>
- * </ul>
- * <p>
- * The stepper implementation can be traced and profiled by setting the debug options:
- * <ul>
- * <li><i>org.eclipse.tcf.te.runtime.stepper/trace/stepping</i></li>
- * <li><i>org.eclipse.tcf.te.runtime.stepper/profile/stepping</i></li>
- * </ul>
- */
-public class SingleContextStepper extends AbstractStepper {
-
- /**
- * Constructor.
- */
- public SingleContextStepper() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.extensions.AbstractStepper#getName()
- */
- @Override
- protected String getName() {
- return getData() != null ? getData().getStringProperty(IStepperProperties.PROP_NAME) : null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.extensions.AbstractStepper#getContexts()
- */
- @Override
- protected IStepContext[] getContexts() {
- return getData() != null && getData().getProperty(IStepperProperties.PROP_CONTEXTS) != null ? (IStepContext[])getData().getProperty(IStepperProperties.PROP_CONTEXTS) : new IStepContext[0];
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.extensions.AbstractStepper#getStepGroupId()
- */
- @Override
- protected String getStepGroupId() {
- return getData() != null ? getData().getStringProperty(IStepperProperties.PROP_STEP_GROUP_ID) : null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.extensions.AbstractStepper#getStepGroup(java.lang.String)
- */
- @Override
- 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);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.extensions.AbstractStepper#doCreateStepExecutor(org.eclipse.tcf.te.runtime.stepper.interfaces.IStep, java.lang.String, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId)
- */
- @Override
- protected IStepExecutor doCreateStepExecutor(IStep step, String secondaryId, IFullQualifiedId fullQualifiedStepId) {
- Assert.isNotNull(step);
- Assert.isNotNull(secondaryId);
- Assert.isNotNull(fullQualifiedStepId);
- return new StepExecutor();
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/AbstractStepper.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java
index 21383ba00..846b9ad6c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/extensions/AbstractStepper.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java
@@ -7,7 +7,7 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.runtime.stepper.extensions;
+package org.eclipse.tcf.te.runtime.stepper.stepper;
import java.text.MessageFormat;
import java.util.ArrayList;
@@ -28,18 +28,19 @@ 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.StepperAttributeUtil;
+import org.eclipse.tcf.te.runtime.stepper.StepperManager;
import org.eclipse.tcf.te.runtime.stepper.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IContextManipulator;
-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.IStepper;
+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;
@@ -48,15 +49,14 @@ import org.eclipse.tcf.te.runtime.utils.StatusHelper;
/**
* An abstract stepper implementation.
*/
-public abstract class AbstractStepper extends ExecutableExtension implements IStepper, IContextManipulator {
+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 String activeContextId = null;
- private IStepContext activeContext = null;
+ private IStepContext context = null;
private boolean cancelable = true;
/**
@@ -75,7 +75,7 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
/**
* Constructor.
*/
- public AbstractStepper() {
+ public Stepper() {
super();
}
@@ -84,14 +84,34 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
*
* @return A name.
*/
- protected abstract String getName();
+ 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 contexts the stepper is associated with.
+ * Returns the step group for the given step group id.
*
- * @return An array of context objects or an empty list.
+ * @param The step group id. Must not be <code>null</code>:
+ * @return The step group or <code>null</code>.
*/
- protected abstract IStepContext[] getContexts();
+ 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.
@@ -102,28 +122,18 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
*
* @return The step executor instance.
*/
- protected abstract IStepExecutor doCreateStepExecutor(IStep step, String secondaryId, IFullQualifiedId fullQualifiedStepId);
-
- /**
- * Returns the id of the step group to execute by the stepper.
- *
- * @return The step group id.
- */
- protected abstract String getStepGroupId();
-
- /**
- * 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 abstract IStepGroup getStepGroup(String id);
+ 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(IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws IllegalStateException {
+ 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);
@@ -134,6 +144,7 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
}
// set the initial stepper attributes
+ this.context = context;
this.data = data;
this.monitor = monitor;
this.fullQualifiedId = fullQualifiedId;
@@ -141,18 +152,14 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
// but not finished yet
this.finished = false;
- // set the initial stepper attributes
- this.activeContext = null;
- this.activeContextId = null;
-
// call the hook for the subclasses to initialize themselves
onInitialize(data, fullQualifiedId, monitor);
setInitialized();
- CoreBundleActivator.getTraceHandler().trace("AbstractStepper#initialize:" //$NON-NLS-1$
- + " data = " + data, //$NON-NLS-1$
- 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
+ CoreBundleActivator.getTraceHandler().trace("Stepper#initialize:" //$NON-NLS-1$
+ + " data = " + data, //$NON-NLS-1$
+ 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
}
/**
@@ -179,7 +186,7 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
* @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#isInitialized()
*/
@Override
- public final boolean isInitialized() {
+ public final boolean isInitialized() {
return initialized;
}
@@ -202,77 +209,21 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
}
/**
- * Sets the active context.
- *
- * @param context The active context or <code>null</code>.
- */
- protected final void setActiveContext(IStepContext context) {
- // do not use equals() here!!!
- if (activeContext != context) {
- if (activeContext instanceof IPropertiesContainer) {
- ((IPropertiesContainer)activeContext).setProperty("stepperContext::" + getId(), null); //$NON-NLS-1$
- }
- activeContext = context;
- if (activeContext instanceof IPropertiesContainer) {
- ((IPropertiesContainer)activeContext).setProperty("stepperContext::" + getId(), true); //$NON-NLS-1$
- }
- }
- }
-
- /**
* Get the active context.
*
* @return The active context or <code>null</code>.
*/
- protected IStepContext getActiveContext() {
- if (isInitialized() && activeContext == null) {
- IStepContext newContext = (IStepContext)StepperAttributeUtil.getProperty(IContextManipulator.CONTEXT, getFullQualifiedId(), getData());
- if (newContext != null) {
- setActiveContext(newContext);
- }
- if (activeContext == null) {
- IStepContext[] contexts = getContexts();
- if (contexts != null && contexts.length > 0) {
- for (IStepContext context : contexts) {
- setActiveContext(context);
- StepperAttributeUtil.setProperty(IContextManipulator.CONTEXT, getFullQualifiedId(), getData(), activeContext);
- break;
- }
- }
- }
- }
- return activeContext;
- }
-
- /**
- * Sets the active context id.
- *
- * @param contextId The active context id or <code>null</code>.
- */
- protected final void setActiveContextId(String contextId) {
- activeContextId = contextId;
+ protected IStepContext getContext() {
+ return context;
}
/**
- * Get the active context id.
+ * Get the context id.
*
- * @return The active context id or <code>null</code>.
+ * @return The context id or <code>null</code>.
*/
- protected String getActiveContextId() {
- if (isInitialized() && activeContextId == null) {
- String newContextId = (String)StepperAttributeUtil.getProperty(IContextManipulator.CONTEXT_ID, getFullQualifiedId(), getData());
- if (newContextId != null && newContextId.trim().length() > 0) {
- activeContextId = newContextId.trim();
- }
- if (activeContextId == null) {
- IStepContext context = getActiveContext();
- if (context != null) {
- activeContextId = context.getId();
- StepperAttributeUtil.setProperty(IContextManipulator.CONTEXT_ID, getFullQualifiedId(), getData(), activeContextId);
- }
- }
- }
- return activeContextId;
+ protected String getContextId() {
+ return context != null ? context.getId() : null;
}
/**
@@ -309,16 +260,13 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
*/
protected final void setFinished() {
finished = true;
- if (activeContext instanceof IPropertiesContainer) {
- ((IPropertiesContainer)activeContext).setProperty("stepperContext::" + getId(), null); //$NON-NLS-1$
- }
}
/* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#isFinished()
*/
@Override
- public final boolean isFinished() {
+ public final boolean isFinished() {
return finished;
}
@@ -326,20 +274,19 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
* @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#cleanup()
*/
@Override
- public void cleanup() {
+ public void cleanup() {
// Set the progress monitor done here in any case
- if (getMonitor() != null) getMonitor().done();
+ if (getMonitor() != null) {
+ getMonitor().done();
+ }
// Reset the initial stepper attributes
+ context = null;
data = null;
monitor = null;
fullQualifiedId = null;
finished = false;
initialized = false;
-
- // Reset the initial stepper attributes
- setActiveContext(null);
- setActiveContextId(null);
}
/* (non-Javadoc)
@@ -358,20 +305,20 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
* @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper#execute()
*/
@Override
- public final void execute() throws CoreException {
+ public final void execute() throws CoreException {
long startTime = System.currentTimeMillis();
- CoreBundleActivator.getTraceHandler().trace("AbstractStepper#execute: *** ENTERED", //$NON-NLS-1$
- 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
+ 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);
+ + " ***", //$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.AbstractStepper_error_initializeNotCalled));
+ Messages.Stepper_error_initializeNotCalled));
}
// Create a container for collecting the non-severe status objects
@@ -391,8 +338,8 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
// Check if we need a multi status
if (statusContainer.size() > 1) {
MultiStatus multiStatus =
- new MultiStatus(CoreBundleActivator.getUniqueIdentifier(), 0,
- NLS.bind(Messages.AbstractStepper_multiStatus_finishedWithWarnings, getName()), null);
+ new MultiStatus(CoreBundleActivator.getUniqueIdentifier(), 0,
+ NLS.bind(Messages.Stepper_multiStatus_finishedWithWarnings, getName()), null);
for (IStatus subStatus : statusContainer) {
multiStatus.merge(subStatus);
}
@@ -410,12 +357,12 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
setFinished();
long endTime = System.currentTimeMillis();
- CoreBundleActivator.getTraceHandler().trace("AbstractStepper#execute: *** DONE", //$NON-NLS-1$
- 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
+ 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);
+ + " , delay = " + (endTime - startTime) + " ms]" //$NON-NLS-1$ //$NON-NLS-2$
+ + " ***", //$NON-NLS-1$
+ 0, ITraceIds.PROFILE_STEPPING, IStatus.WARNING, this);
}
}
@@ -434,7 +381,7 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
// 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.AbstractStepper_error_missingStepGroupId, getName())));
+ NLS.bind(Messages.Stepper_error_missingStepGroupId, getName())));
}
// Get the step group
@@ -443,13 +390,13 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
// 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.AbstractStepper_error_missingStepGroup, stepGroupId)));
+ 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, getActiveContextId(), null);
+ 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);
@@ -477,46 +424,32 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
throw new CoreException(StatusHelper.getStatus(new OperationCanceledException()));
}
- CoreBundleActivator.getTraceHandler().trace("AbstractStepper#executeStepGroup: step group: '" + stepGroup.getLabel() + "'", //$NON-NLS-1$ //$NON-NLS-2$
- 0, ITraceIds.TRACE_STEPPING, IStatus.WARNING, this);
+ 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(getContexts());
+ IStepGroupable[] groupables = stepGroup.getSteps(getContext());
IStepGroupIterator iterator = stepGroup.getStepGroupIterator();
IFullQualifiedId fullQualifiedIterationId = fullQualifiedGroupId;
int iteration = 0;
if (iterator != null) {
- iterator.initialize(getActiveContext(), getData(), fullQualifiedGroupId, getMonitor());
+ iterator.initialize(getContext(), getData(), fullQualifiedGroupId, getMonitor());
}
- boolean next = iterator == null || iterator.hasNext(getActiveContext(), 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(getActiveContext(), getData(), fullQualifiedIterationId, getMonitor());
- // set the active context if the step has manipulated it
- if (iterator instanceof IContextManipulator) {
- IStepContext newContext =
- (IStepContext)StepperAttributeUtil.getProperty(IContextManipulator.CONTEXT, fullQualifiedIterationId, getData());
- String newContextId =
- StepperAttributeUtil.getStringProperty(IContextManipulator.CONTEXT_ID, fullQualifiedIterationId, getData());
- if (newContext != null) {
- setActiveContext(newContext);
- }
- if (newContextId != null &&
- newContextId.trim().length() > 0) {
- setActiveContextId(newContextId.trim());
- }
- }
+ 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(getActiveContext(), getData(), fullQualifiedGroupId, getMonitor());
+ next = iterator != null && iterator.hasNext(getContext(), getData(), fullQualifiedGroupId, getMonitor());
}
}
@@ -545,9 +478,9 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
// If the passed in groupable is disabled -> we are done immediately
if (groupable.isDisabled()) {
- CoreBundleActivator.getTraceHandler().trace("AbstractStepper#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);
+ 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;
}
@@ -575,19 +508,7 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
try {
executedSteps.add(new ExecutedContextStep(id, step));
// Invoke the executor now
- executor.execute(step, id, getActiveContext(), getData(), getMonitor());
- // set the active context if the step has manipulated it
- if (step instanceof IContextManipulator) {
- IStepContext newContext = (IStepContext)StepperAttributeUtil.getProperty(IContextManipulator.CONTEXT, id, getData());
- String newContextId = StepperAttributeUtil.getStringProperty(IContextManipulator.CONTEXT_ID, id, getData());
- if (newContext != null) {
- setActiveContext(newContext);
- }
- if (newContextId != null &&
- newContextId.trim().length() > 0) {
- setActiveContextId(newContextId.trim());
- }
- }
+ executor.execute(step, id, getContext(), getData(), getMonitor());
}
catch (Exception e) {
// Catch the CoreException first hand as we need to continue the
@@ -647,11 +568,9 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
if (!requiredStepExecuted) {
throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- MessageFormat.format(Messages.AbstractStepper_error_requiredStepNotExecuted,
- NLS.bind((groupable.getExtension() instanceof IStep
- ? Messages.AbstractStepper_error_step
- : Messages.AbstractStepper_error_requiredStepOrGroup), dependency)
- )));
+ 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
@@ -683,7 +602,7 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
ExecutedContextStep executedStep = executedSteps.remove(executedSteps.size()-1);
if (executedStep.step instanceof IExtendedStep) {
IExtendedStep step = (IExtendedStep)executedStep.step;
- step.rollback(getActiveContext(), getData(), rollBackStatus, executedStep.id, rollbackProgress, this);
+ step.rollback(getContext(), getData(), rollBackStatus, executedStep.id, rollbackProgress, this);
}
else {
this.done(this, status);
@@ -716,20 +635,20 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
int totalWork = 0;
// Loop the group steps and summarize the returned total work
- IStepGroupable[] groupables = stepGroup.getSteps(getContexts());
+ IStepGroupable[] groupables = stepGroup.getSteps(getContext());
for (IStepGroupable groupable : groupables) {
int work = groupable.getExtension() instanceof IStep
- ? ((IStep)groupable.getExtension()).getTotalWork(getActiveContext(), getData())
- : groupable.getExtension() instanceof IStepGroup
- ? calculateTotalWork((IStepGroup)groupable.getExtension())
- : IProgressMonitor.UNKNOWN;
-
- if (work == IProgressMonitor.UNKNOWN) {
- totalWork = IProgressMonitor.UNKNOWN;
- break;
- }
+ ? ((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;
+ totalWork += work;
}
return totalWork;
@@ -804,7 +723,7 @@ public abstract class AbstractStepper extends ExecutableExtension implements ISt
// a new MultiStatus.
if (!statusContainer.isEmpty()) {
MultiStatus multiStatus = new MultiStatus(status.getPlugin(), status.getCode(),
- NLS.bind(Messages.AbstractStepper_multiStatus_finishedWithErrors, getName()), null);
+ NLS.bind(Messages.Stepper_multiStatus_finishedWithErrors, getName()), null);
for (IStatus stat : statusContainer) {
multiStatus.merge(stat);
}

Back to the top