Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2012-05-16 11:26:50 +0000
committerUwe Stieber2012-05-16 11:28:58 +0000
commita7169af26fdc4587176181834fb52930965ab87a (patch)
tree5801b61fb0fd20e0279c1ed334978551f29b691b /target_explorer/plugins
parent23928d4dbc8a573bfd3f96bf794ef77e19dc5a7d (diff)
downloadorg.eclipse.tcf-a7169af26fdc4587176181834fb52930965ab87a.tar.gz
org.eclipse.tcf-a7169af26fdc4587176181834fb52930965ab87a.tar.xz
org.eclipse.tcf-a7169af26fdc4587176181834fb52930965ab87a.zip
Target Explorer: ADD DnD support for launches
Diffstat (limited to 'target_explorer/plugins')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchConfigHelper.java234
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchManager.java20
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchSpecification.java528
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java64
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/interfaces/ILaunchManagerDelegate.java43
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/projects/ReferencedProjectItem.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml73
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/DeleteHandler.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/RefreshHandler.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/FileTransferFilter.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchConfigTypeFilter.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchContextFilter.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/RefProjectsFilter.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/DescriptionColumnLabelProvider.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LastLaunchedColumnLabelProvider.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNavigatorContentProvider.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchTreeLabelProvider.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/CommonDnD.java471
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DragAssistant.java53
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DragSourceListener.java66
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DropAssistant.java46
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DropTargetListener.java50
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchModel.java36
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchNode.java62
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.properties6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/StepContextAdapter.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/RemoteAppLaunchManagerDelegate.java167
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppFilter.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/CommonDnD.java68
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/CategoryAddToContributionItem.java3
34 files changed, 1462 insertions, 589 deletions
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 1a5119fe9..2cec6cff7 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,108 +1,126 @@
-/*******************************************************************************
- * 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.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.ILaunchMode;
-
-/**
- * Static launch configuration utility implementations.
- */
-public class LaunchConfigHelper {
-
- /**
- * 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.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;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchManager.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchManager.java
index 23cb4e8bf..45022fd48 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchManager.java
@@ -218,11 +218,7 @@ public class LaunchManager extends PlatformObject {
.equals(launchConfigTypeId)) {
try {
// create the launch configuration working copy instance
- wc = launchConfigType.newInstance(null, DebugPlugin
- .getDefault()
- .getLaunchManager()
- .generateLaunchConfigurationName(launchSpec
- .getLaunchConfigName()));
+ wc = launchConfigType.newInstance(null, LaunchConfigHelper.getUniqueLaunchConfigName(launchSpec.getLaunchConfigName()));
// initialize the launch configuration working copy
delegate.initLaunchConfigAttributes(wc, launchSpec);
// and save the launch configuration
@@ -420,18 +416,4 @@ public class LaunchManager extends PlatformObject {
throw new LaunchServiceException(e);
}
}
-
- /**
- * Remove all illegal characters in the launch configuration name candidate.
- *
- * @param candidate The launch configuration name candidate.
- * @return The unified launch configuration name.
- */
- public static String getUnifiedLaunchConfigName(String candidate) {
- if (candidate != null) {
- candidate = candidate.replaceAll("[/\\\"&?:@*]", "_"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return candidate;
- }
-
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchSpecification.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchSpecification.java
index ab5716ab0..114d0160a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchSpecification.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchSpecification.java
@@ -1,262 +1,266 @@
-/*******************************************************************************
- * 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.Hashtable;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchAttribute;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
-import org.eclipse.tcf.te.launch.core.nls.Messages;
-
-/**
- * Default launch specification implementation.
- */
-public class LaunchSpecification extends PlatformObject implements ILaunchSpecification {
- private final Map<String, ILaunchAttribute> attributes = new Hashtable<String, ILaunchAttribute>();
- private final String typeId;
- private final String mode;
- private String launchConfigName;
- private String launchActionLabel;
- private boolean readOnly;
- private boolean valid = true;
- private String errorMessage = null;
-
- /**
- * Constructor.
- * <p>
- * Creates a new launch specification instance for the specified launch configuration type
- * id and the specified launch mode. The launch specification is not locked against modifications
- * by default!
- *
- * @param typeId The launch configuration type id of the described launch configuration.
- * @param mode The launch mode. @see <code>org.eclipse.debug.core.ILaunchManager</code>!
- */
- public LaunchSpecification(String typeId, String mode) {
- super();
- this.typeId = typeId;
- this.mode = mode;
- this.attributes.clear();
- setReadOnly(false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getLaunchConfigurationTypeId()
- */
- @Override
- public String getLaunchConfigurationTypeId() {
- return typeId;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getLaunchMode()
- */
- @Override
- public String getLaunchMode() {
- return mode;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#isReadOnly()
- */
- @Override
- public boolean isReadOnly() {
- return readOnly;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#setReadOnly(boolean)
- */
- @Override
- public void setReadOnly(boolean readOnly) {
- this.readOnly = readOnly;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#addAttribute(java.lang.String, java.lang.Object)
- */
- @Override
- public void addAttribute(String key, Object value) {
- addAttribute(key, value, false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#addAttribute(java.lang.String, java.lang.Object, boolean)
- */
- @Override
- public void addAttribute(String key, Object value, boolean createOnly) {
- Assert.isNotNull(key);
-
- if (isReadOnly()) return;
-
- // Attention: If the value == null -> remove the key from the map!!!
- if (value != null) {
- attributes.put(key, new LaunchAttribute(key, value, createOnly));
- }
- else {
- attributes.remove(key);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#hasAttribute(java.lang.String)
- */
- @Override
- public boolean hasAttribute(String key) {
- Assert.isNotNull(key);
- return attributes.containsKey(key);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#removeAttribute(java.lang.String)
- */
- @Override
- public Object removeAttribute(String key) {
- Assert.isNotNull(key);
- if (isReadOnly()) return null;
- return attributes.remove(key);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#isCreateOnlyAttribute(java.lang.String)
- */
- @Override
- public boolean isCreateOnlyAttribute(String key) {
- Assert.isNotNull(key);
- ILaunchAttribute attribute = getAttribute(key);
- return attribute != null && attribute.isCreateOnlyAttribute();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getAttribute(java.lang.String, java.lang.Object)
- */
- @Override
- public Object getAttribute(String key, Object defaultValue) {
- Assert.isNotNull(key);
- ILaunchAttribute attribute = getAttribute(key);
- return (attribute != null && attribute.getValue() != null) ? attribute.getValue() : defaultValue;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#clear()
- */
- @Override
- public void clear() {
- if (isReadOnly()) {
- return;
- }
- attributes.clear();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#size()
- */
- @Override
- public int size() {
- return attributes.size();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#isEmpty()
- */
- @Override
- public boolean isEmpty() {
- return attributes.isEmpty();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getAttribute(java.lang.String)
- */
- @Override
- public ILaunchAttribute getAttribute(String key) {
- Assert.isNotNull(key);
- return attributes.get(key);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getAllAttributes()
- */
- @Override
- public ILaunchAttribute[] getAllAttributes() {
- return attributes.values().toArray(new ILaunchAttribute[attributes.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getLaunchActionLabel()
- */
- @Override
- public String getLaunchActionLabel() {
- return launchActionLabel;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getLaunchConfigName()
- */
- @Override
- public String getLaunchConfigName() {
- return launchConfigName != null ? launchConfigName : Messages.DefaultLaunchManagerDelegate_defaultLaunchName;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#setLaunchActionLabel(java.lang.String)
- */
- @Override
- public void setLaunchActionLabel(String launchActionLabel) {
- this.launchActionLabel = launchActionLabel;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#setLaunchConfigName(java.lang.String)
- */
- @Override
- public void setLaunchConfigName(String launchConfigName) {
- this.launchConfigName = LaunchManager.getUnifiedLaunchConfigName(launchConfigName);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#isValid()
- */
- @Override
- public boolean isValid() {
- return valid;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#setIsValid(boolean)
- */
- @Override
- public void setIsValid(boolean valid) {
- this.valid = valid;
- if (valid) {
- errorMessage = null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getErrorMessage()
- */
- @Override
- public String getErrorMessage() {
- if (!isValid()) {
- return errorMessage;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#setErrorMessage(java.lang.String)
- */
- @Override
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- }
-}
+/*******************************************************************************
+ * 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.Hashtable;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchAttribute;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
+import org.eclipse.tcf.te.launch.core.nls.Messages;
+
+/**
+ * Default launch specification implementation.
+ */
+public class LaunchSpecification extends PlatformObject implements ILaunchSpecification {
+ private final Map<String, ILaunchAttribute> attributes = new Hashtable<String, ILaunchAttribute>();
+ private final String typeId;
+ private final String mode;
+ private String launchConfigName;
+ private String launchActionLabel;
+ private boolean readOnly;
+ private boolean valid = true;
+ private String errorMessage = null;
+
+ /**
+ * Constructor.
+ * <p>
+ * Creates a new launch specification instance for the specified launch configuration type
+ * id and the specified launch mode. The launch specification is not locked against modifications
+ * by default!
+ *
+ * @param typeId The launch configuration type id of the described launch configuration.
+ * @param mode The launch mode. @see <code>org.eclipse.debug.core.ILaunchManager</code>!
+ */
+ public LaunchSpecification(String typeId, String mode) {
+ super();
+ this.typeId = typeId;
+ this.mode = mode;
+ this.attributes.clear();
+ setReadOnly(false);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getLaunchConfigurationTypeId()
+ */
+ @Override
+ public String getLaunchConfigurationTypeId() {
+ return typeId;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getLaunchMode()
+ */
+ @Override
+ public String getLaunchMode() {
+ return mode;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#isReadOnly()
+ */
+ @Override
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#setReadOnly(boolean)
+ */
+ @Override
+ public void setReadOnly(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#addAttribute(java.lang.String, java.lang.Object)
+ */
+ @Override
+ public void addAttribute(String key, Object value) {
+ addAttribute(key, value, false);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#addAttribute(java.lang.String, java.lang.Object, boolean)
+ */
+ @Override
+ public void addAttribute(String key, Object value, boolean createOnly) {
+ Assert.isNotNull(key);
+
+ if (isReadOnly()) {
+ return;
+ }
+
+ // Attention: If the value == null -> remove the key from the map!!!
+ if (value != null) {
+ attributes.put(key, new LaunchAttribute(key, value, createOnly));
+ }
+ else {
+ attributes.remove(key);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#hasAttribute(java.lang.String)
+ */
+ @Override
+ public boolean hasAttribute(String key) {
+ Assert.isNotNull(key);
+ return attributes.containsKey(key);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#removeAttribute(java.lang.String)
+ */
+ @Override
+ public Object removeAttribute(String key) {
+ Assert.isNotNull(key);
+ if (isReadOnly()) {
+ return null;
+ }
+ return attributes.remove(key);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#isCreateOnlyAttribute(java.lang.String)
+ */
+ @Override
+ public boolean isCreateOnlyAttribute(String key) {
+ Assert.isNotNull(key);
+ ILaunchAttribute attribute = getAttribute(key);
+ return attribute != null && attribute.isCreateOnlyAttribute();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getAttribute(java.lang.String, java.lang.Object)
+ */
+ @Override
+ public Object getAttribute(String key, Object defaultValue) {
+ Assert.isNotNull(key);
+ ILaunchAttribute attribute = getAttribute(key);
+ return (attribute != null && attribute.getValue() != null) ? attribute.getValue() : defaultValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#clear()
+ */
+ @Override
+ public void clear() {
+ if (isReadOnly()) {
+ return;
+ }
+ attributes.clear();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#size()
+ */
+ @Override
+ public int size() {
+ return attributes.size();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#isEmpty()
+ */
+ @Override
+ public boolean isEmpty() {
+ return attributes.isEmpty();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getAttribute(java.lang.String)
+ */
+ @Override
+ public ILaunchAttribute getAttribute(String key) {
+ Assert.isNotNull(key);
+ return attributes.get(key);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getAllAttributes()
+ */
+ @Override
+ public ILaunchAttribute[] getAllAttributes() {
+ return attributes.values().toArray(new ILaunchAttribute[attributes.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getLaunchActionLabel()
+ */
+ @Override
+ public String getLaunchActionLabel() {
+ return launchActionLabel;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getLaunchConfigName()
+ */
+ @Override
+ public String getLaunchConfigName() {
+ return launchConfigName != null ? launchConfigName : Messages.DefaultLaunchManagerDelegate_defaultLaunchName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#setLaunchActionLabel(java.lang.String)
+ */
+ @Override
+ public void setLaunchActionLabel(String launchActionLabel) {
+ this.launchActionLabel = launchActionLabel;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#setLaunchConfigName(java.lang.String)
+ */
+ @Override
+ public void setLaunchConfigName(String launchConfigName) {
+ this.launchConfigName = LaunchConfigHelper.getUniqueLaunchConfigName(launchConfigName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#isValid()
+ */
+ @Override
+ public boolean isValid() {
+ return valid;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#setIsValid(boolean)
+ */
+ @Override
+ public void setIsValid(boolean valid) {
+ this.valid = valid;
+ if (valid) {
+ errorMessage = null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#getErrorMessage()
+ */
+ @Override
+ public String getErrorMessage() {
+ if (!isValid()) {
+ return errorMessage;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification#setErrorMessage(java.lang.String)
+ */
+ @Override
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+}
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 458b6ed1a..9c482faf5 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
@@ -22,7 +22,6 @@ 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;
@@ -54,11 +53,6 @@ import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransfer
* 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.
@@ -97,6 +91,15 @@ public class DefaultLaunchManagerDelegate extends ExecutableExtension implements
validateLaunchSpecification(launchSpec);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#updateLaunchConfig(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy, org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext, boolean)
+ */
+ @Override
+ public void updateLaunchConfig(ILaunchConfigurationWorkingCopy wc, ISelectionContext selContext, boolean replace) {
+ Assert.isNotNull(wc);
+ Assert.isNotNull(selContext);
+ }
+
@Override
public boolean isDefaultAttribute(String attributeKey, Object specValue, Object confValue, ILaunchSpecification launchSpec, ILaunchConfiguration launchConfig, String launchMode) {
Assert.isNotNull(attributeKey);
@@ -216,9 +219,14 @@ public class DefaultLaunchManagerDelegate extends ExecutableExtension implements
*/
@Override
public String getDefaultLaunchName(ILaunchSpecification launchSpec) {
- if (launchSpec.getLaunchConfigName() != null) {
- return launchSpec.getLaunchConfigName();
- }
+ return Messages.DefaultLaunchManagerDelegate_defaultLaunchName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate#getDefaultLaunchName(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public String getDefaultLaunchName(ILaunchConfiguration launchConfig) {
return Messages.DefaultLaunchManagerDelegate_defaultLaunchName;
}
@@ -577,7 +585,7 @@ public class DefaultLaunchManagerDelegate extends ExecutableExtension implements
* @see #getAttributeRanking(String)
*/
protected int getFullMatchRanking() {
- return 0;
+ return 1;
}
/**
@@ -747,34 +755,6 @@ public class DefaultLaunchManagerDelegate extends ExecutableExtension implements
}
/* (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
@@ -782,14 +762,6 @@ public class DefaultLaunchManagerDelegate extends ExecutableExtension implements
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;
- }
-
@Override
public String getDescription(ILaunchConfiguration config) {
return config.getName();
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 2c8135f00..7a012a753 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
@@ -10,7 +10,6 @@
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;
@@ -72,6 +71,16 @@ public interface ILaunchManagerDelegate extends IExecutableExtension {
public void updateLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec);
/**
+ * Updates a launch configuration with the given selection context.
+ *
+ * @param wc The launch configuration working copy.
+ * @param selContext The selection context to use for the update.
+ * @param replace <code>true</code> if existing attribute values should be replaced,
+ * <code>false</code> if data from the selection context should be added to existing values.
+ */
+ public void updateLaunchConfig(ILaunchConfigurationWorkingCopy wc, ISelectionContext selContext, boolean replace);
+
+ /**
* 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>.
@@ -106,6 +115,14 @@ public interface ILaunchManagerDelegate extends IExecutableExtension {
public String getDefaultLaunchName(ILaunchSpecification launchSpec);
/**
+ * Get the default launch configuration name.
+ *
+ * @param launchConfig The launch configuration to create a default name for the launch config. Must not be <code>null</code>.
+ * @return The default launch configuration name.
+ */
+ public String getDefaultLaunchName(ILaunchConfiguration launchConfig);
+
+ /**
* Get a launch specification with all needed attributes for this delegate taken from the selection to find or create a new
* launch configuration.
*
@@ -142,25 +159,6 @@ public interface ILaunchManagerDelegate extends IExecutableExtension {
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.
*
@@ -172,11 +170,6 @@ public interface ILaunchManagerDelegate extends IExecutableExtension {
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();
-
- /**
* Get a short description for the given launch configuration.
* @param config The launch configuration.
* @return The description.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/projects/ReferencedProjectItem.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/projects/ReferencedProjectItem.java
index 5140628c5..ca39a9b9a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/projects/ReferencedProjectItem.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/projects/ReferencedProjectItem.java
@@ -25,6 +25,11 @@ public class ReferencedProjectItem extends PropertiesContainer implements IRefer
setProperty(PROPERTY_ENABLED, true);
}
+ public ReferencedProjectItem(String projectName) {
+ this();
+ setProperty(PROPERTY_PROJECT_NAME, projectName);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem#isEnabled()
*/
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/META-INF/MANIFEST.MF
index 48b326eb0..f87c3bb71 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/META-INF/MANIFEST.MF
@@ -38,6 +38,7 @@ Export-Package: org.eclipse.tcf.te.launch.ui.activator;x-internal:=true,
org.eclipse.tcf.te.launch.ui.internal.handler,
org.eclipse.tcf.te.launch.ui.internal.properties,
org.eclipse.tcf.te.launch.ui.internal.viewer,
+ org.eclipse.tcf.te.launch.ui.internal.viewer.dnd,
org.eclipse.tcf.te.launch.ui.model,
org.eclipse.tcf.te.launch.ui.nls;x-internal:=true,
org.eclipse.tcf.te.launch.ui.properties,
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml
index b87c62496..3c8af6a53 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml
@@ -47,6 +47,14 @@
isRoot="false"/>
</includes>
</viewerContentBinding>
+ <dragAssistant
+ class="org.eclipse.tcf.te.launch.ui.internal.viewer.dnd.DragAssistant"
+ viewerId="org.eclipse.tcf.te.ui.views.View">
+ </dragAssistant>
+ <dragAssistant
+ class="org.eclipse.tcf.te.launch.ui.internal.viewer.dnd.DragAssistant"
+ viewerId="org.eclipse.ui.navigator.ProjectExplorer">
+ </dragAssistant>
</extension>
<!-- Navigator content contributions -->
@@ -62,9 +70,16 @@
<instanceof value="org.eclipse.tcf.te.ui.views.interfaces.ICategory"/>
</triggerPoints>
<possibleChildren>
- <instanceof value="org.eclipse.tcf.te.launch.ui.model.LaunchNode"/>
+ <instanceof value="java.lang.Object"/>
</possibleChildren>
<commonSorter class="org.eclipse.tcf.te.launch.ui.internal.viewer.LaunchTreeViewerSorter"/>
+ <dropAssistant
+ class="org.eclipse.tcf.te.launch.ui.internal.viewer.dnd.DropAssistant"
+ id="org.eclipse.tcf.te.launch.ui.navigator.dnd">
+ <possibleDropTargets>
+ <instanceof value="java.lang.Object"/>
+ </possibleDropTargets>
+ </dropAssistant>
</navigatorContent>
</extension>
@@ -81,7 +96,7 @@
<instanceof value="org.eclipse.core.resources.IProject"/>
</triggerPoints>
<possibleChildren>
- <instanceof value="org.eclipse.tcf.te.launch.ui.model.LaunchNode"/>
+ <instanceof value="java.lang.Object"/>
</possibleChildren>
<commonSorter
class="org.eclipse.tcf.te.launch.ui.internal.viewer.LaunchTreeViewerSorter">
@@ -94,6 +109,13 @@
<reference definitionId="launch.expressions.isSingleLaunchConfig"/>
</enablement>
</actionProvider>
+ <dropAssistant
+ class="org.eclipse.tcf.te.launch.ui.internal.viewer.dnd.DropAssistant"
+ id="org.eclipse.tcf.te.launch.ui.navigator.dnd">
+ <possibleDropTargets>
+ <instanceof value="java.lang.Object"/>
+ </possibleDropTargets>
+ </dropAssistant>
</navigatorContent>
</extension>
@@ -105,8 +127,29 @@
contentProvider="org.eclipse.tcf.te.launch.ui.internal.viewer.LaunchEditorContentProvider">
<creation>
<style name="SWT.FULL_SELECTION"/>
- <style name="SWT.SINGLE"/>
+ <style name="SWT.MULTI"/>
</creation>
+ <dragSupport
+ class="org.eclipse.tcf.te.launch.ui.internal.viewer.dnd.DragSourceListener">
+ <operations>
+ <operation name="DND.DROP_COPY"/>
+ <operation name="DND.DROP_MOVE"/>
+ <operation name="DND.DROP_LINK"/>
+ </operations>
+ <transferTypes>
+ <transferType name ="LocalSelectionTransfer"/>
+ </transferTypes>
+ </dragSupport>
+ <dropSupport
+ class="org.eclipse.tcf.te.launch.ui.internal.viewer.dnd.DropTargetListener">
+ <operations>
+ <operation name="DND.DROP_COPY"/>
+ <operation name="DND.DROP_MOVE"/>
+ </operations>
+ <transferTypes>
+ <transferType name ="LocalSelectionTransfer"/>
+ </transferTypes>
+ </dropSupport>
</viewer>
<columnContribution viewerId="org.eclipse.tcf.te.launch.ui.viewer.launches">
<column
@@ -146,7 +189,7 @@
id="org.eclipse.tcf.te.launch.ui.views.project.dynamic.new"
class="org.eclipse.tcf.te.launch.ui.internal.handler.NewLaunchConfigurationContributionItem">
<visibleWhen>
- <reference definitionId="launch.expressions.isSingleLaunchConfigOrType"/>
+ <reference definitionId="launch.expressions.isMultiLaunchConfigOrType"/>
</visibleWhen>
</dynamic>
</menu>
@@ -243,7 +286,7 @@
id="org.eclipse.tcf.te.launch.ui.views.target.dynamic.new"
class="org.eclipse.tcf.te.launch.ui.internal.handler.NewLaunchConfigurationContributionItem">
<visibleWhen>
- <reference definitionId="launch.expressions.isSingleLaunchConfigOrType"/>
+ <reference definitionId="launch.expressions.isMultiLaunchConfigOrType"/>
</visibleWhen>
</dynamic>
</menu>
@@ -320,7 +363,7 @@
id="org.eclipse.tcf.te.launch.ui.editor.dynamic.new"
class="org.eclipse.tcf.te.launch.ui.internal.handler.NewLaunchConfigurationContributionItem">
<visibleWhen>
- <reference definitionId="launch.expressions.isSingleLaunchConfigOrType"/>
+ <reference definitionId="launch.expressions.isMultiLaunchConfigOrType"/>
</visibleWhen>
</dynamic>
</menu>
@@ -617,6 +660,7 @@
<and>
<with variable="activePartId">
<or>
+ <equals value="org.eclipse.tcf.te.ui.views.View"/>
<equals value="org.eclipse.tcf.te.ui.views.Editor"/>
<equals value="org.eclipse.ui.navigator.ProjectExplorer"/>
</or>
@@ -638,6 +682,7 @@
</activeWhen>
<enabledWhen>
<with variable="selection">
+ <count value="1"/>
<iterate
operator="and"
ifEmpty="false">
@@ -662,6 +707,7 @@
</activeWhen>
<enabledWhen>
<with variable="selection">
+ <count value="1"/>
<iterate
operator="and"
ifEmpty="false">
@@ -787,6 +833,21 @@
</iterate>
</with>
</definition>
+ <definition id="launch.expressions.isMultiLaunchConfigOrType">
+ <with variable="selection">
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <and>
+ <instanceof value="org.eclipse.tcf.te.launch.ui.model.LaunchNode"/>
+ <or>
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfig"/>
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfigType"/>
+ </or>
+ </and>
+ </iterate>
+ </with>
+ </definition>
<definition id="launch.expressions.isSingleLaunchConfig">
<with variable="selection">
<count value="1"/>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java
index dc73b596d..17a94ef7a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java
@@ -30,12 +30,12 @@ public class LaunchNodePropertyTester extends PropertyTester {
if (receiver instanceof LaunchNode) {
LaunchNode node = (LaunchNode)receiver;
if (property.equals("isLaunchConfigType")) { //$NON-NLS-1$
- if (LaunchNode.TYPE_LAUNCH_CONFIG_TYPE.equals(node.getType())) {
+ if (node.isType(LaunchNode.TYPE_LAUNCH_CONFIG_TYPE)) {
return expectedValue == null || expectedValue.equals(node.getLaunchConfigurationType().getIdentifier());
}
}
else if (property.equals("isLaunchConfig")) { //$NON-NLS-1$
- return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType());
+ return node.isType(LaunchNode.TYPE_LAUNCH_CONFIG);
}
else if (property.equals("canDelete")) { //$NON-NLS-1$
return deleteHandler.canDelete(receiver);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/DeleteHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/DeleteHandler.java
index e04476f64..92efcc82d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/DeleteHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/DeleteHandler.java
@@ -64,7 +64,7 @@ public class DeleteHandler extends AbstractHandler {
public boolean canDelete(Object element) {
if (element instanceof LaunchNode) {
LaunchNode node = (LaunchNode)element;
- return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType()) &&
+ return node.isType(LaunchNode.TYPE_LAUNCH_CONFIG) &&
(node.getModel().getModelRoot() instanceof ICategory || !node.getLaunchConfiguration().isReadOnly());
}
return false;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/RefreshHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/RefreshHandler.java
index 22d0806a2..bb6126b24 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/RefreshHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/RefreshHandler.java
@@ -19,6 +19,8 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.tcf.te.launch.ui.model.LaunchModel;
import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
+import org.eclipse.tcf.te.runtime.events.ChangeEvent;
+import org.eclipse.tcf.te.runtime.events.EventManager;
import org.eclipse.ui.handlers.HandlerUtil;
/**
@@ -68,7 +70,9 @@ public class RefreshHandler extends AbstractHandler {
if (element instanceof LaunchNode) {
LaunchNode node = (LaunchNode)element;
LaunchModel model = node.getModel();
- model.refresh();
+ if (model.refresh()) {
+ EventManager.getInstance().fireEvent(new ChangeEvent(this, ChangeEvent.ID_CHANGED, null, null));
+ }
}
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/FileTransferFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/FileTransferFilter.java
index 09ff00639..86250deb7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/FileTransferFilter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/FileTransferFilter.java
@@ -27,7 +27,7 @@ public class FileTransferFilter implements IFilter {
if (toTest instanceof LaunchNode) {
LaunchNode node = (LaunchNode)toTest;
try {
- return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType()) &&
+ return node.isType(LaunchNode.TYPE_LAUNCH_CONFIG) &&
node.getLaunchConfiguration().getAttribute(IFileTransferLaunchAttributes.ATTR_FILE_TRANSFERS, (String)null) != null;
}
catch (Exception e) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchConfigTypeFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchConfigTypeFilter.java
index 9a1a31f36..5e3f6c362 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchConfigTypeFilter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchConfigTypeFilter.java
@@ -26,7 +26,7 @@ public class LaunchConfigTypeFilter implements IFilter {
if (toTest instanceof LaunchNode) {
LaunchNode node = (LaunchNode)toTest;
try {
- return LaunchNode.TYPE_LAUNCH_CONFIG_TYPE.equals(node.getType());
+ return node.isType(LaunchNode.TYPE_LAUNCH_CONFIG_TYPE);
}
catch (Exception e) {
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchContextFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchContextFilter.java
index 62606e928..05c10fb0d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchContextFilter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchContextFilter.java
@@ -27,7 +27,7 @@ public class LaunchContextFilter implements IFilter {
if (toTest instanceof LaunchNode) {
LaunchNode node = (LaunchNode)toTest;
try {
- return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType()) &&
+ return node.isType(LaunchNode.TYPE_LAUNCH_CONFIG) &&
node.getLaunchConfiguration().getAttribute(ILaunchContextLaunchAttributes.ATTR_LAUNCH_CONTEXTS, (String)null) != null;
}
catch (Exception e) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/RefProjectsFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/RefProjectsFilter.java
index a5db903b7..47f36fc84 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/RefProjectsFilter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/RefProjectsFilter.java
@@ -27,7 +27,7 @@ public class RefProjectsFilter implements IFilter {
if (toTest instanceof LaunchNode) {
LaunchNode node = (LaunchNode)toTest;
try {
- return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType()) &&
+ return node.isType(LaunchNode.TYPE_LAUNCH_CONFIG) &&
node.getLaunchConfiguration().getAttribute(IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS, (String)null) != null;
}
catch (Exception e) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/DescriptionColumnLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/DescriptionColumnLabelProvider.java
index bd8151f10..9fc5bc23a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/DescriptionColumnLabelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/DescriptionColumnLabelProvider.java
@@ -25,7 +25,7 @@ public class DescriptionColumnLabelProvider extends LabelProvider {
*/
@Override
public String getText(Object element) {
- if (element instanceof LaunchNode && (LaunchNode.TYPE_LAUNCH_CONFIG.equals(((LaunchNode)element).getType()))) {
+ if (element instanceof LaunchNode && (((LaunchNode)element).isType(LaunchNode.TYPE_LAUNCH_CONFIG))) {
String[] modes = LaunchConfigHelper.getLaunchConfigTypeModes(((LaunchNode)element).getLaunchConfigurationType(), false);
if (modes != null && modes.length > 0) {
ILaunchManagerDelegate delegate = LaunchManager.getInstance().getLaunchManagerDelegate(((LaunchNode)element).getLaunchConfigurationType(), modes[0]);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LastLaunchedColumnLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LastLaunchedColumnLabelProvider.java
index 780430418..496977e5b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LastLaunchedColumnLabelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LastLaunchedColumnLabelProvider.java
@@ -28,7 +28,7 @@ public class LastLaunchedColumnLabelProvider extends LabelProvider {
*/
@Override
public String getText(Object element) {
- if (element instanceof LaunchNode && (LaunchNode.TYPE_LAUNCH_CONFIG.equals(((LaunchNode)element).getType()))) {
+ if (element instanceof LaunchNode && (((LaunchNode)element).isType(LaunchNode.TYPE_LAUNCH_CONFIG))) {
try {
String lastLaunched = DefaultPersistenceDelegate.getAttribute(((LaunchNode)element).getLaunchConfiguration(), ICommonLaunchAttributes.ATTR_LAST_LAUNCHED, (String)null);
if (lastLaunched != null) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNavigatorContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNavigatorContentProvider.java
index 0663725ae..53697bb24 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNavigatorContentProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNavigatorContentProvider.java
@@ -52,9 +52,9 @@ public class LaunchNavigatorContentProvider extends TreeContentProvider implemen
if (element instanceof LaunchNode) {
LaunchNode node = (LaunchNode)element;
if (node.getParent() == null ||
- LaunchNode.TYPE_ROOT.equals(node.getType()) ||
- (!isTypeNodeVisible() && LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType())) ||
- (!isRootNodeVisible() && LaunchNode.TYPE_LAUNCH_CONFIG_TYPE.equals(node.getType()))) {
+ node.isType(LaunchNode.TYPE_ROOT) ||
+ (!isTypeNodeVisible() && node.isType(LaunchNode.TYPE_LAUNCH_CONFIG)) ||
+ (!isRootNodeVisible() && node.isType(LaunchNode.TYPE_LAUNCH_CONFIG_TYPE))) {
return node.getModel().getModelRoot();
}
@@ -126,7 +126,7 @@ public class LaunchNavigatorContentProvider extends TreeContentProvider implemen
node.getModel();
}
List<IModelNode> children = new ArrayList<IModelNode>();
- if (LaunchNode.TYPE_ROOT.equals(node.getType())) {
+ if (node.isType(LaunchNode.TYPE_ROOT)) {
if (isTypeNodeVisible()) {
// return all type nodes of the model
if (isEmptyTypeNodeVisible()) {
@@ -170,7 +170,7 @@ public class LaunchNavigatorContentProvider extends TreeContentProvider implemen
if (element instanceof LaunchNode) {
LaunchNode node = (LaunchNode)element;
List<IModelNode> children = new ArrayList<IModelNode>();
- if (LaunchNode.TYPE_ROOT.equals(node.getType())) {
+ if (node.isType(LaunchNode.TYPE_ROOT)) {
if (isTypeNodeVisible()) {
// return all type nodes of the model
if (isEmptyTypeNodeVisible()) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchTreeLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchTreeLabelProvider.java
index 962ab9c34..f6e9158bc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchTreeLabelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchTreeLabelProvider.java
@@ -43,13 +43,13 @@ public class LaunchTreeLabelProvider extends LabelProvider implements ILabelDeco
if (element instanceof LaunchNode) {
Image image = null;
LaunchNode node = (LaunchNode)element;
- if (LaunchNode.TYPE_ROOT.equals(node.getType())) {
+ if (node.isType(LaunchNode.TYPE_ROOT)) {
image = UIPlugin.getImage(ImageConsts.OBJ_Launches_Root);
}
- else if (LaunchNode.TYPE_LAUNCH_CONFIG_TYPE.equals(node.getType())) {
+ else if (node.isType(LaunchNode.TYPE_LAUNCH_CONFIG_TYPE)) {
image = DebugUITools.getImage(node.getLaunchConfigurationType().getIdentifier());
}
- else if (LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType())) {
+ else if (node.isType(LaunchNode.TYPE_LAUNCH_CONFIG)) {
try {
image = DebugUITools.getImage(node.getLaunchConfiguration().getType().getIdentifier());
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/CommonDnD.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/CommonDnD.java
new file mode 100644
index 000000000..678557c0f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/CommonDnD.java
@@ -0,0 +1,471 @@
+/*******************************************************************************
+ * 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.ui.internal.viewer.dnd;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.utils.elf.Elf.Attribute;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.ILaunchMode;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.ILaunchGroup;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.tcf.te.core.cdt.elf.ElfUtils;
+import org.eclipse.tcf.te.launch.core.bindings.LaunchConfigTypeBindingsManager;
+import org.eclipse.tcf.te.launch.core.lm.LaunchConfigHelper;
+import org.eclipse.tcf.te.launch.core.lm.LaunchManager;
+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.persistence.launchcontext.LaunchContextsPersistenceDelegate;
+import org.eclipse.tcf.te.launch.core.selection.LaunchSelection;
+import org.eclipse.tcf.te.launch.core.selection.ProjectSelectionContext;
+import org.eclipse.tcf.te.launch.core.selection.RemoteSelectionContext;
+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.launch.ui.activator.UIPlugin;
+import org.eclipse.tcf.te.launch.ui.model.LaunchModel;
+import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
+import org.eclipse.tcf.te.launch.ui.nls.Messages;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.ui.jface.dialogs.OptionalMessageDialog;
+import org.eclipse.tcf.te.ui.views.Managers;
+import org.eclipse.tcf.te.ui.views.ViewsUtil;
+import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
+import org.eclipse.tcf.te.ui.views.interfaces.IRoot;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.ui.dialogs.ListDialog;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+
+/**
+ * Common DND operation implementations.
+ */
+public class CommonDnD {
+
+ /**
+ * If the current selection is draggable.
+ *
+ * @param selection The currently selected nodes.
+ * @return true if it is draggable.
+ */
+ public boolean isDraggable(IStructuredSelection selection) {
+ if (selection == null || selection.isEmpty()) {
+ return false;
+ }
+ Object[] objects = selection.toArray();
+ for (Object object : objects) {
+ if (!isDraggableObject(translateObject(object))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Translate the object.
+ * @param object
+ * @return
+ */
+ private Object translateObject(Object object) {
+ if (object == null || object instanceof LaunchNode || object instanceof IModelNode || object instanceof ICategory) {
+ return object;
+ }
+ IResource resource = (IResource)Platform.getAdapterManager().loadAdapter(object, IResource.class.getName());
+ if (resource != null) {
+ IPath location = resource.getLocation();
+ if (location != null) {
+ try {
+ int elfType = ElfUtils.getELFType(location.toFile());
+ if (elfType == Attribute.ELF_TYPE_EXE || elfType == Attribute.ELF_TYPE_OBJ) {
+ return resource;
+ }
+ }
+ catch (Exception e) {
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * If the specified object is a draggable element.
+ *
+ * @param object The object to be dragged.
+ * @return true if it is draggable.
+ */
+ private boolean isDraggableObject(Object object) {
+ return (object instanceof LaunchNode && ((LaunchNode)object).getLaunchConfiguration() != null) ||
+ (!(object instanceof LaunchNode) && object instanceof IModelNode) ||
+ object instanceof IResource;
+ }
+
+ /**
+ * Validate dropping when the elements being dragged are local selection.
+ *
+ * @param dropAdapter The common drop adapter.
+ * @param target The target object.
+ * @param operation The DnD operation.
+ * @param transferType The transfered data type.
+ *
+ * @return true if it is valid for dropping.
+ */
+ public boolean isValidDnD(CommonDropAdapter dropAdapter, Object target, int operation, TransferData transferType) {
+ boolean valid = false;
+
+ int overrideOperation = -1;
+
+ IStructuredSelection selection = null;
+ if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
+ LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
+ selection = (IStructuredSelection) transfer.getSelection();
+ }
+ if (selection == null) {
+ return false;
+ }
+
+ boolean allow = true;
+ target = translateObject(target);
+ Iterator<?> iterator = selection.iterator();
+ boolean isCopy = (operation & DND.DROP_COPY) != 0;
+ while (iterator.hasNext() && allow) {
+ Object from = translateObject(iterator.next());
+ if (from instanceof LaunchNode) {
+ LaunchNode fromNode = (LaunchNode)from;
+ if (target instanceof LaunchNode) {
+ // LaunchNode toNode = (LaunchNode)target;
+ allow = false;
+ }
+ else if (target instanceof IModelNode) {
+ IModelNode toContext = (IModelNode)target;
+ allow &= internalValidate(fromNode, null, toContext, true, isCopy);
+ }
+ else if (target instanceof IResource) {
+ IResource toResource = (IResource)target;
+ allow &= internalValidate(fromNode, toResource, null, true, isCopy);
+ }
+ else if (target instanceof ICategory) {
+ ICategory toCategory = (ICategory)target;
+ overrideOperation = DND.DROP_LINK;
+ allow &= fromNode.getLaunchConfiguration() != null && IUIConstants.ID_CAT_FAVORITES.equals(toCategory.getId()) &&
+ !Managers.getCategoryManager().belongsTo(toCategory.getId(), LaunchModel.getCategoryId(fromNode.getLaunchConfiguration()));
+ }
+ else if (target instanceof IRoot) {
+ allow &= fromNode.getModel().getModelRoot() instanceof ICategory && fromNode.getLaunchConfiguration() != null &&
+ Managers.getCategoryManager().belongsTo(((ICategory)fromNode.getModel().getModelRoot()).getId(), LaunchModel.getCategoryId(fromNode.getLaunchConfiguration()));
+ }
+ else {
+ allow = false;
+ }
+ }
+ else if (from instanceof IModelNode) {
+ IModelNode fromContext = (IModelNode)from;
+ if (target instanceof LaunchNode) {
+ LaunchNode toNode = (LaunchNode)target;
+ overrideOperation = DND.DROP_MOVE;
+ allow &= internalValidate(toNode, null, fromContext, true, false);
+ }
+ else {
+ allow = false;
+ }
+ }
+ else if (from instanceof IResource) {
+ IResource fromResource = (IResource)from;
+ if (target instanceof LaunchNode) {
+ LaunchNode toNode = (LaunchNode)target;
+ allow &= internalValidate(toNode, fromResource, null, !isCopy, false);
+ }
+ else if (target instanceof IModelNode) {
+ IModelNode toContext = (IModelNode)target;
+ ILaunchSelection launchSel = new LaunchSelection(null, new ISelectionContext[]{
+ new RemoteSelectionContext(toContext, new Object[]{toContext}, true),
+ new ProjectSelectionContext(fromResource.getProject(), new Object[]{fromResource.getLocation()}, true)
+ });
+ String[] typeIds = LaunchConfigTypeBindingsManager.getInstance().getValidLaunchConfigTypes(launchSel);
+ allow &= typeIds != null && typeIds.length > 0;
+ }
+ else {
+ allow = false;
+ }
+ }
+ else {
+ allow = false;
+ }
+ }
+ valid = allow;
+
+ if (dropAdapter != null) {
+ if (!valid) {
+ dropAdapter.overrideOperation(DND.DROP_NONE);
+ }
+ else if (overrideOperation > -1) {
+ dropAdapter.overrideOperation(overrideOperation);
+ }
+ }
+
+ return valid;
+ }
+
+ private boolean internalValidate(LaunchNode node, IResource resource, IModelNode context, boolean replaceData, boolean duplicateConfig) {
+ if (node.getLaunchConfiguration() == null) {
+ return false;
+ }
+ if (resource != null) {
+ if (!LaunchConfigTypeBindingsManager.getInstance().isValidLaunchConfigType(
+ node.getLaunchConfigurationType().getIdentifier(),
+ new LaunchSelection(null, new ProjectSelectionContext(resource.getProject(), new Object[]{resource.getLocation()}, true)))) {
+ return false;
+ }
+ }
+ if (context != null) {
+ if (!LaunchConfigTypeBindingsManager.getInstance().isValidLaunchConfigType(
+ node.getLaunchConfigurationType().getIdentifier(),
+ new LaunchSelection(null, new RemoteSelectionContext(context, true)))) {
+ return false;
+ }
+ IModelNode[] oldContexts = LaunchContextsPersistenceDelegate.getLaunchContexts(node.getLaunchConfiguration());
+ if (oldContexts != null && Arrays.asList(oldContexts).contains(context) && !duplicateConfig) {
+ return false;
+ }
+ }
+
+ return true;
+
+ }
+ /**
+ * Perform the drop operation over dragged selection.
+ *
+ * @param dropAdapter The common drop adapter.
+ * @param target The target Object to be moved to.
+ * @param operation The current DnD operation.
+ * @param selection The local selection being dropped.
+ * @return true if the dropping is successful.
+ */
+ public boolean doDnD(CommonDropAdapter dropAdapter, Object target, int operation, IStructuredSelection selection) {
+ boolean success = true;
+ target = translateObject(target);
+ Iterator<?> iterator = selection.iterator();
+ boolean isCopy = (operation & DND.DROP_COPY) != 0;
+ while (iterator.hasNext()) {
+ Object from = translateObject(iterator.next());
+ if (from instanceof LaunchNode) {
+ LaunchNode fromNode = (LaunchNode)from;
+ if (target instanceof LaunchNode) {
+ // LaunchNode toNode = (LaunchNode)target;
+ success = false;
+ }
+ else if (target instanceof IModelNode) {
+ IModelNode toContext = (IModelNode)target;
+ success &= internalDrop(fromNode, null, toContext, true, isCopy);
+ }
+ else if (target instanceof IResource) {
+ IResource toResource = (IResource)target;
+ success &= internalDrop(fromNode, toResource, null, true, isCopy);
+ }
+ else if (target instanceof ICategory) {
+ ICategory toCategory = (ICategory)target;
+ success &= Managers.getCategoryManager().add(toCategory.getId(), LaunchModel.getCategoryId(fromNode.getLaunchConfiguration()));
+ }
+ else if (target instanceof IRoot) {
+ success &= Managers.getCategoryManager().remove(((ICategory)fromNode.getModel().getModelRoot()).getId(),
+ LaunchModel.getCategoryId(fromNode.getLaunchConfiguration()));
+ }
+ else {
+ success = false;
+ }
+ }
+ else if (from instanceof IModelNode) {
+ IModelNode fromContext = (IModelNode)from;
+ if (target instanceof LaunchNode) {
+ LaunchNode toNode = (LaunchNode)target;
+ success &= internalDrop(toNode, null, fromContext, true, false);
+ }
+ else {
+ success = false;
+ }
+ }
+ else if (from instanceof IResource) {
+ IResource fromResource = (IResource)from;
+ if (target instanceof LaunchNode) {
+ LaunchNode toNode = (LaunchNode)target;
+ success &= internalDrop(toNode, fromResource, null, !isCopy, false);
+ }
+ else if (target instanceof IModelNode) {
+ IModelNode toContext = (IModelNode)target;
+ ILaunchSelection launchSel = new LaunchSelection(null, new ISelectionContext[]{
+ new RemoteSelectionContext(toContext, new Object[]{toContext}, true),
+ new ProjectSelectionContext(fromResource.getProject(), new Object[]{fromResource.getLocation()}, true)
+ });
+ String[] typeIds = LaunchConfigTypeBindingsManager.getInstance().getValidLaunchConfigTypes(launchSel);
+ if (typeIds != null && typeIds.length > 0) {
+ String typeId = null;
+ if (typeIds.length == 1) {
+ typeId = typeIds[0];
+ }
+ else {
+ typeId = askForLaunchType(typeIds);
+ }
+ if (typeId != null) {
+ ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(typeId);
+ String[] modes = LaunchConfigHelper.getLaunchConfigTypeModes(type, false);
+ if (modes != null && modes.length > 0) {
+ String mode = null;
+ if (modes.length == 1) {
+ mode = modes[0];
+ }
+ else {
+ mode = askForLaunchMode(type, modes);
+ }
+ if (mode != null) {
+ success &= openLaunchConfigDialog(type, mode, new LaunchSelection(mode, launchSel.getSelectedContexts()));
+ }
+ }
+ }
+ }
+ }
+ else {
+ success = false;
+ }
+ }
+ else {
+ success = false;
+ }
+ }
+ // Fire a refresh of the view
+ ViewsUtil.refresh(IUIConstants.ID_EXPLORER);
+ return success;
+ }
+
+ private String askForLaunchType(String[] typeIds) {
+ List<ILaunchConfigurationType> types = new ArrayList<ILaunchConfigurationType>();
+ for (String typeId : typeIds) {
+ types.add(DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(typeId));
+ }
+ ListDialog dialog = new ListDialog(UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell());
+ dialog.setTitle(Messages.CommonDnD_launchType_dialog_title);
+ dialog.setMessage(Messages.CommonDnD_launchType_dialog_message);
+ dialog.setInput(types.toArray());
+ dialog.setContentProvider(new ArrayContentProvider());
+ dialog.setLabelProvider(new LabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return ((ILaunchConfigurationType)element).getName();
+ }
+ });
+ dialog.setInitialSelections(new Object[]{types.get(0)});
+ if (dialog.open() == Window.OK) {
+ return ((ILaunchConfigurationType)dialog.getResult()[0]).getIdentifier();
+ }
+ return null;
+ }
+
+ private String askForLaunchMode(ILaunchConfigurationType type, String[] modes) {
+ List<String> modeLabels = new ArrayList<String>();
+ int defaultIndex = 0;
+ for (String mode : modes) {
+ ILaunchMode launchMode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(mode);
+ modeLabels.add(launchMode.getLabel());
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+ defaultIndex = modeLabels.size()-1;
+ }
+ }
+ if (modeLabels.size() > 0) {
+ modeLabels.add(IDialogConstants.CANCEL_LABEL);
+ OptionalMessageDialog dialog = new OptionalMessageDialog(
+ UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
+ Messages.CommonDnD_launchMode_dialog_title,
+ null,
+ NLS.bind(Messages.CommonDnD_launchMode_dialog_message, type.getName()),
+ MessageDialog.QUESTION,
+ modeLabels.toArray(new String[modeLabels.size()]),
+ defaultIndex,
+ null, null);
+ int result = dialog.open();
+ if (result >= IDialogConstants.INTERNAL_ID) {
+ return modes[result - IDialogConstants.INTERNAL_ID];
+ }
+ }
+ return null;
+ }
+
+ private boolean openLaunchConfigDialog(ILaunchConfigurationType type, String mode, ILaunchSelection launchSel) {
+ try {
+ ILaunchManagerDelegate delegate = LaunchManager.getInstance().getLaunchManagerDelegate(type, mode);
+ if (delegate != null) {
+ // create an empty launch configuration specification to initialize all attributes with their default defaults.
+ ILaunchSpecification launchSpec = delegate.getLaunchSpecification(type.getIdentifier(), launchSel);
+ // initialize the new launch config.
+ // ignore validation result of launch spec - init as much attributes as possible
+ if (launchSpec != null) {
+ ILaunchConfiguration[] launchConfigs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(type);
+ launchConfigs = delegate.getMatchingLaunchConfigurations(launchSpec, launchConfigs);
+
+ ILaunchConfiguration config = launchConfigs != null && launchConfigs.length > 0 ? launchConfigs[0] : null;
+ config = LaunchManager.getInstance().createOrUpdateLaunchConfiguration(config, launchSpec);
+
+ ILaunchGroup launchGroup = DebugUITools.getLaunchGroup(config, mode);
+ DebugUITools.openLaunchConfigurationDialogOnGroup(UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
+ new StructuredSelection(config), launchGroup.getIdentifier());
+ return true;
+ }
+ }
+ }
+ catch (Exception e) {
+ return false;
+ }
+ return false;
+ }
+
+ private boolean internalDrop(LaunchNode node, IResource resource, IModelNode context, boolean replaceData, boolean duplicateConfig) {
+ try {
+ ILaunchManagerDelegate delegate = LaunchManager.getInstance().getLaunchManagerDelegate(node.getLaunchConfigurationType(), ""); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = node.getLaunchConfiguration().getWorkingCopy();
+ if (resource != null) {
+ delegate.updateLaunchConfig(wc, new ProjectSelectionContext(resource.getProject(), new Object[]{resource.getLocation()}, true), replaceData);
+ }
+ if (context != null) {
+ delegate.updateLaunchConfig(wc, new RemoteSelectionContext(context, new Object[]{context}, true), replaceData);
+ }
+ if (duplicateConfig) {
+ wc = wc.copy(LaunchConfigHelper.getUniqueLaunchConfigName(delegate.getDefaultLaunchName(wc)));
+ }
+ else {
+ String newName = LaunchConfigHelper.getUniqueLaunchConfigName(delegate.getDefaultLaunchName(wc)).replaceAll("\\([0-9]+\\)$", "").trim(); //$NON-NLS-1$ //$NON-NLS-2$
+ String oldName = wc.getName().replaceAll("\\([0-9]+\\)$", "").trim(); //$NON-NLS-1$ //$NON-NLS-2$;
+ if (!newName.equals(oldName)) {
+ wc.rename(LaunchConfigHelper.getUniqueLaunchConfigName(newName));
+ }
+ }
+ wc.doSave();
+ return true;
+ }
+ catch (Exception e) {
+ return false;
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DragAssistant.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DragAssistant.java
new file mode 100644
index 000000000..41aebdd1b
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DragAssistant.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.ui.internal.viewer.dnd;
+
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.ui.navigator.CommonDragAdapterAssistant;
+
+/**
+ * Drag assistant implementation.
+ */
+public class DragAssistant extends CommonDragAdapterAssistant {
+
+ private CommonDnD commonDnD = new CommonDnD();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#dragStart(org.eclipse.swt.dnd.DragSourceEvent, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ public void dragStart(DragSourceEvent event, IStructuredSelection selection) {
+ event.doit = commonDnD.isDraggable(selection);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#getSupportedTransferTypes()
+ */
+ @Override
+ public Transfer[] getSupportedTransferTypes() {
+ return new Transfer[] {LocalSelectionTransfer.getTransfer()};
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#setDragData(org.eclipse.swt.dnd.DragSourceEvent, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ public boolean setDragData(DragSourceEvent event, IStructuredSelection aSelection) {
+ if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
+ event.data = LocalSelectionTransfer.getTransfer().getSelection();
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DragSourceListener.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DragSourceListener.java
new file mode 100644
index 000000000..342729dfb
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DragSourceListener.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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.ui.internal.viewer.dnd;
+
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.dnd.DragSourceAdapter;
+import org.eclipse.swt.dnd.DragSourceEvent;
+
+/**
+ * The drag source listener for the launches of Target Explorer.
+ */
+public class DragSourceListener extends DragSourceAdapter {
+ // The tree viewer in which the DnD gesture happens.
+ private TreeViewer viewer;
+
+ private CommonDnD commonDnD = new CommonDnD();
+
+ /**
+ * Create an DragSourceListener using the specified tree viewer.
+ *
+ * @param viewer The file system tree viewer.
+ */
+ public DragSourceListener(TreeViewer viewer) {
+ super();
+ this.viewer = viewer;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.dnd.DragSourceListener#dragStart(org.eclipse.swt.dnd.DragSourceEvent)
+ */
+ @Override
+ public void dragStart(DragSourceEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+ event.doit = commonDnD.isDraggable(selection);
+ LocalSelectionTransfer.getTransfer().setSelection(selection);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData(org.eclipse.swt.dnd.DragSourceEvent)
+ */
+ @Override
+ public void dragSetData(DragSourceEvent event) {
+ if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
+ event.data = LocalSelectionTransfer.getTransfer().getSelection();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.dnd.DragSourceListener#dragFinished(org.eclipse.swt.dnd.DragSourceEvent)
+ */
+ @Override
+ public void dragFinished(DragSourceEvent event) {
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DropAssistant.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DropAssistant.java
new file mode 100644
index 000000000..75f4c7414
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DropAssistant.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.ui.internal.viewer.dnd;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
+
+/**
+ * Drop assistant implementation.
+ */
+public class DropAssistant extends CommonDropAdapterAssistant {
+
+ private CommonDnD commonDnD = new CommonDnD();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData)
+ */
+ @Override
+ public IStatus validateDrop(Object target, int operation, TransferData transferType) {
+ boolean valid = commonDnD.isValidDnD(getCommonDropAdapter(), target, operation, transferType);
+
+ return valid ? Status.OK_STATUS : Status.CANCEL_STATUS;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handleDrop(org.eclipse.ui.navigator.CommonDropAdapter, org.eclipse.swt.dnd.DropTargetEvent, java.lang.Object)
+ */
+ @Override
+ public IStatus handleDrop(CommonDropAdapter adapter, DropTargetEvent event, Object target) {
+ boolean sucess = commonDnD.doDnD(adapter, target, adapter.getCurrentOperation(), (IStructuredSelection) event.data);
+
+ return sucess ? Status.OK_STATUS : Status.CANCEL_STATUS;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DropTargetListener.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DropTargetListener.java
new file mode 100644
index 000000000..8516ebb4d
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/dnd/DropTargetListener.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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.ui.internal.viewer.dnd;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.ViewerDropAdapter;
+import org.eclipse.swt.dnd.TransferData;
+
+/**
+ * The drop target listener for the launches of Target Explorer.
+ */
+public class DropTargetListener extends ViewerDropAdapter {
+
+ private CommonDnD commonDnD = new CommonDnD();
+
+ /**
+ * Create DropTargetListener using the viewer.
+ *
+ * @param viewer The file system tree viewer.
+ */
+ public DropTargetListener(TreeViewer viewer) {
+ super(viewer);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerDropAdapter#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData)
+ */
+ @Override
+ public boolean validateDrop(Object target, int operation, TransferData transferType) {
+ return commonDnD.isValidDnD(null, target != null ? target : getViewer().getInput(), operation, transferType);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerDropAdapter#performDrop(java.lang.Object)
+ */
+ @Override
+ public boolean performDrop(Object data) {
+ return commonDnD.doDnD(null, getCurrentTarget() != null ? getCurrentTarget() : getViewer().getInput(), getCurrentOperation(), (IStructuredSelection)data);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchModel.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchModel.java
index 2549147e2..d5ec186cc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchModel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchModel.java
@@ -71,10 +71,13 @@ public final class LaunchModel implements IEventListener, ILaunchConfigurationLi
private final LaunchNode rootNode;
private final Object modelRoot;
+ private String lastAddedUUID = null;
+
/**
* Constructor.
*/
private LaunchModel(Object modelRoot) {
+ Assert.isNotNull(modelRoot);
this.modelRoot = modelRoot;
rootNode = new LaunchNode(this);
refresh();
@@ -92,8 +95,11 @@ public final class LaunchModel implements IEventListener, ILaunchConfigurationLi
public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
if (!configuration.isWorkingCopy()) {
if (getModelRoot() instanceof ICategory) {
- Managers.getCategoryManager().remove(((ICategory)getModelRoot()).getId(), getCategoryId(configuration));
+ if (!getCategoryId(configuration).equals(lastAddedUUID)) {
+ Managers.getCategoryManager().remove(((ICategory)getModelRoot()).getId(), getCategoryId(configuration));
+ }
nameToUUID.remove(configuration.getName());
+ lastAddedUUID = null;
}
if (refresh()) {
EventManager.getInstance().fireEvent(new ChangeEvent(this, ChangeEvent.ID_REMOVED, null, null));
@@ -118,6 +124,11 @@ public final class LaunchModel implements IEventListener, ILaunchConfigurationLi
@Override
public void launchConfigurationAdded(ILaunchConfiguration configuration) {
if (!configuration.isWorkingCopy()) {
+ if (getModelRoot() instanceof ICategory) {
+ if (Managers.getCategoryManager().belongsTo(((ICategory)getModelRoot()).getId(), getCategoryId(configuration))) {
+ lastAddedUUID = getCategoryId(configuration);
+ }
+ }
if (refresh()) {
EventManager.getInstance().fireEvent(new ChangeEvent(this, ChangeEvent.ID_ADDED, null, null));
}
@@ -208,7 +219,7 @@ public final class LaunchModel implements IEventListener, ILaunchConfigurationLi
}
else if (parent instanceof IModelNode) {
IModelNode[] contexts = LaunchContextsPersistenceDelegate.getLaunchContexts(config);
- if (contexts == null || contexts.length == 0 || Arrays.asList(contexts).contains(parent)) {
+ if (contexts != null && Arrays.asList(contexts).contains(parent)) {
changed |= checkAndAdd(config, (IContainerModelNode)typeNode, configNodes);
}
}
@@ -250,12 +261,25 @@ public final class LaunchModel implements IEventListener, ILaunchConfigurationLi
return false;
}
- private IModelNode find(Object data, List<IModelNode> list) {
+ private IModelNode find(ILaunchConfiguration config, List<IModelNode> list) {
+ for (IModelNode candidate : list) {
+ if (candidate instanceof LaunchNode) {
+ LaunchNode node = new LaunchNode(config);
+ node.setProperty(LaunchNode.PROPERTY_MODEL, this);
+ if (((LaunchNode)candidate).equals(node)) {
+ return candidate;
+ }
+ }
+ }
+ return null;
+ }
+
+ private IModelNode find(ILaunchConfigurationType type, List<IModelNode> list) {
for (IModelNode candidate : list) {
if (candidate instanceof LaunchNode) {
- if ((data instanceof LaunchNode && ((LaunchNode)candidate).equals(data)) ||
- (data instanceof ILaunchConfiguration && ((LaunchNode)candidate).equals(new LaunchNode((ILaunchConfiguration)data))) ||
- (data instanceof ILaunchConfigurationType && ((LaunchNode)candidate).equals(new LaunchNode((ILaunchConfigurationType)data)))) {
+ LaunchNode node = new LaunchNode(type);
+ node.setProperty(LaunchNode.PROPERTY_MODEL, this);
+ if (((LaunchNode)candidate).equals(node)) {
return candidate;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchNode.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchNode.java
index 5e5bb5e94..ca7025501 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchNode.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchNode.java
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.tcf.te.launch.core.lm.LaunchConfigHelper;
@@ -31,7 +32,9 @@ public class LaunchNode extends ContainerModelNode {
public static final String TYPE_LAUNCH_CONFIG_TYPE = "launchConfigType"; //$NON-NLS-1$
public static final String TYPE_LAUNCH_CONFIG = "launchConfig"; //$NON-NLS-1$
- private static final String PROPERTY_MODEL = "model"; //$NON-NLS-1$
+ protected static final String PROPERTY_LAUNCH_CONFIG_TYPE = TYPE_LAUNCH_CONFIG_TYPE;
+ protected static final String PROPERTY_LAUNCH_CONFIG = TYPE_LAUNCH_CONFIG;
+ protected static final String PROPERTY_MODEL = "model"; //$NON-NLS-1$
private LaunchNode(String type) {
super();
@@ -45,18 +48,21 @@ public class LaunchNode extends ContainerModelNode {
public LaunchNode(ILaunchConfiguration config) {
this(TYPE_LAUNCH_CONFIG);
- setProperty(TYPE_LAUNCH_CONFIG, config);
+ setProperty(PROPERTY_LAUNCH_CONFIG, config);
}
public LaunchNode(ILaunchConfigurationType configType) {
this(TYPE_LAUNCH_CONFIG_TYPE);
- setProperty(TYPE_LAUNCH_CONFIG_TYPE, configType);
+ setProperty(PROPERTY_LAUNCH_CONFIG_TYPE, configType);
}
- public String getType() {
- return getStringProperty(IModelNode.PROPERTY_TYPE);
+ public boolean isType(String type) {
+ return type.equals(getStringProperty(IModelNode.PROPERTY_TYPE));
}
+ /**
+ * Return the model for this node. Must not be <code>null</code>.
+ */
public LaunchModel getModel() {
LaunchModel model = (LaunchModel)getProperty(PROPERTY_MODEL);
IModelNode parent = getParent();
@@ -66,16 +72,20 @@ public class LaunchNode extends ContainerModelNode {
parent = parent.getParent();
}
+ Assert.isNotNull(model);
return model;
}
+ /**
+ * Return the launch confuration for this node or <code>null</code>.
+ */
public ILaunchConfiguration getLaunchConfiguration() {
- if (TYPE_LAUNCH_CONFIG.equals(getType())) {
- return (ILaunchConfiguration)getProperty(TYPE_LAUNCH_CONFIG);
- }
- return null;
+ return (ILaunchConfiguration)getProperty(PROPERTY_LAUNCH_CONFIG);
}
+ /**
+ * Return the launch configuration type for this launch node or <code>null</code>.
+ */
public ILaunchConfigurationType getLaunchConfigurationType() {
if (getLaunchConfiguration() != null) {
try {
@@ -84,13 +94,10 @@ public class LaunchNode extends ContainerModelNode {
catch (Exception e) {
}
}
- else if (TYPE_LAUNCH_CONFIG.equals(getType())) {
+ else if (isType(TYPE_LAUNCH_CONFIG)) {
return ((LaunchNode)getParent()).getLaunchConfigurationType();
}
- else if (TYPE_LAUNCH_CONFIG_TYPE.equals(getType())) {
- return (ILaunchConfigurationType)getProperty(TYPE_LAUNCH_CONFIG_TYPE);
- }
- return null;
+ return (ILaunchConfigurationType)getProperty(PROPERTY_LAUNCH_CONFIG_TYPE);
}
/* (non-Javadoc)
@@ -98,13 +105,13 @@ public class LaunchNode extends ContainerModelNode {
*/
@Override
public String getName() {
- if (TYPE_ROOT.equals(getType())) {
+ if (isType(TYPE_ROOT)) {
return "Launches"; //$NON-NLS-1$
}
- else if (TYPE_LAUNCH_CONFIG_TYPE.equals(getType())) {
+ else if (isType(TYPE_LAUNCH_CONFIG_TYPE)) {
return getLaunchConfigurationType().getName();
}
- else if (TYPE_LAUNCH_CONFIG.equals(getType())) {
+ else if (isType(TYPE_LAUNCH_CONFIG)) {
return getLaunchConfiguration().getName();
}
return super.getName();
@@ -115,19 +122,26 @@ public class LaunchNode extends ContainerModelNode {
*/
@Override
public boolean equals(Object obj) {
- if (obj instanceof LaunchNode && getType() != null && getType().equals(((LaunchNode)obj).getType())) {
- if (TYPE_LAUNCH_CONFIG_TYPE.equals(getType())) {
- return getLaunchConfigurationType().equals(((LaunchNode)obj).getLaunchConfigurationType());
- }
- else if (TYPE_LAUNCH_CONFIG.equals(getType())) {
- return getLaunchConfiguration().equals(((LaunchNode)obj).getLaunchConfiguration());
+ if (obj instanceof LaunchNode && isType(((LaunchNode)obj).getStringProperty(PROPERTY_TYPE))) {
+ if (getModel().getModelRoot().equals(((LaunchNode)obj).getModel().getModelRoot())) {
+ if (isType(TYPE_LAUNCH_CONFIG_TYPE)) {
+ return getLaunchConfigurationType().equals(((LaunchNode)obj).getLaunchConfigurationType());
+ }
+ else if (isType(TYPE_LAUNCH_CONFIG)) {
+ return getLaunchConfiguration().equals(((LaunchNode)obj).getLaunchConfiguration());
+ }
}
}
return super.equals(obj);
}
+ /**
+ * Check if the launch config node is valid for the given launch mode.
+ * @param mode The launch mode or <code>null</code> to check for all supported modes;
+ * @return <code>true</code> if the node is valid for the the given launch mode (or all supported modes if mode is <code>null</code>).
+ */
public boolean isValidFor(String mode) {
- if (TYPE_LAUNCH_CONFIG.equals(getType())) {
+ if (isType(TYPE_LAUNCH_CONFIG)) {
if (getLaunchConfigurationType() == null) {
return false;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.java
index 7590875c5..1b72558de 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.java
@@ -121,4 +121,9 @@ public class Messages extends NLS {
public static String LaunchDialogHandler_dialog_title;
public static String LaunchDialogHandler_dialog_message;
+
+ public static String CommonDnD_launchMode_dialog_title;
+ public static String CommonDnD_launchMode_dialog_message;
+ public static String CommonDnD_launchType_dialog_title;
+ public static String CommonDnD_launchType_dialog_message;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.properties
index ad79aa25e..f88d3cce5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.properties
@@ -64,3 +64,9 @@ DeleteHandlerDelegate_question_message = Are you sure you want to delete ''{0}''
LaunchDialogHandler_dialog_title = Choose launch mode
LaunchDialogHandler_dialog_message = Please choose a launch mode for {0} launch ''{1}''.
+
+CommonDnD_launchMode_dialog_title = Choose launch mode
+CommonDnD_launchMode_dialog_message = Please choose a launch mode for {0} launch.
+
+CommonDnD_launchType_dialog_title = Choose launch configuration type
+CommonDnD_launchType_dialog_message = Please choose a launch configuration type.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java
index 6b34849b2..268cf1426 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java
@@ -28,6 +28,12 @@ public class FileTransferItem extends PropertiesContainer implements IFileTransf
setProperty(PROPERTY_DIRECTION, HOST_TO_TARGET);
}
+ public FileTransferItem(IPath fromHost, IPath toTarget) {
+ this();
+ setProperty(PROPERTY_HOST, fromHost.toPortableString());
+ setProperty(PROPERTY_TARGET, toTarget.toPortableString());
+ }
+
/* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IFileTransferItem#isEnabled()
*/
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/StepContextAdapter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/StepContextAdapter.java
index b089e53ba..b077a9f2b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/StepContextAdapter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/StepContextAdapter.java
@@ -52,7 +52,7 @@ public class StepContextAdapter extends PlatformObject implements IStepContext {
*/
@Override
public String getId() {
- return launch != null ? launch.getLaunchConfiguration().getName() : null;
+ return launch != null && launch.getLaunchConfiguration() != null ? launch.getLaunchConfiguration().getName() : null;
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/RemoteAppLaunchManagerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/RemoteAppLaunchManagerDelegate.java
index 8e5ff5f41..b4c0c66e6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/RemoteAppLaunchManagerDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/RemoteAppLaunchManagerDelegate.java
@@ -25,7 +25,6 @@ import org.eclipse.tcf.te.launch.core.lm.interfaces.IFileTransferLaunchAttribute
import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchContextLaunchAttributes;
import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
import org.eclipse.tcf.te.launch.core.lm.interfaces.IReferencedProjectLaunchAttributes;
-import org.eclipse.tcf.te.launch.core.nls.Messages;
import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate;
import org.eclipse.tcf.te.launch.core.persistence.filetransfer.FileTransfersPersistenceDelegate;
import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate;
@@ -45,7 +44,6 @@ import org.eclipse.tcf.te.tcf.launch.core.interfaces.IRemoteAppLaunchAttributes;
/**
* RemoteAppLaunchManagerDelegate
*/
-@SuppressWarnings("restriction")
public class RemoteAppLaunchManagerDelegate extends DefaultLaunchManagerDelegate {
private static final String[] MANDATORY_CONFIG_ATTRIBUTES = new String[] {
@@ -75,10 +73,47 @@ public class RemoteAppLaunchManagerDelegate extends DefaultLaunchManagerDelegate
}
if (launchSpec.hasAttribute(IFileTransferLaunchAttributes.ATTR_FILE_TRANSFERS)) {
wc.setAttribute(IFileTransferLaunchAttributes.ATTR_FILE_TRANSFERS, (String)launchSpec.getAttribute(IFileTransferLaunchAttributes.ATTR_FILE_TRANSFERS).getValue());
- if (launchSpec.hasAttribute(IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS)) {
- wc.setAttribute(IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS, (String)launchSpec.getAttribute(IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS).getValue());
+ }
+ if (launchSpec.hasAttribute(IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS)) {
+ wc.setAttribute(IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS, (String)launchSpec.getAttribute(IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS).getValue());
+ }
+ }
+
+ @Override
+ public void updateLaunchConfig(ILaunchConfigurationWorkingCopy wc, ISelectionContext selContext, boolean replace) {
+ super.updateLaunchConfig(wc, selContext, replace);
+
+ if (selContext instanceof IProjectSelectionContext) {
+ List<IFileTransferItem> transfers;
+ List<IReferencedProjectItem> projects;
+ String processPath;
+ if (replace) {
+ transfers = new ArrayList<IFileTransferItem>();
+ projects = new ArrayList<IReferencedProjectItem>();
+ processPath = getProcessImageAndSetProjectAndTransfer((IProjectSelectionContext)selContext, transfers, projects);
+
+ FileTransfersPersistenceDelegate.setFileTransfers(wc, transfers.toArray(new IFileTransferItem[transfers.size()]));
+ ReferencedProjectsPersistenceDelegate.setReferencedProjects(wc, projects.toArray(new IReferencedProjectItem[projects.size()]));
+ if (processPath != null && processPath.trim().length() > 0) {
+ DefaultPersistenceDelegate.setAttribute(wc, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, processPath);
+ }
+ }
+ else {
+ transfers = new ArrayList<IFileTransferItem>(Arrays.asList(FileTransfersPersistenceDelegate.getFileTransfers(wc)));
+ projects = new ArrayList<IReferencedProjectItem>(Arrays.asList(ReferencedProjectsPersistenceDelegate.getReferencedProjects(wc)));
+ processPath = getProcessImageAndSetProjectAndTransfer((IProjectSelectionContext)selContext, transfers, projects);
+
+ FileTransfersPersistenceDelegate.setFileTransfers(wc, transfers.toArray(new IFileTransferItem[transfers.size()]));
+ ReferencedProjectsPersistenceDelegate.setReferencedProjects(wc, projects.toArray(new IReferencedProjectItem[projects.size()]));
+ if (processPath != null && processPath.trim().length() > 0 && !DefaultPersistenceDelegate.hasAttribute(wc, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE)) {
+ DefaultPersistenceDelegate.setAttribute(wc, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, processPath);
+ }
}
}
+ else if (selContext instanceof IRemoteSelectionContext) {
+ IRemoteSelectionContext remoteCtx = (IRemoteSelectionContext)selContext;
+ LaunchContextsPersistenceDelegate.setLaunchContexts(wc, new IModelNode[]{remoteCtx.getRemoteCtx()});
+ }
}
/* (non-Javadoc)
@@ -96,68 +131,90 @@ public class RemoteAppLaunchManagerDelegate extends DefaultLaunchManagerDelegate
LaunchContextsPersistenceDelegate.setLaunchContexts(launchSpec, launchContexts.toArray(new IModelNode[launchContexts.size()]));
}
- IPropertiesAccessService service = ServiceManager.getInstance().getService(remoteCtx, IPropertiesAccessService.class);
-
- Object dnsName = service != null ? service.getProperty(remoteCtx, "dns.name.transient") : null; //$NON-NLS-1$
- String ctxName = service != null ? (String)service.getTargetAddress(remoteCtx).get(IPropertiesAccessServiceConstants.PROP_ADDRESS) : null;
- ctxName = dnsName != null && dnsName.toString().trim().length() > 0 ? dnsName.toString().trim() : ctxName;
-
- if (ctxName != null) {
- if (launchSpec.getLaunchConfigName() == null ||
- Messages.DefaultLaunchManagerDelegate_defaultLaunchName.equals(launchSpec.getLaunchConfigName())) {
- launchSpec.setLaunchConfigName(ctxName);
- }
- else {
- launchSpec.setLaunchConfigName(launchSpec.getLaunchConfigName() + " (" + ctxName + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
+ launchSpec.setLaunchConfigName(getDefaultLaunchName(launchSpec));
}
else if (selectionContext instanceof IProjectSelectionContext) {
List<IFileTransferItem> transfers = new ArrayList<IFileTransferItem>(Arrays.asList(FileTransfersPersistenceDelegate.getFileTransfers(launchSpec)));
List<IReferencedProjectItem> projects = new ArrayList<IReferencedProjectItem>(Arrays.asList(ReferencedProjectsPersistenceDelegate.getReferencedProjects(launchSpec)));
- String processName = null;
- String processPath = null;
-
- boolean added = false;
- for (Object selection : selectionContext.getSelections()) {
- if (selection instanceof IPath) {
- IPath path = (IPath)selection;
- IFileTransferItem transfer = new FileTransferItem();
- transfer.setProperty(IFileTransferItem.PROPERTY_ENABLED, true);
- transfer.setProperty(IFileTransferItem.PROPERTY_HOST, path.toPortableString());
- transfer.setProperty(IFileTransferItem.PROPERTY_DIRECTION, IFileTransferItem.HOST_TO_TARGET);
- transfer.setProperty(IFileTransferItem.PROPERTY_TARGET, new Path("/tmp/").toPortableString()); //$NON-NLS-1$
- transfers.add(transfer);
- if (!added) {
- processName = path.lastSegment();
- processPath = "/tmp/" + processName; //$NON-NLS-1$
- }
- added = true;
- }
- }
-
- IReferencedProjectItem project = new ReferencedProjectItem();
- project.setProperty(IReferencedProjectItem.PROPERTY_ENABLED, true);
- project.setProperty(IReferencedProjectItem.PROPERTY_PROJECT_NAME, ((IProjectSelectionContext)selectionContext).getProjectCtx().getName());
- projects.add(project);
+ String processPath = getProcessImageAndSetProjectAndTransfer((IProjectSelectionContext)selectionContext, transfers, projects);
FileTransfersPersistenceDelegate.setFileTransfers(launchSpec, transfers.toArray(new IFileTransferItem[transfers.size()]));
ReferencedProjectsPersistenceDelegate.setReferencedProjects(launchSpec, projects.toArray(new IReferencedProjectItem[projects.size()]));
launchSpec.addAttribute(IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, processPath);
- if (launchSpec.getLaunchConfigName() == null ||
- Messages.DefaultLaunchManagerDelegate_defaultLaunchName.equals(launchSpec.getLaunchConfigName())) {
- launchSpec.setLaunchConfigName(processName);
- }
- else {
- launchSpec.setLaunchConfigName(processName + " (" + launchSpec.getLaunchConfigName() + ")"); //$NON-NLS-1$//$NON-NLS-2$
- }
+ launchSpec.setLaunchConfigName(getDefaultLaunchName(launchSpec));
}
return launchSpec;
}
/* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.delegates.DefaultLaunchManagerDelegate#getDefaultLaunchName(org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification)
+ */
+ @Override
+ public String getDefaultLaunchName(ILaunchSpecification launchSpec) {
+ IModelNode[] contexts = LaunchContextsPersistenceDelegate.getLaunchContexts(launchSpec);
+ String processPath = (String)launchSpec.getAttribute(IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, null);
+ String name = getDefaultLaunchName((contexts != null && contexts.length > 0 ? contexts[0] : null), processPath);
+ return name != null && name.trim().length() > 0 ? name.trim() : super.getDefaultLaunchName(launchSpec);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.delegates.DefaultLaunchManagerDelegate#getDefaultLaunchName(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public String getDefaultLaunchName(ILaunchConfiguration launchConfig) {
+ IModelNode[] contexts = LaunchContextsPersistenceDelegate.getLaunchContexts(launchConfig);
+ String processPath = DefaultPersistenceDelegate.getAttribute(launchConfig, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, (String)null);
+ String name = getDefaultLaunchName((contexts != null && contexts.length > 0 ? contexts[0] : null), processPath);
+ return name != null && name.trim().length() > 0 ? name.trim() : super.getDefaultLaunchName(launchConfig);
+ }
+
+ private String getDefaultLaunchName(IModelNode context, String processPath) {
+ String name = ""; //$NON-NLS-1$
+ if (processPath != null) {
+ name += new Path(processPath).lastSegment();
+ }
+ if (context != null) {
+ IPropertiesAccessService service = ServiceManager.getInstance().getService(context, IPropertiesAccessService.class);
+ Object dnsName = service != null ? service.getProperty(context, "dns.name.transient") : null; //$NON-NLS-1$
+ String ctxName = service != null ? (String)service.getTargetAddress(context).get(IPropertiesAccessServiceConstants.PROP_ADDRESS) : null;
+ ctxName = dnsName != null && dnsName.toString().trim().length() > 0 ? dnsName.toString().trim() : ctxName;
+
+ name += " (" + ctxName + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return name.trim();
+ }
+
+ private String getProcessImageAndSetProjectAndTransfer(IProjectSelectionContext prjContext, List<IFileTransferItem> transfers, List<IReferencedProjectItem> projects) {
+ String processName = null;
+ String processPath = null;
+
+ boolean added = false;
+ for (Object selection : prjContext.getSelections()) {
+ if (selection instanceof IPath) {
+ IPath path = (IPath)selection;
+ IFileTransferItem transfer = new FileTransferItem(path, new Path("/tmp/")); //$NON-NLS-1$
+ if (!transfers.contains(transfer)) {
+ transfers.add(transfer);
+ }
+ if (!added) {
+ processName = path.lastSegment();
+ processPath = "/tmp/" + processName; //$NON-NLS-1$
+ }
+ added = true;
+ }
+ }
+
+ IReferencedProjectItem project = new ReferencedProjectItem(prjContext.getProjectCtx().getName());
+ if (!projects.contains(project)) {
+ projects.add(project);
+ }
+
+ return processPath;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.launch.core.lm.delegates.DefaultLaunchManagerDelegate#validate(java.lang.String, org.eclipse.debug.core.ILaunchConfiguration)
*/
@Override
@@ -235,11 +292,9 @@ public class RemoteAppLaunchManagerDelegate extends DefaultLaunchManagerDelegate
}
}
- @Override
- protected int getFullMatchRanking() {
- return 1;
- }
-
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.delegates.DefaultLaunchManagerDelegate#getDescription(org.eclipse.debug.core.ILaunchConfiguration)
+ */
@Override
public String getDescription(ILaunchConfiguration config) {
String image = DefaultPersistenceDelegate.getAttribute(config, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, (String)null);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppFilter.java
index 5fe9e5d2d..d7f7cda6f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppFilter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppFilter.java
@@ -26,7 +26,7 @@ public class RemoteAppFilter implements IFilter {
public boolean select(Object toTest) {
if (toTest instanceof LaunchNode) {
LaunchNode node = (LaunchNode)toTest;
- return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType()) &&
+ return node.isType(LaunchNode.TYPE_LAUNCH_CONFIG) &&
node.getLaunchConfigurationType().getIdentifier().equals(ILaunchTypes.REMOTE_APPLICATION);
}
return false;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/CommonDnD.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/CommonDnD.java
index e42137123..257d79059 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/CommonDnD.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/CommonDnD.java
@@ -72,11 +72,13 @@ public class CommonDnD {
if (target instanceof ICategory) {
ICategory hovered = (ICategory) target;
if (IUIConstants.ID_CAT_FAVORITES.equals(hovered.getId())
- || IUIConstants.ID_CAT_MY_TARGETS.equals(hovered.getId())) {
+ || IUIConstants.ID_CAT_MY_TARGETS.equals(hovered.getId())) {
Iterator<?> iterator = selection.iterator();
while (iterator.hasNext()) {
Object element = iterator.next();
- if (!(element instanceof IPeerModel)) continue;
+ if (!isDraggableObject(element)) {
+ continue;
+ }
Managers.getCategoryManager().add(hovered.getId(), ((IPeerModel)element).getPeerId());
}
// Fire a refresh of the view
@@ -86,7 +88,9 @@ public class CommonDnD {
Iterator<?> iterator = selection.iterator();
while (iterator.hasNext()) {
Object element = iterator.next();
- if (!(element instanceof IPeerModel)) continue;
+ if (!isDraggableObject(element)) {
+ continue;
+ }
// To determine the parent category, we have to look at the tree path
TreePath[] pathes = selection instanceof TreeSelection ? ((TreeSelection)selection).getPathsFor(element) : null;
@@ -139,16 +143,29 @@ public class CommonDnD {
IStructuredSelection selection = (IStructuredSelection) transfer.getSelection();
if (target instanceof ICategory) {
- ICategory hovered = (ICategory) target;
+ ICategory category = (ICategory) target;
// Dragging to the "Neighborhood" category is not possible
- if (!IUIConstants.ID_CAT_NEIGHBORHOOD.equals(hovered.getId())) {
- valid = true;
+ if (!IUIConstants.ID_CAT_NEIGHBORHOOD.equals(category.getId())) {
+ boolean allow = true;
+ Iterator<?> iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ Object element = iterator.next();
+ if (!isDraggableObject(element)) {
+ allow = false;
+ break;
+ }
+ if (Managers.getCategoryManager().belongsTo(category.getId(), ((IPeerModel)element).getPeerId())) {
+ allow = false;
+ break;
+ }
+ }
+ valid = allow;
// If the target is the "Favorites" or the "My Targets" category,
// force DROP_LINK operation
- if ((IUIConstants.ID_CAT_FAVORITES.equals(hovered.getId()) || IUIConstants.ID_CAT_MY_TARGETS.equals(hovered.getId()))
- && (operation & DND.DROP_LINK) == 0) {
+ if ((IUIConstants.ID_CAT_FAVORITES.equals(category.getId()) || IUIConstants.ID_CAT_MY_TARGETS.equals(category.getId()))
+ && (operation & DND.DROP_LINK) == 0) {
overrideOperation = DND.DROP_LINK;
}
}
@@ -159,21 +176,42 @@ public class CommonDnD {
Iterator<?> iterator = selection.iterator();
while (iterator.hasNext()) {
Object element = iterator.next();
- if (!(element instanceof IPeerModel)) {
+ if (!isDraggableObject(element)) {
allow = false;
break;
}
- if (!Managers.getCategoryManager().belongsTo(IUIConstants.ID_CAT_FAVORITES, ((IPeerModel)element).getPeerId())
- && !Managers.getCategoryManager().belongsTo(IUIConstants.ID_CAT_MY_TARGETS, ((IPeerModel)element).getPeerId())) {
- allow = false;
- break;
+
+ // To determine the parent category, we have to look at the tree path
+ TreePath[] pathes = selection instanceof TreeSelection ? ((TreeSelection)selection).getPathsFor(element) : null;
+ if (pathes != null && pathes.length > 0) {
+ for (TreePath path : pathes) {
+ ICategory category = null;
+ TreePath parentPath = path.getParentPath();
+ while (parentPath != null) {
+ if (parentPath.getLastSegment() instanceof ICategory) {
+ category = (ICategory)parentPath.getLastSegment();
+ break;
+ }
+ parentPath = parentPath.getParentPath();
+ }
+
+ if (category == null || IUIConstants.ID_CAT_NEIGHBORHOOD.equals(category.getId())) {
+ allow = false;
+ break;
+ }
+ }
}
}
valid = allow;
}
- if (overrideOperation != -1 && dropAdapter != null) {
- dropAdapter.overrideOperation(overrideOperation);
+ if (dropAdapter != null) {
+ if (!valid) {
+ dropAdapter.overrideOperation(DND.DROP_NONE);
+ }
+ else if (overrideOperation != -1) {
+ dropAdapter.overrideOperation(overrideOperation);
+ }
}
return valid;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/CategoryAddToContributionItem.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/CategoryAddToContributionItem.java
index 1246ddcfd..be21e2ee9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/CategoryAddToContributionItem.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/CategoryAddToContributionItem.java
@@ -117,8 +117,7 @@ public class CategoryAddToContributionItem extends AbstractCategoryContributionI
// Delegate to the categorizable element
ICategorizable categorizable = getCategorizable(element);
- Assert.isNotNull(categorizable);
- enabled &= categorizable.isEnabled(ICategorizable.OPERATION.ADD, category);
+ enabled &= categorizable != null && categorizable.isEnabled(ICategorizable.OPERATION.ADD, category);
if (!enabled) {
break;
}

Back to the top