diff options
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.launch.core')
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/internal/LaunchConfigurationDelegate.java) | 3 | ||||
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchConfigHelper.java | 278 | ||||
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java | 24 |
3 files changed, 155 insertions, 150 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/internal/LaunchConfigurationDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java index 5b3fd9dac..5612da668 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/internal/LaunchConfigurationDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java @@ -7,7 +7,7 @@ * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ -package org.eclipse.tcf.te.launch.core.lm.internal; +package org.eclipse.tcf.te.launch.core.delegates; import java.util.ArrayList; import java.util.Date; @@ -36,7 +36,6 @@ import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.osgi.util.NLS; import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator; import org.eclipse.tcf.te.launch.core.bindings.LaunchConfigTypeBindingsManager; -import org.eclipse.tcf.te.launch.core.delegates.Launch; import org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem; import org.eclipse.tcf.te.launch.core.lm.interfaces.ICommonLaunchAttributes; import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchConfigHelper.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchConfigHelper.java index 2cec6cff7..084e96f3a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchConfigHelper.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchConfigHelper.java @@ -1,126 +1,152 @@ -/*******************************************************************************
- * 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;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.ILaunchMode;
-
-/**
- * Static launch configuration utility implementations.
- */
-public class LaunchConfigHelper {
-
- /**
- * Generate a unique launch config name.
- * @param name The suggested name.
- * @return The unique name.
- */
- public static String getUniqueLaunchConfigName(String name) {
- return DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(name);
- }
-
- /**
- * Get a sorted list of all launch modes for the given launch configuration type.
- *
- * @param launchConfigType The launch configuration type.
- * @param reverse If <code>true</code> the sorted list order is reversed.
- *
- * @return Sorted list of supported launch modes.
- */
- public static String[] getLaunchConfigTypeModes(ILaunchConfigurationType launchConfigType, boolean reverse) {
- return getLaunchConfigTypeModes(new ILaunchConfigurationType[] { launchConfigType }, reverse);
- }
-
- /**
- * Get a sorted list of all launch modes for the given launch configuration types.
- *
- * @param launchConfigTypes The launch configuration types.
- * @param reverse If <code>true</code> the sorted list order is reversed.
- *
- * @return Sorted list of supported launch modes.
- */
- public static String[] getLaunchConfigTypeModes(ILaunchConfigurationType[] launchConfigTypes, boolean reverse) {
- List<String> modes = new ArrayList<String>();
- for (ILaunchConfigurationType launchConfigType : launchConfigTypes) {
- for (Object modeCombination : launchConfigType.getSupportedModeCombinations()) {
- if (((Set<?>) modeCombination).size() == 1) {
- String mode = (String) ((Set<?>) modeCombination).toArray()[0];
- if (!modes.contains(mode)) {
- modes.add(mode);
- }
- }
- }
- }
- return getLaunchModesSorted(modes.toArray(new String[modes.size()]), reverse);
- }
-
- /**
- * Gets a sorted list of launch mode identifiers.
- *
- * @param launchModes The launch modes. Must not be <code>null</code>.
- * @param reverse If <code>true</code> the sorted list order is reversed.
- *
- * @return Sorted list of launch mode identifiers.
- */
- public static String[] getLaunchModesSorted(ILaunchMode[] launchModes, boolean reverse) {
- Assert.isNotNull(launchModes);
-
- String[] modes = new String[launchModes.length];
- for (int i = 0; i < launchModes.length; i++) {
- modes[i] = launchModes[i].getIdentifier();
- }
- return getLaunchModesSorted(modes, reverse);
- }
-
- /**
- * Gets a sorted list of launch mode identifiers.
- *
- * @param launchModes The unsorted list of launch modes identifiers. Must not be <code>null</code>.
- * @param reverse If <code>true</code> the sorted list order is reversed.
- *
- * @return Sorted list of launch mode identifiers.
- */
- public static String[] getLaunchModesSorted(String[] launchModes, final boolean reverse) {
- Assert.isNotNull(launchModes);
-
- // sort the list of launch modes
- // Run is always the first, followed by Debug.
- // All other modes are sorted alphabetically at the end of the list.
- Arrays.sort(launchModes, new Comparator<String>() {
- @Override
- public int compare(String o1, String o2) {
- if (o1.equals(ILaunchManager.RUN_MODE) && !o2.equals(ILaunchManager.RUN_MODE)) {
- return reverse ? 1 : -1;
- }
- if (o2.equals(ILaunchManager.RUN_MODE) && !o1.equals(ILaunchManager.RUN_MODE)) {
- return reverse ? -1 : 1;
- }
- if (o1.equals(ILaunchManager.DEBUG_MODE) && !o2.equals(ILaunchManager.DEBUG_MODE)) {
- return reverse ? 1 : -1;
- }
- if (o2.equals(ILaunchManager.DEBUG_MODE) && !o1.equals(ILaunchManager.DEBUG_MODE)) {
- return reverse ? -1 : 1;
- }
- return reverse ? o2.compareTo(o1) : o1.compareTo(o2);
- }
- });
-
- return launchModes;
- }
-}
+/******************************************************************************* + * 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; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.core.ILaunchMode; + +/** + * Static launch configuration utility implementations. + */ +public class LaunchConfigHelper { + + /** + * Generate a unique launch config name. + * @param name The suggested name. + * @return The unique name. + */ + public static String getUniqueLaunchConfigName(String name) { + return DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(name); + } + + public static void addLaunchConfigAttribute(ILaunchConfigurationWorkingCopy wc, String key, Object value) { + if (value instanceof String) { + wc.setAttribute(key, (String)value); + } + else if (value instanceof List) { + wc.setAttribute(key, (List<?>)value); + } + else if (value instanceof Map) { + wc.setAttribute(key, (Map<?,?>)value); + } + else if (value instanceof Set) { + wc.setAttribute(key, (Set<?>)value); + } + else if (value instanceof Boolean) { + wc.setAttribute(key, ((Boolean)value).booleanValue()); + } + else if (value instanceof Number) { + wc.setAttribute(key, ((Number)value).intValue()); + } + else { + throw new IllegalArgumentException("Unknown attribute type " + value.getClass().getName() + "(" + value.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + } + + /** + * Get a sorted list of all launch modes for the given launch configuration type. + * + * @param launchConfigType The launch configuration type. + * @param reverse If <code>true</code> the sorted list order is reversed. + * + * @return Sorted list of supported launch modes. + */ + public static String[] getLaunchConfigTypeModes(ILaunchConfigurationType launchConfigType, boolean reverse) { + return getLaunchConfigTypeModes(new ILaunchConfigurationType[] { launchConfigType }, reverse); + } + + /** + * Get a sorted list of all launch modes for the given launch configuration types. + * + * @param launchConfigTypes The launch configuration types. + * @param reverse If <code>true</code> the sorted list order is reversed. + * + * @return Sorted list of supported launch modes. + */ + public static String[] getLaunchConfigTypeModes(ILaunchConfigurationType[] launchConfigTypes, boolean reverse) { + List<String> modes = new ArrayList<String>(); + for (ILaunchConfigurationType launchConfigType : launchConfigTypes) { + for (Object modeCombination : launchConfigType.getSupportedModeCombinations()) { + if (((Set<?>) modeCombination).size() == 1) { + String mode = (String) ((Set<?>) modeCombination).toArray()[0]; + if (!modes.contains(mode)) { + modes.add(mode); + } + } + } + } + return getLaunchModesSorted(modes.toArray(new String[modes.size()]), reverse); + } + + /** + * Gets a sorted list of launch mode identifiers. + * + * @param launchModes The launch modes. Must not be <code>null</code>. + * @param reverse If <code>true</code> the sorted list order is reversed. + * + * @return Sorted list of launch mode identifiers. + */ + public static String[] getLaunchModesSorted(ILaunchMode[] launchModes, boolean reverse) { + Assert.isNotNull(launchModes); + + String[] modes = new String[launchModes.length]; + for (int i = 0; i < launchModes.length; i++) { + modes[i] = launchModes[i].getIdentifier(); + } + return getLaunchModesSorted(modes, reverse); + } + + /** + * Gets a sorted list of launch mode identifiers. + * + * @param launchModes The unsorted list of launch modes identifiers. Must not be <code>null</code>. + * @param reverse If <code>true</code> the sorted list order is reversed. + * + * @return Sorted list of launch mode identifiers. + */ + public static String[] getLaunchModesSorted(String[] launchModes, final boolean reverse) { + Assert.isNotNull(launchModes); + + // sort the list of launch modes + // Run is always the first, followed by Debug. + // All other modes are sorted alphabetically at the end of the list. + Arrays.sort(launchModes, new Comparator<String>() { + @Override + public int compare(String o1, String o2) { + if (o1.equals(ILaunchManager.RUN_MODE) && !o2.equals(ILaunchManager.RUN_MODE)) { + return reverse ? 1 : -1; + } + if (o2.equals(ILaunchManager.RUN_MODE) && !o1.equals(ILaunchManager.RUN_MODE)) { + return reverse ? -1 : 1; + } + if (o1.equals(ILaunchManager.DEBUG_MODE) && !o2.equals(ILaunchManager.DEBUG_MODE)) { + return reverse ? 1 : -1; + } + if (o2.equals(ILaunchManager.DEBUG_MODE) && !o1.equals(ILaunchManager.DEBUG_MODE)) { + return reverse ? -1 : 1; + } + return reverse ? o2.compareTo(o1) : o1.compareTo(o2); + } + }); + + return launchModes; + } +} 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 0de4061d6..68fa6f022 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 @@ -28,6 +28,7 @@ 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.IReferencedProjectItem; import org.eclipse.tcf.te.launch.core.interfaces.tracing.ITraceIds; +import org.eclipse.tcf.te.launch.core.lm.LaunchConfigHelper; 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; @@ -63,28 +64,7 @@ public class DefaultLaunchManagerDelegate extends ExecutableExtension implements protected void copySpecToConfig(ILaunchSpecification launchSpec, ILaunchConfigurationWorkingCopy wc) { for (ILaunchAttribute attribute : launchSpec.getAllAttributes()) { - Object value = attribute.getValue(); - if (value instanceof String) { - wc.setAttribute(attribute.getKey(), (String)value); - } - else if (value instanceof List) { - wc.setAttribute(attribute.getKey(), (List<?>)value); - } - else if (value instanceof Map) { - wc.setAttribute(attribute.getKey(), (Map<?,?>)value); - } - else if (value instanceof Set) { - wc.setAttribute(attribute.getKey(), (Set<?>)value); - } - else if (value instanceof Boolean) { - wc.setAttribute(attribute.getKey(), ((Boolean)value).booleanValue()); - } - else if (value instanceof Number) { - wc.setAttribute(attribute.getKey(), ((Number)value).intValue()); - } - else { - throw new IllegalArgumentException("Unknown attribute type " + value.getClass().getName() + "(" + value.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } + LaunchConfigHelper.addLaunchConfigAttribute(wc, attribute.getKey(), attribute.getValue()); } } |