diff options
author | Tobias Schwarz | 2012-02-29 06:44:31 +0000 |
---|---|---|
committer | Uwe Stieber | 2012-02-29 06:44:31 +0000 |
commit | 7609fc7616cfe2b2e8aaf04a52ca10a34558ca13 (patch) | |
tree | a14a188f9752ff72c44752fe21593672693ae531 /target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse | |
parent | bc2bdd576dcdfe79d0dd4f4ed14d486b16853fbc (diff) | |
download | org.eclipse.tcf-7609fc7616cfe2b2e8aaf04a52ca10a34558ca13.tar.gz org.eclipse.tcf-7609fc7616cfe2b2e8aaf04a52ca10a34558ca13.tar.xz org.eclipse.tcf-7609fc7616cfe2b2e8aaf04a52ca10a34558ca13.zip |
Target Explorer: Cherry-Pick: Remove stepper and variant delegate extension points
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse')
11 files changed, 1004 insertions, 1400 deletions
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 1ed089acf..1d55155a1 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java @@ -29,7 +29,6 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.tcf.te.launch.core.bindings.internal.LaunchConfigTypeBinding;
import org.eclipse.tcf.te.launch.core.bindings.internal.OverwritableLaunchBinding;
-import org.eclipse.tcf.te.launch.core.extensions.internal.LaunchModeVariantDelegateExtensionPointManager;
import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate;
import org.eclipse.tcf.te.launch.core.lm.internal.ExtensionPointManager;
import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
@@ -38,8 +37,6 @@ import org.eclipse.tcf.te.runtime.extensions.ExtensionPointComparator; import org.eclipse.tcf.te.runtime.stepper.StepperManager;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStep;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IVariantDelegate;
/**
@@ -148,71 +145,21 @@ public class LaunchConfigTypeBindingsManager { }
/**
- * Get the registered launch mode variant delegate for the given launch configuration type and launch mode.
+ * Get the registered step group id for the given launch configuration type and launch mode.
*
* @param typeId The launch configuration type id. Must not be <code>null</code>.
* @param mode The launch mode. Must not be <code>null</code>.
*
- * @return The launch mode variant delegate, or a <code>null</code> if no delegate is registered for the
- * given launch configuration type id and launch mode.
- */
- public IVariantDelegate getLaunchModeVariantDelegate(String typeId, String mode) {
- Assert.isNotNull(typeId);
- Assert.isNotNull(mode);
-
- LaunchConfigTypeBinding binding = bindings.get(typeId);
- if (binding != null) {
- String id = binding.getLaunchModeVariantDelegate(mode);
- if (id != null) {
- return LaunchModeVariantDelegateExtensionPointManager.getInstance().getLaunchModeVariantDelegate(id);
- }
- }
- return null;
- }
-
- /**
- * Get the registered stepper for the given launch configuration type id and launch mode.
- *
- * @param typeId The launch configuration type id. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
-
- * @return The stepper or <code>null</code> if no stepper is registered for the
- * given launch configuration type id and launch mode.
- */
- public IStepper getStepper(String typeId, String mode) {
- Assert.isNotNull(typeId);
- Assert.isNotNull(mode);
-
- IStepper stepper = null;
-
- LaunchConfigTypeBinding binding = bindings.get(typeId);
- if (binding != null) {
- String id = binding.getStepper(mode);
- if (id != null) {
- stepper = StepperManager.getInstance().getStepperExtManager().getStepper(id, false);
- }
- }
-
- return stepper;
- }
-
- /**
- * Get the registered step group id for the given launch configuration type, launch mode and variant.
- *
- * @param typeId The launch configuration type id. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
- * @param variant The launch mode variant or <code>null</code>.
- *
* @return The launch step group id or <code>null</code> if no step group is registered for the
- * given launch configuration type id, launch mode and variant.
+ * given launch configuration type id and launch mode.
*/
- public String getStepGroupId(String typeId, String mode, String variant) {
+ public String getStepGroupId(String typeId, String mode) {
Assert.isNotNull(typeId);
Assert.isNotNull(mode);
LaunchConfigTypeBinding binding = bindings.get(typeId);
if (binding != null) {
- return binding.getStepGroupId(mode, variant);
+ return binding.getStepGroupId(mode);
}
return null;
}
@@ -284,15 +231,6 @@ public class LaunchConfigTypeBindingsManager { binding.addLaunchManagerDelegate(new OverwritableLaunchBinding(id, overwrites, modes));
}
- IConfigurationElement[] launchModeVariantDelegateBindings = element.getChildren("launchModeVariantDelegate"); //$NON-NLS-1$
- for (IConfigurationElement launchModeVariantDelegateBinding : launchModeVariantDelegateBindings) {
- String id = launchModeVariantDelegateBinding.getAttribute("id"); //$NON-NLS-1$
- String overwrites = launchModeVariantDelegateBinding.getAttribute("overwrites"); //$NON-NLS-1$
- String modes = launchModeVariantDelegateBinding.getAttribute("modes"); //$NON-NLS-1$
-
- binding.addLaunchModeVariantDelegate(new OverwritableLaunchBinding(id, overwrites, modes));
- }
-
IConfigurationElement[] stepperBindings = element.getChildren("stepper"); //$NON-NLS-1$
for (IConfigurationElement stepperBinding : stepperBindings) {
String id = stepperBinding.getAttribute("id"); //$NON-NLS-1$
@@ -307,9 +245,8 @@ public class LaunchConfigTypeBindingsManager { String id = stepGroupBinding.getAttribute("id"); //$NON-NLS-1$
String overwrites = stepGroupBinding.getAttribute("overwrites"); //$NON-NLS-1$
String modes = stepGroupBinding.getAttribute("modes"); //$NON-NLS-1$
- String variants = stepGroupBinding.getAttribute("variants"); //$NON-NLS-1$
- binding.addStepGroup(new OverwritableLaunchBinding(id, overwrites, modes, variants));
+ binding.addStepGroup(new OverwritableLaunchBinding(id, overwrites, modes));
}
IConfigurationElement[] enablements = element.getChildren("enablement"); //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IOverwritableLaunchBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IOverwritableLaunchBinding.java index 1b8586fb1..4aed764b2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IOverwritableLaunchBinding.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IOverwritableLaunchBinding.java @@ -1,24 +1,24 @@ -/******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.launch.core.bindings.interfaces; - -/** - * Interface to be implemented by a overwritable launch configuration type binding element. - */ -public interface IOverwritableLaunchBinding extends IVaryableLaunchBinding { - - /** - * Returns if or if not this binding overwrites the given bindings id. - * - * @param id The id. Must not be <code>null</code>. - * @return <code>True</code> if this binding overwrites the given bindings id, <code>false</code> if not. - */ - public boolean overwrites(String id); -} +/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.core.bindings.interfaces;
+
+/**
+ * Interface to be implemented by a overwritable launch configuration type binding element.
+ */
+public interface IOverwritableLaunchBinding extends ILaunchBinding {
+
+ /**
+ * Returns if or if not this binding overwrites the given bindings id.
+ *
+ * @param id The id. Must not be <code>null</code>.
+ * @return <code>True</code> if this binding overwrites the given bindings id, <code>false</code> if not.
+ */
+ public boolean overwrites(String id);
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IVaryableLaunchBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IVaryableLaunchBinding.java deleted file mode 100644 index 89528a0ea..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/interfaces/IVaryableLaunchBinding.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.launch.core.bindings.interfaces; - -/** - * Interface to be implemented by a launch configuration type binding element - * which is supporting launch mode variants. - */ -public interface IVaryableLaunchBinding extends ILaunchBinding { - - /** - * Returns if or if not the given launch mode is handled by this binding. - * <p> - * <b>Note:</b> The launch mode and launch mode variant are considered valid - * if <code>null</code> or an empty string is passed. - * - * @param mode The launch mode. Must not be <code>null</code>. - * @param variant The launch mode variant to check or <code>null</code>. - * - * @return <code>True</code> if the launch mode is valid, <code>false</code> otherwise. - */ - public boolean isValidLaunchMode(String mode, String variant); -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java index 0c3998b70..73df9b5aa 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java @@ -23,7 +23,6 @@ import org.eclipse.core.runtime.Status; import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
import org.eclipse.tcf.te.launch.core.bindings.interfaces.ILaunchBinding;
import org.eclipse.tcf.te.launch.core.bindings.interfaces.IOverwritableLaunchBinding;
-import org.eclipse.tcf.te.launch.core.bindings.interfaces.IVaryableLaunchBinding;
import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
@@ -38,7 +37,6 @@ public class LaunchConfigTypeBinding { private final List<ILaunchBinding> lmDelegateBindings = new ArrayList<ILaunchBinding>();
private final List<ILaunchBinding> stepperBindings = new ArrayList<ILaunchBinding>();
private final List<ILaunchBinding> stepGroupBindings = new ArrayList<ILaunchBinding>();
- private final List<ILaunchBinding> variantDelegateBindings = new ArrayList<ILaunchBinding>();
// The list of enablement expressions
private final List<Expression> expressions = new ArrayList<Expression>();
@@ -89,31 +87,6 @@ public class LaunchConfigTypeBinding { }
/**
- * Returns the launch mode variant delegate id for the given launch mode.
- *
- * @param mode The launch mode. Must not be <code>null</code>.
- * @return The launch mode variant delegate id or <code>null</code>.
- */
- public String getLaunchModeVariantDelegate(String mode) {
- Assert.isNotNull(mode);
-
- ILaunchBinding binding = getBinding(variantDelegateBindings, mode);
- return binding != null ? binding.getId() : null;
- }
-
- /**
- * Adds the given launch mode variant delegate binding.
- *
- * @param binding The binding. Must not be <code>null</code>.
- */
- public void addLaunchModeVariantDelegate(IOverwritableLaunchBinding binding) {
- Assert.isNotNull(binding);
- if (!variantDelegateBindings.contains(binding)) {
- variantDelegateBindings.add(binding);
- }
- }
-
- /**
* Returns the stepper id for the given launch mode.
*
* @param mode The launch mode. Must not be <code>null</code>.
@@ -139,15 +112,14 @@ public class LaunchConfigTypeBinding { }
/**
- * Returns the step group id for the given launch mode and variant.
+ * Returns the step group id for the given launch mode.
*
* @param mode The launch mode. Must not be <code>null</code>.
- * @param variant The launch mode variant or <code>null</code>.
*
* @return The step group id or <code>null</code>.
*/
- public String getStepGroupId(String mode, String variant) {
- ILaunchBinding binding = getBinding(stepGroupBindings, mode, variant);
+ public String getStepGroupId(String mode) {
+ ILaunchBinding binding = getBinding(stepGroupBindings, mode);
return binding != null ? binding.getId() : null;
}
@@ -251,22 +223,16 @@ public class LaunchConfigTypeBinding { *
* @param bindings The list of available bindings. Must not be <code>null</code>.
* @param mode The launch mode. Must not be <code>null</code>.
- * @param variant The launch mode variant or <code>null</code>.
*
* @return The list of valid bindings for the given launch mode or an empty list.
*/
- private List<ILaunchBinding> getBindings(List<ILaunchBinding> bindings, String mode, String variant) {
+ private List<ILaunchBinding> getBindings(List<ILaunchBinding> bindings, String mode) {
Assert.isNotNull(bindings);
Assert.isNotNull(mode);
List<ILaunchBinding> candidates = new ArrayList<ILaunchBinding>();
for (ILaunchBinding binding : bindings) {
- if (binding instanceof IVaryableLaunchBinding) {
- if (((IVaryableLaunchBinding) binding).isValidLaunchMode(mode, variant)) {
- candidates.add(binding);
- }
- }
- else if (binding.isValidLaunchMode(mode)) {
+ if (binding.isValidLaunchMode(mode)) {
candidates.add(binding);
}
}
@@ -283,25 +249,12 @@ public class LaunchConfigTypeBinding { * @return The resolved binding or <code>null</code>.
*/
private ILaunchBinding getBinding(List<ILaunchBinding> bindings, String mode) {
- return getBinding(bindings, mode, null);
- }
-
- /**
- * Returns the resolved binding in case of overwritable bindings.
- *
- * @param bindings The list of available bindings. Must not be <code>null</code>.
- * @param mode The launch mode. Must not be <code>null</code>.
- * @param variant The launch mode variant or <code>null</code>.
- *
- * @return The resolved binding or <code>null</code>.
- */
- private ILaunchBinding getBinding(List<ILaunchBinding> bindings, String mode, String variant) {
Assert.isNotNull(bindings);
Assert.isNotNull(mode);
ILaunchBinding binding = null;
- List<ILaunchBinding> candidates = getBindings(bindings, mode, variant);
+ List<ILaunchBinding> candidates = getBindings(bindings, mode);
for (int i = 0; i < candidates.size(); i++) {
if (binding == null) {
binding = candidates.get(i);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/OverwritableLaunchBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/OverwritableLaunchBinding.java index a779e198d..21c73cdb1 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/OverwritableLaunchBinding.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/OverwritableLaunchBinding.java @@ -1,83 +1,71 @@ -/******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.launch.core.bindings.internal; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.tcf.te.launch.core.bindings.interfaces.IOverwritableLaunchBinding; - -/** - * Overwritable launch configuration type binding element implementation. - */ -public class OverwritableLaunchBinding extends VaryableLaunchBinding implements IOverwritableLaunchBinding { - - private String[] overwrites; - - /** - * Constructor. - * - * @param id The launch binding id. Must not be <code>null</code>. - * @param overwrites The overwritten launch binding id's or <code>null</code>. - * @param modes The launch modes or <code>null</code> - */ - public OverwritableLaunchBinding(String id, String overwrites, String modes) { - this(id, overwrites, modes, null); - } - - /** - * Constructor. - * - * @param id The launch binding id. Must not be <code>null</code>. - * @param overwrites The overwritten launch binding id's or <code>null</code>. - * @param modes The launch modes or <code>null</code> - * @param variants The launch mode variants or <code>null</code>. - */ - public OverwritableLaunchBinding(String id, String overwrites, String modes, String variants) { - super(id, modes, variants); - - if (overwrites != null) this.overwrites = overwrites.trim().split("( )*,( )*"); //$NON-NLS-1$ - else this.overwrites = new String[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.bindings.interfaces.IOverwritableLaunchBinding#overwrites(java.lang.String) - */ - @Override - public boolean overwrites(String id) { - Assert.isNotNull(id); - for (int i = 0; i < overwrites.length; i++) { - if (id.equals(overwrites[i])) { - return true; - } - } - return overwrites.length == 0; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuffer toString = new StringBuffer(); - - toString.append("OverwriteableLaunchBinding("); //$NON-NLS-1$ - toString.append(getId()); - toString.append(", launchModes"); //$NON-NLS-1$ - toString.append(toString(getModes())); - if (getVariants().length > 0) { - toString.append(", launchModeVariants"); //$NON-NLS-1$ - toString.append(toString(getVariants())); - } - toString.append(", overwrites"); //$NON-NLS-1$ - toString.append(toString(overwrites)); - toString.append(")"); //$NON-NLS-1$ - - return toString.toString(); - } -} +/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.core.bindings.internal;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.tcf.te.launch.core.bindings.interfaces.IOverwritableLaunchBinding;
+
+/**
+ * Overwritable launch configuration type binding element implementation.
+ */
+public class OverwritableLaunchBinding extends LaunchBinding implements IOverwritableLaunchBinding {
+
+ private String[] overwrites;
+
+ /**
+ * Constructor.
+ *
+ * @param id The launch binding id. Must not be <code>null</code>.
+ * @param overwrites The overwritten launch binding id's or <code>null</code>.
+ * @param modes The launch modes or <code>null</code>
+ */
+ public OverwritableLaunchBinding(String id, String overwrites, String modes) {
+ super(id, modes);
+
+ if (overwrites != null) {
+ this.overwrites = overwrites.trim().split("( )*,( )*"); //$NON-NLS-1$
+ }
+ else {
+ this.overwrites = new String[0];
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.bindings.interfaces.IOverwritableLaunchBinding#overwrites(java.lang.String)
+ */
+ @Override
+ public boolean overwrites(String id) {
+ Assert.isNotNull(id);
+ for (String overwrite : overwrites) {
+ if (id.equals(overwrite)) {
+ return true;
+ }
+ }
+ return overwrites.length == 0;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuffer toString = new StringBuffer();
+
+ toString.append("OverwriteableLaunchBinding("); //$NON-NLS-1$
+ toString.append(getId());
+ toString.append(", launchModes"); //$NON-NLS-1$
+ toString.append(toString(getModes()));
+ toString.append(", overwrites"); //$NON-NLS-1$
+ toString.append(toString(overwrites));
+ toString.append(")"); //$NON-NLS-1$
+
+ return toString.toString();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/VaryableLaunchBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/VaryableLaunchBinding.java deleted file mode 100644 index 1dc77592b..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/VaryableLaunchBinding.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.launch.core.bindings.internal; - -import org.eclipse.tcf.te.launch.core.bindings.interfaces.IVaryableLaunchBinding; - -/** - * Launch binding supporting launch mode variants. - */ -public class VaryableLaunchBinding extends LaunchBinding implements IVaryableLaunchBinding { - private final String[] variants; - - /** - * Constructor. - * - * @param id The launch binding id. Must not be <code>null</code>. - * @param modes The launch modes or <code>null</code> - * @param variants The launch mode variants or <code>null</code>. - */ - public VaryableLaunchBinding(String id, String modes, String variants) { - super(id, modes); - - if (variants != null) this.variants = variants.trim().split("( )*,( )*"); //$NON-NLS-1$ - else this.variants = new String[0]; - } - - /** - * Returns the list of handled variants. - * - * @return The list of handled variants or an empty list. - */ - public final String[] getVariants() { - return variants; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.bindings.interfaces.IVaryableLaunchBinding#isValidLaunchMode(java.lang.String, java.lang.String) - */ - @Override - public boolean isValidLaunchMode(String launchMode, String variant) { - boolean valid = isValidLaunchMode(launchMode); - if (!valid) return false; - - if (variant == null || variant.length() == 0) - return true; - - for (String candidate : getVariants()) - if (variant.equals(candidate)) return true; - - return getVariants().length == 0; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuffer toString = new StringBuffer(); - - toString.append("LaunchBinding("); //$NON-NLS-1$ - toString.append(getId()); - toString.append(", launchModes"); //$NON-NLS-1$ - toString.append(toString(getModes())); - toString.append(", launchModeVariants"); //$NON-NLS-1$ - toString.append(toString(getVariants())); - toString.append(")"); //$NON-NLS-1$ - - return toString.toString(); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java index 457356626..1e737fa4e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java @@ -26,7 +26,6 @@ import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.debug.core.model.IBreakpoint;
@@ -40,7 +39,6 @@ import org.eclipse.tcf.te.launch.core.nls.Messages; import org.eclipse.tcf.te.launch.core.persistence.ContextSelectorPersistenceDelegate;
import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate;
import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
import org.eclipse.tcf.te.runtime.interfaces.ISharedConstants;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
@@ -50,6 +48,7 @@ import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperProperties;
import org.eclipse.tcf.te.runtime.stepper.interfaces.tracing.ITraceIds;
+import org.eclipse.tcf.te.runtime.stepper.stepper.Stepper;
/**
* Default launch configuration delegate implementation.
@@ -100,41 +99,11 @@ public class LaunchConfigurationDelegate extends AbstractLaunchConfigurationDele launch.setAttribute(ICommonLaunchAttributes.ILAUNCH_ATTRIBUTE_LAUNCH_SEQUENCE_COMPLETED, Boolean.FALSE.toString());
// The stepper instance to be used
- IStepper stepper = null;
+ IStepper stepper = new Stepper();
IStatus status = null;
try {
- // Get the launch configuration type from the launch configuration.
- // This may throw an CoreException if the launch configuration type
- // cannot be retrieved or instantiated.
- ILaunchConfigurationType type = configuration.getType();
-
// Get the associated stepper for this launch
- stepper = LaunchConfigTypeBindingsManager.getInstance().getStepper(type.getIdentifier(), mode);
- if (stepper == null) {
- // Failed to retrieve stepper for this launch -> throw a CoreException
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- NLS.bind(Messages.LaunchConfigurationDelegate_error_failedToGetStepper, type.getIdentifier(), mode)));
- }
-
- // In case the stepper is already busy with another launch, we need a second instance
- if (stepper.isInitialized()) {
- try {
- // Create a new stepper instance
- IStepper candidate = stepper.getClass().newInstance();
- // Note: If the stepper is an instance of ExecutableExtension, the candidate has to be too.
- if (stepper instanceof ExecutableExtension) {
- ((ExecutableExtension)stepper).cloneInitializationData((ExecutableExtension)candidate);
- }
- // Force to use the newly created instance
- stepper = candidate;
- } catch (Exception e) {
- // Failed to clone already initialized stepper -> throw a CoreException
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- NLS.bind(Messages.LaunchConfigurationDelegate_error_failedToCloneStepper, type.getIdentifier(), mode)));
- }
- }
-
IFullQualifiedId fullQualifiedId = new FullQualifiedId(IStepper.ID_TYPE_STEPPER_ID, stepper.getId(), null);
// Get the launch properties container
IPropertiesContainer properties = (IPropertiesContainer)launch.getAdapter(IPropertiesContainer.class);
@@ -145,8 +114,7 @@ public class LaunchConfigurationDelegate extends AbstractLaunchConfigurationDele properties.setProperty(IStepperProperties.PROP_STEP_GROUP_ID,
LaunchConfigTypeBindingsManager.getInstance().getStepGroupId(
launchConfig.getType().getIdentifier(),
- launch.getLaunchMode(),
- properties.getStringProperty(ICommonLaunchAttributes.ATTR_DELEGATE_VARIANT)));
+ launch.getLaunchMode()));
IModelNode[] contexts = ContextSelectorPersistenceDelegate.decodeLaunchContexts(
launchConfig.getAttribute(IContextSelectorLaunchAttributes.ATTR_LAUNCH_CONTEXTS, (String)null));
@@ -200,9 +168,7 @@ public class LaunchConfigurationDelegate extends AbstractLaunchConfigurationDele }
// Cleanup the stepper
- if (stepper != null) {
- stepper.cleanup();
- }
+ stepper.cleanup();
// Set the launch completed here. Doesn't matter if the launch might completed with error or not.
launch.setAttribute(ICommonLaunchAttributes.ILAUNCH_ATTRIBUTE_LAUNCH_SEQUENCE_COMPLETED, Boolean.TRUE.toString());
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/extensions/internal/LaunchModeVariantDelegateExtensionPointManager.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/extensions/internal/LaunchModeVariantDelegateExtensionPointManager.java deleted file mode 100644 index 908bd6341..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/extensions/internal/LaunchModeVariantDelegateExtensionPointManager.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.launch.core.extensions.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager; -import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy; -import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IVariantDelegate; - -/** - * Launch mode variant delegate extension point manager. - */ -public class LaunchModeVariantDelegateExtensionPointManager extends AbstractExtensionPointManager<IVariantDelegate> { - - /* - * Thread save singleton instance creation. - */ - private static class LazyInstanceHolder { - public static LaunchModeVariantDelegateExtensionPointManager instance = new LaunchModeVariantDelegateExtensionPointManager(); - } - - /** - * Returns the singleton instance for the manager. - */ - public static LaunchModeVariantDelegateExtensionPointManager getInstance() { - return LazyInstanceHolder.instance; - } - - /** - * Constructor. - */ - LaunchModeVariantDelegateExtensionPointManager() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName() - */ - @Override - protected String getConfigurationElementName() { - return "delegate"; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId() - */ - @Override - protected String getExtensionPointId() { - return "org.eclipse.tcf.te.launch.core.launchModeVariantDelegates"; //$NON-NLS-1$ - } - - /** - * Get the list of all registered launch mode variant delegates. - */ - public IVariantDelegate[] getLaunchModeVariantDelegates() { - List<IVariantDelegate> delegates = new ArrayList<IVariantDelegate>(); - for (ExecutableExtensionProxy<IVariantDelegate> proxy : getExtensions().values()) { - IExecutableExtension candidate = proxy.getInstance(); - if (candidate instanceof IVariantDelegate && !delegates.contains(candidate)) { - delegates.add((IVariantDelegate)candidate); - } - } - - return delegates.toArray(new IVariantDelegate[delegates.size()]); - } - - /** - * Returns the launch mode variant delegate with the given id. - * - * @param id The id of the launch mode variant delegate. Must not be <code>null</code>. - */ - public IVariantDelegate getLaunchModeVariantDelegate(String id) { - Assert.isNotNull(id); - IVariantDelegate delegate = null; - if (getExtensions().containsKey(id)) { - delegate = getExtensions().get(id).getInstance(); - } - - return delegate; - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java index 8fa98f12b..9c621a2da 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java @@ -1,734 +1,717 @@ -/******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.launch.core.lm.delegates; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationType; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator; -import org.eclipse.tcf.te.launch.core.bindings.LaunchConfigTypeBindingsManager; -import org.eclipse.tcf.te.launch.core.exceptions.LaunchServiceException; -import org.eclipse.tcf.te.launch.core.interfaces.tracing.ITraceIds; -import org.eclipse.tcf.te.launch.core.lm.LaunchConfigSorter; -import org.eclipse.tcf.te.launch.core.lm.LaunchSpecification; -import org.eclipse.tcf.te.launch.core.lm.interfaces.ICommonLaunchAttributes; -import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchAttribute; -import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate; -import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification; -import org.eclipse.tcf.te.launch.core.nls.Messages; -import org.eclipse.tcf.te.launch.core.preferences.IPreferenceKeys; -import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection; -import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext; -import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension; - -/** - * Default launch manager delegate implementation. - */ -public class DefaultLaunchManagerDelegate extends ExecutableExtension implements ILaunchManagerDelegate { - protected final static int NO_MATCH = 0; - protected final static int PARTIAL_MATCH = 1; - protected final static int FULL_MATCH = 2; - - protected String errorMessage = null; - - /** - * Constructor. - */ - public DefaultLaunchManagerDelegate() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#initLaunchConfigAttributes(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy, org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification) - */ - @Override - public void initLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec) { - Assert.isNotNull(wc); - Assert.isNotNull(launchSpec); - validateLaunchSpecification(launchSpec); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#updateLaunchConfigAttributes(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy, org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification) - */ - @Override - public void updateLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec) { - Assert.isNotNull(wc); - Assert.isNotNull(launchSpec); - validateLaunchSpecification(launchSpec); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#isDefaultAttribute(java.lang.String, java.lang.Object, org.eclipse.debug.core.ILaunchConfiguration, java.lang.String) - */ - @Override - public boolean isDefaultAttribute(String attributeKey, Object attributeValue, ILaunchConfiguration launchConfig, String launchMode) { - Assert.isNotNull(attributeKey); - Assert.isNotNull(launchConfig); - Assert.isNotNull(launchMode); - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getMatchingLaunchConfigurations(org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification, org.eclipse.debug.core.ILaunchConfiguration[]) - */ - @Override - public final ILaunchConfiguration[] getMatchingLaunchConfigurations(ILaunchSpecification launchSpec, ILaunchConfiguration[] launchConfigs) throws LaunchServiceException { - if (launchConfigs == null || launchConfigs.length == 0) { - return new ILaunchConfiguration[0]; - } - else if (launchSpec != null) { - List<LaunchConfigSorter> rankedList = new ArrayList<LaunchConfigSorter>(); - for (ILaunchConfiguration launchConfig : launchConfigs) { - if (CoreBundleActivator.getTraceHandler() - .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) { - System.out.println("\n***\n"); //$NON-NLS-1$ - } - - int ranking = 0; - try { - ranking = getLaunchConfigRanking(launchSpec, launchConfig); - } - catch (LaunchServiceException e) { - switch (e.getType()) { - case LaunchServiceException.TYPE_MISSING_LAUNCH_CONFIG_ATTR: - ranking = 0; - break; - default: - throw e; - } - } - - int fullMatchRanking = getFullMatchRanking(); - - if (CoreBundleActivator.getTraceHandler() - .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) { - StringBuilder message = new StringBuilder("Ranking launch spec ("); //$NON-NLS-1$ - message.append(launchSpec.getLaunchConfigName()); - message.append(") vs launch configuration ("); //$NON-NLS-1$ - message.append(launchConfig.getName()); - message.append(") = "); //$NON-NLS-1$ - message.append(ranking); - message.append(" ; full match ranking = "); //$NON-NLS-1$ - message.append(fullMatchRanking); - - CoreBundleActivator - .getTraceHandler() - .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this); - } - - if (ranking >= fullMatchRanking) { - rankedList.add(new LaunchConfigSorter(launchConfig, ranking)); - } - } - - // sort results and write back into array - Collections.sort(rankedList); - ILaunchConfiguration[] matchingConfigs = new ILaunchConfiguration[rankedList.size()]; - for (int i = 0; i < rankedList.size(); i++) { - matchingConfigs[i] = rankedList.get(i).getConfig(); - } - - return matchingConfigs; - } - else { - return launchConfigs; - } - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getLaunchSpecification(java.lang.String, org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection) - */ - @Override - public final ILaunchSpecification getLaunchSpecification(String launchConfigTypeId, ILaunchSelection launchSelection) { - return getLaunchSpecification(launchConfigTypeId, launchSelection, null); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getLaunchSpecification(java.lang.String, org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection, java.lang.String) - */ - @Override - public final ILaunchSpecification getLaunchSpecification(String launchConfigTypeId, ILaunchSelection launchSelection, String variant) { - ILaunchSpecification spec = null; - - if (isValidLaunchSelection(launchSelection)) { - spec = new LaunchSpecification(launchConfigTypeId, launchSelection.getLaunchMode()); - spec.addAttribute(ICommonLaunchAttributes.ATTR_DELEGATE_VARIANT, variant, true); - - for (ISelectionContext selectionContext : launchSelection.getSelectedContexts()) { - // For launch specifications, all selection contexts needs to be set as preferred - // for full validation. - // otherwise "not preferred" contexts are valid even if they are not for a give - // launch configuration type id. - selectionContext.setIsPreferredContext(true); - if (LaunchConfigTypeBindingsManager - .getInstance() - .isValidLaunchConfigType(launchConfigTypeId, launchSelection.getLaunchMode(), selectionContext)) { - spec = addLaunchSpecAttributes(spec, launchConfigTypeId, selectionContext); - } - } - - // If the number of selected contexts is 0, we have to call addLaunchSpecAttributes - // one time to add the selection independent attributes. - if (launchSelection.getSelectedContexts().length == 0) { - spec = addLaunchSpecAttributes(spec, launchConfigTypeId, null); - } - } - - return spec; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getDefaultLaunchName(org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification) - */ - @Override - public String getDefaultLaunchName(ILaunchSpecification launchSpec) { - return Messages.DefaultLaunchManagerDelegate_defaultLaunchName; - } - - /** - * Add all needed selections to the launch specification. - * <p> - * Subclasses needs to override and super-call this method! - * <p> - * <b>Note:</b> The selection context can be <code>null</code>. In this case, the method - * implementation is expected to add only selection independent attributes! - * - * @param launchSpec The launch specification to add selections to. Must not be - * <code>null</code>. - * @param launchConfigTypeId The launch configuration type id. Must not be <code>null</code>. - * @param selectionContext The validated selection context with the selection(s) or - * <code>null</code> - * - * @return The launch specification with attributes from the selection context. - */ - protected ILaunchSpecification addLaunchSpecAttributes(ILaunchSpecification launchSpec, String launchConfigTypeId, ISelectionContext selectionContext) { - Assert.isNotNull(launchSpec); - Assert.isNotNull(launchConfigTypeId); - return launchSpec; - } - - /** - * Returns the ranking of the launch configuration compared to the launch specification. - * <p> - * If all attributes of the launch specification matches with the corresponding attributes of - * the launch configuration, the ranking should be at least as high as the number of attributes - * in the launch specification. The ranking should grow with every additional attribute value - * that is set to default. - * <p> - * If only a set of attributes matches, the ranking should be less than the number of attributes - * in the launch specification. - * <p> - * If no attribute matches zero should be returned. - * - * @param launchSpec The launch specification the launch configuration should be compared to. - * @param launchConfig The launch configuration to find a ranking for. - * @return The ranking of the launch configuration. - * @throws <code>LaunchServiceException</code> exception when mandatory attributes are missing - */ - private int getLaunchConfigRanking(ILaunchSpecification launchSpec, ILaunchConfiguration launchConfig) throws LaunchServiceException { - int ranking = 0; - int mandatorys = 0; - Map<?, ?> configAttributes = null; - Set<?> configKeys = null; - try { - configAttributes = launchConfig.getAttributes(); - configKeys = configAttributes.keySet(); - } - catch (Exception e) { - return 0; - } - - // Read the launch configuration matching mode from the preferences - int mode = CoreBundleActivator.getScopedPreferences() - .getInt(IPreferenceKeys.PREF_LAUNCH_CONFIG_FIND_CREATE_MODE); - if (launchSpec.getAttribute(IPreferenceKeys.PREF_LAUNCH_CONFIG_FIND_CREATE_MODE, null) instanceof Integer) { - mode = ((Integer) launchSpec - .getAttribute(IPreferenceKeys.PREF_LAUNCH_CONFIG_FIND_CREATE_MODE, null)) - .intValue(); - } - - if (CoreBundleActivator.getTraceHandler() - .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) { - StringBuilder message = new StringBuilder("Ranking launch spec ("); //$NON-NLS-1$ - message.append(launchSpec.getLaunchConfigName()); - message.append(") vs launch configuration ("); //$NON-NLS-1$ - message.append(launchConfig.getName()); - message.append("): Matching mode = "); //$NON-NLS-1$ - if (mode == IPreferenceKeys.MODE_ALWAYS_NEW) { - message.append(" ALWAYS_NEW "); //$NON-NLS-1$ - } - else if (mode == IPreferenceKeys.MODE_FIRST_MATCHING) { - message.append(" FIRST_MATCHING "); //$NON-NLS-1$ - } - else if (mode == IPreferenceKeys.MODE_FULL_MATCH_TARGET) { - message.append(" FULL_MATCH_TARGET "); //$NON-NLS-1$ - } - else if (mode == IPreferenceKeys.MODE_FULL_MATCH_LAUNCH_CONFIG) { - message.append(" FULL_MATCH_LAUNCH_CONFIG "); //$NON-NLS-1$ - } - - CoreBundleActivator - .getTraceHandler() - .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this); - } - - for (ILaunchAttribute specAttribute : launchSpec.getAllAttributes()) { - if (!specAttribute.isCreateOnlyAttribute()) { - String key = specAttribute.getKey(); - Object specValue = specAttribute.getValue(); - Object configValue = configAttributes.get(key); - int match = compareAttributeValues(key, specValue, configValue, launchSpec, launchConfig); - - if (CoreBundleActivator.getTraceHandler() - .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) { - StringBuilder message = new StringBuilder("Launch spec attribute '"); //$NON-NLS-1$ - message.append(specAttribute.getKey()); - message.append("': mandatory = "); //$NON-NLS-1$ - message.append(isMandatoryAttribute(key)); - message.append("; match = "); //$NON-NLS-1$ - if (match == NO_MATCH) { - message.append("NO_MATCH"); //$NON-NLS-1$ - } - else if (match == PARTIAL_MATCH) { - message.append("PARTIAL_MATCH"); //$NON-NLS-1$ - } - else if (match == FULL_MATCH) { - message.append("FULL_MATCH"); //$NON-NLS-1$ - } - if (match != FULL_MATCH) { - message.append("\n\t\tspecValue = "); //$NON-NLS-1$ - message.append(specValue != null ? specValue.toString() : "null"); //$NON-NLS-1$ - message.append("\n\t\tconfigValue = "); //$NON-NLS-1$ - message.append(configValue != null ? configValue.toString() : "null"); //$NON-NLS-1$ - } - - CoreBundleActivator - .getTraceHandler() - .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this); - } - - if (match == PARTIAL_MATCH && mode == IPreferenceKeys.MODE_FULL_MATCH_LAUNCH_CONFIG) { - return 0; - } - if (match > NO_MATCH) { - int attrRanking = getAttributeRanking(key); - ranking += attrRanking * (attrRanking > 1 ? 4 : 1); - if (match == FULL_MATCH) { - ranking += attrRanking * (attrRanking > 1 ? 2 : 1); - } - configKeys.remove(key); - if (isMandatoryAttribute(key)) { - mandatorys++; - } - } - else { - return 0; - } - } - else { - if (CoreBundleActivator.getTraceHandler() - .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) { - StringBuilder message = new StringBuilder("Skipped launch spec attribute '"); //$NON-NLS-1$ - message.append(specAttribute.getKey()); - message.append("': is create only attribute"); //$NON-NLS-1$ - - CoreBundleActivator - .getTraceHandler() - .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this); - } - } - } - if (mandatorys < getNumMandatoryAttributes()) { - throw new LaunchServiceException("missing mandatory attribute in ILaunchSpecification", //$NON-NLS-1$ - LaunchServiceException.TYPE_MISSING_LAUNCH_SPEC_ATTR); - } - - Iterator<?> configIt = configKeys.iterator(); - while (configIt.hasNext()) { - String key = (String) configIt.next(); - Object specValue = launchSpec.getAttribute(key, null); - Object configValue = configAttributes.get(key); - - int match = compareAttributeValues(key, specValue, configValue, launchSpec, launchConfig); - if (match > NO_MATCH) { - int attrRanking = getAttributeRanking(key); - ranking += attrRanking * (attrRanking > 1 ? 4 : 1); - if (match == FULL_MATCH) { - ranking += attrRanking * (attrRanking > 1 ? 2 : 1); - } - } - } - - return ranking; - } - - /** - * Returns the number of defined attributes for this launch manager delegate. - * - * @see #getAttributeRanking(String) - */ - protected int getNumAttributes() { - return 0; - } - - /** - * Returns the list of mandatory attributes for a launch specification handled by this launch - * manager delegate. - * <p> - * The returned value must not be <code>null</code>, if no attributes are mandatory, an empty - * list should be returned. - * - * @see #getAttributeRanking(String) - */ - protected List<String> getMandatoryAttributes() { - return Collections.emptyList(); - } - - private boolean validateLaunchSpecification(ILaunchSpecification launchSpec) { - boolean valid = true; - if (launchSpec == null || !launchSpec.isValid()) { - return false; - } - for (String attribute : getMandatoryAttributes()) { - if (!launchSpec.hasAttribute(attribute)) { - valid = false; - break; - } - } - launchSpec.setIsValid(valid); - return valid; - } - - /** - * Method for basic launch selection validations like checking the number of project or target - * contexts. - * <p> - * The default implementation returns always <code>true</code>. - * - * @param launchSelection The launch selection to check. - * @return <code>True</code> if the launch selection is valid, <code>false</code> otherwise. - */ - protected boolean isValidLaunchSelection(ILaunchSelection launchSelection) { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#validate(java.lang.String, org.eclipse.debug.core.ILaunchConfiguration) - */ - @Override - public void validate(String launchMode, ILaunchConfiguration launchConfig) throws LaunchServiceException { - String missingAttributes = null; - for (String attribute : getMandatoryAttributes()) { - if (!isValidAttribute(attribute, launchConfig, launchMode)) { - missingAttributes = (missingAttributes == null) ? attribute : missingAttributes + ", " + attribute; //$NON-NLS-1$ - } - } - if (missingAttributes != null) { - throw new LaunchServiceException("Missing launch configuration attributes: " + '\n' + missingAttributes, LaunchServiceException.TYPE_MISSING_LAUNCH_CONFIG_ATTR); //$NON-NLS-1$ - } - } - - /** - * Validate a single attribute for a given launch configuration and a launch mode. This method - * needs to be overwritten when contributing new launch modes which does not need all attributes. - * - * @param attributeKey The attribute key. - * @param launchConfig The launch configuration. - * @param launchMode The launch mode. - * - * @return <code>True</code>, if the attribute value is valid. - */ - protected boolean isValidAttribute(String attributeKey, ILaunchConfiguration launchConfig, String launchMode) { - try { - if (launchConfig == null || !launchConfig.hasAttribute(attributeKey)) { - return false; - } - } - catch (CoreException e) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#validate(org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification) - */ - @Override - public void validate(ILaunchSpecification launchSpec) throws LaunchServiceException { - String missingAttributes = null; - for (String attribute : getMandatoryAttributes()) { - if (launchSpec == null || !launchSpec.hasAttribute(attribute)) { - // Remember the missing attribute for adding the list to the exception. - missingAttributes = (missingAttributes == null) ? attribute : missingAttributes + ", " + attribute; //$NON-NLS-1$ - } - } - if (missingAttributes != null) { - throw new LaunchServiceException("Missing launch specification attributes: " + '\n' + missingAttributes, LaunchServiceException.TYPE_MISSING_LAUNCH_SPEC_ATTR); //$NON-NLS-1$ - } - } - - /** - * Returns the number of defined mandatory attributes. - * - * @see #getMandatoryAttributes() - * @see #getAttributeRanking(String) - */ - protected final int getNumMandatoryAttributes() { - return getMandatoryAttributes().size(); - } - - /** - * Returns true if the attribute key is in the list of mandatory attributes. - * - * @see #getMandatoryAttributes() - * @see #getAttributeRanking(String) - */ - protected final boolean isMandatoryAttribute(String attributeKey) { - return getMandatoryAttributes().contains(attributeKey); - } - - /** - * Returns the ranking for the given attribute key. - * <p> - * The default ranking is 1, ranking of mandatory and other fundamental attributes should be - * coded as <code>2^n</code>. - * <p> - * The more important an attribute is the higher <code>n</code> should be, <code>n</code> should - * never be less than the number of attributes with a lower ranking. - * <p> - * Multiple attributes can have an equal ranking when one attribute can compensate the absence - * of an other attribute with the same ranking. - * - * <pre> - * Example: - * - * Attributes a through f - * Attributes a and b are mandatory, b is more important than a. - * The attributes c and d should be higher prior than e and f, but should have equal ranking. - * - * The ranking looks like the following: - * Attribute Ranking - * b 32 (2^5) - * a 16 (2^4) - * c, d 4 (2^2) - * e, f 1 (2^0) - * - * With this rankings it is not possible to compensate a missing higher prior attribute with - * one or more lower prior attributes. - * - * Additional methods returns the following values for this example: - * - * getNumAttributes() == 6 - * getMandatoryAttibutes() == {a, b} - * getNumMandatoryAttributes() == 2 - * getFullMatchRanking() >= 48 (the value can be greater than 48 depending - * on the implementation of the launch manager delegate) - * </pre> - * - * @param attributeKey The attribute key for which the ranking should be returned - */ - protected int getAttributeRanking(String attributeKey) { - return 1; - } - - /** - * Minimum ranking for a launch configuration to be handled as full match when comparing to a - * launch specification. - * <p> - * Should be overwritten when the method {@link #getAttributeRanking(String)} was overwritten. - * - * @see #getAttributeRanking(String) - */ - protected int getFullMatchRanking() { - return 0; - } - - /** - * Compares an attribute value of launch configuration and specification. - * - * If both values are not null, calls {@link #equals(String, Object, Object, ILaunchSpecification, ILaunchConfiguration, String)} - * to compare the values. If one of the values is <code>null</code>, and the not <code>null</code> value is default, <code>true</code> - * is returned. If both values are <code>null</code>, <code>true</code> is returned. - * - * @param attributeKey The attribute key. Must not be <code>null</code>. - * @param specValue The launch specification value. - * @param confValue The launch configuration value. - * @param launchSpec The launch specification which is the source of the <code>specValue</code>. Must not be <code>null</code>. - * @param launchConfig The launch configuration which is the source of the <code>confValue</code>. Must not be <code>null</code>. - * @return NO_MATCH, PARTIAL_MATCH or FULL_MATCH - */ - protected int compareAttributeValues(String attributeKey, Object specValue, Object confValue, ILaunchSpecification launchSpec, ILaunchConfiguration launchConfig) { - Assert.isNotNull(attributeKey); - Assert.isNotNull(launchSpec); - Assert.isNotNull(launchConfig); - - // values are equal if both are null - if (specValue == null && confValue == null) { - return FULL_MATCH; - } - // if launch specification value is null, - // values are equal if launch configuration value is default - else if (specValue == null) { - Assert.isNotNull(confValue); - return isDefaultAttribute(attributeKey, confValue, launchConfig, launchSpec.getLaunchMode()) ? FULL_MATCH : NO_MATCH; - } - // if launch configuration value is default, - // values are equal if launch specification value is default too - else if (isDefaultAttribute(attributeKey, confValue, launchConfig, launchSpec.getLaunchMode()) || confValue == null) { - Assert.isNotNull(specValue); - return isDefaultAttribute(attributeKey, specValue, launchConfig, launchSpec.getLaunchMode()) ? FULL_MATCH : NO_MATCH; - } - // use object.equals as default - else { - Assert.isNotNull(specValue); - Assert.isNotNull(confValue); - return equals(attributeKey, specValue, confValue, launchSpec, launchConfig, launchSpec.getLaunchMode()); - } - } - - /** - * Compares the attribute value of launch configuration and launch specification. - * <p> - * The handling of null values is implemented in the calling private method - * {@link #compareAttributeValues(String, Object, Object, ILaunchSpecification, ILaunchConfiguration)}. - * When overwriting this method the implementor can be certain both values are not <code>null</code>. - * - * @param attributeKey The attribute key - * @param specValue The launch specification value. Must not be <code>null</code>. - * @param confValue The launch configuration value. Must not be <code>null</code>. - * @param launchSpec The launch specification. - * @param launchConfig The launch configuration which is the source of the <code>confValue</code>. - * @param launchMode The current launch mode. - * - * @return NO_MATCH, PARTIAL_MATCH or FULL_MATCH - */ - protected int equals(String attributeKey, Object specValue, Object confValue, ILaunchSpecification launchSpec, ILaunchConfiguration launchConfig, String launchMode) { - Assert.isNotNull(specValue); - Assert.isNotNull(confValue); - - if (ICommonLaunchAttributes.ATTR_PROJECTS_FOR_BUILD.equals(attributeKey)) { - // get match of list objects - int match = specValue.equals(confValue) ? FULL_MATCH : NO_MATCH; - // compare objects in the list when they are not already equal - if (match != FULL_MATCH && specValue instanceof List<?> && confValue instanceof List<?>) { - List<?> specProject = (List<?>) specValue; - List<?> confProject = (List<?>) confValue; - match = (specProject.isEmpty() || confProject.isEmpty()) ? PARTIAL_MATCH : NO_MATCH; - List<?> refProjects = null; - try { - refProjects = launchConfig.getAttribute(ICommonLaunchAttributes.ATTR_REFERENCED_PROJECTS, (List<?>) null); - } - catch (CoreException e) { - // ignore - } - for (int i = 0; i < specProject.size(); i++) { - Object specObject = specProject.get(i); - if (specObject != null && confProject.contains(specObject)) { - // spec object can be found in the configuration - if (match == NO_MATCH) { - // full match on first element in the spec list, - // otherwise partial match - match = (i == 0) ? FULL_MATCH : PARTIAL_MATCH; - } - } - else if (specObject != null && refProjects != null && refProjects.contains(specObject)) { - // spec object can be found in the configuration - if (match == NO_MATCH) { - match = PARTIAL_MATCH; - } - } - else if (match == FULL_MATCH) { - // reduce full to partial match when spec object wasn't found - match = PARTIAL_MATCH; - } - } - // reduce full to partial match when list size is not equal - // but all spec values where found in the configuration project list - if (match == FULL_MATCH && specProject.size() != confProject.size()) { - match = PARTIAL_MATCH; - } - } - return match; - } - - return specValue.equals(confValue) ? FULL_MATCH : NO_MATCH; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#showLaunchDialog(int) - */ - @Override - public boolean showLaunchDialog(int situation) { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#showLaunchConfigOnly() - */ - @Override - public boolean showLaunchConfigOnly() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#showLaunchConfigSelectionDialog(org.eclipse.debug.core.ILaunchConfigurationType, org.eclipse.debug.core.ILaunchConfiguration[]) - */ - @Override - public boolean showLaunchConfigSelectionDialog(ILaunchConfigurationType type, ILaunchConfiguration[] launchConfigs) { - if (type != null) { - String key = type.getIdentifier() + ".hideLaunchConfigSelectionDialog"; //$NON-NLS-1$ - return !CoreBundleActivator.getScopedPreferences().getBoolean(key); - } - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getErrorMessage() - */ - @Override - public String getErrorMessage() { - return errorMessage; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getVariants(org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection) - */ - @Override - public String[] getVariants(ILaunchSelection launchSelection) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#equals(org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext, org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext) - */ - @Override - public boolean equals(ISelectionContext ctx1, ISelectionContext ctx2) { - return (ctx1 == null && ctx2 == null) || (ctx1 != null && ctx1.equals(ctx2)); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#useDefaultConnection() - */ - @Override - public boolean useDefaultConnection() { - return true; - } -} +/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.core.lm.delegates;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.launch.core.bindings.LaunchConfigTypeBindingsManager;
+import org.eclipse.tcf.te.launch.core.exceptions.LaunchServiceException;
+import org.eclipse.tcf.te.launch.core.interfaces.tracing.ITraceIds;
+import org.eclipse.tcf.te.launch.core.lm.LaunchConfigSorter;
+import org.eclipse.tcf.te.launch.core.lm.LaunchSpecification;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ICommonLaunchAttributes;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchAttribute;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
+import org.eclipse.tcf.te.launch.core.nls.Messages;
+import org.eclipse.tcf.te.launch.core.preferences.IPreferenceKeys;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
+
+/**
+ * Default launch manager delegate implementation.
+ */
+public class DefaultLaunchManagerDelegate extends ExecutableExtension implements ILaunchManagerDelegate {
+ protected final static int NO_MATCH = 0;
+ protected final static int PARTIAL_MATCH = 1;
+ protected final static int FULL_MATCH = 2;
+
+ protected String errorMessage = null;
+
+ /**
+ * Constructor.
+ */
+ public DefaultLaunchManagerDelegate() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#initLaunchConfigAttributes(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy, org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification)
+ */
+ @Override
+ public void initLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec) {
+ Assert.isNotNull(wc);
+ Assert.isNotNull(launchSpec);
+ validateLaunchSpecification(launchSpec);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#updateLaunchConfigAttributes(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy, org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification)
+ */
+ @Override
+ public void updateLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec) {
+ Assert.isNotNull(wc);
+ Assert.isNotNull(launchSpec);
+ validateLaunchSpecification(launchSpec);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#isDefaultAttribute(java.lang.String, java.lang.Object, org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
+ */
+ @Override
+ public boolean isDefaultAttribute(String attributeKey, Object attributeValue, ILaunchConfiguration launchConfig, String launchMode) {
+ Assert.isNotNull(attributeKey);
+ Assert.isNotNull(launchConfig);
+ Assert.isNotNull(launchMode);
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getMatchingLaunchConfigurations(org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification, org.eclipse.debug.core.ILaunchConfiguration[])
+ */
+ @Override
+ public final ILaunchConfiguration[] getMatchingLaunchConfigurations(ILaunchSpecification launchSpec, ILaunchConfiguration[] launchConfigs) throws LaunchServiceException {
+ if (launchConfigs == null || launchConfigs.length == 0) {
+ return new ILaunchConfiguration[0];
+ }
+ else if (launchSpec != null) {
+ List<LaunchConfigSorter> rankedList = new ArrayList<LaunchConfigSorter>();
+ for (ILaunchConfiguration launchConfig : launchConfigs) {
+ if (CoreBundleActivator.getTraceHandler()
+ .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
+ System.out.println("\n***\n"); //$NON-NLS-1$
+ }
+
+ int ranking = 0;
+ try {
+ ranking = getLaunchConfigRanking(launchSpec, launchConfig);
+ }
+ catch (LaunchServiceException e) {
+ switch (e.getType()) {
+ case LaunchServiceException.TYPE_MISSING_LAUNCH_CONFIG_ATTR:
+ ranking = 0;
+ break;
+ default:
+ throw e;
+ }
+ }
+
+ int fullMatchRanking = getFullMatchRanking();
+
+ if (CoreBundleActivator.getTraceHandler()
+ .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
+ StringBuilder message = new StringBuilder("Ranking launch spec ("); //$NON-NLS-1$
+ message.append(launchSpec.getLaunchConfigName());
+ message.append(") vs launch configuration ("); //$NON-NLS-1$
+ message.append(launchConfig.getName());
+ message.append(") = "); //$NON-NLS-1$
+ message.append(ranking);
+ message.append(" ; full match ranking = "); //$NON-NLS-1$
+ message.append(fullMatchRanking);
+
+ CoreBundleActivator
+ .getTraceHandler()
+ .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this);
+ }
+
+ if (ranking >= fullMatchRanking) {
+ rankedList.add(new LaunchConfigSorter(launchConfig, ranking));
+ }
+ }
+
+ // sort results and write back into array
+ Collections.sort(rankedList);
+ ILaunchConfiguration[] matchingConfigs = new ILaunchConfiguration[rankedList.size()];
+ for (int i = 0; i < rankedList.size(); i++) {
+ matchingConfigs[i] = rankedList.get(i).getConfig();
+ }
+
+ return matchingConfigs;
+ }
+ else {
+ return launchConfigs;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getLaunchSpecification(java.lang.String, org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection)
+ */
+ @Override
+ public final ILaunchSpecification getLaunchSpecification(String launchConfigTypeId, ILaunchSelection launchSelection) {
+ ILaunchSpecification spec = null;
+
+ if (isValidLaunchSelection(launchSelection)) {
+ spec = new LaunchSpecification(launchConfigTypeId, launchSelection.getLaunchMode());
+
+ for (ISelectionContext selectionContext : launchSelection.getSelectedContexts()) {
+ // For launch specifications, all selection contexts needs to be set as preferred
+ // for full validation.
+ // otherwise "not preferred" contexts are valid even if they are not for a give
+ // launch configuration type id.
+ selectionContext.setIsPreferredContext(true);
+ if (LaunchConfigTypeBindingsManager
+ .getInstance()
+ .isValidLaunchConfigType(launchConfigTypeId, launchSelection.getLaunchMode(), selectionContext)) {
+ spec = addLaunchSpecAttributes(spec, launchConfigTypeId, selectionContext);
+ }
+ }
+
+ // If the number of selected contexts is 0, we have to call addLaunchSpecAttributes
+ // one time to add the selection independent attributes.
+ if (launchSelection.getSelectedContexts().length == 0) {
+ spec = addLaunchSpecAttributes(spec, launchConfigTypeId, null);
+ }
+ }
+
+ return spec;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getDefaultLaunchName(org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification)
+ */
+ @Override
+ public String getDefaultLaunchName(ILaunchSpecification launchSpec) {
+ return Messages.DefaultLaunchManagerDelegate_defaultLaunchName;
+ }
+
+ /**
+ * Add all needed selections to the launch specification.
+ * <p>
+ * Subclasses needs to override and super-call this method!
+ * <p>
+ * <b>Note:</b> The selection context can be <code>null</code>. In this case, the method
+ * implementation is expected to add only selection independent attributes!
+ *
+ * @param launchSpec The launch specification to add selections to. Must not be
+ * <code>null</code>.
+ * @param launchConfigTypeId The launch configuration type id. Must not be <code>null</code>.
+ * @param selectionContext The validated selection context with the selection(s) or
+ * <code>null</code>
+ *
+ * @return The launch specification with attributes from the selection context.
+ */
+ protected ILaunchSpecification addLaunchSpecAttributes(ILaunchSpecification launchSpec, String launchConfigTypeId, ISelectionContext selectionContext) {
+ Assert.isNotNull(launchSpec);
+ Assert.isNotNull(launchConfigTypeId);
+ return launchSpec;
+ }
+
+ /**
+ * Returns the ranking of the launch configuration compared to the launch specification.
+ * <p>
+ * If all attributes of the launch specification matches with the corresponding attributes of
+ * the launch configuration, the ranking should be at least as high as the number of attributes
+ * in the launch specification. The ranking should grow with every additional attribute value
+ * that is set to default.
+ * <p>
+ * If only a set of attributes matches, the ranking should be less than the number of attributes
+ * in the launch specification.
+ * <p>
+ * If no attribute matches zero should be returned.
+ *
+ * @param launchSpec The launch specification the launch configuration should be compared to.
+ * @param launchConfig The launch configuration to find a ranking for.
+ * @return The ranking of the launch configuration.
+ * @throws <code>LaunchServiceException</code> exception when mandatory attributes are missing
+ */
+ private int getLaunchConfigRanking(ILaunchSpecification launchSpec, ILaunchConfiguration launchConfig) throws LaunchServiceException {
+ int ranking = 0;
+ int mandatorys = 0;
+ Map<?, ?> configAttributes = null;
+ Set<?> configKeys = null;
+ try {
+ configAttributes = launchConfig.getAttributes();
+ configKeys = configAttributes.keySet();
+ }
+ catch (Exception e) {
+ return 0;
+ }
+
+ // Read the launch configuration matching mode from the preferences
+ int mode = CoreBundleActivator.getScopedPreferences()
+ .getInt(IPreferenceKeys.PREF_LAUNCH_CONFIG_FIND_CREATE_MODE);
+ if (launchSpec.getAttribute(IPreferenceKeys.PREF_LAUNCH_CONFIG_FIND_CREATE_MODE, null) instanceof Integer) {
+ mode = ((Integer) launchSpec
+ .getAttribute(IPreferenceKeys.PREF_LAUNCH_CONFIG_FIND_CREATE_MODE, null))
+ .intValue();
+ }
+
+ if (CoreBundleActivator.getTraceHandler()
+ .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
+ StringBuilder message = new StringBuilder("Ranking launch spec ("); //$NON-NLS-1$
+ message.append(launchSpec.getLaunchConfigName());
+ message.append(") vs launch configuration ("); //$NON-NLS-1$
+ message.append(launchConfig.getName());
+ message.append("): Matching mode = "); //$NON-NLS-1$
+ if (mode == IPreferenceKeys.MODE_ALWAYS_NEW) {
+ message.append(" ALWAYS_NEW "); //$NON-NLS-1$
+ }
+ else if (mode == IPreferenceKeys.MODE_FIRST_MATCHING) {
+ message.append(" FIRST_MATCHING "); //$NON-NLS-1$
+ }
+ else if (mode == IPreferenceKeys.MODE_FULL_MATCH_TARGET) {
+ message.append(" FULL_MATCH_TARGET "); //$NON-NLS-1$
+ }
+ else if (mode == IPreferenceKeys.MODE_FULL_MATCH_LAUNCH_CONFIG) {
+ message.append(" FULL_MATCH_LAUNCH_CONFIG "); //$NON-NLS-1$
+ }
+
+ CoreBundleActivator
+ .getTraceHandler()
+ .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this);
+ }
+
+ for (ILaunchAttribute specAttribute : launchSpec.getAllAttributes()) {
+ if (!specAttribute.isCreateOnlyAttribute()) {
+ String key = specAttribute.getKey();
+ Object specValue = specAttribute.getValue();
+ Object configValue = configAttributes.get(key);
+ int match = compareAttributeValues(key, specValue, configValue, launchSpec, launchConfig);
+
+ if (CoreBundleActivator.getTraceHandler()
+ .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
+ StringBuilder message = new StringBuilder("Launch spec attribute '"); //$NON-NLS-1$
+ message.append(specAttribute.getKey());
+ message.append("': mandatory = "); //$NON-NLS-1$
+ message.append(isMandatoryAttribute(key));
+ message.append("; match = "); //$NON-NLS-1$
+ if (match == NO_MATCH) {
+ message.append("NO_MATCH"); //$NON-NLS-1$
+ }
+ else if (match == PARTIAL_MATCH) {
+ message.append("PARTIAL_MATCH"); //$NON-NLS-1$
+ }
+ else if (match == FULL_MATCH) {
+ message.append("FULL_MATCH"); //$NON-NLS-1$
+ }
+ if (match != FULL_MATCH) {
+ message.append("\n\t\tspecValue = "); //$NON-NLS-1$
+ message.append(specValue != null ? specValue.toString() : "null"); //$NON-NLS-1$
+ message.append("\n\t\tconfigValue = "); //$NON-NLS-1$
+ message.append(configValue != null ? configValue.toString() : "null"); //$NON-NLS-1$
+ }
+
+ CoreBundleActivator
+ .getTraceHandler()
+ .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this);
+ }
+
+ if (match == PARTIAL_MATCH && mode == IPreferenceKeys.MODE_FULL_MATCH_LAUNCH_CONFIG) {
+ return 0;
+ }
+ if (match > NO_MATCH) {
+ int attrRanking = getAttributeRanking(key);
+ ranking += attrRanking * (attrRanking > 1 ? 4 : 1);
+ if (match == FULL_MATCH) {
+ ranking += attrRanking * (attrRanking > 1 ? 2 : 1);
+ }
+ configKeys.remove(key);
+ if (isMandatoryAttribute(key)) {
+ mandatorys++;
+ }
+ }
+ else {
+ return 0;
+ }
+ }
+ else {
+ if (CoreBundleActivator.getTraceHandler()
+ .isSlotEnabled(0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING)) {
+ StringBuilder message = new StringBuilder("Skipped launch spec attribute '"); //$NON-NLS-1$
+ message.append(specAttribute.getKey());
+ message.append("': is create only attribute"); //$NON-NLS-1$
+
+ CoreBundleActivator
+ .getTraceHandler()
+ .trace(message.toString(), 0, ITraceIds.TRACE_LAUNCHCONFIGURATIONMATCHING, IStatus.INFO, this);
+ }
+ }
+ }
+ if (mandatorys < getNumMandatoryAttributes()) {
+ throw new LaunchServiceException("missing mandatory attribute in ILaunchSpecification", //$NON-NLS-1$
+ LaunchServiceException.TYPE_MISSING_LAUNCH_SPEC_ATTR);
+ }
+
+ Iterator<?> configIt = configKeys.iterator();
+ while (configIt.hasNext()) {
+ String key = (String) configIt.next();
+ Object specValue = launchSpec.getAttribute(key, null);
+ Object configValue = configAttributes.get(key);
+
+ int match = compareAttributeValues(key, specValue, configValue, launchSpec, launchConfig);
+ if (match > NO_MATCH) {
+ int attrRanking = getAttributeRanking(key);
+ ranking += attrRanking * (attrRanking > 1 ? 4 : 1);
+ if (match == FULL_MATCH) {
+ ranking += attrRanking * (attrRanking > 1 ? 2 : 1);
+ }
+ }
+ }
+
+ return ranking;
+ }
+
+ /**
+ * Returns the number of defined attributes for this launch manager delegate.
+ *
+ * @see #getAttributeRanking(String)
+ */
+ protected int getNumAttributes() {
+ return 0;
+ }
+
+ /**
+ * Returns the list of mandatory attributes for a launch specification handled by this launch
+ * manager delegate.
+ * <p>
+ * The returned value must not be <code>null</code>, if no attributes are mandatory, an empty
+ * list should be returned.
+ *
+ * @see #getAttributeRanking(String)
+ */
+ protected List<String> getMandatoryAttributes() {
+ return Collections.emptyList();
+ }
+
+ private boolean validateLaunchSpecification(ILaunchSpecification launchSpec) {
+ boolean valid = true;
+ if (launchSpec == null || !launchSpec.isValid()) {
+ return false;
+ }
+ for (String attribute : getMandatoryAttributes()) {
+ if (!launchSpec.hasAttribute(attribute)) {
+ valid = false;
+ break;
+ }
+ }
+ launchSpec.setIsValid(valid);
+ return valid;
+ }
+
+ /**
+ * Method for basic launch selection validations like checking the number of project or target
+ * contexts.
+ * <p>
+ * The default implementation returns always <code>true</code>.
+ *
+ * @param launchSelection The launch selection to check.
+ * @return <code>True</code> if the launch selection is valid, <code>false</code> otherwise.
+ */
+ protected boolean isValidLaunchSelection(ILaunchSelection launchSelection) {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#validate(java.lang.String, org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public void validate(String launchMode, ILaunchConfiguration launchConfig) throws LaunchServiceException {
+ String missingAttributes = null;
+ for (String attribute : getMandatoryAttributes()) {
+ if (!isValidAttribute(attribute, launchConfig, launchMode)) {
+ missingAttributes = (missingAttributes == null) ? attribute : missingAttributes + ", " + attribute; //$NON-NLS-1$
+ }
+ }
+ if (missingAttributes != null) {
+ throw new LaunchServiceException("Missing launch configuration attributes: " + '\n' + missingAttributes, LaunchServiceException.TYPE_MISSING_LAUNCH_CONFIG_ATTR); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Validate a single attribute for a given launch configuration and a launch mode. This method
+ * needs to be overwritten when contributing new launch modes which does not need all attributes.
+ *
+ * @param attributeKey The attribute key.
+ * @param launchConfig The launch configuration.
+ * @param launchMode The launch mode.
+ *
+ * @return <code>True</code>, if the attribute value is valid.
+ */
+ protected boolean isValidAttribute(String attributeKey, ILaunchConfiguration launchConfig, String launchMode) {
+ try {
+ if (launchConfig == null || !launchConfig.hasAttribute(attributeKey)) {
+ return false;
+ }
+ }
+ catch (CoreException e) {
+ return false;
+ }
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#validate(org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification)
+ */
+ @Override
+ public void validate(ILaunchSpecification launchSpec) throws LaunchServiceException {
+ String missingAttributes = null;
+ for (String attribute : getMandatoryAttributes()) {
+ if (launchSpec == null || !launchSpec.hasAttribute(attribute)) {
+ // Remember the missing attribute for adding the list to the exception.
+ missingAttributes = (missingAttributes == null) ? attribute : missingAttributes + ", " + attribute; //$NON-NLS-1$
+ }
+ }
+ if (missingAttributes != null) {
+ throw new LaunchServiceException("Missing launch specification attributes: " + '\n' + missingAttributes, LaunchServiceException.TYPE_MISSING_LAUNCH_SPEC_ATTR); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Returns the number of defined mandatory attributes.
+ *
+ * @see #getMandatoryAttributes()
+ * @see #getAttributeRanking(String)
+ */
+ protected final int getNumMandatoryAttributes() {
+ return getMandatoryAttributes().size();
+ }
+
+ /**
+ * Returns true if the attribute key is in the list of mandatory attributes.
+ *
+ * @see #getMandatoryAttributes()
+ * @see #getAttributeRanking(String)
+ */
+ protected final boolean isMandatoryAttribute(String attributeKey) {
+ return getMandatoryAttributes().contains(attributeKey);
+ }
+
+ /**
+ * Returns the ranking for the given attribute key.
+ * <p>
+ * The default ranking is 1, ranking of mandatory and other fundamental attributes should be
+ * coded as <code>2^n</code>.
+ * <p>
+ * The more important an attribute is the higher <code>n</code> should be, <code>n</code> should
+ * never be less than the number of attributes with a lower ranking.
+ * <p>
+ * Multiple attributes can have an equal ranking when one attribute can compensate the absence
+ * of an other attribute with the same ranking.
+ *
+ * <pre>
+ * Example:
+ *
+ * Attributes a through f
+ * Attributes a and b are mandatory, b is more important than a.
+ * The attributes c and d should be higher prior than e and f, but should have equal ranking.
+ *
+ * The ranking looks like the following:
+ * Attribute Ranking
+ * b 32 (2^5)
+ * a 16 (2^4)
+ * c, d 4 (2^2)
+ * e, f 1 (2^0)
+ *
+ * With this rankings it is not possible to compensate a missing higher prior attribute with
+ * one or more lower prior attributes.
+ *
+ * Additional methods returns the following values for this example:
+ *
+ * getNumAttributes() == 6
+ * getMandatoryAttibutes() == {a, b}
+ * getNumMandatoryAttributes() == 2
+ * getFullMatchRanking() >= 48 (the value can be greater than 48 depending
+ * on the implementation of the launch manager delegate)
+ * </pre>
+ *
+ * @param attributeKey The attribute key for which the ranking should be returned
+ */
+ protected int getAttributeRanking(String attributeKey) {
+ return 1;
+ }
+
+ /**
+ * Minimum ranking for a launch configuration to be handled as full match when comparing to a
+ * launch specification.
+ * <p>
+ * Should be overwritten when the method {@link #getAttributeRanking(String)} was overwritten.
+ *
+ * @see #getAttributeRanking(String)
+ */
+ protected int getFullMatchRanking() {
+ return 0;
+ }
+
+ /**
+ * Compares an attribute value of launch configuration and specification.
+ *
+ * If both values are not null, calls {@link #equals(String, Object, Object, ILaunchSpecification, ILaunchConfiguration, String)}
+ * to compare the values. If one of the values is <code>null</code>, and the not <code>null</code> value is default, <code>true</code>
+ * is returned. If both values are <code>null</code>, <code>true</code> is returned.
+ *
+ * @param attributeKey The attribute key. Must not be <code>null</code>.
+ * @param specValue The launch specification value.
+ * @param confValue The launch configuration value.
+ * @param launchSpec The launch specification which is the source of the <code>specValue</code>. Must not be <code>null</code>.
+ * @param launchConfig The launch configuration which is the source of the <code>confValue</code>. Must not be <code>null</code>.
+ * @return NO_MATCH, PARTIAL_MATCH or FULL_MATCH
+ */
+ protected int compareAttributeValues(String attributeKey, Object specValue, Object confValue, ILaunchSpecification launchSpec, ILaunchConfiguration launchConfig) {
+ Assert.isNotNull(attributeKey);
+ Assert.isNotNull(launchSpec);
+ Assert.isNotNull(launchConfig);
+
+ // values are equal if both are null
+ if (specValue == null && confValue == null) {
+ return FULL_MATCH;
+ }
+ // if launch specification value is null,
+ // values are equal if launch configuration value is default
+ else if (specValue == null) {
+ Assert.isNotNull(confValue);
+ return isDefaultAttribute(attributeKey, confValue, launchConfig, launchSpec.getLaunchMode()) ? FULL_MATCH : NO_MATCH;
+ }
+ // if launch configuration value is default,
+ // values are equal if launch specification value is default too
+ else if (isDefaultAttribute(attributeKey, confValue, launchConfig, launchSpec.getLaunchMode()) || confValue == null) {
+ Assert.isNotNull(specValue);
+ return isDefaultAttribute(attributeKey, specValue, launchConfig, launchSpec.getLaunchMode()) ? FULL_MATCH : NO_MATCH;
+ }
+ // use object.equals as default
+ else {
+ Assert.isNotNull(specValue);
+ Assert.isNotNull(confValue);
+ return equals(attributeKey, specValue, confValue, launchSpec, launchConfig, launchSpec.getLaunchMode());
+ }
+ }
+
+ /**
+ * Compares the attribute value of launch configuration and launch specification.
+ * <p>
+ * The handling of null values is implemented in the calling private method
+ * {@link #compareAttributeValues(String, Object, Object, ILaunchSpecification, ILaunchConfiguration)}.
+ * When overwriting this method the implementor can be certain both values are not <code>null</code>.
+ *
+ * @param attributeKey The attribute key
+ * @param specValue The launch specification value. Must not be <code>null</code>.
+ * @param confValue The launch configuration value. Must not be <code>null</code>.
+ * @param launchSpec The launch specification.
+ * @param launchConfig The launch configuration which is the source of the <code>confValue</code>.
+ * @param launchMode The current launch mode.
+ *
+ * @return NO_MATCH, PARTIAL_MATCH or FULL_MATCH
+ */
+ protected int equals(String attributeKey, Object specValue, Object confValue, ILaunchSpecification launchSpec, ILaunchConfiguration launchConfig, String launchMode) {
+ Assert.isNotNull(specValue);
+ Assert.isNotNull(confValue);
+
+ if (ICommonLaunchAttributes.ATTR_PROJECTS_FOR_BUILD.equals(attributeKey)) {
+ // get match of list objects
+ int match = specValue.equals(confValue) ? FULL_MATCH : NO_MATCH;
+ // compare objects in the list when they are not already equal
+ if (match != FULL_MATCH && specValue instanceof List<?> && confValue instanceof List<?>) {
+ List<?> specProject = (List<?>) specValue;
+ List<?> confProject = (List<?>) confValue;
+ match = (specProject.isEmpty() || confProject.isEmpty()) ? PARTIAL_MATCH : NO_MATCH;
+ List<?> refProjects = null;
+ try {
+ refProjects = launchConfig.getAttribute(ICommonLaunchAttributes.ATTR_REFERENCED_PROJECTS, (List<?>) null);
+ }
+ catch (CoreException e) {
+ // ignore
+ }
+ for (int i = 0; i < specProject.size(); i++) {
+ Object specObject = specProject.get(i);
+ if (specObject != null && confProject.contains(specObject)) {
+ // spec object can be found in the configuration
+ if (match == NO_MATCH) {
+ // full match on first element in the spec list,
+ // otherwise partial match
+ match = (i == 0) ? FULL_MATCH : PARTIAL_MATCH;
+ }
+ }
+ else if (specObject != null && refProjects != null && refProjects.contains(specObject)) {
+ // spec object can be found in the configuration
+ if (match == NO_MATCH) {
+ match = PARTIAL_MATCH;
+ }
+ }
+ else if (match == FULL_MATCH) {
+ // reduce full to partial match when spec object wasn't found
+ match = PARTIAL_MATCH;
+ }
+ }
+ // reduce full to partial match when list size is not equal
+ // but all spec values where found in the configuration project list
+ if (match == FULL_MATCH && specProject.size() != confProject.size()) {
+ match = PARTIAL_MATCH;
+ }
+ }
+ return match;
+ }
+
+ return specValue.equals(confValue) ? FULL_MATCH : NO_MATCH;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#showLaunchDialog(int)
+ */
+ @Override
+ public boolean showLaunchDialog(int situation) {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#showLaunchConfigOnly()
+ */
+ @Override
+ public boolean showLaunchConfigOnly() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#showLaunchConfigSelectionDialog(org.eclipse.debug.core.ILaunchConfigurationType, org.eclipse.debug.core.ILaunchConfiguration[])
+ */
+ @Override
+ public boolean showLaunchConfigSelectionDialog(ILaunchConfigurationType type, ILaunchConfiguration[] launchConfigs) {
+ if (type != null) {
+ String key = type.getIdentifier() + ".hideLaunchConfigSelectionDialog"; //$NON-NLS-1$
+ return !CoreBundleActivator.getScopedPreferences().getBoolean(key);
+ }
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getErrorMessage()
+ */
+ @Override
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#equals(org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext, org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext)
+ */
+ @Override
+ public boolean equals(ISelectionContext ctx1, ISelectionContext ctx2) {
+ return (ctx1 == null && ctx2 == null) || (ctx1 != null && ctx1.equals(ctx2));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#useDefaultConnection()
+ */
+ @Override
+ public boolean useDefaultConnection() {
+ return true;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ICommonLaunchAttributes.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ICommonLaunchAttributes.java index 63582ad78..525754897 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ICommonLaunchAttributes.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ICommonLaunchAttributes.java @@ -35,11 +35,6 @@ public interface ICommonLaunchAttributes { public static final String ATTR_LAST_LAUNCHED = ATTR_PREFIX + ".lastLaunched"; //$NON-NLS-1$
/**
- * Launch mode variant id.
- */
- public static final String ATTR_DELEGATE_VARIANT = ATTR_PREFIX + ".delegateVariant"; //$NON-NLS-1$
-
- /**
* Attribute used exclusively with <code>ILaunch.setAttribute</code> to mark when
* then launch sequence finished. The attribute does not tell if an error occurred
* during the launch!
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ILaunchManagerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ILaunchManagerDelegate.java index f9e1c202e..658adb15c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ILaunchManagerDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ILaunchManagerDelegate.java @@ -1,196 +1,177 @@ -/******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.launch.core.lm.interfaces; - -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationType; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.tcf.te.launch.core.exceptions.LaunchServiceException; -import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection; -import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext; -import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension; - -/** - * Describes the interface used by the <code>LaunchManager</code> to create - * and manage the different types of possible launch configurations in a generalized, - * simple and abstract way. A <code>ILaunchManagerDelegate</code> is strictly bound - * to one specific <code>ILaunchConfigurationType</code> and is capable and responsible - * to initializing and handling launch configurations of this type. A launch manager - * delegate is contribute through the <code>org.eclipse.tcf.te.launch.core.launchManagerDelegates</code> - * extension point! - */ -public interface ILaunchManagerDelegate extends IExecutableExtension { - - public static final int SITUATION_BEFORE_LAUNCH = 0; - public static final int SITUATION_AFTER_LAUNCH_FAILED = 99; - - // Constants for signaling the type of found matches - - /** - * Constant to signal to ignore this matching. - */ - public final static int IGNORE = -1; - - /** - * Constant to signal a no match (no attributes are matching). - */ - public final static int NO_MATCH = 0; - - /** - * Constant to signal a partial match (some attributes are matching). - */ - public final static int PARTIAL_MATCH = 1; - - /** - * Constant to signal a full match (all attributes are matching). - */ - public final static int FULL_MATCH = 2; - - /** - * Initialize the launch configuration attributes based on the specified launch specification. If an launch - * configuration attribute is not listed within the specified launch specification, the corresponding attribute is - * initialized with an default. - * - * @param wc The launch configuration working copy to initialize. Must not be <code>null</code>! - * @param launchSpec The launch specification. Must not be <code>null</code>! - */ - public void initLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec); - - /** - * Updates a found launch configuration based on the specified launch specification. - * - * @param wc The launch configuration working copy to initialize. Must not be <code>null</code>! - * @param launchSpec The launch specification. Must not be <code>null</code>! - */ - public void updateLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec); - - /** - * Test the specified attribute if or if not the specified attribute value is an default value or not. - * - * @param attributeKey The attribute key/name. Must not be <code>null</code>. - * @param attributeValue The attribute value to test. - * @param launchConfig The original launch configuration. Needed to access relevant attributes for default value - * calculation. Must not be <code>null</code>! - * @param launchMode The launch mode. Default values may differ for different launch modes. Must not be - * <code>null</code>! - * @return <code>true</code> if the specified attribute value is the default value, <code>false</code> otherwise. - */ - public boolean isDefaultAttribute(String attributeKey, Object attributeValue, ILaunchConfiguration launchConfig, String launchMode); - - /** - * Returns a ranked list of launch configurations that best matches the given launch specification. In case of no - * results or a given empty or null launch configuration list an empty list should be returned. If no launch specification - * is given, the original list should be returned. - * - * @param launchSpec The launch specification the launch configurations should match. - * @param launchConfigs A full list of launch configurations to check for best matching. - * @return List of matching launch configurations starting with best match on first index. - * @throws LaunchServiceException - */ - public ILaunchConfiguration[] getMatchingLaunchConfigurations(ILaunchSpecification launchSpec, ILaunchConfiguration[] launchConfigs) throws LaunchServiceException; - - /** - * Get the default launch configuration name. - * - * @param launchSpec The launch specification to create a default name for the launch config. Must not be <code>null</code>. - * @return The default launch configuration name. - */ - public String getDefaultLaunchName(ILaunchSpecification launchSpec); - - /** - * Get a launch specification with all needed attributes for this delegate taken from the selection to find or create a new - * launch configuration. - * - * @param launchConfigTypeId The launch configuration type id. - * @param launchSelection The selected contexts. - * @return Launch specification with attributes set from selected contexts. - * @throws LaunchServiceException - */ - public ILaunchSpecification getLaunchSpecification(String launchConfigTypeId, ILaunchSelection launchSelection); - - /** - * Get a launch spec with all needed attributes for this delegate and variant taken from the selection to find or create a new - * launch configuration. - * - * @param launchConfigTypeId The launch configuration type id. - * @param launchSelection The selected contexts. - * @param variant The delegate variant. - * @return Launch spec with attributes set from selected contexts. - * @throws LaunchServiceException - */ - public ILaunchSpecification getLaunchSpecification(String launchConfigTypeId, ILaunchSelection launchSelection, String variant); - - /** - * Validates a launch specification. - * - * @param launchSpec The launch specification to validate. - * @throws LaunchServiceException If validation fails with further information about the reason (e.q. missing - * attributes) - */ - public void validate(ILaunchSpecification launchSpec) throws LaunchServiceException; - - /** - * Validates a launch configuration. - * - * @param launchConfig The launch configuration to validate. - * @param launchMode The launch mode. - * @throws LaunchServiceException If validation fails with further information about the reason (e.q. missing - * attributes) - */ - public void validate(String launchMode, ILaunchConfiguration launchConfig) throws LaunchServiceException; - - /** - * Returns true, if the launch dialog should be shown before launch. - * @param situation The situation (before launch, after launch, ..) - */ - public boolean showLaunchDialog(int situation); - - /** - * Returns true, if the launch dialog should only show the given launch configuration (no launch configuration type tree). - */ - public boolean showLaunchConfigOnly(); - - /** - * Returns <code>true</code> if a dialog should pop up when at least one matching - * launch configuration was found. - * If <code>false</code> is returned, the first matching launch configuration will be used. - * - * @param type The launch configuration type to check. - */ - public boolean showLaunchConfigSelectionDialog(ILaunchConfigurationType type, ILaunchConfiguration[] launchConfigs); - - /** - * Returns the error message when not valid, otherwise <code>null</code>. - */ - public String getErrorMessage(); - - /** - * Return the list of variants or null. - * - * @param launchSelection The launch selection or <code>null</code>. - */ - public String[] getVariants(ILaunchSelection launchSelection); - - /** - * Return <code>true</code> if the two selection contexts are equal - * for this launch configuration type. - * - * @param ctx1 The first launch selection context or <code>null</code>. - * @param ctx2 The second launch selection context or <code>null</code>. - * - * @return <code>True</code> if the two selection contexts are equal for this launch configuration type, <code>false</code> otherwise. - */ - public boolean equals(ISelectionContext ctx1, ISelectionContext ctx2); - - /** - * Return <code>true</code> if a default connection should be used when the connection selection is empty. - */ - public boolean useDefaultConnection(); -} +/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.core.lm.interfaces;
+
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.tcf.te.launch.core.exceptions.LaunchServiceException;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
+import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
+
+/**
+ * Describes the interface used by the <code>LaunchManager</code> to create
+ * and manage the different types of possible launch configurations in a generalized,
+ * simple and abstract way. A <code>ILaunchManagerDelegate</code> is strictly bound
+ * to one specific <code>ILaunchConfigurationType</code> and is capable and responsible
+ * to initializing and handling launch configurations of this type. A launch manager
+ * delegate is contribute through the <code>org.eclipse.tcf.te.launch.core.launchManagerDelegates</code>
+ * extension point!
+ */
+public interface ILaunchManagerDelegate extends IExecutableExtension {
+
+ public static final int SITUATION_BEFORE_LAUNCH = 0;
+ public static final int SITUATION_AFTER_LAUNCH_FAILED = 99;
+
+ // Constants for signaling the type of found matches
+
+ /**
+ * Constant to signal to ignore this matching.
+ */
+ public final static int IGNORE = -1;
+
+ /**
+ * Constant to signal a no match (no attributes are matching).
+ */
+ public final static int NO_MATCH = 0;
+
+ /**
+ * Constant to signal a partial match (some attributes are matching).
+ */
+ public final static int PARTIAL_MATCH = 1;
+
+ /**
+ * Constant to signal a full match (all attributes are matching).
+ */
+ public final static int FULL_MATCH = 2;
+
+ /**
+ * Initialize the launch configuration attributes based on the specified launch specification. If an launch
+ * configuration attribute is not listed within the specified launch specification, the corresponding attribute is
+ * initialized with an default.
+ *
+ * @param wc The launch configuration working copy to initialize. Must not be <code>null</code>!
+ * @param launchSpec The launch specification. Must not be <code>null</code>!
+ */
+ public void initLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec);
+
+ /**
+ * Updates a found launch configuration based on the specified launch specification.
+ *
+ * @param wc The launch configuration working copy to initialize. Must not be <code>null</code>!
+ * @param launchSpec The launch specification. Must not be <code>null</code>!
+ */
+ public void updateLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec);
+
+ /**
+ * Test the specified attribute if or if not the specified attribute value is an default value or not.
+ *
+ * @param attributeKey The attribute key/name. Must not be <code>null</code>.
+ * @param attributeValue The attribute value to test.
+ * @param launchConfig The original launch configuration. Needed to access relevant attributes for default value
+ * calculation. Must not be <code>null</code>!
+ * @param launchMode The launch mode. Default values may differ for different launch modes. Must not be
+ * <code>null</code>!
+ * @return <code>true</code> if the specified attribute value is the default value, <code>false</code> otherwise.
+ */
+ public boolean isDefaultAttribute(String attributeKey, Object attributeValue, ILaunchConfiguration launchConfig, String launchMode);
+
+ /**
+ * Returns a ranked list of launch configurations that best matches the given launch specification. In case of no
+ * results or a given empty or null launch configuration list an empty list should be returned. If no launch specification
+ * is given, the original list should be returned.
+ *
+ * @param launchSpec The launch specification the launch configurations should match.
+ * @param launchConfigs A full list of launch configurations to check for best matching.
+ * @return List of matching launch configurations starting with best match on first index.
+ * @throws LaunchServiceException
+ */
+ public ILaunchConfiguration[] getMatchingLaunchConfigurations(ILaunchSpecification launchSpec, ILaunchConfiguration[] launchConfigs) throws LaunchServiceException;
+
+ /**
+ * Get the default launch configuration name.
+ *
+ * @param launchSpec The launch specification to create a default name for the launch config. Must not be <code>null</code>.
+ * @return The default launch configuration name.
+ */
+ public String getDefaultLaunchName(ILaunchSpecification launchSpec);
+
+ /**
+ * Get a launch specification with all needed attributes for this delegate taken from the selection to find or create a new
+ * launch configuration.
+ *
+ * @param launchConfigTypeId The launch configuration type id.
+ * @param launchSelection The selected contexts.
+ * @return Launch specification with attributes set from selected contexts.
+ * @throws LaunchServiceException
+ */
+ public ILaunchSpecification getLaunchSpecification(String launchConfigTypeId, ILaunchSelection launchSelection);
+
+ /**
+ * Validates a launch specification.
+ *
+ * @param launchSpec The launch specification to validate.
+ * @throws LaunchServiceException If validation fails with further information about the reason (e.q. missing
+ * attributes)
+ */
+ public void validate(ILaunchSpecification launchSpec) throws LaunchServiceException;
+
+ /**
+ * Validates a launch configuration.
+ *
+ * @param launchConfig The launch configuration to validate.
+ * @param launchMode The launch mode.
+ * @throws LaunchServiceException If validation fails with further information about the reason (e.q. missing
+ * attributes)
+ */
+ public void validate(String launchMode, ILaunchConfiguration launchConfig) throws LaunchServiceException;
+
+ /**
+ * Returns true, if the launch dialog should be shown before launch.
+ * @param situation The situation (before launch, after launch, ..)
+ */
+ public boolean showLaunchDialog(int situation);
+
+ /**
+ * Returns true, if the launch dialog should only show the given launch configuration (no launch configuration type tree).
+ */
+ public boolean showLaunchConfigOnly();
+
+ /**
+ * Returns <code>true</code> if a dialog should pop up when at least one matching
+ * launch configuration was found.
+ * If <code>false</code> is returned, the first matching launch configuration will be used.
+ *
+ * @param type The launch configuration type to check.
+ */
+ public boolean showLaunchConfigSelectionDialog(ILaunchConfigurationType type, ILaunchConfiguration[] launchConfigs);
+
+ /**
+ * Returns the error message when not valid, otherwise <code>null</code>.
+ */
+ public String getErrorMessage();
+
+ /**
+ * Return <code>true</code> if the two selection contexts are equal
+ * for this launch configuration type.
+ *
+ * @param ctx1 The first launch selection context or <code>null</code>.
+ * @param ctx2 The second launch selection context or <code>null</code>.
+ *
+ * @return <code>True</code> if the two selection contexts are equal for this launch configuration type, <code>false</code> otherwise.
+ */
+ public boolean equals(ISelectionContext ctx1, ISelectionContext ctx2);
+
+ /**
+ * Return <code>true</code> if a default connection should be used when the connection selection is empty.
+ */
+ public boolean useDefaultConnection();
+}
|