Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF75
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.properties28
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml26
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchConfigTypeBindings.exsd28
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java701
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java700
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/PropertyTester.java40
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java651
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ICommonLaunchAttributes.java165
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/IContextSelectorLaunchAttributes.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/ContextSelectorPersistenceDelegate.java1099
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/steps/AbstractLaunchStep.java46
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/steps/RemoveLaunchStep.java45
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/selector/ContextSelectorSection.java61
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IPersistable2.java53
-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
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF57
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.properties41
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml85
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AdapterFactory.java74
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/StepContextAdapter.java222
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AbstractTcfLaunchStep.java32
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/CloseChannelStep.java49
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/OpenChannelStep.java61
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml137
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerModelPersistableAdapter.java170
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/nodes/InvalidPeerModel.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/plugin.xml12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/StepperTestCase.java56
50 files changed, 4360 insertions, 4733 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF
index 81f5a00f6..694deca1b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF
@@ -1,36 +1,39 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.tcf.te.launch.core;singleton:=true
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator
-Bundle-Vendor: %providerName
-Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
- org.eclipse.core.expressions;bundle-version="3.4.300",
- org.eclipse.debug.core;bundle-version="3.7.0",
- org.eclipse.tcf.te.runtime;bundle-version="1.0.0",
- org.eclipse.tcf.te.runtime.concurrent;bundle-version="1.0.0",
- org.eclipse.tcf.te.runtime.model;bundle-version="1.0.0",
- org.eclipse.tcf.te.runtime.statushandler;bundle-version="1.0.0",
- org.eclipse.tcf.te.runtime.stepper;bundle-version="1.0.0"
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Bundle-ActivationPolicy: lazy
-Bundle-Localization: plugin
-Export-Package: org.eclipse.tcf.te.launch.core.activator;x-internal:=true,
- org.eclipse.tcf.te.launch.core.adapters.internal;x-internal:=true,
- org.eclipse.tcf.te.launch.core.bindings,
- org.eclipse.tcf.te.launch.core.bindings.interfaces,
- org.eclipse.tcf.te.launch.core.bindings.internal;x-friends:="org.eclipse.tcf.te.launch.ui",
- org.eclipse.tcf.te.launch.core.delegates,
- org.eclipse.tcf.te.launch.core.exceptions,
- org.eclipse.tcf.te.launch.core.extensions.internal;x-internal:=true,
- org.eclipse.tcf.te.launch.core.interfaces.tracing,
- org.eclipse.tcf.te.launch.core.lm,
- org.eclipse.tcf.te.launch.core.lm.delegates,
- org.eclipse.tcf.te.launch.core.lm.interfaces,
- org.eclipse.tcf.te.launch.core.lm.internal;x-internal:=true,
- org.eclipse.tcf.te.launch.core.nls;x-internal:=true,
- org.eclipse.tcf.te.launch.core.persistence,
- org.eclipse.tcf.te.launch.core.preferences,
- org.eclipse.tcf.te.launch.core.selection,
- org.eclipse.tcf.te.launch.core.selection.interfaces
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.tcf.te.launch.core;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator
+Bundle-Vendor: %providerName
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
+ org.eclipse.core.expressions;bundle-version="3.4.300",
+ org.eclipse.debug.core;bundle-version="3.7.0",
+ org.eclipse.tcf.te.runtime;bundle-version="1.0.0",
+ org.eclipse.tcf.te.runtime.concurrent;bundle-version="1.0.0",
+ org.eclipse.tcf.te.runtime.model;bundle-version="1.0.0",
+ org.eclipse.tcf.te.runtime.statushandler;bundle-version="1.0.0",
+ org.eclipse.tcf.te.runtime.stepper;bundle-version="1.0.0",
+ org.eclipse.tcf.te.runtime.persistence;bundle-version="1.0.0",
+ org.eclipse.tcf.te.runtime.services;bundle-version="1.0.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Export-Package: org.eclipse.tcf.te.launch.core.activator;x-internal:=true,
+ org.eclipse.tcf.te.launch.core.adapters.internal;x-internal:=true,
+ org.eclipse.tcf.te.launch.core.bindings,
+ org.eclipse.tcf.te.launch.core.bindings.interfaces,
+ org.eclipse.tcf.te.launch.core.bindings.internal;x-friends:="org.eclipse.tcf.te.launch.ui",
+ org.eclipse.tcf.te.launch.core.delegates,
+ org.eclipse.tcf.te.launch.core.exceptions,
+ org.eclipse.tcf.te.launch.core.extensions.internal;x-internal:=true,
+ org.eclipse.tcf.te.launch.core.interfaces.tracing,
+ org.eclipse.tcf.te.launch.core.lm,
+ org.eclipse.tcf.te.launch.core.lm.delegates,
+ org.eclipse.tcf.te.launch.core.lm.interfaces,
+ org.eclipse.tcf.te.launch.core.lm.internal;x-internal:=true,
+ org.eclipse.tcf.te.launch.core.nls;x-internal:=true,
+ org.eclipse.tcf.te.launch.core.persistence,
+ org.eclipse.tcf.te.launch.core.preferences,
+ org.eclipse.tcf.te.launch.core.selection,
+ org.eclipse.tcf.te.launch.core.selection.interfaces,
+ org.eclipse.tcf.te.launch.core.steps
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.properties
index a3934d8d4..a2c59bb53 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.properties
@@ -1,12 +1,16 @@
-##################################################################################
-# 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
-##################################################################################
-
-pluginName = Target Explorer, Launching, Core
-providerName = Eclipse.org - TCF
+##################################################################################
+# 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
+##################################################################################
+
+pluginName = Target Explorer, Launching, Core
+providerName = Eclipse.org - TCF
+
+Extension.LaunchConfigTypeBindings.name=Launch Configuration Type Bindings
+Extension.LaunchManagerDelegates.name=Launch Manager Delegates
+Extension.LaunchModeVariantDelegates.name=Launch Mode Variant Delegates
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
index 73209e33b..72bf67db3 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
@@ -3,9 +3,9 @@
<plugin>
<!-- Extension points -->
- <extension-point id="launchConfigTypeBindings" name="Launch Configuration Type Bindings" schema="schema/launchConfigTypeBindings.exsd"/>
- <extension-point id="launchManagerDelegates" name="Launch Manager Delegates" schema="schema/launchManagerDelegates.exsd"/>
- <extension-point id="launchModeVariantDelegates" name="Launch Mode Variant Delegates" schema="schema/launchModeVariantDelegates.exsd"/>
+ <extension-point id="launchConfigTypeBindings" name="%Extension.LaunchConfigTypeBindings.name" schema="schema/launchConfigTypeBindings.exsd"/>
+ <extension-point id="launchManagerDelegates" name="%Extension.LaunchManagerDelegates.name" schema="schema/launchManagerDelegates.exsd"/>
+ <extension-point id="launchModeVariantDelegates" name="%Extension.LaunchModeVariantDelegates.name" schema="schema/launchModeVariantDelegates.exsd"/>
<!-- Adapter factory contributions -->
<extension point="org.eclipse.core.runtime.adapters">
@@ -24,4 +24,24 @@
</initializer>
</extension>
+<!-- Property tester contributions -->
+ <extension point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.tcf.te.launch.core.bindings.internal.PropertyTester"
+ id="org.eclipse.tcf.te.launch.core.PropertyTester"
+ namespace="org.eclipse.tcf.te.launch.core"
+ properties="launchMode,launchConfigTypeId"
+ type="org.eclipse.debug.core.ILaunch">
+ </propertyTester>
+ </extension>
+
+<!-- Launch Step contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.stepper.steps">
+ <step
+ class="org.eclipse.tcf.te.launch.core.steps.RemoveLaunchStep"
+ id="org.eclipse.tcf.te.launch.core.removeLaunchStep"
+ label="%LaunchStep.RemoveLaunch.name">
+ </step>
+ </extension>
+
</plugin>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchConfigTypeBindings.exsd b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchConfigTypeBindings.exsd
index e2f9cbf94..eb9008325 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchConfigTypeBindings.exsd
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/schema/launchConfigTypeBindings.exsd
@@ -60,7 +60,6 @@
<element ref="launchManagerDelegate" minOccurs="0" maxOccurs="unbounded"/>
<element ref="launchModeVariantDelegate" minOccurs="0" maxOccurs="unbounded"/>
<element ref="stepper" minOccurs="0" maxOccurs="unbounded"/>
- <element ref="step" minOccurs="0" maxOccurs="unbounded"/>
<element ref="stepGroup" minOccurs="0" maxOccurs="unbounded"/>
<element ref="enablement" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
@@ -179,33 +178,6 @@
</complexType>
</element>
- <element name="step">
- <annotation>
- <documentation>
- A step could be bound to a launch configuration type for each available launch mode. If no launch mode is specified, the step is used for all launch modes the launch configuration type supports.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- The id of the step to use.
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.tcf.te.runtime.stepper.steps/step/@id"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="modes" type="string">
- <annotation>
- <documentation>
- The comma separated list of launch modes to use the step for. If not specified, the step is used for all undefined launch modes, for which the launch configuration type can be used.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
<element name="stepGroup">
<annotation>
<documentation>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java
index 31a95d8c5..1ed089acf 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java
@@ -1,369 +1,332 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.launch.core.bindings;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Set;
-
-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.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.tcf.te.launch.core.bindings.internal.LaunchBinding;
-import org.eclipse.tcf.te.launch.core.bindings.internal.LaunchConfigTypeBinding;
-import org.eclipse.tcf.te.launch.core.bindings.internal.OverwritableLaunchBinding;
-import org.eclipse.tcf.te.launch.core.extensions.internal.LaunchModeVariantDelegateExtensionPointManager;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate;
-import org.eclipse.tcf.te.launch.core.lm.internal.ExtensionPointManager;
-import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
-import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
-import org.eclipse.tcf.te.runtime.extensions.ExtensionPointComparator;
-import org.eclipse.tcf.te.runtime.stepper.StepperManager;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStep;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IVariantDelegate;
-
-
-/**
- * Manager that controls the launch configuration type bindings.
- */
-public class LaunchConfigTypeBindingsManager {
- // Map of all launch configuration type bindings by id
- private final Map<String, LaunchConfigTypeBinding> bindings = new Hashtable<String, LaunchConfigTypeBinding>();
-
- /*
- * Thread save singleton instance creation.
- */
- private static class LazyInstanceHolder {
- public static LaunchConfigTypeBindingsManager instance = new LaunchConfigTypeBindingsManager();
- }
-
- /**
- * Returns the singleton instance.
- */
- public static LaunchConfigTypeBindingsManager getInstance() {
- return LazyInstanceHolder.instance;
- }
-
- /**
- * Constructor.
- */
- LaunchConfigTypeBindingsManager() {
- // Load the launch configuration type bindings on instantiation.
- loadBindingsExtensions();
- }
-
- /**
- * Get all valid launch configuration type id's for the given selection.
- *
- * @param selection The selection or <code>null</code>.
- * @return The list of valid launch configuration type id's for the selection or an empty list.
- */
- public String[] getValidLaunchConfigTypes(ILaunchSelection selection) {
- Set<String> validLaunchTypes = new HashSet<String>();
- if (selection != null && selection.getSelectedContexts() != null && selection.getSelectedContexts().length > 0) {
- for (String launchConfigTypeId : bindings.keySet()) {
- if (isValidLaunchConfigType(launchConfigTypeId, selection)) {
- validLaunchTypes.add(launchConfigTypeId);
- }
- }
- }
- return validLaunchTypes.toArray(new String[validLaunchTypes.size()]);
- }
-
- /**
- * Validates the given launch selection.
- *
- * @param typeId The launch configuration type id. Must not be <code>null</code>.
- * @param selection The selection. Must not be <code>null</code>.
- */
- public boolean isValidLaunchConfigType(String typeId, ILaunchSelection selection) {
- Assert.isNotNull(typeId);
- Assert.isNotNull(selection);
-
- LaunchConfigTypeBinding binding = bindings.get(typeId);
- ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(typeId);
- return (launchConfigType != null && launchConfigType.isPublic() &&
- (selection.getLaunchMode() == null || launchConfigType.supportsMode(selection.getLaunchMode())) &&
- binding != null && binding.validate(selection) != EvaluationResult.FALSE);
- }
-
- /**
- * Validates the given launch selection.
- *
- * @param typeId The launch configuration type id. Must not be <code>null</code>.
- * @param mode The launch mode or <code>null</code>.
- * @param context The selection context. Must not be <code>null</code>.
- */
- public boolean isValidLaunchConfigType(String typeId, String mode, ISelectionContext context) {
- Assert.isNotNull(typeId);
- Assert.isNotNull(context);
-
- LaunchConfigTypeBinding binding = bindings.get(typeId);
- ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(typeId);
- return (launchConfigType != null && launchConfigType.isPublic() &&
- (mode == null || launchConfigType.supportsMode(mode)) &&
- binding != null && binding.validate(mode, context) != EvaluationResult.FALSE);
- }
-
- /**
- * Get the registered launch manager delegate for the given launch configuration type and launch mode.
- *
- * @param typeId The launch configuration type id. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
- *
- * @return The launch manager delegate, or a default delegate if no delegate is registered for the
- * given launch configuration type id and launch mode.
- */
- public ILaunchManagerDelegate getLaunchManagerDelegate(String typeId, String mode) {
- Assert.isNotNull(typeId);
- Assert.isNotNull(mode);
-
- LaunchConfigTypeBinding binding = bindings.get(typeId);
- if (binding != null) {
- String id = binding.getLaunchManagerDelegate(mode);
- if (id != null) {
- return ExtensionPointManager.getInstance().getLaunchManagerDelegate(id);
- }
- }
- return ExtensionPointManager.getInstance().getDefaultLaunchManagerDelegate();
- }
-
- /**
- * Get the registered launch mode variant delegate for the given launch configuration type and launch mode.
- *
- * @param typeId The launch configuration type id. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
- *
- * @return The launch mode variant delegate, or a <code>null</code> if no delegate is registered for the
- * given launch configuration type id and launch mode.
- */
- public IVariantDelegate getLaunchModeVariantDelegate(String typeId, String mode) {
- Assert.isNotNull(typeId);
- Assert.isNotNull(mode);
-
- LaunchConfigTypeBinding binding = bindings.get(typeId);
- if (binding != null) {
- String id = binding.getLaunchModeVariantDelegate(mode);
- if (id != null) {
- return LaunchModeVariantDelegateExtensionPointManager.getInstance().getLaunchModeVariantDelegate(id);
- }
- }
- return null;
- }
-
- /**
- * Get the registered stepper for the given launch configuration type id and launch mode.
- *
- * @param typeId The launch configuration type id. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
-
- * @return The stepper or <code>null</code> if no stepper is registered for the
- * given launch configuration type id and launch mode.
- */
- public IStepper getStepper(String typeId, String mode) {
- Assert.isNotNull(typeId);
- Assert.isNotNull(mode);
-
- IStepper stepper = null;
-
- LaunchConfigTypeBinding binding = bindings.get(typeId);
- if (binding != null) {
- String id = binding.getStepper(mode);
- if (id != null) {
- stepper = StepperManager.getInstance().getStepperExtManager().getStepper(id, false);
- }
- }
-
- return stepper;
- }
-
- /**
- * Get the registered step group for the given launch configuration type and launch mode.
- *
- * @param typeId The launch configuration type id. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
- * @param variant The launch mode variant or <code>null</code>.
- *
- * @return The launch step group or <code>null</code> if no step group is registered for the
- * given launch configuration type id and launch mode.
- */
- public IStepGroup getStepGroup(String typeId, String mode, String variant) {
- Assert.isNotNull(typeId);
- Assert.isNotNull(mode);
-
- LaunchConfigTypeBinding binding = bindings.get(typeId);
- if (binding != null) {
- String id = binding.getStepGroup(mode, variant);
- if (id != null) {
- return getStepGroup(id);
- }
- }
- return null;
- }
-
- /**
- * Get the registered step group identified by the specified unique id.
- *
- * @param id The step group id. Must not be <code>null</code>.
- * @return The step group or <code>null</code>, if no step group is registered for the specified id.
- */
- public IStepGroup getStepGroup(String id) {
- Assert.isNotNull(id);
- return StepperManager.getInstance().getStepGroupExtManager().getStepGroup(id, true);
- }
-
- /**
- * Get the registered step identified by the specified unique id.
- *
- * @param id The launch step id. Must not be <code>null</code>.
- * @return The launch step or <code>null</code> if no step is registered for the specified id.
- */
- public IStep getStep(String id) {
- Assert.isNotNull(id);
- return StepperManager.getInstance().getStepExtManager().getStep(id, true);
- }
-
- /**
- * Returns if or if not the given step id is valid for the given combination
- * of launch configuration type id and launch mode. A launch step is invalid if not
- * bound to the launch configuration type for the given launch mode.
- *
- * @param id The launch step id. Must not be <code>null</code>.
- * @param typeId The launch configuration type id. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
- *
- * @return <code>True</code> if the launch step id is valid, <code>false</code> otherwise.
- */
- public boolean isValidStep(String id, String typeId, String mode) {
- Assert.isNotNull(id);
- Assert.isNotNull(typeId);
- Assert.isNotNull(mode);
-
- LaunchConfigTypeBinding binding = bindings.get(typeId);
- if (binding != null) {
- String[] steps = binding.getSteps(mode);
- for (String stepId : steps) {
- if (id.equals(stepId)) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- /*
- * Load and register all launch configuration type bindings.
- */
- private void loadBindingsExtensions() {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint point = registry.getExtensionPoint("org.eclipse.tcf.te.launch.core.launchConfigTypeBindings"); //$NON-NLS-1$
- if (point != null) {
- IExtension[] bindings = point.getExtensions();
- Arrays.sort(bindings, new ExtensionPointComparator());
- for (IExtension binding : bindings) {
- IConfigurationElement[] elements = binding.getConfigurationElements();
- for (IConfigurationElement element : elements) {
- loadBinding(element);
- }
- }
- }
- }
-
- /**
- * Load a single launch configuration type binding.
- *
- * @param element The configuration element. Must not be <code>null</code>.
- */
- private void loadBinding(IConfigurationElement element) {
- Assert.isNotNull(element);
-
- if (!element.getName().equals("launchConfigTypeBinding")) { //$NON-NLS-1$
- return;
- }
-
- String launchConfigTypeId = element.getAttribute("launchConfigTypeId"); //$NON-NLS-1$
- if (!bindings.containsKey(launchConfigTypeId)) {
- bindings.put(launchConfigTypeId, new LaunchConfigTypeBinding(launchConfigTypeId));
- }
- LaunchConfigTypeBinding binding = bindings.get(launchConfigTypeId);
-
- IConfigurationElement[] lmDelegateBindings = element.getChildren("launchManagerDelegate"); //$NON-NLS-1$
- for (IConfigurationElement lmDelegateBinding : lmDelegateBindings) {
- String id = lmDelegateBinding.getAttribute("id"); //$NON-NLS-1$
- String overwrites = lmDelegateBinding.getAttribute("overwrites"); //$NON-NLS-1$
- String modes = lmDelegateBinding.getAttribute("modes"); //$NON-NLS-1$
-
- binding.addLaunchManagerDelegate(new OverwritableLaunchBinding(id, overwrites, modes));
- }
-
- IConfigurationElement[] launchModeVariantDelegateBindings = element.getChildren("launchModeVariantDelegate"); //$NON-NLS-1$
- for (IConfigurationElement launchModeVariantDelegateBinding : launchModeVariantDelegateBindings) {
- String id = launchModeVariantDelegateBinding.getAttribute("id"); //$NON-NLS-1$
- String overwrites = launchModeVariantDelegateBinding.getAttribute("overwrites"); //$NON-NLS-1$
- String modes = launchModeVariantDelegateBinding.getAttribute("modes"); //$NON-NLS-1$
-
- binding.addLaunchModeVariantDelegate(new OverwritableLaunchBinding(id, overwrites, modes));
- }
-
- IConfigurationElement[] stepperBindings = element.getChildren("stepper"); //$NON-NLS-1$
- for (IConfigurationElement stepperBinding : stepperBindings) {
- String id = stepperBinding.getAttribute("id"); //$NON-NLS-1$
- String overwrites = stepperBinding.getAttribute("overwrites"); //$NON-NLS-1$
- String modes = stepperBinding.getAttribute("modes"); //$NON-NLS-1$
-
- binding.addStepper(new OverwritableLaunchBinding(id, overwrites, modes));
- }
-
- IConfigurationElement[] stepBindings = element.getChildren("step"); //$NON-NLS-1$
- for (IConfigurationElement stepBinding : stepBindings) {
- String id = stepBinding.getAttribute("id"); //$NON-NLS-1$
- String modes = stepBinding.getAttribute("modes"); //$NON-NLS-1$
-
- binding.addStep(new LaunchBinding(id, modes));
- }
-
- IConfigurationElement[] stepGroupBindings = element.getChildren("stepGroup"); //$NON-NLS-1$
- for (IConfigurationElement stepGroupBinding : stepGroupBindings) {
- String id = stepGroupBinding.getAttribute("id"); //$NON-NLS-1$
- String overwrites = stepGroupBinding.getAttribute("overwrites"); //$NON-NLS-1$
- String modes = stepGroupBinding.getAttribute("modes"); //$NON-NLS-1$
- String variants = stepGroupBinding.getAttribute("variants"); //$NON-NLS-1$
-
- binding.addStepGroup(new OverwritableLaunchBinding(id, overwrites, modes, variants));
- }
-
- IConfigurationElement[] enablements = element.getChildren("enablement"); //$NON-NLS-1$
- for (IConfigurationElement enablement : enablements) {
- Expression expression = null;
- try {
- expression = ExpressionConverter.getDefault().perform(enablement);
- } catch (CoreException e) {
- if (Platform.inDebugMode()) e.printStackTrace();
- }
-
- if (expression != null) binding.addEnablement(expression);
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.core.bindings;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Set;
+
+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.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.tcf.te.launch.core.bindings.internal.LaunchConfigTypeBinding;
+import org.eclipse.tcf.te.launch.core.bindings.internal.OverwritableLaunchBinding;
+import org.eclipse.tcf.te.launch.core.extensions.internal.LaunchModeVariantDelegateExtensionPointManager;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate;
+import org.eclipse.tcf.te.launch.core.lm.internal.ExtensionPointManager;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
+import org.eclipse.tcf.te.runtime.extensions.ExtensionPointComparator;
+import org.eclipse.tcf.te.runtime.stepper.StepperManager;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStep;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IVariantDelegate;
+
+
+/**
+ * Manager that controls the launch configuration type bindings.
+ */
+public class LaunchConfigTypeBindingsManager {
+ // Map of all launch configuration type bindings by id
+ private final Map<String, LaunchConfigTypeBinding> bindings = new Hashtable<String, LaunchConfigTypeBinding>();
+
+ /*
+ * Thread save singleton instance creation.
+ */
+ private static class LazyInstanceHolder {
+ public static LaunchConfigTypeBindingsManager instance = new LaunchConfigTypeBindingsManager();
+ }
+
+ /**
+ * Returns the singleton instance.
+ */
+ public static LaunchConfigTypeBindingsManager getInstance() {
+ return LazyInstanceHolder.instance;
+ }
+
+ /**
+ * Constructor.
+ */
+ LaunchConfigTypeBindingsManager() {
+ // Load the launch configuration type bindings on instantiation.
+ loadBindingsExtensions();
+ }
+
+ /**
+ * Get all valid launch configuration type id's for the given selection.
+ *
+ * @param selection The selection or <code>null</code>.
+ * @return The list of valid launch configuration type id's for the selection or an empty list.
+ */
+ public String[] getValidLaunchConfigTypes(ILaunchSelection selection) {
+ Set<String> validLaunchTypes = new HashSet<String>();
+ if (selection != null && selection.getSelectedContexts() != null && selection.getSelectedContexts().length > 0) {
+ for (String launchConfigTypeId : bindings.keySet()) {
+ if (isValidLaunchConfigType(launchConfigTypeId, selection)) {
+ validLaunchTypes.add(launchConfigTypeId);
+ }
+ }
+ }
+ return validLaunchTypes.toArray(new String[validLaunchTypes.size()]);
+ }
+
+ /**
+ * Validates the given launch selection.
+ *
+ * @param typeId The launch configuration type id. Must not be <code>null</code>.
+ * @param selection The selection. Must not be <code>null</code>.
+ */
+ public boolean isValidLaunchConfigType(String typeId, ILaunchSelection selection) {
+ Assert.isNotNull(typeId);
+ Assert.isNotNull(selection);
+
+ LaunchConfigTypeBinding binding = bindings.get(typeId);
+ ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(typeId);
+ return (launchConfigType != null && launchConfigType.isPublic() &&
+ (selection.getLaunchMode() == null || launchConfigType.supportsMode(selection.getLaunchMode())) &&
+ binding != null && binding.validate(selection) != EvaluationResult.FALSE);
+ }
+
+ /**
+ * Validates the given launch selection.
+ *
+ * @param typeId The launch configuration type id. Must not be <code>null</code>.
+ * @param mode The launch mode or <code>null</code>.
+ * @param context The selection context. Must not be <code>null</code>.
+ */
+ public boolean isValidLaunchConfigType(String typeId, String mode, ISelectionContext context) {
+ Assert.isNotNull(typeId);
+ Assert.isNotNull(context);
+
+ LaunchConfigTypeBinding binding = bindings.get(typeId);
+ ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(typeId);
+ return (launchConfigType != null && launchConfigType.isPublic() &&
+ (mode == null || launchConfigType.supportsMode(mode)) &&
+ binding != null && binding.validate(mode, context) != EvaluationResult.FALSE);
+ }
+
+ /**
+ * Get the registered launch manager delegate for the given launch configuration type and launch mode.
+ *
+ * @param typeId The launch configuration type id. Must not be <code>null</code>.
+ * @param mode The launch mode. Must not be <code>null</code>.
+ *
+ * @return The launch manager delegate, or a default delegate if no delegate is registered for the
+ * given launch configuration type id and launch mode.
+ */
+ public ILaunchManagerDelegate getLaunchManagerDelegate(String typeId, String mode) {
+ Assert.isNotNull(typeId);
+ Assert.isNotNull(mode);
+
+ LaunchConfigTypeBinding binding = bindings.get(typeId);
+ if (binding != null) {
+ String id = binding.getLaunchManagerDelegate(mode);
+ if (id != null) {
+ return ExtensionPointManager.getInstance().getLaunchManagerDelegate(id);
+ }
+ }
+ return ExtensionPointManager.getInstance().getDefaultLaunchManagerDelegate();
+ }
+
+ /**
+ * Get the registered launch mode variant delegate for the given launch configuration type and launch mode.
+ *
+ * @param typeId The launch configuration type id. Must not be <code>null</code>.
+ * @param mode The launch mode. Must not be <code>null</code>.
+ *
+ * @return The launch mode variant delegate, or a <code>null</code> if no delegate is registered for the
+ * given launch configuration type id and launch mode.
+ */
+ public IVariantDelegate getLaunchModeVariantDelegate(String typeId, String mode) {
+ Assert.isNotNull(typeId);
+ Assert.isNotNull(mode);
+
+ LaunchConfigTypeBinding binding = bindings.get(typeId);
+ if (binding != null) {
+ String id = binding.getLaunchModeVariantDelegate(mode);
+ if (id != null) {
+ return LaunchModeVariantDelegateExtensionPointManager.getInstance().getLaunchModeVariantDelegate(id);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get the registered stepper for the given launch configuration type id and launch mode.
+ *
+ * @param typeId The launch configuration type id. Must not be <code>null</code>.
+ * @param mode The launch mode. Must not be <code>null</code>.
+
+ * @return The stepper or <code>null</code> if no stepper is registered for the
+ * given launch configuration type id and launch mode.
+ */
+ public IStepper getStepper(String typeId, String mode) {
+ Assert.isNotNull(typeId);
+ Assert.isNotNull(mode);
+
+ IStepper stepper = null;
+
+ LaunchConfigTypeBinding binding = bindings.get(typeId);
+ if (binding != null) {
+ String id = binding.getStepper(mode);
+ if (id != null) {
+ stepper = StepperManager.getInstance().getStepperExtManager().getStepper(id, false);
+ }
+ }
+
+ return stepper;
+ }
+
+ /**
+ * Get the registered step group id for the given launch configuration type, launch mode and variant.
+ *
+ * @param typeId The launch configuration type id. Must not be <code>null</code>.
+ * @param mode The launch mode. Must not be <code>null</code>.
+ * @param variant The launch mode variant or <code>null</code>.
+ *
+ * @return The launch step group id or <code>null</code> if no step group is registered for the
+ * given launch configuration type id, launch mode and variant.
+ */
+ public String getStepGroupId(String typeId, String mode, String variant) {
+ Assert.isNotNull(typeId);
+ Assert.isNotNull(mode);
+
+ LaunchConfigTypeBinding binding = bindings.get(typeId);
+ if (binding != null) {
+ return binding.getStepGroupId(mode, variant);
+ }
+ return null;
+ }
+
+ /**
+ * Get the registered step group identified by the specified unique id.
+ *
+ * @param id The step group id. Must not be <code>null</code>.
+ * @return The step group or <code>null</code>, if no step group is registered for the specified id.
+ */
+ public IStepGroup getStepGroup(String id) {
+ Assert.isNotNull(id);
+ return StepperManager.getInstance().getStepGroupExtManager().getStepGroup(id, true);
+ }
+
+ /**
+ * Get the registered step identified by the specified unique id.
+ *
+ * @param id The launch step id. Must not be <code>null</code>.
+ * @return The launch step or <code>null</code> if no step is registered for the specified id.
+ */
+ public IStep getStep(String id) {
+ Assert.isNotNull(id);
+ return StepperManager.getInstance().getStepExtManager().getStep(id, true);
+ }
+
+ /*
+ * Load and register all launch configuration type bindings.
+ */
+ private void loadBindingsExtensions() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint point = registry.getExtensionPoint("org.eclipse.tcf.te.launch.core.launchConfigTypeBindings"); //$NON-NLS-1$
+ if (point != null) {
+ IExtension[] bindings = point.getExtensions();
+ Arrays.sort(bindings, new ExtensionPointComparator());
+ for (IExtension binding : bindings) {
+ IConfigurationElement[] elements = binding.getConfigurationElements();
+ for (IConfigurationElement element : elements) {
+ loadBinding(element);
+ }
+ }
+ }
+ }
+
+ /**
+ * Load a single launch configuration type binding.
+ *
+ * @param element The configuration element. Must not be <code>null</code>.
+ */
+ private void loadBinding(IConfigurationElement element) {
+ Assert.isNotNull(element);
+
+ if (!element.getName().equals("launchConfigTypeBinding")) { //$NON-NLS-1$
+ return;
+ }
+
+ String launchConfigTypeId = element.getAttribute("launchConfigTypeId"); //$NON-NLS-1$
+ if (!bindings.containsKey(launchConfigTypeId)) {
+ bindings.put(launchConfigTypeId, new LaunchConfigTypeBinding(launchConfigTypeId));
+ }
+ LaunchConfigTypeBinding binding = bindings.get(launchConfigTypeId);
+
+ IConfigurationElement[] lmDelegateBindings = element.getChildren("launchManagerDelegate"); //$NON-NLS-1$
+ for (IConfigurationElement lmDelegateBinding : lmDelegateBindings) {
+ String id = lmDelegateBinding.getAttribute("id"); //$NON-NLS-1$
+ String overwrites = lmDelegateBinding.getAttribute("overwrites"); //$NON-NLS-1$
+ String modes = lmDelegateBinding.getAttribute("modes"); //$NON-NLS-1$
+
+ binding.addLaunchManagerDelegate(new OverwritableLaunchBinding(id, overwrites, modes));
+ }
+
+ IConfigurationElement[] launchModeVariantDelegateBindings = element.getChildren("launchModeVariantDelegate"); //$NON-NLS-1$
+ for (IConfigurationElement launchModeVariantDelegateBinding : launchModeVariantDelegateBindings) {
+ String id = launchModeVariantDelegateBinding.getAttribute("id"); //$NON-NLS-1$
+ String overwrites = launchModeVariantDelegateBinding.getAttribute("overwrites"); //$NON-NLS-1$
+ String modes = launchModeVariantDelegateBinding.getAttribute("modes"); //$NON-NLS-1$
+
+ binding.addLaunchModeVariantDelegate(new OverwritableLaunchBinding(id, overwrites, modes));
+ }
+
+ IConfigurationElement[] stepperBindings = element.getChildren("stepper"); //$NON-NLS-1$
+ for (IConfigurationElement stepperBinding : stepperBindings) {
+ String id = stepperBinding.getAttribute("id"); //$NON-NLS-1$
+ String overwrites = stepperBinding.getAttribute("overwrites"); //$NON-NLS-1$
+ String modes = stepperBinding.getAttribute("modes"); //$NON-NLS-1$
+
+ binding.addStepper(new OverwritableLaunchBinding(id, overwrites, modes));
+ }
+
+ IConfigurationElement[] stepGroupBindings = element.getChildren("stepGroup"); //$NON-NLS-1$
+ for (IConfigurationElement stepGroupBinding : stepGroupBindings) {
+ String id = stepGroupBinding.getAttribute("id"); //$NON-NLS-1$
+ String overwrites = stepGroupBinding.getAttribute("overwrites"); //$NON-NLS-1$
+ String modes = stepGroupBinding.getAttribute("modes"); //$NON-NLS-1$
+ String variants = stepGroupBinding.getAttribute("variants"); //$NON-NLS-1$
+
+ binding.addStepGroup(new OverwritableLaunchBinding(id, overwrites, modes, variants));
+ }
+
+ IConfigurationElement[] enablements = element.getChildren("enablement"); //$NON-NLS-1$
+ for (IConfigurationElement enablement : enablements) {
+ Expression expression = null;
+ try {
+ expression = ExpressionConverter.getDefault().perform(enablement);
+ } catch (CoreException e) {
+ if (Platform.inDebugMode()) {
+ e.printStackTrace();
+ }
+ }
+
+ if (expression != null) {
+ binding.addEnablement(expression);
+ }
+ }
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java
index 47fca5653..0c3998b70 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java
@@ -1,365 +1,335 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.launch.core.bindings.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.launch.core.bindings.interfaces.ILaunchBinding;
-import org.eclipse.tcf.te.launch.core.bindings.interfaces.IOverwritableLaunchBinding;
-import org.eclipse.tcf.te.launch.core.bindings.interfaces.IVaryableLaunchBinding;
-import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
-import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
-
-/**
- * Launch configuration type binding implementation.
- */
-public class LaunchConfigTypeBinding {
- // The launch configuration type id
- private final String typeId;
-
- // Lists of sub bindings
- private final List<ILaunchBinding> lmDelegateBindings = new ArrayList<ILaunchBinding>();
- private final List<ILaunchBinding> stepperBindings = new ArrayList<ILaunchBinding>();
- private final List<ILaunchBinding> stepBindings = new ArrayList<ILaunchBinding>();
- private final List<ILaunchBinding> stepGroupBindings = new ArrayList<ILaunchBinding>();
- private final List<ILaunchBinding> variantDelegateBindings = new ArrayList<ILaunchBinding>();
-
- // The list of enablement expressions
- private final List<Expression> expressions = new ArrayList<Expression>();
-
- /**
- * Constructor.
- *
- * @param typeId The launch configuration type id the binding applies to. Must not be
- * <code>null</code>.
- */
- public LaunchConfigTypeBinding(String typeId) {
- Assert.isNotNull(typeId);
- this.typeId = typeId;
- }
-
- /**
- * Returns the launch configuration type id the binding applies to.
- *
- * @return The launch configuration type id.
- */
- public String getTypeId() {
- return typeId;
- }
-
- /**
- * Returns the launch manager delegate id for the given launch mode.
- *
- * @param mode The launch mode. Must not be <code>null</code>.
- * @return The launch manager delegate id or <code>null</code>.
- */
- public String getLaunchManagerDelegate(String mode) {
- Assert.isNotNull(mode);
-
- ILaunchBinding binding = getBinding(lmDelegateBindings, mode);
- return binding != null ? binding.getId() : null;
- }
-
- /**
- * Adds the given launch manager delegate binding.
- *
- * @param binding The binding. Must not be <code>null</code>.
- */
- public void addLaunchManagerDelegate(IOverwritableLaunchBinding binding) {
- Assert.isNotNull(binding);
- if (!lmDelegateBindings.contains(binding)) lmDelegateBindings.add(binding);
- }
-
- /**
- * Returns the launch mode variant delegate id for the given launch mode.
- *
- * @param mode The launch mode. Must not be <code>null</code>.
- * @return The launch mode variant delegate id or <code>null</code>.
- */
- public String getLaunchModeVariantDelegate(String mode) {
- Assert.isNotNull(mode);
-
- ILaunchBinding binding = getBinding(variantDelegateBindings, mode);
- return binding != null ? binding.getId() : null;
- }
-
- /**
- * Adds the given launch mode variant delegate binding.
- *
- * @param binding The binding. Must not be <code>null</code>.
- */
- public void addLaunchModeVariantDelegate(IOverwritableLaunchBinding binding) {
- Assert.isNotNull(binding);
- if (!variantDelegateBindings.contains(binding)) variantDelegateBindings.add(binding);
- }
-
- /**
- * Returns the stepper id for the given launch mode.
- *
- * @param mode The launch mode. Must not be <code>null</code>.
- * @return The stepper id or <code>null</code>.
- */
- public String getStepper(String mode) {
- Assert.isNotNull(mode);
-
- ILaunchBinding binding = getBinding(stepperBindings, mode);
- return binding != null ? binding.getId() : null;
- }
-
- /**
- * Adds the given stepper binding.
- *
- * @param binding The binding. Must not be <code>null</code>.
- */
- public void addStepper(IOverwritableLaunchBinding binding) {
- Assert.isNotNull(binding);
- if (!stepperBindings.contains(binding)) stepperBindings.add(binding);
- }
-
- /**
- * Returns the list of available step id's bound the given launch mode.
- *
- * @param mode The launch mode. Must not be <code>null</code>.
- * @return The list of available launch step id's or an empty list.
- */
- public String[] getSteps(String mode) {
- Assert.isNotNull(mode);
-
- List<ILaunchBinding> bindings = getBindings(stepBindings, mode);
- List<String> candidates = new ArrayList<String>();
- for (ILaunchBinding binding : bindings) {
- if (!candidates.contains(binding.getId())) candidates.add(binding.getId());
- }
- return candidates.toArray(new String[candidates.size()]);
- }
-
- /**
- * Adds the given step binding.
- *
- * @param binding The binding. Must not be <code>null</code>.
- */
- public void addStep(ILaunchBinding binding) {
- Assert.isNotNull(binding);
- if (!stepBindings.contains(binding)) stepBindings.add(binding);
- }
-
- /**
- * Returns the step group id for the given launch mode and variant.
- *
- * @param mode The launch mode. Must not be <code>null</code>.
- * @param variant The launch mode variant or <code>null</code>.
- *
- * @return The stepper id or <code>null</code>.
- */
- public String getStepGroup(String mode, String variant) {
- ILaunchBinding binding = getBinding(stepGroupBindings, mode, variant);
- return binding != null ? binding.getId() : null;
- }
-
- /**
- * Adds the given step group binding.
- *
- * @param binding The binding. Must not be <code>null</code>.
- */
- public void addStepGroup(ILaunchBinding binding) {
- Assert.isNotNull(binding);
- if (!stepGroupBindings.contains(binding)) stepGroupBindings.add(binding);
- }
-
- /**
- * Adds the given enablement expression.
- *
- * @param enablement The enablement expression. Must not be <code>null</code>.
- */
- public void addEnablement(Expression expression) {
- Assert.isNotNull(expression);
- if (!expressions.contains(expression)) expressions.add(expression);
- }
-
- /**
- * Evaluates the enablement expressions with the given launch selection.
- *
- * @param selection The launch selection. Must not be <code>null</code>.
- * @return The result of the enablement expression evaluation.
- */
- public EvaluationResult validate(ILaunchSelection selection) {
- Assert.isNotNull(selection);
-
- EvaluationResult result = EvaluationResult.NOT_LOADED;
-
- EvaluationResult valresult;
- for (ISelectionContext context : selection.getSelectedContexts()) {
- if (context.isPreferredContext()) {
- valresult = validate(selection.getLaunchMode(), context);
- if (valresult == EvaluationResult.FALSE) {
- return EvaluationResult.FALSE;
- }
- else if (valresult != EvaluationResult.NOT_LOADED) {
- result = valresult;
- }
- }
- }
- return result;
- }
-
- /**
- * Evaluates the enablement expressions with the given launch mode and selection context.
- *
- * @param mode The launch mode. Must not be <code>null</code>.
- * @param context The launch selection context or <code>null</code>.
- *
- * @return The result of the enablement expression evaluation.
- */
- public EvaluationResult validate(String mode, ISelectionContext context) {
- EvaluationResult result = context.isPreferredContext() ? EvaluationResult.FALSE : EvaluationResult.NOT_LOADED;
-
- if (expressions.isEmpty()) {
- return EvaluationResult.TRUE;
- }
- EvaluationResult valresult;
- for (Expression expression : expressions) {
- // Set the default variable and "selection" is the selection context
- EvaluationContext evalContext = new EvaluationContext(null, context);
- evalContext.addVariable("selection", context); //$NON-NLS-1$
- evalContext.addVariable("mode", mode); //$NON-NLS-1$
- // Allow plugin activation
- evalContext.setAllowPluginActivation(true);
- // Evaluate the expression
- try {
- valresult = expression.evaluate(evalContext);
- } catch (CoreException e) {
- valresult = EvaluationResult.FALSE;
-
- if (Platform.inDebugMode()) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), e.getLocalizedMessage(), e);
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- }
-
- if (valresult == EvaluationResult.TRUE) {
- return EvaluationResult.TRUE;
- }
- if (valresult != EvaluationResult.NOT_LOADED) {
- result = valresult;
- }
- }
-
- return result;
- }
-
- /**
- * Returns the list of bindings valid for the given launch mode.
- *
- * @param bindings The list of available bindings. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
- *
- * @return The list of valid bindings for the given launch mode or an empty list.
- */
- private List<ILaunchBinding> getBindings(List<ILaunchBinding> bindings, String mode) {
- return getBindings(bindings, mode, null);
- }
-
- /**
- * Returns the list of bindings valid for the given launch mode.
- *
- * @param bindings The list of available bindings. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
- * @param variant The launch mode variant or <code>null</code>.
- *
- * @return The list of valid bindings for the given launch mode or an empty list.
- */
- private List<ILaunchBinding> getBindings(List<ILaunchBinding> bindings, String mode, String variant) {
- Assert.isNotNull(bindings);
- Assert.isNotNull(mode);
-
- List<ILaunchBinding> candidates = new ArrayList<ILaunchBinding>();
- for (ILaunchBinding binding : bindings) {
- if (binding instanceof IVaryableLaunchBinding) {
- if (((IVaryableLaunchBinding) binding).isValidLaunchMode(mode, variant)) {
- candidates.add(binding);
- }
- }
- else if (binding.isValidLaunchMode(mode)) {
- candidates.add(binding);
- }
- }
-
- return candidates;
- }
-
- /**
- * Returns the resolved binding in case of overwritable bindings.
- *
- * @param bindings The list of available bindings. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
- *
- * @return The resolved binding or <code>null</code>.
- */
- private ILaunchBinding getBinding(List<ILaunchBinding> bindings, String mode) {
- return getBinding(bindings, mode, null);
- }
-
- /**
- * Returns the resolved binding in case of overwritable bindings.
- *
- * @param bindings The list of available bindings. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
- * @param variant The launch mode variant or <code>null</code>.
- *
- * @return The resolved binding or <code>null</code>.
- */
- private ILaunchBinding getBinding(List<ILaunchBinding> bindings, String mode, String variant) {
- Assert.isNotNull(bindings);
- Assert.isNotNull(mode);
-
- ILaunchBinding binding = null;
-
- List<ILaunchBinding> candidates = getBindings(bindings, mode, variant);
- for (int i = 0; i < candidates.size(); i++) {
- if (binding == null) {
- binding = candidates.get(i);
- }
- for (int j = 0; j < candidates.size(); j++) {
- ILaunchBinding cj = candidates.get(j);
- if (cj instanceof IOverwritableLaunchBinding
- && ((IOverwritableLaunchBinding) cj).overwrites(binding.getId())) {
- binding = cj;
- }
- }
- }
-
- return binding;
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- StringBuffer toString = new StringBuffer();
-
- toString.append("LaunchConfigTypeBinding("); //$NON-NLS-1$
- toString.append(typeId);
- toString.append(")"); //$NON-NLS-1$
-
- return toString.toString();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.core.bindings.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.launch.core.bindings.interfaces.ILaunchBinding;
+import org.eclipse.tcf.te.launch.core.bindings.interfaces.IOverwritableLaunchBinding;
+import org.eclipse.tcf.te.launch.core.bindings.interfaces.IVaryableLaunchBinding;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
+
+/**
+ * Launch configuration type binding implementation.
+ */
+public class LaunchConfigTypeBinding {
+ // The launch configuration type id
+ private final String typeId;
+
+ // Lists of sub bindings
+ private final List<ILaunchBinding> lmDelegateBindings = new ArrayList<ILaunchBinding>();
+ private final List<ILaunchBinding> stepperBindings = new ArrayList<ILaunchBinding>();
+ private final List<ILaunchBinding> stepGroupBindings = new ArrayList<ILaunchBinding>();
+ private final List<ILaunchBinding> variantDelegateBindings = new ArrayList<ILaunchBinding>();
+
+ // The list of enablement expressions
+ private final List<Expression> expressions = new ArrayList<Expression>();
+
+ /**
+ * Constructor.
+ *
+ * @param typeId The launch configuration type id the binding applies to. Must not be
+ * <code>null</code>.
+ */
+ public LaunchConfigTypeBinding(String typeId) {
+ Assert.isNotNull(typeId);
+ this.typeId = typeId;
+ }
+
+ /**
+ * Returns the launch configuration type id the binding applies to.
+ *
+ * @return The launch configuration type id.
+ */
+ public String getTypeId() {
+ return typeId;
+ }
+
+ /**
+ * Returns the launch manager delegate id for the given launch mode.
+ *
+ * @param mode The launch mode. Must not be <code>null</code>.
+ * @return The launch manager delegate id or <code>null</code>.
+ */
+ public String getLaunchManagerDelegate(String mode) {
+ Assert.isNotNull(mode);
+
+ ILaunchBinding binding = getBinding(lmDelegateBindings, mode);
+ return binding != null ? binding.getId() : null;
+ }
+
+ /**
+ * Adds the given launch manager delegate binding.
+ *
+ * @param binding The binding. Must not be <code>null</code>.
+ */
+ public void addLaunchManagerDelegate(IOverwritableLaunchBinding binding) {
+ Assert.isNotNull(binding);
+ if (!lmDelegateBindings.contains(binding)) {
+ lmDelegateBindings.add(binding);
+ }
+ }
+
+ /**
+ * Returns the launch mode variant delegate id for the given launch mode.
+ *
+ * @param mode The launch mode. Must not be <code>null</code>.
+ * @return The launch mode variant delegate id or <code>null</code>.
+ */
+ public String getLaunchModeVariantDelegate(String mode) {
+ Assert.isNotNull(mode);
+
+ ILaunchBinding binding = getBinding(variantDelegateBindings, mode);
+ return binding != null ? binding.getId() : null;
+ }
+
+ /**
+ * Adds the given launch mode variant delegate binding.
+ *
+ * @param binding The binding. Must not be <code>null</code>.
+ */
+ public void addLaunchModeVariantDelegate(IOverwritableLaunchBinding binding) {
+ Assert.isNotNull(binding);
+ if (!variantDelegateBindings.contains(binding)) {
+ variantDelegateBindings.add(binding);
+ }
+ }
+
+ /**
+ * Returns the stepper id for the given launch mode.
+ *
+ * @param mode The launch mode. Must not be <code>null</code>.
+ * @return The stepper id or <code>null</code>.
+ */
+ public String getStepper(String mode) {
+ Assert.isNotNull(mode);
+
+ ILaunchBinding binding = getBinding(stepperBindings, mode);
+ return binding != null ? binding.getId() : null;
+ }
+
+ /**
+ * Adds the given stepper binding.
+ *
+ * @param binding The binding. Must not be <code>null</code>.
+ */
+ public void addStepper(IOverwritableLaunchBinding binding) {
+ Assert.isNotNull(binding);
+ if (!stepperBindings.contains(binding)) {
+ stepperBindings.add(binding);
+ }
+ }
+
+ /**
+ * Returns the step group id for the given launch mode and variant.
+ *
+ * @param mode The launch mode. Must not be <code>null</code>.
+ * @param variant The launch mode variant or <code>null</code>.
+ *
+ * @return The step group id or <code>null</code>.
+ */
+ public String getStepGroupId(String mode, String variant) {
+ ILaunchBinding binding = getBinding(stepGroupBindings, mode, variant);
+ return binding != null ? binding.getId() : null;
+ }
+
+ /**
+ * Adds the given step group binding.
+ *
+ * @param binding The binding. Must not be <code>null</code>.
+ */
+ public void addStepGroup(ILaunchBinding binding) {
+ Assert.isNotNull(binding);
+ if (!stepGroupBindings.contains(binding)) {
+ stepGroupBindings.add(binding);
+ }
+ }
+
+ /**
+ * Adds the given enablement expression.
+ *
+ * @param enablement The enablement expression. Must not be <code>null</code>.
+ */
+ public void addEnablement(Expression expression) {
+ Assert.isNotNull(expression);
+ if (!expressions.contains(expression)) {
+ expressions.add(expression);
+ }
+ }
+
+ /**
+ * Evaluates the enablement expressions with the given launch selection.
+ *
+ * @param selection The launch selection. Must not be <code>null</code>.
+ * @return The result of the enablement expression evaluation.
+ */
+ public EvaluationResult validate(ILaunchSelection selection) {
+ Assert.isNotNull(selection);
+
+ EvaluationResult result = EvaluationResult.NOT_LOADED;
+
+ EvaluationResult valresult;
+ for (ISelectionContext context : selection.getSelectedContexts()) {
+ if (context.isPreferredContext()) {
+ valresult = validate(selection.getLaunchMode(), context);
+ if (valresult == EvaluationResult.FALSE) {
+ return EvaluationResult.FALSE;
+ }
+ else if (valresult != EvaluationResult.NOT_LOADED) {
+ result = valresult;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Evaluates the enablement expressions with the given launch mode and selection context.
+ *
+ * @param mode The launch mode. Must not be <code>null</code>.
+ * @param context The launch selection context or <code>null</code>.
+ *
+ * @return The result of the enablement expression evaluation.
+ */
+ public EvaluationResult validate(String mode, ISelectionContext context) {
+ EvaluationResult result = context.isPreferredContext() ? EvaluationResult.FALSE : EvaluationResult.NOT_LOADED;
+
+ if (expressions.isEmpty()) {
+ return EvaluationResult.TRUE;
+ }
+ EvaluationResult valresult;
+ for (Expression expression : expressions) {
+ // Set the default variable and "selection" is the selection context
+ EvaluationContext evalContext = new EvaluationContext(null, context);
+ evalContext.addVariable("selection", context); //$NON-NLS-1$
+ evalContext.addVariable("mode", mode); //$NON-NLS-1$
+ // Allow plugin activation
+ evalContext.setAllowPluginActivation(true);
+ // Evaluate the expression
+ try {
+ valresult = expression.evaluate(evalContext);
+ } catch (CoreException e) {
+ valresult = EvaluationResult.FALSE;
+
+ if (Platform.inDebugMode()) {
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), e.getLocalizedMessage(), e);
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
+ }
+ }
+
+ if (valresult == EvaluationResult.TRUE) {
+ return EvaluationResult.TRUE;
+ }
+ if (valresult != EvaluationResult.NOT_LOADED) {
+ result = valresult;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns the list of bindings valid for the given launch mode.
+ *
+ * @param bindings The list of available bindings. Must not be <code>null</code>.
+ * @param mode The launch mode. Must not be <code>null</code>.
+ * @param variant The launch mode variant or <code>null</code>.
+ *
+ * @return The list of valid bindings for the given launch mode or an empty list.
+ */
+ private List<ILaunchBinding> getBindings(List<ILaunchBinding> bindings, String mode, String variant) {
+ Assert.isNotNull(bindings);
+ Assert.isNotNull(mode);
+
+ List<ILaunchBinding> candidates = new ArrayList<ILaunchBinding>();
+ for (ILaunchBinding binding : bindings) {
+ if (binding instanceof IVaryableLaunchBinding) {
+ if (((IVaryableLaunchBinding) binding).isValidLaunchMode(mode, variant)) {
+ candidates.add(binding);
+ }
+ }
+ else if (binding.isValidLaunchMode(mode)) {
+ candidates.add(binding);
+ }
+ }
+
+ return candidates;
+ }
+
+ /**
+ * Returns the resolved binding in case of overwritable bindings.
+ *
+ * @param bindings The list of available bindings. Must not be <code>null</code>.
+ * @param mode The launch mode. Must not be <code>null</code>.
+ *
+ * @return The resolved binding or <code>null</code>.
+ */
+ private ILaunchBinding getBinding(List<ILaunchBinding> bindings, String mode) {
+ return getBinding(bindings, mode, null);
+ }
+
+ /**
+ * Returns the resolved binding in case of overwritable bindings.
+ *
+ * @param bindings The list of available bindings. Must not be <code>null</code>.
+ * @param mode The launch mode. Must not be <code>null</code>.
+ * @param variant The launch mode variant or <code>null</code>.
+ *
+ * @return The resolved binding or <code>null</code>.
+ */
+ private ILaunchBinding getBinding(List<ILaunchBinding> bindings, String mode, String variant) {
+ Assert.isNotNull(bindings);
+ Assert.isNotNull(mode);
+
+ ILaunchBinding binding = null;
+
+ List<ILaunchBinding> candidates = getBindings(bindings, mode, variant);
+ for (int i = 0; i < candidates.size(); i++) {
+ if (binding == null) {
+ binding = candidates.get(i);
+ }
+ for (int j = 0; j < candidates.size(); j++) {
+ ILaunchBinding cj = candidates.get(j);
+ if (cj instanceof IOverwritableLaunchBinding
+ && ((IOverwritableLaunchBinding) cj).overwrites(binding.getId())) {
+ binding = cj;
+ }
+ }
+ }
+
+ return binding;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuffer toString = new StringBuffer();
+
+ toString.append("LaunchConfigTypeBinding("); //$NON-NLS-1$
+ toString.append(typeId);
+ toString.append(")"); //$NON-NLS-1$
+
+ return toString.toString();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/PropertyTester.java
new file mode 100644
index 000000000..3d55f1c07
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/PropertyTester.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.core.bindings.internal;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunch;
+
+/**
+ * Launch property tester.
+ */
+public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ */
+ @Override
+ public boolean test(final Object receiver, String property, Object[] args, Object expectedValue) {
+
+ if (receiver instanceof ILaunch) {
+ if ("launchMode".equals(property) && expectedValue instanceof String) { //$NON-NLS-1$
+ return ((ILaunch)receiver).getLaunchMode().equalsIgnoreCase((String)expectedValue);
+ }
+ if ("launchConfigTypeid".equals(property) && expectedValue instanceof String) { //$NON-NLS-1$
+ try {
+ return ((ILaunch)receiver).getLaunchConfiguration().getType().getIdentifier().equalsIgnoreCase((String)expectedValue);
+ }
+ catch (CoreException e) {
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java
index 3e0509f55..457356626 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java
@@ -1,316 +1,335 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.launch.core.delegates;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.IStatusHandler;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.launch.core.bindings.LaunchConfigTypeBindingsManager;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.ICommonLaunchAttributes;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate;
-import org.eclipse.tcf.te.launch.core.nls.Messages;
-import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate;
-import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
-import org.eclipse.tcf.te.runtime.interfaces.ISharedConstants;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.stepper.FullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.tracing.ITraceIds;
-
-/**
- * Default launch configuration delegate implementation.
- * <p>
- * The launch configuration delegate implements the bridge between the native Eclipse launch
- * configuration framework and the stepper engine. The delegate is standard for all
- * launch configurations which supports extensible and modularized launching.
- * <p>
- * <b>Implementation Details</b>:<br>
- * <ul>
- * <li>The launch configuration delegate signals the completion of the launch sequence via
- * the custom {@link ILaunch} attribute {@link ICommonLaunchAttributes#ILAUNCH_ATTRIBUTE_LAUNCH_SEQUENCE_COMPLETED}.</li>
- * <li>The launch configuration delegates enforces the removal of the launch from the Eclipse
- * debug platforms launch manager if the progress monitor is set to canceled or an status with
- * severity {@link IStatus#CANCEL} had been thrown by the stepper implementation.</li>
- * <li>The launch configuration delegate creates launches of type {@link Launch}.</li>
- * </ul>
- */
-public class LaunchConfigurationDelegate extends AbstractLaunchConfigurationDelegate {
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
- Assert.isNotNull(configuration);
- Assert.isNotNull(mode);
- Assert.isNotNull(launch);
-
- // Note: This method is typically called within a worker thread from the launch configuration framework.
-
- long startTime = System.currentTimeMillis();
- ILaunchConfigurationWorkingCopy launchConfig = configuration.getWorkingCopy();
- launchConfig.setAttribute(ICommonLaunchAttributes.ATTR_LAST_LAUNCHED, Long.toString(startTime));
- launchConfig.doSave();
-
- CoreBundleActivator.getTraceHandler().trace("LaunchConfigurationDelegate#launch: *** ENTERED" //$NON-NLS-1$
- + " (" + configuration.getName() + ")", //$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);
-
- // Reset the attribute to tell if the launch sequence has been completed. Clients cannot
- // use ILaunch.isTerminated() as this is passing through to a possibly associated IProcess
- // object. We need to know when the launch itself has finished the job, not when the process
- // might have died.
- launch.setAttribute(ICommonLaunchAttributes.ILAUNCH_ATTRIBUTE_LAUNCH_SEQUENCE_COMPLETED, Boolean.FALSE.toString());
-
- // The stepper instance to be used
- IStepper stepper = null;
- IStatus status = null;
-
- try {
- // Get the launch configuration type from the launch configuration.
- // This may throw an CoreException if the launch configuration type
- // cannot be retrieved or instantiated.
- ILaunchConfigurationType type = configuration.getType();
-
- // Get the associated stepper for this launch
- stepper = LaunchConfigTypeBindingsManager.getInstance().getStepper(type.getIdentifier(), mode);
- if (stepper == null) {
- // Failed to retrieve stepper for this launch -> throw a CoreException
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- NLS.bind(Messages.LaunchConfigurationDelegate_error_failedToGetStepper, type.getIdentifier(), mode)));
- }
-
- // In case the stepper is already busy with another launch, we need a second instance
- if (stepper.isInitialized()) {
- try {
- // Create a new stepper instance
- IStepper candidate = stepper.getClass().newInstance();
- // Note: If the stepper is an instance of ExecutableExtension, the candidate has to be too.
- if (stepper instanceof ExecutableExtension) {
- ((ExecutableExtension)stepper).cloneInitializationData((ExecutableExtension)candidate);
- }
- // Force to use the newly created instance
- stepper = candidate;
- } catch (Exception e) {
- // Failed to clone already initialized stepper -> throw a CoreException
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- NLS.bind(Messages.LaunchConfigurationDelegate_error_failedToCloneStepper, type.getIdentifier(), mode)));
- }
- }
-
- IFullQualifiedId fullQualifiedId = new FullQualifiedId(IStepper.ID_TYPE_STEPPER_ID, stepper.getId(), null);
- // Get the launch properties container
- IPropertiesContainer properties = (IPropertiesContainer)launch.getAdapter(IPropertiesContainer.class);
- Assert.isNotNull(properties);
- // Initialize the stepper
- stepper.initialize(properties, fullQualifiedId, monitor != null ? monitor : new NullProgressMonitor());
-
- // Execute
- stepper.execute();
-
- // Wait for the stepper to be finished
- ExecutorsUtil.waitAndExecute(0, new IStepper.ExecutionFinishedConditionTester(stepper));
- } catch (CoreException e) {
- // We have to catch the CoreException here as we do want to open the
- // launch configurations dialog on ERROR only.
- status = e.getStatus();
-
- ILaunchManagerDelegate delegate = LaunchConfigTypeBindingsManager.getInstance().getLaunchManagerDelegate(configuration.getType().getIdentifier(), mode);
-
- if (status == null || (status.getSeverity() == IStatus.ERROR && delegate.showLaunchDialog(ILaunchManagerDelegate.SITUATION_AFTER_LAUNCH_FAILED))) {
- // just pass on the exception as is
- throw e;
- }
-
- // Try to get a handler for the status
- IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
- // If we cannot get a handler, pass on the exception
- if (handler == null) {
- throw e;
- }
-
- // Invoke the handler directly and drop the exception
- handler.handleStatus(status, this);
-
- // Mimic the original launch configuration behavior if an exception occurred
- // by removing the launch, if empty, and setting the progress monitor canceled.
- // @see LaunchConfiguration#launch(String, IProgressMonitor, boolean, boolean), line #768
- if (!launch.hasChildren()) {
- DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch);
- if (monitor != null) {
- monitor.setCanceled(true);
- }
- }
- } finally {
- // Mimic the original launch configuration behavior if monitor is set
- // canceled and make sure that the launch get's removed.
- if (monitor == null || monitor.isCanceled()) {
- DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch);
- }
-
- // Cleanup the stepper
- if (stepper != null) {
- stepper.cleanup();
- }
-
- // Set the launch completed here. Doesn't matter if the launch might completed with error or not.
- launch.setAttribute(ICommonLaunchAttributes.ILAUNCH_ATTRIBUTE_LAUNCH_SEQUENCE_COMPLETED, Boolean.TRUE.toString());
-
- long endTime = System.currentTimeMillis();
- CoreBundleActivator.getTraceHandler().trace("LaunchConfigurationDelegate#launch: *** DONE" //$NON-NLS-1$
- + " (" + configuration.getName() + ")", //$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);
-
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
- */
- @Override
- public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
- return new Launch(configuration, mode, null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getProjectsForProblemSearch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
- */
- @Override
- protected IProject[] getProjectsForProblemSearch(ILaunchConfiguration configuration, String mode) throws CoreException {
- // Return the same list of projects as we have to build
- return getBuildOrder(configuration, mode);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
- */
- @Override
- protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
- // The result list. Return always an empty list at least. If returning null,
- // the super implementation will perform a incremental workspace build.
- List<IProject> projects = new ArrayList<IProject>();
-
- // Return the projects to build within the order the user configured within
- // the corresponding UI launch tab.
- List<String> projectNames = (List<String>)DefaultPersistenceDelegate.getAttribute(configuration, ICommonLaunchAttributes.ATTR_PROJECTS_FOR_BUILD, (List<?>)null);
- if (projectNames != null) {
- projects.addAll(findProjectResources(projectNames));
- }
-
- // If the list of projects is not empty, we have to check for duplicates
- // and possible sub projects. As we cannot pre check if a project must
- // be build, we have to avoid building the same project again and again.
- checkForDuplicatesAndSubProjects(projects);
-
- return projects.toArray(new IProject[projects.size()]);
- }
-
- /**
- * Lookup the corresponding project resources for the given list of project
- * names. If one of the referenced projects cannot be found or is closed,
- * a {@link CoreException} will be thrown.
- *
- * @param projectNames The list of project names. Must be not <code>null</code>.
- * @return The list of project resources or an empty list.
- */
- protected List<IProject> findProjectResources(List<String> projectNames) throws CoreException {
- Assert.isNotNull(projectNames);
-
- List<IProject> projects = new ArrayList<IProject>();
-
- // Project resources are stored with the workspace root
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- for (String projectName : projectNames) {
- // Query the project resource from the workspace root.
- IProject project = root.getProject(projectName);
- if (!project.isAccessible()) {
- // Not accessible -> means the project does either not exist or
- // is closed.
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- NLS.bind(Messages.LaunchConfigurationDelegate_error_inaccessibleReferencedProject, projectName)
- ));
- }
-
- // add the project resource to the list
- projects.add(project);
- }
-
- return projects;
- }
-
- /**
- * Check for duplicates and sub projects in the given list of project
- * resources.
- *
- * @param projects The list of project resources. Must be not <code>null</code>.
- */
- protected void checkForDuplicatesAndSubProjects(List<IProject> projects) {
- Assert.isNotNull(projects);
-
- // The list of already processed project names
- List<String> processedProjectNames = new ArrayList<String>();
-
- // Loop the project list and determine the duplicates. Use an
- // iterator here as we manipulate the list directly.
- ListIterator<IProject> iterator = projects.listIterator();
- while (iterator.hasNext()) {
- IProject project = iterator.next();
- // If the project name is within the list of already processed
- // projects, the project will be deleted from the list.
- if (processedProjectNames.contains(project.getName())) {
- iterator.remove();
- continue;
- }
-
- // Add the project name to the list of processed project names
- processedProjectNames.add(project.getName());
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBreakpoints(org.eclipse.debug.core.ILaunchConfiguration)
- *
- * Note: Redefined to be public accessible. Needed to access the breakpoints without
- * duplicating the super implementation.
- */
- @Override
- public IBreakpoint[] getBreakpoints(ILaunchConfiguration configuration) {
- return super.getBreakpoints(configuration);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.core.delegates;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.IStatusHandler;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.launch.core.bindings.LaunchConfigTypeBindingsManager;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ICommonLaunchAttributes;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.IContextSelectorLaunchAttributes;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate;
+import org.eclipse.tcf.te.launch.core.nls.Messages;
+import org.eclipse.tcf.te.launch.core.persistence.ContextSelectorPersistenceDelegate;
+import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate;
+import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
+import org.eclipse.tcf.te.runtime.interfaces.ISharedConstants;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.runtime.stepper.FullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperProperties;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.tracing.ITraceIds;
+
+/**
+ * Default launch configuration delegate implementation.
+ * <p>
+ * The launch configuration delegate implements the bridge between the native Eclipse launch
+ * configuration framework and the stepper engine. The delegate is standard for all
+ * launch configurations which supports extensible and modularized launching.
+ * <p>
+ * <b>Implementation Details</b>:<br>
+ * <ul>
+ * <li>The launch configuration delegate signals the completion of the launch sequence via
+ * the custom {@link ILaunch} attribute {@link ICommonLaunchAttributes#ILAUNCH_ATTRIBUTE_LAUNCH_SEQUENCE_COMPLETED}.</li>
+ * <li>The launch configuration delegates enforces the removal of the launch from the Eclipse
+ * debug platforms launch manager if the progress monitor is set to canceled or an status with
+ * severity {@link IStatus#CANCEL} had been thrown by the stepper implementation.</li>
+ * <li>The launch configuration delegate creates launches of type {@link Launch}.</li>
+ * </ul>
+ */
+public class LaunchConfigurationDelegate extends AbstractLaunchConfigurationDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ Assert.isNotNull(configuration);
+ Assert.isNotNull(mode);
+ Assert.isNotNull(launch);
+
+ // Note: This method is typically called within a worker thread from the launch configuration framework.
+
+ long startTime = System.currentTimeMillis();
+ ILaunchConfigurationWorkingCopy launchConfig = configuration.getWorkingCopy();
+ launchConfig.setAttribute(ICommonLaunchAttributes.ATTR_LAST_LAUNCHED, Long.toString(startTime));
+ launchConfig.doSave();
+
+ CoreBundleActivator.getTraceHandler().trace("LaunchConfigurationDelegate#launch: *** ENTERED" //$NON-NLS-1$
+ + " (" + configuration.getName() + ")", //$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);
+
+ // Reset the attribute to tell if the launch sequence has been completed. Clients cannot
+ // use ILaunch.isTerminated() as this is passing through to a possibly associated IProcess
+ // object. We need to know when the launch itself has finished the job, not when the process
+ // might have died.
+ launch.setAttribute(ICommonLaunchAttributes.ILAUNCH_ATTRIBUTE_LAUNCH_SEQUENCE_COMPLETED, Boolean.FALSE.toString());
+
+ // The stepper instance to be used
+ IStepper stepper = null;
+ IStatus status = null;
+
+ try {
+ // Get the launch configuration type from the launch configuration.
+ // This may throw an CoreException if the launch configuration type
+ // cannot be retrieved or instantiated.
+ ILaunchConfigurationType type = configuration.getType();
+
+ // Get the associated stepper for this launch
+ stepper = LaunchConfigTypeBindingsManager.getInstance().getStepper(type.getIdentifier(), mode);
+ if (stepper == null) {
+ // Failed to retrieve stepper for this launch -> throw a CoreException
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
+ NLS.bind(Messages.LaunchConfigurationDelegate_error_failedToGetStepper, type.getIdentifier(), mode)));
+ }
+
+ // In case the stepper is already busy with another launch, we need a second instance
+ if (stepper.isInitialized()) {
+ try {
+ // Create a new stepper instance
+ IStepper candidate = stepper.getClass().newInstance();
+ // Note: If the stepper is an instance of ExecutableExtension, the candidate has to be too.
+ if (stepper instanceof ExecutableExtension) {
+ ((ExecutableExtension)stepper).cloneInitializationData((ExecutableExtension)candidate);
+ }
+ // Force to use the newly created instance
+ stepper = candidate;
+ } catch (Exception e) {
+ // Failed to clone already initialized stepper -> throw a CoreException
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
+ NLS.bind(Messages.LaunchConfigurationDelegate_error_failedToCloneStepper, type.getIdentifier(), mode)));
+ }
+ }
+
+ IFullQualifiedId fullQualifiedId = new FullQualifiedId(IStepper.ID_TYPE_STEPPER_ID, stepper.getId(), null);
+ // Get the launch properties container
+ IPropertiesContainer properties = (IPropertiesContainer)launch.getAdapter(IPropertiesContainer.class);
+ Assert.isNotNull(properties);
+
+ // Add some information to the stepper data
+ properties.setProperty(IStepperProperties.PROP_NAME, launchConfig.getName());
+ properties.setProperty(IStepperProperties.PROP_STEP_GROUP_ID,
+ LaunchConfigTypeBindingsManager.getInstance().getStepGroupId(
+ launchConfig.getType().getIdentifier(),
+ launch.getLaunchMode(),
+ properties.getStringProperty(ICommonLaunchAttributes.ATTR_DELEGATE_VARIANT)));
+
+ IModelNode[] contexts = ContextSelectorPersistenceDelegate.decodeLaunchContexts(
+ launchConfig.getAttribute(IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS, (String)null));
+ properties.setProperty(IContextSelectorLaunchAttributes.ATTR_ACTIVE_LAUNCH_CONTEXT, contexts != null && contexts.length > 0 ? contexts[0] : null);
+
+ // Initialize the stepper
+ IStepContext context = (IStepContext)launch.getAdapter(IStepContext.class);
+ stepper.initialize(context, properties, fullQualifiedId, monitor != null ? monitor : new NullProgressMonitor());
+
+ // Execute
+ stepper.execute();
+
+ // Wait for the stepper to be finished
+ ExecutorsUtil.waitAndExecute(0, new IStepper.ExecutionFinishedConditionTester(stepper));
+ } catch (CoreException e) {
+ // We have to catch the CoreException here as we do want to open the
+ // launch configurations dialog on ERROR only.
+ status = e.getStatus();
+
+ ILaunchManagerDelegate delegate = LaunchConfigTypeBindingsManager.getInstance().getLaunchManagerDelegate(configuration.getType().getIdentifier(), mode);
+
+ if (status == null || (status.getSeverity() == IStatus.ERROR && delegate.showLaunchDialog(ILaunchManagerDelegate.SITUATION_AFTER_LAUNCH_FAILED))) {
+ // just pass on the exception as is
+ throw e;
+ }
+
+ // Try to get a handler for the status
+ IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
+ // If we cannot get a handler, pass on the exception
+ if (handler == null) {
+ throw e;
+ }
+
+ // Invoke the handler directly and drop the exception
+ handler.handleStatus(status, this);
+
+ // Mimic the original launch configuration behavior if an exception occurred
+ // by removing the launch, if empty, and setting the progress monitor canceled.
+ // @see LaunchConfiguration#launch(String, IProgressMonitor, boolean, boolean), line #768
+ if (!launch.hasChildren()) {
+ DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch);
+ if (monitor != null) {
+ monitor.setCanceled(true);
+ }
+ }
+ } finally {
+ // Mimic the original launch configuration behavior if monitor is set
+ // canceled and make sure that the launch get's removed.
+ if (monitor == null || monitor.isCanceled()) {
+ DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch);
+ }
+
+ // Cleanup the stepper
+ if (stepper != null) {
+ stepper.cleanup();
+ }
+
+ // Set the launch completed here. Doesn't matter if the launch might completed with error or not.
+ launch.setAttribute(ICommonLaunchAttributes.ILAUNCH_ATTRIBUTE_LAUNCH_SEQUENCE_COMPLETED, Boolean.TRUE.toString());
+
+ long endTime = System.currentTimeMillis();
+ CoreBundleActivator.getTraceHandler().trace("LaunchConfigurationDelegate#launch: *** DONE" //$NON-NLS-1$
+ + " (" + configuration.getName() + ")", //$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);
+
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
+ */
+ @Override
+ public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
+ return new Launch(configuration, mode, null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getProjectsForProblemSearch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
+ */
+ @Override
+ protected IProject[] getProjectsForProblemSearch(ILaunchConfiguration configuration, String mode) throws CoreException {
+ // Return the same list of projects as we have to build
+ return getBuildOrder(configuration, mode);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
+ */
+ @Override
+ protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
+ // The result list. Return always an empty list at least. If returning null,
+ // the super implementation will perform a incremental workspace build.
+ List<IProject> projects = new ArrayList<IProject>();
+
+ // Return the projects to build within the order the user configured within
+ // the corresponding UI launch tab.
+ List<String> projectNames = (List<String>)DefaultPersistenceDelegate.getAttribute(configuration, ICommonLaunchAttributes.ATTR_PROJECTS_FOR_BUILD, (List<?>)null);
+ if (projectNames != null) {
+ projects.addAll(findProjectResources(projectNames));
+ }
+
+ // If the list of projects is not empty, we have to check for duplicates
+ // and possible sub projects. As we cannot pre check if a project must
+ // be build, we have to avoid building the same project again and again.
+ checkForDuplicatesAndSubProjects(projects);
+
+ return projects.toArray(new IProject[projects.size()]);
+ }
+
+ /**
+ * Lookup the corresponding project resources for the given list of project
+ * names. If one of the referenced projects cannot be found or is closed,
+ * a {@link CoreException} will be thrown.
+ *
+ * @param projectNames The list of project names. Must be not <code>null</code>.
+ * @return The list of project resources or an empty list.
+ */
+ protected List<IProject> findProjectResources(List<String> projectNames) throws CoreException {
+ Assert.isNotNull(projectNames);
+
+ List<IProject> projects = new ArrayList<IProject>();
+
+ // Project resources are stored with the workspace root
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ for (String projectName : projectNames) {
+ // Query the project resource from the workspace root.
+ IProject project = root.getProject(projectName);
+ if (!project.isAccessible()) {
+ // Not accessible -> means the project does either not exist or
+ // is closed.
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
+ NLS.bind(Messages.LaunchConfigurationDelegate_error_inaccessibleReferencedProject, projectName)
+ ));
+ }
+
+ // add the project resource to the list
+ projects.add(project);
+ }
+
+ return projects;
+ }
+
+ /**
+ * Check for duplicates and sub projects in the given list of project
+ * resources.
+ *
+ * @param projects The list of project resources. Must be not <code>null</code>.
+ */
+ protected void checkForDuplicatesAndSubProjects(List<IProject> projects) {
+ Assert.isNotNull(projects);
+
+ // The list of already processed project names
+ List<String> processedProjectNames = new ArrayList<String>();
+
+ // Loop the project list and determine the duplicates. Use an
+ // iterator here as we manipulate the list directly.
+ ListIterator<IProject> iterator = projects.listIterator();
+ while (iterator.hasNext()) {
+ IProject project = iterator.next();
+ // If the project name is within the list of already processed
+ // projects, the project will be deleted from the list.
+ if (processedProjectNames.contains(project.getName())) {
+ iterator.remove();
+ continue;
+ }
+
+ // Add the project name to the list of processed project names
+ processedProjectNames.add(project.getName());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBreakpoints(org.eclipse.debug.core.ILaunchConfiguration)
+ *
+ * Note: Redefined to be public accessible. Needed to access the breakpoints without
+ * duplicating the super implementation.
+ */
+ @Override
+ public IBreakpoint[] getBreakpoints(ILaunchConfiguration configuration) {
+ return super.getBreakpoints(configuration);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ICommonLaunchAttributes.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ICommonLaunchAttributes.java
index e702164e3..63582ad78 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ICommonLaunchAttributes.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ICommonLaunchAttributes.java
@@ -1,82 +1,83 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.launch.core.lm.interfaces;
-
-/**
- * Defines the common attribute id's used to access launch configuration properties.
- */
-public interface ICommonLaunchAttributes {
-
- /**
- * Define the prefix used by all other attribute id's as prefix.
- */
- public static final String ATTR_PREFIX = "org.eclipse.tcf.te.launch"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute: List of projects which must be build before executing the launch.
- */
- public static final String ATTR_PROJECTS_FOR_BUILD = ATTR_PREFIX + ".projectsForBuild"; //$NON-NLS-1$
- /**
- * Launch configuration attribute: List of referenced projects.
- */
- public static final String ATTR_REFERENCED_PROJECTS = ATTR_PREFIX + ".referencedProjects"; //$NON-NLS-1$
-
- /**
- * Time stamp when last launched.
- */
- public static final String ATTR_LAST_LAUNCHED = ATTR_PREFIX + ".lastLaunched"; //$NON-NLS-1$
-
- /**
- * Launch mode variant id.
- */
- public static final String ATTR_DELEGATE_VARIANT = ATTR_PREFIX + ".delegateVariant"; //$NON-NLS-1$
-
- /**
- * Attribute used exclusively with <code>ILaunch.setAttribute</code> to mark when
- * then launch sequence finished. The attribute does not tell if an error occurred
- * during the launch!
- */
- public static final String ILAUNCH_ATTRIBUTE_LAUNCH_SEQUENCE_COMPLETED = "launchSequenceCompleted"; //$NON-NLS-1$
-
- // Copied from IDebugUIConstants to make them available for non-UI plugin's.
-
- /**
- * Debug UI plug-in identifier (value <code>"org.eclipse.debug.ui"</code>).
- */
- public static final String PLUGIN_ID_DEBUG_UI = "org.eclipse.debug.ui"; //$NON-NLS-1$;
-
- /**
- * Debug CORE plug-in identifier (value <code>"org.eclipse.debug.core"</code>).
- */
- public static final String PLUGIN_ID_DEBUG_CORE = "org.eclipse.debug.core"; //$NON-NLS-1$;
-
- /**
- * Launch configuration boolean attribute specifying whether output from the launched process will
- * be captured and written to the console. Default value is <code>true</code>.
- *
- * @since 3.4
- */
- public static final String ATTR_CAPTURE_OUTPUT = PLUGIN_ID_DEBUG_CORE + ".capture_output"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute specifying a file name that console output should
- * be written to or <code>null</code> if none. Default value is <code>null</code>.
- * When specified, all output from the launched process will be written to the file.
- * The file name attribute may contain variables which will be resolved by the
- * {@link org.eclipse.core.variables.IStringVariableManager}.
- *
- * @see IDebugUIConstants
- * @since 3.1
- */
- public static final String ATTR_CAPTURE_IN_FILE = PLUGIN_ID_DEBUG_UI + ".ATTR_CAPTURE_IN_FILE"; //$NON-NLS-1$
-}
-
-
-
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.core.lm.interfaces;
+
+/**
+ * Defines the common attribute id's used to access launch configuration properties.
+ */
+public interface ICommonLaunchAttributes {
+
+ /**
+ * Define the prefix used by all other attribute id's as prefix.
+ */
+ public static final String ATTR_PREFIX = "org.eclipse.tcf.te.launch"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute: List of projects which must be build before executing the launch.
+ */
+ public static final String ATTR_PROJECTS_FOR_BUILD = ATTR_PREFIX + ".projectsForBuild"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute: List of referenced projects.
+ */
+ public static final String ATTR_REFERENCED_PROJECTS = ATTR_PREFIX + ".referencedProjects"; //$NON-NLS-1$
+
+ /**
+ * Time stamp when last launched.
+ */
+ public static final String ATTR_LAST_LAUNCHED = ATTR_PREFIX + ".lastLaunched"; //$NON-NLS-1$
+
+ /**
+ * Launch mode variant id.
+ */
+ public static final String ATTR_DELEGATE_VARIANT = ATTR_PREFIX + ".delegateVariant"; //$NON-NLS-1$
+
+ /**
+ * Attribute used exclusively with <code>ILaunch.setAttribute</code> to mark when
+ * then launch sequence finished. The attribute does not tell if an error occurred
+ * during the launch!
+ */
+ public static final String ILAUNCH_ATTRIBUTE_LAUNCH_SEQUENCE_COMPLETED = "launchSequenceCompleted"; //$NON-NLS-1$
+
+ // Copied from IDebugUIConstants to make them available for non-UI plugin's.
+
+ /**
+ * Debug UI plug-in identifier (value <code>"org.eclipse.debug.ui"</code>).
+ */
+ public static final String PLUGIN_ID_DEBUG_UI = "org.eclipse.debug.ui"; //$NON-NLS-1$;
+
+ /**
+ * Debug CORE plug-in identifier (value <code>"org.eclipse.debug.core"</code>).
+ */
+ public static final String PLUGIN_ID_DEBUG_CORE = "org.eclipse.debug.core"; //$NON-NLS-1$;
+
+ /**
+ * Launch configuration boolean attribute specifying whether output from the launched process will
+ * be captured and written to the console. Default value is <code>true</code>.
+ *
+ * @since 3.4
+ */
+ public static final String ATTR_CAPTURE_OUTPUT = PLUGIN_ID_DEBUG_CORE + ".capture_output"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute specifying a file name that console output should
+ * be written to or <code>null</code> if none. Default value is <code>null</code>.
+ * When specified, all output from the launched process will be written to the file.
+ * The file name attribute may contain variables which will be resolved by the
+ * {@link org.eclipse.core.variables.IStringVariableManager}.
+ *
+ * @see IDebugUIConstants
+ * @since 3.1
+ */
+ public static final String ATTR_CAPTURE_IN_FILE = PLUGIN_ID_DEBUG_UI + ".ATTR_CAPTURE_IN_FILE"; //$NON-NLS-1$
+}
+
+
+
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/IContextSelectorLaunchAttributes.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/IContextSelectorLaunchAttributes.java
index f1730858c..5f9026565 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/IContextSelectorLaunchAttributes.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/IContextSelectorLaunchAttributes.java
@@ -15,6 +15,11 @@ package org.eclipse.tcf.te.launch.core.lm.interfaces;
public interface IContextSelectorLaunchAttributes {
/**
+ * Launch configuration attribute: The active launch context the launch is operating with.
+ */
+ public static final String ATTR_ACTIVE_LAUNCH_CONTEXT = ICommonLaunchAttributes.ATTR_PREFIX + ".active_launch_context"; //$NON-NLS-1$
+
+ /**
* Launch configuration attribute: The launch contexts the launch is operating with. Use
* {@link ContextSelectorPersistanceDelegate} to access
* this attribute within a launch configuration.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/ContextSelectorPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/ContextSelectorPersistenceDelegate.java
index f81436419..0d12273ab 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/ContextSelectorPersistenceDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/ContextSelectorPersistenceDelegate.java
@@ -1,544 +1,555 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.launch.core.persistence;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.IContextSelectorLaunchAttributes;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
-import org.eclipse.tcf.te.runtime.model.factory.Factory;
-import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.osgi.framework.Bundle;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * Context selector persistence delegate.
- */
-public class ContextSelectorPersistenceDelegate {
- // The read cache for step contexts. Avoid running time consuming
- // re-parsing of an already parsed step context description again and again.
- private final static Map<String, List<IStepContext>> readCache = new LinkedHashMap<String, List<IStepContext>>();
- // The write cache for target contexts. Avoids re-generating the XML again and again.
- private final static Map<String, String> writeCache = new LinkedHashMap<String, String>();
-
- // Limit the read cache to the last 10 read step contexts
- private final static int READ_CACHE_MAX_CAPACITY = 25;
- // Limit the write cache to the last 10 written step contexts
- private final static int WRITE_CACHE_MAX_CAPACITY = 25;
-
- /**
- * Saves the selected launch contexts to the specified launch configuration working copy. If the
- * selected launch contexts are <code>null</code> or empty, the attribute will be removed from
- * the specified launch configuration working copy.
- *
- * @param wc The launch configuration working copy. Must not be <code>null</code>.
- * @param contexts The launch contexts to save or <code>null</code>.
- */
- public final static void setLaunchContexts(ILaunchConfigurationWorkingCopy wc, IStepContext[] contexts) {
- Assert.isNotNull(wc);
-
- if (contexts == null || contexts.length == 0) {
- DefaultPersistenceDelegate.setAttribute(wc, IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS, (String) null);
- return;
- }
-
- // Get the encoded XML representation
- String xml = encodeLaunchContexts(contexts);
- // And save them to the launch configuration. If XML == null, the
- // launch contexts will be removed from the launch configuration
- DefaultPersistenceDelegate.setAttribute(wc, IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS, xml);
- }
-
- /**
- * Saves the selected launch contexts to the specified launch specification. If the selected
- * launch contexts are <code>null</code> or empty, the attribute will be removed from the
- * specified launch specification.
- *
- * @param launchSpec The launch specification. Must not be <code>null</code>.
- * @param contexts The launch contexts to save or <code>null</code>.
- */
- public final static void setLaunchContexts(ILaunchSpecification launchSpec, IStepContext[] contexts) {
- Assert.isNotNull(launchSpec);
-
- if (contexts == null || contexts.length == 0) {
- launchSpec.removeAttribute(IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS);
- return;
- }
-
- // Get the encoded XML representation
- String xml = encodeLaunchContexts(contexts);
- // And save them to the launch specification. If XML == null, the
- // launch contexts will be removed from the launch specification
- launchSpec.addAttribute(IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS, xml);
- }
-
- /**
- * Writes the given launch contexts into a string encoded in XML.
- *
- * @param contexts The launch contexts to encode. Must not be <code>null</code>.
- * @return The full XML representation of the given contexts or <code>null</code>.
- */
- public final static String encodeLaunchContexts(IStepContext[] contexts) {
- Assert.isNotNull(contexts);
-
- // The final result
- String result = null;
-
- // Generate the write cache key
- String writeCacheKey = makeWriteCacheKey(contexts);
-
- // Check if we have the contexts already generated before
- synchronized (writeCache) {
- if (writeCache.containsKey(writeCacheKey)) {
- result = writeCache.get(writeCacheKey);
- }
- }
-
- // If no cache hit, generate from scratch
- if (result == null) {
- // First, we write the selected contexts as XML representation into a string
- StringWriter writer = new StringWriter();
-
- try {
- // Write the header and get the initial indentation
- String indentation = writeHeader(writer);
- // Iterate over the given selected step contexts and write them out.
- for (IStepContext node : contexts) {
- writeStepContext(writer, indentation, node);
- }
- // Write the footer
- writeFooter(writer);
-
- // Convert into a string
- result = writer.toString();
-
- synchronized (writeCache) {
- // Limit the write cache capacity
- checkCacheCapacity(writeCache, WRITE_CACHE_MAX_CAPACITY);
- // And put it into the write cache
- writeCache.put(writeCacheKey, result);
- }
- }
- catch (IOException e) {
- // Export to the string writer failed --> remove attribute from launch configuration
- if (Platform.inDebugMode()) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- "Launch framework internal error: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- result = null;
- }
- finally {
- try {
- writer.close();
- }
- catch (IOException e) { /* ignored on purpose */
- }
- }
- }
-
- return result;
- }
-
- /**
- * Generates a write cache key from the given contexts.
- *
- * @param contexts The contexts
- * @return The corresponding write key cache.
- */
- private static String makeWriteCacheKey(IStepContext[] contexts) {
- Assert.isNotNull(contexts);
-
- StringBuffer key = new StringBuffer();
- for (IStepContext context : contexts) {
- key.append(Integer.toHexString(context.hashCode()));
- key.append(':');
- }
- if (key.charAt(key.length() - 1) == ':') {
- key.setCharAt(key.length() - 1, ' ');
- }
- return key.toString().trim();
- }
-
- /**
- * Writes the header to the given writer and returns the indentation to be used for following
- * elements.
- *
- * @param writer The writer instance. Must not be <code>null</code>.
- * @throws IOException in case the write failed.
- */
- private static String writeHeader(Writer writer) throws IOException {
- Assert.isNotNull(writer);
- writer.write("<contexts>\n"); //$NON-NLS-1$
- return "\t"; //$NON-NLS-1$
- }
-
- /**
- * Writes the footer to the given writer and returns the indentation to be used for following
- * elements.
- *
- * @param writer The writer instance. Must not be <code>null</code>.
- * @throws IOException in case the write failed.
- */
- private static String writeFooter(Writer writer) throws IOException {
- Assert.isNotNull(writer);
- writer.write("</contexts>\n"); //$NON-NLS-1$
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Writes the step context element to the given writer.
- *
- * @param writer The writer instance. Must not be <code>null</code>.
- * @param indentation The indentation to prefix each exported line with. Must not be <code>null</code>.
- * @param context The step context instance. Must not be <code>null</code>.
- *
- * @throws IOException in case the write failed.
- */
- private static void writeStepContext(Writer writer, String indentation, IStepContext context) throws IOException {
- Assert.isNotNull(writer);
- Assert.isNotNull(indentation);
- Assert.isNotNull(context);
-
- writer.write(indentation + "<context type=\"" + context.getEncodedClassName() + "\">\n"); //$NON-NLS-1$ //$NON-NLS-2$
- writer.write(indentation + "\t" + context.encode() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- writer.write(indentation + "</context>\n"); //$NON-NLS-1$
- }
-
- /**
- * Reads the selected launch contexts from the given XML encoded string.
- *
- * @param encodedContexts The selected launch contexts encoded as XML string. Must not be <code>null</code>.
- * @return The selected launch contexts or an empty array.
- */
- public final static IStepContext[] decodeLaunchContexts(String encodedContexts) {
- Assert.isNotNull(encodedContexts);
-
- List<IStepContext> contexts = null;
-
- if (!"".equals(encodedContexts.trim())) { //$NON-NLS-1$
- synchronized (readCache) {
- // Check if we have the contexts already parsed before
- if (readCache.containsKey(encodedContexts)) {
- // Take the result from the cache
- contexts = readCache.get(encodedContexts);
- // check sanity. If empty or we cannot find the step context,
- // drop the cache value and decode again.
- ListIterator<IStepContext> iterator = contexts.listIterator();
- while (iterator.hasNext()) {
- IStepContext node = iterator.next();
- if (!node.exists()) {
- contexts = null;
- readCache.remove(encodedContexts);
- break;
- }
- }
-
- if (contexts != null && contexts.isEmpty()) {
- readCache.remove(encodedContexts);
- contexts = null;
- }
- }
- }
-
- if (contexts == null || contexts.isEmpty()) {
- contexts = new ArrayList<IStepContext>();
- // We have to parse the contexts from the string
- InputStream input = new ByteArrayInputStream(encodedContexts.getBytes());
- // Instantiate the XML parser
- LaunchContextXMLParser xmlParser = new LaunchContextXMLParser();
- xmlParser.initXMLParser();
- xmlParser.setContexts(contexts);
- try {
- xmlParser.getXMLReader().parse(input, xmlParser);
- if (!contexts.isEmpty()) {
- synchronized (readCache) {
- // Limit the read cache capacity
- checkCacheCapacity(readCache, READ_CACHE_MAX_CAPACITY);
- // Put the result into the read cache
- readCache.put(encodedContexts, contexts);
- }
- }
- }
- catch (Exception e) {
- // Import failed --> remove attribute from launch configuration
- if (Platform.inDebugMode()) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- "Launch framework internal error: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- contexts = null;
- }
- }
- }
-
- return contexts != null ? contexts.toArray(new IStepContext[contexts.size()]) : new IStepContext[0];
- }
-
- /**
- * Internal helper method to ensure a maximum capacity of the caches.
- */
- private final static void checkCacheCapacity(Map<String, ?> cache, int maxCapacity) {
- if (cache.size() < maxCapacity) {
- return;
- }
- // Get all keys
- String[] keys = cache.keySet().toArray(new String[cache.keySet().size()]);
- // And remove all keys starting with the eldest till the
- // capacity is fine again.
- for (String key : keys) {
- cache.remove(key);
- if (cache.size() < maxCapacity / 2) {
- break;
- }
- }
- }
-
- private final static class LaunchContextXMLParser extends DefaultHandler {
- private final int IN_CONTEXTS_DEFINITION = 1;
- private final int IN_CONTEXT_DEFINITION = 2;
-
- private SAXParser parser;
-
- private int parseState;
- private String lastData;
- private String lastType;
- private List<IStepContext> contexts;
-
- /**
- * Constructor
- */
- public LaunchContextXMLParser() {
- super();
-
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setNamespaceAware(false);
- factory.setValidating(false);
- try {
- parser = factory.newSAXParser();
- }
- catch (ParserConfigurationException e) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), e.getClass().getName(), e);
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- catch (SAXException e) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), e.getClass().getName(), e);
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- }
-
- /**
- * Returns the associated XML parser instance.
- */
- protected SAXParser getXMLReader() {
- return parser;
- }
-
- /**
- * Reset the XML parser to a defined start point.
- */
- protected void initXMLParser() {
- parseState = 0;
- lastData = null;
- lastType = null;
- contexts = null;
- }
-
- /**
- * Associate the list instance to store the identified contexts.
- */
- protected void setContexts(List<IStepContext> contexts) {
- this.contexts = contexts;
- }
-
- /*
- * (non-Javadoc)
- * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String,
- * java.lang.String)
- */
- @Override
- public void endElement(String uri, String localName, String name) throws SAXException {
- if ("contexts".equalsIgnoreCase(name) && (parseState & IN_CONTEXTS_DEFINITION) == IN_CONTEXTS_DEFINITION) { //$NON-NLS-1$
- parseState ^= IN_CONTEXTS_DEFINITION;
- }
- if ("context".equalsIgnoreCase(name) && (parseState & IN_CONTEXT_DEFINITION) == IN_CONTEXT_DEFINITION) { //$NON-NLS-1$
- parseState ^= IN_CONTEXT_DEFINITION;
-
- // The context encoded string is in last data
- if (lastType != null && lastData != null) {
- Class<IModelNode> clazz = null;
- try {
- clazz = (Class<IModelNode>)CoreBundleActivator.getContext().getBundle().loadClass(lastType);
- } catch (ClassNotFoundException e) {
- if (Platform.inDebugMode()) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- "Launch framework internal error: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- }
-
- // If the class could not be loaded by our own bundle class loader, try to find
- // the bundle from the class name and try to load the class through the bundle.
- if (clazz == null) {
- String bundleId = lastType;
- Bundle bundle = null;
- while (bundleId != null && bundle == null) {
- bundle = Platform.getBundle(bundleId);
- if (bundle == null) {
- int i = bundleId.lastIndexOf('.');
- if (i != -1) {
- bundleId = bundleId.substring(0, i);
- } else {
- bundleId = null;
- }
- }
- }
-
- if (bundle != null) {
- try {
- clazz = (Class<IModelNode>)bundle.loadClass(lastType);
- } catch (ClassNotFoundException e) {
- if (Platform.inDebugMode()) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- "Launch framework internal error: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- }
- }
- }
-
- if (clazz != null) {
- // Create an instance of this class and try to load the step context
- Object object = Factory.getInstance().newInstance(clazz);
- if (object != null) {
- IStepContext context = (IStepContext)Platform.getAdapterManager().loadAdapter(object, IStepContext.class.getName());
- if (context != null) {
- try {
- // Decodes the context object
- context.decode(lastData);
- if (!contexts.contains(context)) {
- contexts.add(context);
- }
- } catch (IOException e) {
- if (Platform.inDebugMode()) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- "Launch framework internal error: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- }
- }
- }
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
- */
- @Override
- public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
- // Each time we start a new element, throw away the lastData content
- lastData = null;
-
- if ("contexts".equalsIgnoreCase(name)) { //$NON-NLS-1$
- parseState |= IN_CONTEXTS_DEFINITION;
- }
- if ("context".equalsIgnoreCase(name) && (parseState & IN_CONTEXTS_DEFINITION) == IN_CONTEXTS_DEFINITION) { //$NON-NLS-1$
- parseState |= IN_CONTEXT_DEFINITION;
- lastType = attributes.getValue("type"); //$NON-NLS-1$
- }
- }
-
- /* (non-Javadoc)
- * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
- */
- @Override
- public void characters(char ch[], int start, int length) {
- if (lastData == null) {
- lastData = new String(ch, start, length).trim();
- }
- else {
- lastData += new String(ch, start, length).trim();
- }
- }
- }
-
- /**
- * Returns the list of configured launch contexts from the given launch configuration.
- * <p>
- * If the given launch configuration is <code>null</code> and the method will return an empty
- * array.
- *
- * @param configuration The launch configuration or <code>null</code>.
- * @return The list of configured launch contexts or an empty array.
- */
- public static final IStepContext[] getLaunchContexts(ILaunchConfiguration configuration) {
- IStepContext[] contexts = new IStepContext[0];
-
- // First read the contexts written by the launch context selector control.
- if (configuration != null) {
- // Read the context attribute from the launch configuration
- String encodedContexts = DefaultPersistenceDelegate.getAttribute(configuration, IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS, (String) null);
- if (encodedContexts != null) {
- contexts = ContextSelectorPersistenceDelegate.decodeLaunchContexts(encodedContexts);
- }
- }
-
- return contexts;
- }
-
- /**
- * Returns the list of configured launch contexts from the given launch specification.
- * <p>
- * If the given launch specification is <code>null</code> and the method will return an empty
- * array.
- *
- * @param launchSpec The launch specification or <code>null</code>.
- * @return The list of configured launch contexts or an empty array.
- */
- public static final IStepContext[] getLaunchContexts(ILaunchSpecification launchSpec) {
- IStepContext[] contexts = new IStepContext[0];
-
- // First read the contexts written by the launch context selector control.
- if (launchSpec != null) {
- // Read the context attribute from the launch specification
- String encodedContexts = (String) launchSpec.getAttribute(IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS, null);
- if (encodedContexts != null) {
- contexts = ContextSelectorPersistenceDelegate.decodeLaunchContexts(encodedContexts);
- }
- }
-
- return contexts;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.core.persistence;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.IContextSelectorLaunchAttributes;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
+import org.eclipse.tcf.te.runtime.model.factory.Factory;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable2;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService;
+import org.osgi.framework.Bundle;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Context selector persistence delegate.
+ */
+public class ContextSelectorPersistenceDelegate {
+ // The read cache for step contexts. Avoid running time consuming
+ // re-parsing of an already parsed step context description again and again.
+ private final static Map<String, List<IModelNode>> readCache = new LinkedHashMap<String, List<IModelNode>>();
+ // The write cache for target contexts. Avoids re-generating the XML again and again.
+ private final static Map<String, String> writeCache = new LinkedHashMap<String, String>();
+
+ // Limit the read cache to the last 10 read step contexts
+ private final static int READ_CACHE_MAX_CAPACITY = 25;
+ // Limit the write cache to the last 10 written step contexts
+ private final static int WRITE_CACHE_MAX_CAPACITY = 25;
+
+ /**
+ * Saves the selected launch contexts to the specified launch configuration working copy. If the
+ * selected launch contexts are <code>null</code> or empty, the attribute will be removed from
+ * the specified launch configuration working copy.
+ *
+ * @param wc The launch configuration working copy. Must not be <code>null</code>.
+ * @param contexts The launch contexts to save or <code>null</code>.
+ */
+ public final static void setLaunchContexts(ILaunchConfigurationWorkingCopy wc, IModelNode[] contexts) {
+ Assert.isNotNull(wc);
+
+ if (contexts == null || contexts.length == 0) {
+ DefaultPersistenceDelegate.setAttribute(wc, IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS, (String) null);
+ return;
+ }
+
+ // Get the encoded XML representation
+ String xml = encodeLaunchContexts(contexts);
+ // And save them to the launch configuration. If XML == null, the
+ // launch contexts will be removed from the launch configuration
+ DefaultPersistenceDelegate.setAttribute(wc, IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS, xml);
+ }
+
+ /**
+ * Saves the selected launch contexts to the specified launch specification. If the selected
+ * launch contexts are <code>null</code> or empty, the attribute will be removed from the
+ * specified launch specification.
+ *
+ * @param launchSpec The launch specification. Must not be <code>null</code>.
+ * @param contexts The launch contexts to save or <code>null</code>.
+ */
+ public final static void setLaunchContexts(ILaunchSpecification launchSpec, IModelNode[] contexts) {
+ Assert.isNotNull(launchSpec);
+
+ if (contexts == null || contexts.length == 0) {
+ launchSpec.removeAttribute(IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS);
+ return;
+ }
+
+ // Get the encoded XML representation
+ String xml = encodeLaunchContexts(contexts);
+ // And save them to the launch specification. If XML == null, the
+ // launch contexts will be removed from the launch specification
+ launchSpec.addAttribute(IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS, xml);
+ }
+
+ /**
+ * Writes the given launch contexts into a string encoded in XML.
+ *
+ * @param contexts The launch contexts to encode. Must not be <code>null</code>.
+ * @return The full XML representation of the given contexts or <code>null</code>.
+ */
+ public final static String encodeLaunchContexts(IModelNode[] contexts) {
+ Assert.isNotNull(contexts);
+
+ // The final result
+ String result = null;
+
+ // Generate the write cache key
+ String writeCacheKey = makeWriteCacheKey(contexts);
+
+ // Check if we have the contexts already generated before
+ synchronized (writeCache) {
+ if (writeCache.containsKey(writeCacheKey)) {
+ result = writeCache.get(writeCacheKey);
+ }
+ }
+
+ // If no cache hit, generate from scratch
+ if (result == null) {
+ // First, we write the selected contexts as XML representation into a string
+ StringWriter writer = new StringWriter();
+
+ try {
+ // Write the header and get the initial indentation
+ String indentation = writeHeader(writer);
+ // Iterate over the given selected step contexts and write them out.
+ for (IModelNode node : contexts) {
+ writeStepContext(writer, indentation, node);
+ }
+ // Write the footer
+ writeFooter(writer);
+
+ // Convert into a string
+ result = writer.toString();
+
+ synchronized (writeCache) {
+ // Limit the write cache capacity
+ checkCacheCapacity(writeCache, WRITE_CACHE_MAX_CAPACITY);
+ // And put it into the write cache
+ writeCache.put(writeCacheKey, result);
+ }
+ }
+ catch (IOException e) {
+ // Export to the string writer failed --> remove attribute from launch configuration
+ if (Platform.inDebugMode()) {
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
+ "Launch framework internal error: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
+ }
+ result = null;
+ }
+ finally {
+ try {
+ writer.close();
+ }
+ catch (IOException e) { /* ignored on purpose */
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Generates a write cache key from the given contexts.
+ *
+ * @param contexts The contexts
+ * @return The corresponding write key cache.
+ */
+ private static String makeWriteCacheKey(IModelNode[] contexts) {
+ Assert.isNotNull(contexts);
+
+ StringBuffer key = new StringBuffer();
+ for (IModelNode context : contexts) {
+ key.append(Integer.toHexString(context.hashCode()));
+ key.append(':');
+ }
+ if (key.charAt(key.length() - 1) == ':') {
+ key.setCharAt(key.length() - 1, ' ');
+ }
+ return key.toString().trim();
+ }
+
+ /**
+ * Writes the header to the given writer and returns the indentation to be used for following
+ * elements.
+ *
+ * @param writer The writer instance. Must not be <code>null</code>.
+ * @throws IOException in case the write failed.
+ */
+ private static String writeHeader(Writer writer) throws IOException {
+ Assert.isNotNull(writer);
+ writer.write("<contexts>\n"); //$NON-NLS-1$
+ return "\t"; //$NON-NLS-1$
+ }
+
+ /**
+ * Writes the footer to the given writer and returns the indentation to be used for following
+ * elements.
+ *
+ * @param writer The writer instance. Must not be <code>null</code>.
+ * @throws IOException in case the write failed.
+ */
+ private static String writeFooter(Writer writer) throws IOException {
+ Assert.isNotNull(writer);
+ writer.write("</contexts>\n"); //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Writes the step context element to the given writer.
+ *
+ * @param writer The writer instance. Must not be <code>null</code>.
+ * @param indentation The indentation to prefix each exported line with. Must not be <code>null</code>.
+ * @param context The step context instance. Must not be <code>null</code>.
+ *
+ * @throws IOException in case the write failed.
+ */
+ private static void writeStepContext(Writer writer, String indentation, IModelNode context) throws IOException {
+ Assert.isNotNull(writer);
+ Assert.isNotNull(indentation);
+ Assert.isNotNull(context);
+
+ IPersistable2 adapter = (IPersistable2)context.getAdapter(IPersistable2.class);
+
+ writer.write(indentation + "<context type=\"" + adapter.getEncodedClassName(context) + "\">\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ writer.write(indentation + "\t" + adapter.exportStringFrom(context) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ writer.write(indentation + "</context>\n"); //$NON-NLS-1$
+ }
+
+ /**
+ * Reads the selected launch contexts from the given XML encoded string.
+ *
+ * @param encodedContexts The selected launch contexts encoded as XML string. Must not be <code>null</code>.
+ * @return The selected launch contexts or an empty array.
+ */
+ public final static IModelNode[] decodeLaunchContexts(String encodedContexts) {
+ Assert.isNotNull(encodedContexts);
+
+ List<IModelNode> contexts = null;
+
+ if (!"".equals(encodedContexts.trim())) { //$NON-NLS-1$
+ synchronized (readCache) {
+ // Check if we have the contexts already parsed before
+ if (readCache.containsKey(encodedContexts)) {
+ // Take the result from the cache
+ contexts = readCache.get(encodedContexts);
+ // check sanity. If empty or we cannot find the step context,
+ // drop the cache value and decode again.
+ ListIterator<IModelNode> iterator = contexts.listIterator();
+ while (iterator.hasNext()) {
+ IModelNode node = iterator.next();
+ IPropertiesAccessService service = ServiceManager.getInstance().getService(node, IPropertiesAccessService.class);
+ boolean isGhost = false;
+ if (service != null) {
+ Object value = service.getProperty(node, IModelNode.PROPERTY_IS_GHOST);
+ if (value instanceof Boolean) {
+ isGhost = ((Boolean)value).booleanValue();
+ }
+ }
+ if (isGhost) {
+ contexts = null;
+ readCache.remove(encodedContexts);
+ break;
+ }
+ }
+
+ if (contexts != null && contexts.isEmpty()) {
+ readCache.remove(encodedContexts);
+ contexts = null;
+ }
+ }
+ }
+
+ if (contexts == null || contexts.isEmpty()) {
+ contexts = new ArrayList<IModelNode>();
+ // We have to parse the contexts from the string
+ InputStream input = new ByteArrayInputStream(encodedContexts.getBytes());
+ // Instantiate the XML parser
+ LaunchContextXMLParser xmlParser = new LaunchContextXMLParser();
+ xmlParser.initXMLParser();
+ xmlParser.setContexts(contexts);
+ try {
+ xmlParser.getXMLReader().parse(input, xmlParser);
+ if (!contexts.isEmpty()) {
+ synchronized (readCache) {
+ // Limit the read cache capacity
+ checkCacheCapacity(readCache, READ_CACHE_MAX_CAPACITY);
+ // Put the result into the read cache
+ readCache.put(encodedContexts, contexts);
+ }
+ }
+ }
+ catch (Exception e) {
+ // Import failed --> remove attribute from launch configuration
+ if (Platform.inDebugMode()) {
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
+ "Launch framework internal error: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
+ }
+ contexts = null;
+ }
+ }
+ }
+
+ return contexts != null ? contexts.toArray(new IModelNode[contexts.size()]) : new IModelNode[0];
+ }
+
+ /**
+ * Internal helper method to ensure a maximum capacity of the caches.
+ */
+ private final static void checkCacheCapacity(Map<String, ?> cache, int maxCapacity) {
+ if (cache.size() < maxCapacity) {
+ return;
+ }
+ // Get all keys
+ String[] keys = cache.keySet().toArray(new String[cache.keySet().size()]);
+ // And remove all keys starting with the eldest till the
+ // capacity is fine again.
+ for (String key : keys) {
+ cache.remove(key);
+ if (cache.size() < maxCapacity / 2) {
+ break;
+ }
+ }
+ }
+
+ private final static class LaunchContextXMLParser extends DefaultHandler {
+ private final int IN_CONTEXTS_DEFINITION = 1;
+ private final int IN_CONTEXT_DEFINITION = 2;
+
+ private SAXParser parser;
+
+ private int parseState;
+ private String lastData;
+ private String lastType;
+ private List<IModelNode> contexts;
+
+ /**
+ * Constructor
+ */
+ public LaunchContextXMLParser() {
+ super();
+
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(false);
+ factory.setValidating(false);
+ try {
+ parser = factory.newSAXParser();
+ }
+ catch (ParserConfigurationException e) {
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), e.getClass().getName(), e);
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
+ }
+ catch (SAXException e) {
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), e.getClass().getName(), e);
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
+ }
+ }
+
+ /**
+ * Returns the associated XML parser instance.
+ */
+ protected SAXParser getXMLReader() {
+ return parser;
+ }
+
+ /**
+ * Reset the XML parser to a defined start point.
+ */
+ protected void initXMLParser() {
+ parseState = 0;
+ lastData = null;
+ lastType = null;
+ contexts = null;
+ }
+
+ /**
+ * Associate the list instance to store the identified contexts.
+ */
+ protected void setContexts(List<IModelNode> contexts) {
+ this.contexts = contexts;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ public void endElement(String uri, String localName, String name) throws SAXException {
+ if ("contexts".equalsIgnoreCase(name) && (parseState & IN_CONTEXTS_DEFINITION) == IN_CONTEXTS_DEFINITION) { //$NON-NLS-1$
+ parseState ^= IN_CONTEXTS_DEFINITION;
+ }
+ if ("context".equalsIgnoreCase(name) && (parseState & IN_CONTEXT_DEFINITION) == IN_CONTEXT_DEFINITION) { //$NON-NLS-1$
+ parseState ^= IN_CONTEXT_DEFINITION;
+
+ // The context encoded string is in last data
+ if (lastType != null && lastData != null) {
+ Class<IModelNode> clazz = null;
+ try {
+ clazz = (Class<IModelNode>)CoreBundleActivator.getContext().getBundle().loadClass(lastType);
+ } catch (ClassNotFoundException e) {
+ if (Platform.inDebugMode()) {
+ IStatus status = new Status(IStatus.WARNING, CoreBundleActivator.getUniqueIdentifier(),
+ "Launch framework internal error: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
+ }
+ }
+
+ // If the class could not be loaded by our own bundle class loader, try to find
+ // the bundle from the class name and try to load the class through the bundle.
+ if (clazz == null) {
+ String bundleId = lastType;
+ Bundle bundle = null;
+ while (bundleId != null && bundle == null) {
+ bundle = Platform.getBundle(bundleId);
+ if (bundle == null) {
+ int i = bundleId.lastIndexOf('.');
+ if (i != -1) {
+ bundleId = bundleId.substring(0, i);
+ } else {
+ bundleId = null;
+ }
+ }
+ }
+
+ if (bundle != null) {
+ try {
+ clazz = (Class<IModelNode>)bundle.loadClass(lastType);
+ } catch (ClassNotFoundException e) {
+ if (Platform.inDebugMode()) {
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
+ "Launch framework internal error: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
+ }
+ }
+ }
+ }
+
+ if (clazz != null) {
+ // Create an instance of this class and try to load the step context
+ Object object = Factory.getInstance().newInstance(clazz);
+ if (object instanceof IAdaptable) {
+ try {
+ IPersistable2 adapter = (IPersistable2)((IAdaptable)object).getAdapter(IPersistable2.class);
+ // Decodes the context object
+ IModelNode context = (IModelNode)adapter.importFrom(lastData);
+ if (!contexts.contains(context)) {
+ contexts.add(context);
+ }
+ } catch (IOException e) {
+ if (Platform.inDebugMode()) {
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
+ "Launch framework internal error: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
+ Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
+ */
+ @Override
+ public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
+ // Each time we start a new element, throw away the lastData content
+ lastData = null;
+
+ if ("contexts".equalsIgnoreCase(name)) { //$NON-NLS-1$
+ parseState |= IN_CONTEXTS_DEFINITION;
+ }
+ if ("context".equalsIgnoreCase(name) && (parseState & IN_CONTEXTS_DEFINITION) == IN_CONTEXTS_DEFINITION) { //$NON-NLS-1$
+ parseState |= IN_CONTEXT_DEFINITION;
+ lastType = attributes.getValue("type"); //$NON-NLS-1$
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
+ */
+ @Override
+ public void characters(char ch[], int start, int length) {
+ if (lastData == null) {
+ lastData = new String(ch, start, length).trim();
+ }
+ else {
+ lastData += new String(ch, start, length).trim();
+ }
+ }
+ }
+
+ /**
+ * Returns the list of configured launch contexts from the given launch configuration.
+ * <p>
+ * If the given launch configuration is <code>null</code> and the method will return an empty
+ * array.
+ *
+ * @param configuration The launch configuration or <code>null</code>.
+ * @return The list of configured launch contexts or an empty array.
+ */
+ public static final IModelNode[] getLaunchContexts(ILaunchConfiguration configuration) {
+ IModelNode[] contexts = new IModelNode[0];
+
+ // First read the contexts written by the launch context selector control.
+ if (configuration != null) {
+ // Read the context attribute from the launch configuration
+ String encodedContexts = DefaultPersistenceDelegate.getAttribute(configuration, IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS, (String) null);
+ if (encodedContexts != null) {
+ contexts = ContextSelectorPersistenceDelegate.decodeLaunchContexts(encodedContexts);
+ }
+ }
+
+ return contexts;
+ }
+
+ /**
+ * Returns the list of configured launch contexts from the given launch specification.
+ * <p>
+ * If the given launch specification is <code>null</code> and the method will return an empty
+ * array.
+ *
+ * @param launchSpec The launch specification or <code>null</code>.
+ * @return The list of configured launch contexts or an empty array.
+ */
+ public static final IModelNode[] getLaunchContexts(ILaunchSpecification launchSpec) {
+ IModelNode[] contexts = new IModelNode[0];
+
+ // First read the contexts written by the launch context selector control.
+ if (launchSpec != null) {
+ // Read the context attribute from the launch specification
+ String encodedContexts = (String) launchSpec.getAttribute(IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS, null);
+ if (encodedContexts != null) {
+ contexts = ContextSelectorPersistenceDelegate.decodeLaunchContexts(encodedContexts);
+ }
+ }
+
+ return contexts;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/steps/AbstractLaunchStep.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/steps/AbstractLaunchStep.java
new file mode 100644
index 000000000..8b425d9e4
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/steps/AbstractLaunchStep.java
@@ -0,0 +1,46 @@
+/*
+ * AbstractLaunchStep.java
+ * Created on 22.02.2012
+ *
+ * Copyright 2012 Wind River Systems Inc. All rights reserved.
+ */
+package org.eclipse.tcf.te.launch.core.steps;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.IContextSelectorLaunchAttributes;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.runtime.stepper.extensions.AbstractStep;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+
+/**
+ * AbstractLaunchStep
+ * @author tobias.schwarz@windriver.com
+ */
+public abstract class AbstractLaunchStep extends AbstractStep {
+
+ /**
+ * Rteurns the launch object for the given step context.
+ *
+ * @param context The step context.
+ * @return The launch or <code>null</code>.
+ */
+ protected ILaunch getLaunch(IStepContext context) {
+ Assert.isNotNull(context);
+ return (ILaunch)context.getAdapter(ILaunch.class);
+ }
+
+ /**
+ * Returns the active launch context model node that is currently used.
+ *
+ * @param data The data giving object. Must not be <code>null</code>.
+ * @return The active launch context model node.
+ */
+ protected IModelNode getActiveLaunchContext(IPropertiesContainer data) {
+ Assert.isNotNull(data);
+ Object context = data.getProperty(IContextSelectorLaunchAttributes.ATTR_ACTIVE_LAUNCH_CONTEXT);
+ Assert.isTrue(context instanceof IModelNode);
+ return (IModelNode)context;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/steps/RemoveLaunchStep.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/steps/RemoveLaunchStep.java
new file mode 100644
index 000000000..eaedffede
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/steps/RemoveLaunchStep.java
@@ -0,0 +1,45 @@
+/*
+ * RemoveLaunchStep.java
+ * Created on 28.02.2012
+ *
+ * Copyright 2012 Wind River Systems Inc. All rights reserved.
+ */
+package org.eclipse.tcf.te.launch.core.steps;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+
+/**
+ * RemoveLaunchStep
+ * @author tobias.schwarz@windriver.com
+ */
+public class RemoveLaunchStep extends AbstractLaunchStep {
+
+ /**
+ * Constructor.
+ */
+ public RemoveLaunchStep() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
+ */
+ @Override
+ public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) {
+ DebugPlugin.getDefault().getLaunchManager().removeLaunch(getLaunch(context));
+ callback.done(this, Status.OK_STATUS);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/selector/ContextSelectorSection.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/selector/ContextSelectorSection.java
index 721555d85..0a3692f0f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/selector/ContextSelectorSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/selector/ContextSelectorSection.java
@@ -13,7 +13,6 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jface.action.Action;
@@ -28,7 +27,6 @@ import org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart;
import org.eclipse.tcf.te.launch.ui.internal.ImageConsts;
import org.eclipse.tcf.te.launch.ui.nls.Messages;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
import org.eclipse.tcf.te.ui.forms.parts.AbstractSection;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
@@ -48,23 +46,23 @@ public class ContextSelectorSection extends AbstractSection implements ILaunchCo
protected class RefreshAction extends Action {
/**
- * Constructor.
- */
- public RefreshAction() {
- super(null, IAction.AS_PUSH_BUTTON);
- setImageDescriptor(UIPlugin.getImageDescriptor(ImageConsts.ACTION_Refresh_Enabled));
- setToolTipText(Messages.ContextSelectorControl_toolbar_refresh_tooltip);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- if (selector != null && selector.getViewer() != null) {
- selector.getViewer().refresh();
- }
- }
+ * Constructor.
+ */
+ public RefreshAction() {
+ super(null, IAction.AS_PUSH_BUTTON);
+ setImageDescriptor(UIPlugin.getImageDescriptor(ImageConsts.ACTION_Refresh_Enabled));
+ setToolTipText(Messages.ContextSelectorControl_toolbar_refresh_tooltip);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ if (selector != null && selector.getViewer() != null) {
+ selector.getViewer().refresh();
+ }
+ }
}
/**
@@ -120,7 +118,7 @@ public class ContextSelectorSection extends AbstractSection implements ILaunchCo
@Override
public void dispose() {
if (selector != null) { selector.dispose(); selector = null; }
- super.dispose();
+ super.dispose();
}
/* (non-Javadoc)
@@ -128,8 +126,8 @@ public class ContextSelectorSection extends AbstractSection implements ILaunchCo
*/
@Override
protected void createSectionToolbarItems(Section section, FormToolkit toolkit, ToolBarManager tlbMgr) {
- super.createSectionToolbarItems(section, toolkit, tlbMgr);
- tlbMgr.add(new RefreshAction());
+ super.createSectionToolbarItems(section, toolkit, tlbMgr);
+ tlbMgr.add(new RefreshAction());
}
/* (non-Javadoc)
@@ -140,12 +138,11 @@ public class ContextSelectorSection extends AbstractSection implements ILaunchCo
Assert.isNotNull(configuration);
if (selector != null) {
- IStepContext[] contexts = ContextSelectorPersistenceDelegate.getLaunchContexts(configuration);
+ IModelNode[] contexts = ContextSelectorPersistenceDelegate.getLaunchContexts(configuration);
if (contexts != null && contexts.length > 0) {
// Loop the contexts and create a list of nodes
List<IModelNode> nodes = new ArrayList<IModelNode>();
- for (IStepContext context : contexts) {
- IModelNode node = context.getModelNode();
+ for (IModelNode node : contexts) {
if (node != null && !nodes.contains(node)) {
nodes.add(node);
}
@@ -166,18 +163,10 @@ public class ContextSelectorSection extends AbstractSection implements ILaunchCo
if (selector != null) {
IModelNode[] nodes = selector.getCheckedModelContexts();
- // Loop the nodes and create a list of step contexts
- List<IStepContext> contexts = new ArrayList<IStepContext>();
- for (IModelNode node : nodes) {
- IStepContext context = (IStepContext)Platform.getAdapterManager().loadAdapter(node, IStepContext.class.getName());
- if (context != null && !contexts.contains(context)) {
- contexts.add(context);
- }
- }
// Write the selected contexts to the launch configuration
- if (!contexts.isEmpty()) {
- ContextSelectorPersistenceDelegate.setLaunchContexts(configuration, contexts.toArray(new IStepContext[contexts.size()]));
+ if (nodes != null && nodes.length > 0) {
+ ContextSelectorPersistenceDelegate.setLaunchContexts(configuration, nodes);
} else {
ContextSelectorPersistenceDelegate.setLaunchContexts(configuration, null);
}
@@ -191,6 +180,6 @@ public class ContextSelectorSection extends AbstractSection implements ILaunchCo
*/
@Override
public boolean isValid(ILaunchConfiguration configuration) {
- return true;
+ return true;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IPersistable2.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IPersistable2.java
new file mode 100644
index 000000000..5667b1982
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IPersistable2.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.persistence.interfaces;
+
+import java.io.IOException;
+
+/**
+ * Interface to be implemented by string persistable elements.
+ */
+public interface IPersistable2 extends IPersistable {
+
+ /**
+ * Returns the class name of the encoded context.
+ * <p>
+ * The class name is used to load the correct class to decode the persistable representation.
+ *
+ * @param data The data object. Must not be <code>null</code>.
+ * @return The class name of the encoded context.
+ */
+ public String getEncodedClassName(Object data);
+
+
+ /**
+ * Exports the given data object to an external representation.
+ * <p>
+ * As a general guide line, it is expected that the external representation contains only base
+ * Java objects like maps, lists and Strings. Details about the valid object types can be taken
+ * from the referenced persistence delegate.
+ *
+ * @param data The data object. Must not be <code>null</code>.
+ * @return The external representation of the given data object.
+ *
+ * @throws IOException - if the operation fails.
+ */
+ public String exportStringFrom(Object data) throws IOException;
+
+ /**
+ * Imports the given external representation.
+ *
+ * @param external The external representation. Must not be <code>null</code>.
+ * @return The data object or <code>null</code>.
+ *
+ * @throws IOException - if the operation fails.
+ */
+ public Object importFrom(String external) throws IOException;
+}
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);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF
index c7ff2d43b..4e38dded8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF
@@ -1,28 +1,29 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.tcf.te.tcf.launch.core;singleton:=true
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.tcf.te.tcf.launch.core.activator.CoreBundleActivator
-Bundle-Vendor: %providerName
-Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
- org.eclipse.debug.core;bundle-version="3.7.0",
- org.eclipse.tcf.core;bundle-version="1.0.0",
- org.eclipse.tcf.debug;bundle-version="1.0.0",
- org.eclipse.tcf.te.runtime;bundle-version="1.0.0",
- org.eclipse.tcf.te.runtime.concurrent;bundle-version="1.0.0",
- org.eclipse.tcf.te.runtime.model;bundle-version="1.0.0",
- org.eclipse.tcf.te.runtime.services;bundle-version="1.0.0",
- org.eclipse.tcf.te.runtime.stepper;bundle-version="1.0.0",
- org.eclipse.tcf.te.core;bundle-version="1.0.0",
- org.eclipse.tcf.te.launch.core;bundle-version="1.0.0",
- org.eclipse.tcf.te.tcf.core;bundle-version="1.0.0",
- org.eclipse.tcf.te.tcf.locator;bundle-version="1.0.0"
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Bundle-ActivationPolicy: lazy
-Bundle-Localization: plugin
-Export-Package: org.eclipse.tcf.te.tcf.launch.core.activator;x-internal:=true,
- org.eclipse.tcf.te.tcf.launch.core.interfaces,
- org.eclipse.tcf.te.tcf.launch.core.internal.adapters;x-internal:=true,
- org.eclipse.tcf.te.tcf.launch.core.nls;x-internal:=true,
- org.eclipse.tcf.te.tcf.launch.core.services
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.tcf.te.tcf.launch.core;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.tcf.te.tcf.launch.core.activator.CoreBundleActivator
+Bundle-Vendor: %providerName
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
+ org.eclipse.debug.core;bundle-version="3.7.0",
+ org.eclipse.tcf.core;bundle-version="1.0.0",
+ org.eclipse.tcf.debug;bundle-version="1.0.0",
+ org.eclipse.tcf.te.runtime;bundle-version="1.0.0",
+ org.eclipse.tcf.te.runtime.concurrent;bundle-version="1.0.0",
+ org.eclipse.tcf.te.runtime.model;bundle-version="1.0.0",
+ org.eclipse.tcf.te.runtime.services;bundle-version="1.0.0",
+ org.eclipse.tcf.te.runtime.stepper;bundle-version="1.0.0",
+ org.eclipse.tcf.te.core;bundle-version="1.0.0",
+ org.eclipse.tcf.te.launch.core;bundle-version="1.0.0",
+ org.eclipse.tcf.te.tcf.core;bundle-version="1.0.0",
+ org.eclipse.tcf.te.tcf.locator;bundle-version="1.0.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Export-Package: org.eclipse.tcf.te.tcf.launch.core.activator;x-internal:=true,
+ org.eclipse.tcf.te.tcf.launch.core.interfaces,
+ org.eclipse.tcf.te.tcf.launch.core.internal.adapters;x-internal:=true,
+ org.eclipse.tcf.te.tcf.launch.core.nls;x-internal:=true,
+ org.eclipse.tcf.te.tcf.launch.core.services,
+ org.eclipse.tcf.te.tcf.launch.core.steps
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.properties
index 71ecc830e..72d7d64cd 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.properties
@@ -1,16 +1,25 @@
-##################################################################################
-# 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, TCF Launching, Core
-providerName = Eclipse.org - TCF
-
-# ***** Launch Configuration Types *****
-
-LaunchType.Linux.App.name=Remote Linux Application
+##################################################################################
+# 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, TCF Launching, Core
+providerName = Eclipse.org - TCF
+
+# ***** Launch Configuration Types *****
+
+LaunchType.Linux.App.name=Remote Linux Application
+
+# ***** Launch Step Groups *****
+
+LaunchStepGroup.Linux.App.name=Remote Linux Application
+
+# ***** Launch Steps *****
+
+LaunchStep.OpenChannel.name=Open TCF Channel
+LaunchStep.CloseChannel.name=Close TCF Channel
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
index 6df537365..2ae1a6924 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
@@ -5,7 +5,7 @@
<!-- Adapter factory contributions -->
<extension point="org.eclipse.core.runtime.adapters">
<factory
- adaptableType="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"
+ adaptableType="org.eclipse.debug.core.ILaunch"
class="org.eclipse.tcf.te.tcf.launch.core.internal.adapters.AdapterFactory">
<adapter type="org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext"/>
</factory>
@@ -38,5 +38,88 @@
name="%LaunchType.Linux.App.name">
</launchConfigurationType>
</extension>
+
+<!-- Launch Configuration Type Binding contributions -->
+ <extension point="org.eclipse.tcf.te.launch.core.launchConfigTypeBindings">
+ <launchConfigTypeBinding
+ launchConfigTypeId="org.eclipse.tcf.te.tcf.launch.type.linux.app">
+ <stepper
+ id="org.eclipse.tcf.te.runtime.stepper"
+ modes="run,debug">
+ </stepper>
+ <launchManagerDelegate
+ id="org.eclipse.tcf.te.tcf.launch.type.linux.app.launchManagerDelegate"
+ modes="run,debug">
+ </launchManagerDelegate>
+ <stepGroup
+ id="org.eclipse.tcf.te.tcf.launch.type.linux.app.stepGroup"
+ modes="run,debug">
+ </stepGroup>
+ </launchConfigTypeBinding>
+ </extension>
+
+<!-- Launch Manager Delegate contributions -->
+ <extension point="org.eclipse.tcf.te.launch.core.launchManagerDelegates">
+ <delegate
+ class="org.eclipse.tcf.te.launch.core.lm.delegates.DefaultLaunchManagerDelegate"
+ id="org.eclipse.tcf.te.tcf.launch.type.linux.app.launchManagerDelegate">
+ </delegate>
+ </extension>
+
+<!-- Launch Step Group contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.stepper.stepGroups">
+ <stepGroup
+ id="org.eclipse.tcf.te.tcf.launch.type.linux.app.stepGroup"
+ label="%LaunchStepGroup.Linux.App.name"
+ locked="false">
+ <references>
+ <reference
+ id="org.eclipse.tcf.te.tcf.launch.core.openChannelStep"
+ disable="false"
+ hidden="false"
+ removable="false"
+ singleton="true">
+ </reference>
+ <reference
+ id="org.eclipse.tcf.te.tcf.launch.core.closeChannelStep"
+ disable="false"
+ hidden="false"
+ removable="false"
+ singleton="true">
+ </reference>
+ <reference
+ id="org.eclipse.tcf.te.launch.core.removeLaunchStep"
+ disable="false"
+ hidden="false"
+ removable="false"
+ singleton="true">
+ <enablement>
+ <with variable="context">
+ <not>
+ <test property="org.eclipse.tcf.te.launch.core.launchMode" value="debug"/>
+ </not>
+ </with>
+ </enablement>
+ </reference>
+ </references>
+ </stepGroup>
+ </extension>
+
+<!-- Launch Step contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.stepper.steps">
+ <step
+ class="org.eclipse.tcf.te.tcf.launch.core.steps.OpenChannelStep"
+ id="org.eclipse.tcf.te.tcf.launch.core.openChannelStep"
+ label="%LaunchStep.OpenChannel.name">
+ </step>
+ <step
+ class="org.eclipse.tcf.te.tcf.launch.core.steps.CloseChannelStep"
+ id="org.eclipse.tcf.te.tcf.launch.core.closeChannelStep"
+ label="%LaunchStep.CloseChannel.name">
+ <requires
+ id="org.eclipse.tcf.te.tcf.launch.core.openChannelStep">
+ </requires>
+ </step>
+ </extension>
</plugin>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AdapterFactory.java
index afd1bfba4..a822059ba 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AdapterFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AdapterFactory.java
@@ -13,72 +13,76 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchListener;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.interfaces.IDisposable;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.internal.nodes.InvalidPeerModel;
-import org.eclipse.tcf.te.tcf.locator.listener.ModelAdapter;
-import org.eclipse.tcf.te.tcf.locator.model.Model;
/**
* Adapter factory implementation.
*/
-@SuppressWarnings("restriction")
public class AdapterFactory implements IAdapterFactory {
// Maintain a map of step context adapters per peer model
- /* default */ Map<IPeerModel, IStepContext> adapters = new HashMap<IPeerModel, IStepContext>();
+ /* default */ Map<ILaunch, IStepContext> adapters = new HashMap<ILaunch, IStepContext>();
private static final Class<?>[] CLASSES = new Class[] {
IStepContext.class
};
/**
- * Constructor.
- */
- public AdapterFactory() {
- final IModelListener listener = new ModelAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.listener.ModelAdapter#locatorModelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, boolean)
- */
- @Override
- public void locatorModelChanged(ILocatorModel model, IPeerModel peer, boolean added) {
- // If a peer gets removed, remove the step context adapter too
- if (peer != null && !added) {
- IStepContext adapter = adapters.remove(peer);
- if (adapter instanceof IDisposable) ((IDisposable)adapter).dispose();
- }
- }
- };
+ * Constructor.
+ */
+ public AdapterFactory() {
+ final ILaunchListener listener = new ILaunchListener() {
+ @Override
+ public void launchRemoved(ILaunch launch) {
+ IStepContext adapter = adapters.remove(launch);
+ if (adapter instanceof IDisposable) {
+ ((IDisposable)adapter).dispose();
+ }
+ }
+ @Override
+ public void launchChanged(ILaunch launch) {
+ IStepContext adapter = adapters.remove(launch);
+ if (adapter instanceof IDisposable) {
+ ((IDisposable)adapter).dispose();
+ }
+ }
+ @Override
+ public void launchAdded(ILaunch launch) {
+ }
+ };
- Runnable runnable = new Runnable() {
+ Runnable runnable = new Runnable() {
@Override
public void run() {
- Model.getModel().addListener(listener);
+ DebugPlugin.getDefault().getLaunchManager().addLaunchListener(listener);
}
};
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
- }
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
+ }
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/
- @Override
+ @Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
- if (adaptableObject instanceof IPeerModel) {
+ if (adaptableObject instanceof ILaunch) {
if (IStepContext.class.equals(adapterType)) {
// Lookup the adapter
IStepContext adapter = adapters.get(adaptableObject);
// No adapter yet -> create a new one for this peer
if (adapter == null) {
- adapter = new StepContextAdapter((IPeerModel)adaptableObject);
- if (!(adaptableObject instanceof InvalidPeerModel)) {
- adapters.put((IPeerModel)adaptableObject, adapter);
- }
+ adapter = new StepContextAdapter((ILaunch)adaptableObject);
+ adapters.put((ILaunch)adaptableObject, adapter);
}
return adapter;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/StepContextAdapter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/StepContextAdapter.java
index 0ccb2414c..b089e53ba 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/StepContextAdapter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/StepContextAdapter.java
@@ -9,56 +9,42 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.launch.core.internal.adapters;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.core.TransientPeer;
-import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.protocol.JSON;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.tcf.launch.core.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
-import org.eclipse.tcf.te.tcf.locator.internal.nodes.InvalidPeerModel;
-import org.eclipse.tcf.te.tcf.locator.model.Model;
-import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel;
/**
* Peer model step context adapter implementation.
*/
-@SuppressWarnings("restriction")
public class StepContextAdapter extends PlatformObject implements IStepContext {
- // Reference to the wrapped peer model
- /* default */ IPeerModel peerModel;
+ // Reference to the launch
+ private final ILaunch launch;
/**
- * Constructor.
- *
- * @param peerModel The peer model. Must not be <code>null</code>.
- */
- public StepContextAdapter(IPeerModel peerModel) {
- super();
- Assert.isNotNull(peerModel);
- this.peerModel = peerModel;
- }
+ * Constructor.
+ *
+ * @param launch The launch. Must not be <code>null</code>.
+ */
+ public StepContextAdapter(ILaunch launch) {
+ super();
+ Assert.isNotNull(launch);
+ this.launch = launch;
+ }
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNodeProvider#getModelNode()
+ /**
+ * Returns the launch.
+ * @return The launch.
*/
- @Override
- public IModelNode getModelNode() {
- return peerModel;
+ public ILaunch getLaunch() {
+ return launch;
}
/* (non-Javadoc)
@@ -66,7 +52,7 @@ public class StepContextAdapter extends PlatformObject implements IStepContext {
*/
@Override
public String getId() {
- return peerModel != null ? peerModel.getPeerId() : null;
+ return launch != null ? launch.getLaunchConfiguration().getName() : null;
}
/* (non-Javadoc)
@@ -76,150 +62,44 @@ public class StepContextAdapter extends PlatformObject implements IStepContext {
public String getName() {
final AtomicReference<String> name = new AtomicReference<String>();
- if (peerModel != null) {
+ if (launch != null) {
Runnable runnable = new Runnable() {
@Override
public void run() {
- name.set(peerModel.getName());
+ name.set(getId());
}
};
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
}
return name.get();
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getInfo(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getContextObject()
*/
@Override
- public String getInfo(IPropertiesContainer data) {
- return ""; //$NON-NLS-1$
+ public Object getContextObject() {
+ return launch;
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#exists()
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getInfo(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
*/
@Override
- public boolean exists() {
- final AtomicBoolean isGhost = new AtomicBoolean();
-
- if (peerModel != null) {
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- isGhost.set(peerModel.getBooleanProperty(IModelNode.PROPERTY_IS_GHOST));
- }
- };
-
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ public String getInfo(IPropertiesContainer data) {
+ try {
+ return getName() + "(" + launch.getLaunchMode() + ") - " + launch.getLaunchConfiguration().getType().getName(); //$NON-NLS-1$ //$NON-NLS-2$
}
-
- return peerModel != null && !isGhost.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#encode()
- */
- @Override
- public String encode() {
- final AtomicReference<String> encoded = new AtomicReference<String>();
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- try {
- Map<String, String> attrs = new HashMap<String, String>(peerModel.getPeer().getAttributes());
-
- // Remove all transient attributes
- String[] keys = attrs.keySet().toArray(new String[attrs.keySet().size()]);
- for (String key : keys) {
- if (key.endsWith(".transient")) { //$NON-NLS-1$
- attrs.remove(key);
- }
- }
-
- encoded.set(JSON.toJSON(attrs));
- }
- catch (IOException e) {
- if (Platform.inDebugMode()) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- "StepContextAdapter encode failure: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- }
- }
- };
-
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
-
- return encoded.get() != null ? encoded.get() : ""; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getEncodedClassName()
- */
- @Override
- public String getEncodedClassName() {
- return IPeerModel.class.getName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#decode(java.lang.String)
- */
- @Override
- public void decode(final String value) throws IOException {
- Assert.isNotNull(value);
-
- final AtomicReference<IOException> error = new AtomicReference<IOException>();
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- try {
- Object o = JSON.parseOne(value.getBytes("UTF-8")); //$NON-NLS-1$
- // The decoded object should be a map
- if (o instanceof Map) {
- @SuppressWarnings("unchecked")
- Map<String, String> attrs = (Map<String, String>)o;
-
- // Get the id of the decoded attributes
- String id = attrs.get("ID"); //$NON-NLS-1$
- if (id == null) throw new IOException("StepContextAdapter#decode: Mandatory attribure 'ID' is missing."); //$NON-NLS-1$
-
- // If the ID is matching the associated peer model, than we are done here
- if (peerModel != null && !(peerModel instanceof InvalidPeerModel) && peerModel.getPeerId().equals(id)) {
- return;
- }
-
- // Lookup the id within the model
- IPeerModel candidate = Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(id);
- if (candidate != null) {
- peerModel = candidate;
- return;
- }
-
- // Not found in the model -> create a ghost object
- IPeer peer = new TransientPeer(attrs);
- peerModel = new PeerModel(Model.getModel(), peer);
- peerModel.setProperty(IModelNode.PROPERTY_IS_GHOST, true);
- } else {
- throw new IOException("StepContextAdapter#decode: Object not of map type."); //$NON-NLS-1$
- }
- } catch (IOException e) {
- error.set(e);
- }
- }
- };
-
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
-
- if (error.get() != null) throw error.get();
+ catch (CoreException e) {
+ }
+ return getName() + "(" + launch.getLaunchMode() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
/* (non-Javadoc)
@@ -238,8 +118,12 @@ public class StepContextAdapter extends PlatformObject implements IStepContext {
}
};
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
return object.get() != null ? object.get() : super.getAdapter(adapter);
}
@@ -254,12 +138,20 @@ public class StepContextAdapter extends PlatformObject implements IStepContext {
* @return The adapter or <code>null</code>.
*/
protected Object doGetAdapter(Class<?> adapter) {
- if (IModelNode.class.isAssignableFrom(adapter)) {
- return peerModel;
+ if (ILaunch.class.equals(adapter)) {
+ return launch;
}
- if (IPeer.class.equals(adapter)) {
- return peerModel.getPeer();
+ if (ILaunchConfiguration.class.equals(adapter)) {
+ return launch.getLaunchConfiguration();
+ }
+
+ if (ILaunchConfigurationType.class.equals(adapter)) {
+ try {
+ return launch.getLaunchConfiguration().getType();
+ }
+ catch (CoreException e) {
+ }
}
return null;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AbstractTcfLaunchStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AbstractTcfLaunchStep.java
new file mode 100644
index 000000000..204f0994d
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AbstractTcfLaunchStep.java
@@ -0,0 +1,32 @@
+/*
+ * AbstractTcfLaunchStep.java
+ * Created on 22.02.2012
+ *
+ * Copyright 2012 Wind River Systems Inc. All rights reserved.
+ */
+package org.eclipse.tcf.te.tcf.launch.core.steps;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.tcf.te.launch.core.steps.AbstractLaunchStep;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+
+/**
+ * AbstractTcfLaunchStep
+ * @author tobias.schwarz@windriver.com
+ */
+public abstract class AbstractTcfLaunchStep extends AbstractLaunchStep {
+
+ /**
+ * Returns the active peer model that is currently used.
+ *
+ * @param data The data giving object. Must not be <code>null</code>.
+ * @return The active peer model.
+ */
+ protected IPeerModel getActivePeerModel(IPropertiesContainer data) {
+ IModelNode node = getActiveLaunchContext(data);
+ Assert.isTrue(node instanceof IPeerModel);
+ return (IPeerModel)node;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/CloseChannelStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/CloseChannelStep.java
new file mode 100644
index 000000000..2358d577b
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/CloseChannelStep.java
@@ -0,0 +1,49 @@
+/*
+ * CloseChannelStep.java
+ * Created on 23.02.2012
+ *
+ * Copyright 2012 Wind River Systems Inc. All rights reserved.
+ */
+package org.eclipse.tcf.te.tcf.launch.core.steps;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.protocol.IChannel;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.tcf.core.Tcf;
+
+/**
+ * CloseChannelStep
+ * @author tobias.schwarz@windriver.com
+ */
+public class CloseChannelStep extends AbstractTcfLaunchStep {
+
+ /**
+ * Constructor.
+ */
+ public CloseChannelStep() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
+ */
+ @Override
+ public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) {
+ IChannel channel = Tcf.getChannelManager().getChannel(getActivePeerModel(data).getPeer());
+ if (channel != null && channel.getState() != IChannel.STATE_CLOSED) {
+ Tcf.getChannelManager().closeChannel(channel);
+ }
+ callback.done(this, Status.OK_STATUS);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/OpenChannelStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/OpenChannelStep.java
new file mode 100644
index 000000000..e8dc4c220
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/OpenChannelStep.java
@@ -0,0 +1,61 @@
+/*
+ * OpenChannelStep.java
+ * Created on 22.02.2012
+ *
+ * Copyright 2012 Wind River Systems Inc. All rights reserved.
+ */
+package org.eclipse.tcf.te.tcf.launch.core.steps;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.tcf.protocol.IChannel;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.runtime.utils.StatusHelper;
+import org.eclipse.tcf.te.tcf.core.Tcf;
+import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager;
+
+/**
+ * OpenChannelStep
+ * @author tobias.schwarz@windriver.com
+ */
+public class OpenChannelStep extends AbstractTcfLaunchStep {
+
+ /**
+ * Constructor.
+ */
+ public OpenChannelStep() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
+ */
+ @Override
+ public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) {
+ Tcf.getChannelManager().openChannel(getActivePeerModel(data).getPeer(), false, new IChannelManager.DoneOpenChannel() {
+ @Override
+ public void doneOpenChannel(final Throwable error, final IChannel channel) {
+ callback.done(OpenChannelStep.this, StatusHelper.getStatus(error));
+ }
+ });
+ }
+
+ @Override
+ public void rollback(IStepContext context, IPropertiesContainer data, IStatus status, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) {
+ IChannel channel = Tcf.getChannelManager().getChannel(getActivePeerModel(data).getPeer());
+ if (channel != null && channel.getState() != IChannel.STATE_CLOSED) {
+ Tcf.getChannelManager().closeChannel(channel);
+ }
+ super.rollback(context, data, status, fullQualifiedId, monitor, callback);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
index 7e16fab85..26ce9a9fc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
@@ -1,68 +1,69 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-
-<!-- Preference contributions -->
- <extension point="org.eclipse.core.runtime.preferences">
- <initializer
- class="org.eclipse.tcf.te.tcf.locator.internal.preferences.PreferencesInitializer"/>
- </extension>
-
-<!-- Eclipse core expressions property tester -->
- <extension point="org.eclipse.core.expressions.propertyTesters">
- <propertyTester
- class="org.eclipse.tcf.te.tcf.locator.internal.MyPropertyTester"
- id="org.eclipse.tcf.te.tcf.locator.LocatorModelPropertyTester"
- namespace="org.eclipse.tcf.te.tcf.locator"
- properties="name,hasLocalService,hasRemoteService,isStaticPeer,isRedirected"
- type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel">
- </propertyTester>
- </extension>
-
-<!-- Persistence delegate contributions -->
- <extension point="org.eclipse.tcf.te.runtime.persistence.delegates">
- <delegate
- id="org.eclipse.tcf.te.tcf.locator.persistence"
- class="org.eclipse.tcf.te.tcf.locator.internal.PeersPersistenceDelegate">
- </delegate>
- </extension>
-
-<!-- Adapter factory contributions -->
- <extension point="org.eclipse.core.runtime.adapters">
- <factory
- adaptableType="java.util.Map"
- class="org.eclipse.tcf.te.tcf.locator.internal.adapters.AdapterFactory">
- <adapter type="org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable"/>
- </factory>
-
- <factory
- adaptableType="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"
- class="org.eclipse.tcf.te.tcf.locator.internal.adapters.AdapterFactory">
- <adapter type="org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable"/>
- </factory>
- </extension>
-
-<!-- Service contributions -->
- <extension point="org.eclipse.tcf.te.runtime.services.services">
- <service
- class="org.eclipse.tcf.te.tcf.locator.internal.services.PropertiesAccessService"
- id="org.eclipse.tcf.te.runtime.services.tcf.propertiesAccess">
- <serviceType
- bundleId="org.eclipse.tcf.te.runtime.services"
- class="org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService"/>
- <enablement>
- <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
- </enablement>
- </service>
- </extension>
-
-<!-- Model node factory delegate contributions -->
- <extension point="org.eclipse.tcf.te.runtime.model.factoryDelegates">
- <delegate
- class="org.eclipse.tcf.te.tcf.locator.internal.ModelNodeFactoryDelegate"
- id="org.eclipse.tcf.te.tcf.locator.model.factory.delegate">
- <nodeType class="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
- </delegate>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+<!-- Preference contributions -->
+ <extension point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.tcf.te.tcf.locator.internal.preferences.PreferencesInitializer"/>
+ </extension>
+
+<!-- Eclipse core expressions property tester -->
+ <extension point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.tcf.te.tcf.locator.internal.MyPropertyTester"
+ id="org.eclipse.tcf.te.tcf.locator.LocatorModelPropertyTester"
+ namespace="org.eclipse.tcf.te.tcf.locator"
+ properties="name,hasLocalService,hasRemoteService,isStaticPeer,isRedirected"
+ type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel">
+ </propertyTester>
+ </extension>
+
+<!-- Persistence delegate contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.persistence.delegates">
+ <delegate
+ id="org.eclipse.tcf.te.tcf.locator.persistence"
+ class="org.eclipse.tcf.te.tcf.locator.internal.PeersPersistenceDelegate">
+ </delegate>
+ </extension>
+
+<!-- Adapter factory contributions -->
+ <extension point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="java.util.Map"
+ class="org.eclipse.tcf.te.tcf.locator.internal.adapters.AdapterFactory">
+ <adapter type="org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable"/>
+ </factory>
+
+ <factory
+ adaptableType="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"
+ class="org.eclipse.tcf.te.tcf.locator.internal.adapters.AdapterFactory">
+ <adapter type="org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable"/>
+ <adapter type="org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable2"/>
+ </factory>
+ </extension>
+
+<!-- Service contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.services.services">
+ <service
+ class="org.eclipse.tcf.te.tcf.locator.internal.services.PropertiesAccessService"
+ id="org.eclipse.tcf.te.runtime.services.tcf.propertiesAccess">
+ <serviceType
+ bundleId="org.eclipse.tcf.te.runtime.services"
+ class="org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService"/>
+ <enablement>
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
+ </enablement>
+ </service>
+ </extension>
+
+<!-- Model node factory delegate contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.model.factoryDelegates">
+ <delegate
+ class="org.eclipse.tcf.te.tcf.locator.internal.ModelNodeFactoryDelegate"
+ id="org.eclipse.tcf.te.tcf.locator.model.factory.delegate">
+ <nodeType class="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
+ </delegate>
+ </extension>
+
+</plugin>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java
index 2e337fd41..ce13c9dab 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java
@@ -12,8 +12,9 @@ package org.eclipse.tcf.te.tcf.locator.internal.adapters;
import java.util.Map;
import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable2;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
/**
* Static peers adapter factory implementation.
@@ -24,7 +25,8 @@ public class AdapterFactory implements IAdapterFactory {
private final IPersistable peerModelPersistableAdapter = new PeerModelPersistableAdapter();
private static final Class<?>[] CLASSES = new Class[] {
- IPersistable.class
+ IPersistable.class,
+ IPersistable2.class
};
/* (non-Javadoc)
@@ -42,6 +44,9 @@ public class AdapterFactory implements IAdapterFactory {
if (IPersistable.class.equals(adapterType)) {
return peerModelPersistableAdapter;
}
+ if (IPersistable2.class.equals(adapterType)) {
+ return peerModelPersistableAdapter;
+ }
}
return null;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerModelPersistableAdapter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerModelPersistableAdapter.java
index b8aff7697..edd3bd006 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerModelPersistableAdapter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerModelPersistableAdapter.java
@@ -16,16 +16,26 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.core.TransientPeer;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.JSON;
import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable2;
import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableNodeProperties;
import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
+import org.eclipse.tcf.te.tcf.locator.model.Model;
+import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel;
/**
* Persistable implementation handling peer attributes.
*/
-public class PeerModelPersistableAdapter implements IPersistable {
+public class PeerModelPersistableAdapter implements IPersistable2 {
/* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable#getStorageID()
@@ -38,7 +48,7 @@ public class PeerModelPersistableAdapter implements IPersistable {
/* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable#getURI(java.lang.Object)
*/
- @Override
+ @Override
public URI getURI(final Object data) {
Assert.isNotNull(data);
@@ -57,30 +67,36 @@ public class PeerModelPersistableAdapter implements IPersistable {
}
}
};
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
- if (nodeURI.get() != null) uri = nodeURI.get();
+ if (nodeURI.get() != null) {
+ uri = nodeURI.get();
+ }
}
return uri;
}
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable#getInterfaceType(java.lang.Object)
- */
- @Override
- public String getInterfaceTypeName(Object data) {
- if (data instanceof IPeerModel) {
- return CoreBundleActivator.getUniqueIdentifier() + ":" + IPeerModel.class.getName(); //$NON-NLS-1$
- }
- return null;
- }
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable#getInterfaceType(java.lang.Object)
+ */
+ @Override
+ public String getInterfaceTypeName(Object data) {
+ if (data instanceof IPeerModel) {
+ return CoreBundleActivator.getUniqueIdentifier() + ":" + IPeerModel.class.getName(); //$NON-NLS-1$
+ }
+ return null;
+ }
/* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable#exportFrom(java.lang.Object)
*/
- @Override
+ @Override
public Map<String, Object> exportFrom(final Object data) throws IOException {
Assert.isNotNull(data);
@@ -94,8 +110,12 @@ public class PeerModelPersistableAdapter implements IPersistable {
attributes.set(((IPeerModel)data).getPeer().getAttributes());
}
};
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
}
Map<String, Object> result = null;
@@ -123,4 +143,116 @@ public class PeerModelPersistableAdapter implements IPersistable {
// A new peer with the new attributes needs to be created and set to the peer model.
}
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable2#exportStringFrom(java.lang.Object)
+ */
+ @Override
+ public String exportStringFrom(final Object data) {
+ final AtomicReference<String> encoded = new AtomicReference<String>();
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Map<String, Object> attrs = exportFrom(data);
+
+ // Remove all transient attributes
+ String[] keys = attrs.keySet().toArray(new String[attrs.keySet().size()]);
+ for (String key : keys) {
+ if (key.endsWith(".transient")) { //$NON-NLS-1$
+ attrs.remove(key);
+ }
+ }
+
+ encoded.set(JSON.toJSON(attrs));
+ }
+ catch (IOException e) {
+ if (Platform.inDebugMode()) {
+ IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
+ "PeerModelPersistableAdapter export failure: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
+ Platform.getLog(CoreBundleActivator.getDefault().getBundle()).log(status);
+ }
+ }
+ }
+ };
+
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
+
+ return encoded.get() != null ? encoded.get() : ""; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable2#getEncodedClassName(java.lang.Object)
+ */
+ @Override
+ public String getEncodedClassName(final Object data) {
+ return IPeerModel.class.getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistable2#importFrom(java.lang.String)
+ */
+ @Override
+ public Object importFrom(final String external) throws IOException {
+ Assert.isNotNull(external);
+
+ final AtomicReference<IPeerModel> decoded = new AtomicReference<IPeerModel>();
+ final AtomicReference<IOException> error = new AtomicReference<IOException>();
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Object o = JSON.parseOne(external.getBytes("UTF-8")); //$NON-NLS-1$
+ // The decoded object should be a map
+ if (o instanceof Map) {
+ @SuppressWarnings("unchecked")
+ Map<String, String> attrs = (Map<String, String>)o;
+
+ // Get the id of the decoded attributes
+ String id = attrs.get("ID"); //$NON-NLS-1$
+ if (id == null) {
+ throw new IOException("PeerModelPersistableAdapter#import: Mandatory attribure 'ID' is missing."); //$NON-NLS-1$
+ }
+
+ // Lookup the id within the model
+ IPeerModel candidate = Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(id);
+ if (candidate != null) {
+ decoded.set(candidate);
+ return;
+ }
+
+ // Not found in the model -> create a ghost object
+ IPeer peer = new TransientPeer(attrs);
+ IPeerModel peerModel = new PeerModel(Model.getModel(), peer);
+ peerModel.setProperty(IModelNode.PROPERTY_IS_GHOST, true);
+
+ decoded.set(peerModel);
+ } else {
+ throw new IOException("PeerModelPersistableAdapter#import: Object not of map type."); //$NON-NLS-1$
+ }
+ } catch (IOException e) {
+ error.set(e);
+ }
+ }
+ };
+
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
+
+ if (error.get() != null) {
+ throw error.get();
+ }
+
+ return decoded.get() != null ? decoded.get() : ""; //$NON-NLS-1$
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/nodes/InvalidPeerModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/nodes/InvalidPeerModel.java
index 4d6325a0b..1abbc4ead 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/nodes/InvalidPeerModel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/nodes/InvalidPeerModel.java
@@ -13,6 +13,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode;
@@ -444,7 +445,7 @@ public final class InvalidPeerModel implements IPeerModel {
*/
@Override
public Object getAdapter(Class adapter) {
- throw new IllegalStateException();
+ return Platform.getAdapterManager().getAdapter(this, adapter);
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tests/plugin.xml
index 8d7835fb7..5a5a4298e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tests/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/plugin.xml
@@ -81,18 +81,6 @@
</step>
</extension>
- <extension point="org.eclipse.tcf.te.runtime.stepper.stepBindings">
- <binding
- id="org.eclipse.tcf.te.tests.stepper.steps.binding1"
- stepId="org.eclipse.tcf.te.tests.stepper.step5">
- <enablement>
- <with variable="activeContexts">
- <count value="1"/>
- </with>
- </enablement>
- </binding>
- </extension>
-
<extension point="org.eclipse.tcf.te.runtime.stepper.stepGroups">
<stepGroup
id="org.eclipse.tcf.te.tests.stepper.stepGroup1"
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/StepperTestCase.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/StepperTestCase.java
index aec0fc3ca..8fc7e10d0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/StepperTestCase.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/StepperTestCase.java
@@ -15,6 +15,7 @@ import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.stepper.StepperManager;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStep;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
@@ -28,6 +29,35 @@ import org.eclipse.tcf.te.tests.CoreTestCase;
*/
public class StepperTestCase extends CoreTestCase {
+ protected static class TestStepContext implements IStepContext {
+
+ @Override
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+
+ @Override
+ public String getId() {
+ return "org.eclipse.tcf.te.tests.stepper.TestStepContext"; //$NON-NLS-1$
+ }
+
+ @Override
+ public String getName() {
+ return "TestStepContext"; //$NON-NLS-1$
+ }
+
+ @Override
+ public Object getContextObject() {
+ return this;
+ }
+
+ @Override
+ public String getInfo(IPropertiesContainer data) {
+ return getName();
+ }
+
+ }
+
/**
* Provides a test suite to the caller which combines all single
* test bundled within this category.
@@ -37,8 +67,8 @@ public class StepperTestCase extends CoreTestCase {
public static Test getTestSuite() {
TestSuite testSuite = new TestSuite("Test stepper engine"); //$NON-NLS-1$
- // add ourself to the test suite
- testSuite.addTestSuite(StepperTestCase.class);
+ // add ourself to the test suite
+ testSuite.addTestSuite(StepperTestCase.class);
return testSuite;
}
@@ -62,7 +92,9 @@ public class StepperTestCase extends CoreTestCase {
if (stepper.getId().equals("org.eclipse.tcf.te.runtime.stepper.singleContext")) { //$NON-NLS-1$
singleContext = true;
}
- if (multiContext && singleContext) break;
+ if (multiContext && singleContext) {
+ break;
+ }
}
assertTrue("Default multi context stepper contribution not found.", multiContext); //$NON-NLS-1$
assertTrue("Default single context stepper contribution not found.", singleContext); //$NON-NLS-1$
@@ -90,10 +122,6 @@ public class StepperTestCase extends CoreTestCase {
assertEquals("Unexpected step description found.", "", step.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("Unexpected step class type found.", step instanceof TestStep); //$NON-NLS-1$
assertEquals("Unexpected number of dependencies found.", 0, step.getDependencies().length); //$NON-NLS-1$
-
- assertTrue("Step is not enabled but should.", StepperManager.getInstance().getStepBindingsExtManager().isStepEnabled(step.getId(), null)); //$NON-NLS-1$
- assertTrue("Step is not enabled but should.", StepperManager.getInstance().getStepBindingsExtManager().isStepEnabled(step.getId(), new IStepContext[0])); //$NON-NLS-1$
- assertTrue("Step is not enabled but should.", StepperManager.getInstance().getStepBindingsExtManager().isStepEnabled(step.getId(), new IStepContext[1])); //$NON-NLS-1$
}
if (step.getId().endsWith(".step2")) { //$NON-NLS-1$
@@ -129,10 +157,6 @@ public class StepperTestCase extends CoreTestCase {
assertEquals("Unexpected step description found.", "", step.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("Unexpected step class type found.", step instanceof TestStep); //$NON-NLS-1$
assertEquals("Unexpected number of dependencies found.", 0, step.getDependencies().length); //$NON-NLS-1$
-
- assertFalse("Step is enabled but should not.", StepperManager.getInstance().getStepBindingsExtManager().isStepEnabled(step.getId(), null)); //$NON-NLS-1$
- assertFalse("Step is enabled but should not.", StepperManager.getInstance().getStepBindingsExtManager().isStepEnabled(step.getId(), new IStepContext[0])); //$NON-NLS-1$
- assertTrue("Step is not enabled but should.", StepperManager.getInstance().getStepBindingsExtManager().isStepEnabled(step.getId(), new IStepContext[1])); //$NON-NLS-1$
}
}
@@ -167,7 +191,7 @@ public class StepperTestCase extends CoreTestCase {
assertNull("Unexpected non-null value.", stepGroup.getStepGroupIterator()); //$NON-NLS-1$
try {
- steps = stepGroup.getSteps(new IStepContext[0]);
+ steps = stepGroup.getSteps(new TestStepContext());
} catch (CoreException e) {
error = e;
message = e.getLocalizedMessage();
@@ -185,7 +209,7 @@ public class StepperTestCase extends CoreTestCase {
error = null; message = null; steps = null;
try {
- steps = stepGroup.getSteps(new IStepContext[0]);
+ steps = stepGroup.getSteps(new TestStepContext());
} catch (CoreException e) {
error = e;
message = e.getLocalizedMessage();
@@ -203,7 +227,7 @@ public class StepperTestCase extends CoreTestCase {
error = null; message = null; steps = null;
try {
- steps = stepGroup.getSteps(new IStepContext[0]);
+ steps = stepGroup.getSteps(new TestStepContext());
} catch (CoreException e) {
error = e;
message = e.getLocalizedMessage();
@@ -227,7 +251,7 @@ public class StepperTestCase extends CoreTestCase {
error = null; message = null; steps = null;
try {
- steps = stepGroup.getSteps(new IStepContext[0]);
+ steps = stepGroup.getSteps(new TestStepContext());
} catch (CoreException e) {
error = e;
message = e.getLocalizedMessage();
@@ -243,7 +267,7 @@ public class StepperTestCase extends CoreTestCase {
error = null; message = null; steps = null;
try {
- steps = stepGroup.getSteps(new IStepContext[1]);
+ steps = stepGroup.getSteps(new TestStepContext());
} catch (CoreException e) {
error = e;
message = e.getLocalizedMessage();

Back to the top