Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2017-03-10 15:30:18 +0000
committerSarika Sinha2017-12-11 05:47:08 +0000
commitca4c3de585c743486c2df55b551ec3f2dfd9b6a2 (patch)
treee408d2fd23d7014b1db5116fce46d5ce6e4f0bfb
parent8803c89e9471914c5a66f0f869cd4fea67357576 (diff)
downloadeclipse.platform.debug-ca4c3de585c743486c2df55b551ec3f2dfd9b6a2.tar.gz
eclipse.platform.debug-ca4c3de585c743486c2df55b551ec3f2dfd9b6a2.tar.xz
eclipse.platform.debug-ca4c3de585c743486c2df55b551ec3f2dfd9b6a2.zip
Bug 41353 - Launch configuration prototypesI20171211-2000
First implementation of the launch configuration prototypes mechanism. Change-Id: I21a2a97b83aa9cb1be79153bbc4b72171cc6be20 Signed-off-by: Axel Richard <axel.richard@obeo.fr>
-rw-r--r--org.eclipse.debug.core/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java152
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationType.java44
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java71
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java51
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/IPrototypeAttributesLabelProvider.java29
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java4
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties4
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/IConfigurationElementConstants.java13
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java183
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationInfo.java272
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java35
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java124
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java141
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupMemberChangeListener.java3
-rw-r--r--org.eclipse.debug.core/pom.xml2
-rw-r--r--org.eclipse.debug.core/schema/launchConfigurationTypes.exsd7
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java208
-rw-r--r--org.eclipse.debug.ui/icons/full/dlcl16/link_proto.pngbin0 -> 1422 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/dlcl16/link_proto@2x.pngbin0 -> 2247 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/dlcl16/new_proto.pngbin0 -> 1593 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/dlcl16/new_proto@2x.pngbin0 -> 2756 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/dlcl16/reset_proto.pngbin0 -> 1513 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/dlcl16/reset_proto@2x.pngbin0 -> 2499 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/dlcl16/unlink_proto.pngbin0 -> 1467 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/dlcl16/unlink_proto@2x.pngbin0 -> 2415 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/elcl16/link_proto.pngbin0 -> 1422 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/elcl16/link_proto@2x.pngbin0 -> 2247 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/elcl16/new_proto.pngbin0 -> 1593 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/elcl16/new_proto@2x.pngbin0 -> 2756 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/elcl16/reset_proto.pngbin0 -> 1513 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/elcl16/reset_proto@2x.pngbin0 -> 2499 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/elcl16/unlink_proto.pngbin0 -> 1467 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/elcl16/unlink_proto@2x.pngbin0 -> 2415 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/obj16/check.pngbin0 -> 1411 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/obj16/check@2x.pngbin0 -> 2190 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/obj16/proto_tab.pngbin0 -> 1476 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/obj16/proto_tab@2x.pngbin0 -> 2425 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/obj16/uncheck.pngbin0 -> 1219 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/obj16/uncheck@2x.pngbin0 -> 1540 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/ovr16/prototype.pngbin0 -> 1281 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/ovr16/prototype@2x.pngbin0 -> 1615 bytes
-rw-r--r--org.eclipse.debug.ui/plugin.properties7
-rw-r--r--org.eclipse.debug.ui/plugin.xml21
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java13
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java14
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationSelectionDialog.java10
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java3
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizardPage.java5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationPrototypeAction.java147
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DeleteLaunchConfigurationAction.java5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java11
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTreeContentProvider.java50
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java30
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java66
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java40
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties42
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LinkPrototypeAction.java159
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ResetWithPrototypeValuesAction.java129
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/UnlinkPrototypeAction.java128
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java6
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties6
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTab.java61
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java22
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java16
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java10
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/PrototypeDecorator.java52
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ProtoypeTab.java760
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupTab.java16
72 files changed, 3065 insertions, 121 deletions
diff --git a/org.eclipse.debug.core/META-INF/MANIFEST.MF b/org.eclipse.debug.core/META-INF/MANIFEST.MF
index d80184cbd..941424818 100644
--- a/org.eclipse.debug.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.debug.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.debug.core; singleton:=true
-Bundle-Version: 3.11.100.qualifier
+Bundle-Version: 3.12.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.debug.core.DebugPlugin
Bundle-Vendor: %providerName
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java
index 020ca26cf..0ab64fb71 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -7,10 +7,12 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.core;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -69,6 +71,14 @@ public interface ILaunchConfiguration extends IAdaptable {
public static final String LAUNCH_CONFIGURATION_FILE_EXTENSION = "launch"; //$NON-NLS-1$
/**
+ * The file extension for launch configuration prototype files (value
+ * <code>"prototype"</code>).
+ *
+ * @since 3.12
+ */
+ public static final String LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION = "prototype"; //$NON-NLS-1$
+
+ /**
* Launch configuration attribute storing an identifier of
* a persistable source locator extension. When this attribute is
* specified, a new source locator will be created automatically and
@@ -91,6 +101,38 @@ public interface ILaunchConfiguration extends IAdaptable {
public static final String ATTR_SOURCE_LOCATOR_MEMENTO = DebugPlugin.getUniqueIdentifier() + ".source_locator_memento"; //$NON-NLS-1$
/**
+ * Flag indicating that only this configuration is to be modified by an operation.
+ * Any prototype children referring to this configuration will not be modified.
+ *
+ * @since 3.12
+ */
+ public static final int UPDATE_NONE = 0;
+
+ /**
+ * Flag indicating that this prototype and any effected prototype children of this prototype
+ * should be updated when this prototype is modified.
+ *
+ * @since 3.12
+ */
+ public static final int UPDATE_PROTOTYPE_CHILDREN = 1;
+
+ /**
+ * Type constant (bit mask value 1) which identifies a launch configuration.
+ *
+ * @see #getKind()
+ * @since 3.12
+ */
+ public static final int CONFIGURATION = 0x1;
+
+ /**
+ * Type constant (bit mask value 2) which identifies a launch configuration prototype.
+ *
+ * @see #getKind()
+ * @since 3.12
+ */
+ public static final int PROTOTYPE = 0x2;
+
+ /**
* Returns whether the contents of this launch configuration are
* equal to the contents of the given launch configuration.
*
@@ -122,18 +164,39 @@ public interface ILaunchConfiguration extends IAdaptable {
/**
* Deletes this launch configuration. This configuration's underlying
- * storage is deleted. Has no effect if this configuration
- * does not exist.
+ * storage is deleted. Has no effect if this configuration does not exist.
+ * <p>
+ * Equivalent to #delete(UPDATE_NONE)
+ * </p>
*
* @exception CoreException if this method fails. Reasons include:
- * <ul>
- * <li>An exception occurs while deleting this configuration's
- * underlying storage.</li>
- * </ul>
+ * <ul>
+ * <li>An exception occurs while deleting this
+ * configuration's underlying storage.</li>
+ * </ul>
*/
public void delete() throws CoreException;
/**
+ * Deletes this launch configuration. This configuration's underlying
+ * storage is deleted. Has no effect if this configuration does not exist.
+ * <p>
+ * When UPDATE_PROTOTYPE_CHILDREN is specified, back pointers to this
+ * prototype are cleared in any prototype children.
+ * </p>
+ *
+ * @param flag one of UPDATE_NONE or UPDATE_PROTOTYPE_CHILDREN
+ * @exception CoreException if this method fails. Reasons include:
+ * <ul>
+ * <li>An exception occurs while deleting this
+ * configuration's underlying storage or updating any
+ * prototype children.</li>
+ * </ul>
+ * @since 3.12
+ */
+ public void delete(int flag) throws CoreException;
+
+ /**
* Returns whether this launch configuration's underlying
* storage exists. This is a handle-only method.
*
@@ -597,4 +660,79 @@ public interface ILaunchConfiguration extends IAdaptable {
* @since 3.3
*/
public boolean isReadOnly();
+
+ /**
+ * Returns the prototype this launch configuration was created from or
+ * <code>null</code> if none.
+ *
+ * @return the prototype this launch configuration was created from or
+ * <code>null</code> if none
+ * @throws CoreException if the prototype could not be retrieved or no
+ * longer exists
+ * @since 3.12
+ */
+ public ILaunchConfiguration getPrototype() throws CoreException;
+
+ /**
+ * Check if the given attribute has the same value than the one from its prototype.
+ * @param attribute the attribute to check
+ * @return <code>true</code> if the attribute is modified, <code>false</code> otherwise.
+ * @throws CoreException if an exception occurs while checking
+ * @since 3.12
+ */
+ public boolean isAttributeModified(String attribute) throws CoreException;
+
+ /**
+ * Returns whether this configuration is a prototype.
+ *
+ * @return whether this configuration is a prototype
+ * @since 3.12
+ */
+ public boolean isPrototype();
+
+ /**
+ * Returns all configurations made from this prototype, possibly an empty
+ * collection.
+ *
+ * @return all configurations made from this prototype
+ * @throws CoreException if unable to retrieve this prototype's children
+ * @since 3.12
+ */
+ public Collection<ILaunchConfiguration> getPrototypeChildren() throws CoreException;
+
+ /**
+ * Returns this configuration's kind. One of CONFIGURATION or PROTOTYPE.
+ *
+ * @see #CONFIGURATION
+ * @see #PROTOTYPE
+ *
+ * @return this configuration's kind
+ * @throws CoreException if unable to retrieve this configuration's kind
+ * @since 3.12
+ */
+ public int getKind() throws CoreException;
+
+ /**
+ * Get the visible attributes of this prototype (return <code>null</code> if
+ * the launch configuration is not a prototype).
+ *
+ * @return the visible attributes of this prototype (return
+ * <code>null</code> if the launch configuration is not a
+ * prototype).
+ * @throws CoreException if unable to retrieve this prototype's visible
+ * attribute set.
+ * @since 3.12
+ */
+ public Set<String> getPrototypeVisibleAttributes() throws CoreException;
+
+ /**
+ * Set the visibility of the given prototype's attribute.
+ *
+ * @param attribute the attribute to set
+ * @param visible the visibility
+ * @throws CoreException if unable to set this prototype's attribute
+ * visibility
+ * @since 3.12
+ */
+ public void setPrototypeAttributeVisibility(String attribute, boolean visible) throws CoreException;
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationType.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationType.java
index cd78a8ca4..fbcb08a1e 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationType.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.core;
@@ -315,4 +316,45 @@ public interface ILaunchConfigurationType extends IAdaptable {
*/
public String getContributorName();
+ /**
+ * Returns all launch configuration prototypes of the this type, possibly
+ * an empty collection.
+ *
+ * @return all launch configuration prototypes of the this type
+ * @throws CoreException if unable to retrieve the prototypes
+ * @since 3.12
+ */
+ public ILaunchConfiguration[] getPrototypes() throws CoreException;
+
+ /**
+ * Returns a new launch configuration working copy of this type, that
+ * resides in the specified container, with the given name. When
+ * <code>container</code> is </code>null</code>, the configuration will
+ * reside locally in the metadata area. Note: a launch configuration is not
+ * actually created until the working copy is saved.
+ * <p>
+ * The configuration <code>name</code> parameter cannot contain file
+ * separator characters (sub directories) when the <code>container</code> is
+ * <code>null</code> (i.e. when the configuration is to be stored in the
+ * local metadata area.
+ * </p>
+ *
+ * @param container the container in which the new configuration will
+ * reside, or <code>null</code> if the configuration should
+ * reside locally with the metadata.
+ * @param name name for the launch configuration
+ * @return a new launch configuration working copy instance of this type
+ * @exception CoreException if an instance of this type of launch
+ * configuration could not be created for any reason
+ * @since 3.12
+ */
+ public ILaunchConfigurationWorkingCopy newPrototypeInstance(IContainer container, String name) throws CoreException;
+
+ /**
+ * Returns whether this type of launch configuration supports prototypes.
+ *
+ * @return whether this kind of launch configuration supports the prototypes
+ * @since 3.12
+ */
+ public boolean supportsPrototypes();
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java
index b46e3747b..7b2b5326f 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.core;
@@ -64,13 +65,41 @@ public interface ILaunchConfigurationWorkingCopy extends ILaunchConfiguration, I
* saved to the parent working copy and the parent working copy is returned without
* effecting the original launch configuration.
* </p>
+ * <p>
+ * Equivalent to #doSave(UPDATE_NONE).
+ * </p>
* @return handle to saved launch configuration
* @exception CoreException if an exception occurs while
* writing this configuration to its underlying file.
+ * @see #doSave(int)
*/
public ILaunchConfiguration doSave() throws CoreException;
/**
+ * Saves this working copy to its underlying file and returns a handle to
+ * the resulting launch configuration. Has no effect if this configuration
+ * does not need saving. Creates the underlying file if not yet created.
+ * <p>
+ * Since 3.3, if this is a nested working copy, the contents of this working
+ * copy are saved to the parent working copy and the parent working copy is
+ * returned without effecting the original launch configuration.
+ * </p>
+ * <p>
+ * Updates any affected prototype children based on the given flag. When a
+ * working copy is renamed or moved to a new location, prototype children's
+ * back pointers will be updated to refer the proper configuration.
+ * </p>
+ * @param flag one of {@link ILaunchConfiguration#UPDATE_NONE} or
+ * {@link ILaunchConfiguration#UPDATE_PROTOTYPE_CHILDREN}
+ * @return handle to saved launch configuration
+ * @exception CoreException if an exception occurs while writing this
+ * configuration or any of its affected prototype children to
+ * underlying storage
+ * @since 3.12
+ */
+ public ILaunchConfiguration doSave(int flag) throws CoreException;
+
+ /**
* Sets the integer-valued attribute with the given name.
*
* @param attributeName the name of the attribute, cannot be <code>null</code>
@@ -131,6 +160,15 @@ public interface ILaunchConfigurationWorkingCopy extends ILaunchConfiguration, I
public void setAttribute(String attributeName, boolean value);
/**
+ * Sets the valued attribute with the given name.
+ *
+ * @param attributeName the name of the attribute, cannot be <code>null</code>
+ * @param value the value
+ * @since 3.12
+ */
+ public void setAttribute(String attributeName, Object value);
+
+ /**
* Returns the original launch configuration this working copy
* was created from or <code>null</code> if this is a new
* working copy created from a launch configuration type.
@@ -277,4 +315,35 @@ public interface ILaunchConfigurationWorkingCopy extends ILaunchConfiguration, I
* @since 3.3
*/
public ILaunchConfigurationWorkingCopy getParent();
+
+ /**
+ * Copies all attributes from the given prototype to this working.
+ * Overwrites any existing attributes with the same key.
+ *
+ * @param prototype configuration prototype
+ * @exception CoreException if unable to retrieve attributes from the prototype
+ * @since 3.12
+ */
+ public void copyAttributes(ILaunchConfiguration prototype) throws CoreException;
+
+ /**
+ * Sets the prototype that this configuration is based on, possibly <code>null</code>,
+ * and optionally copies attributes from the prototype to this working copy.
+ * <p>
+ * When the specified prototype is <code>null</code>, this working copy is no longer
+ * associated with any prototype.
+ * </p>
+ * @param prototype prototype or <code>null</code>
+ * @param copy whether to copy attributes from the prototype to this working copy. Has
+ * no effect when prototype is <code>null</code>
+ * @exception CoreException if
+ * <ul>
+ * <li>unable to generate a memento for the given configuration
+ * or copy its attributes</li>
+ * <li>if attempting to set a prototype attribute on an existing prototype - prototypes
+ * cannot be nested</li>
+ * </ul>
+ * @since 3.12
+ */
+ public void setPrototype(ILaunchConfiguration prototype, boolean copy) throws CoreException;
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java
index 534abe840..41ac5e15f 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.core;
@@ -208,7 +209,10 @@ public interface ILaunchManager {
* in the specified file. This method does not check if the specified <code>IFile</code> is
* a launch configuration file or that it exists in the local or
* remote file system.
- *
+ * <p>
+ * Since 3.12, the returned configuration may be a launch configuration template.
+ * </p>
+ *
* @param file launch configuration file
* @return a handle to the launch configuration contained
* in the specified file
@@ -218,7 +222,10 @@ public interface ILaunchManager {
/**
* Returns a handle to the launch configuration specified by
* the given memento. The configuration may not exist.
- *
+ * <p>
+ * Since 3.12, the returned configuration may be a launch configuration template.
+ * </p>
+ *
* @param memento launch configuration memento
* @return a handle to the launch configuration specified by
* the given memento
@@ -234,20 +241,56 @@ public interface ILaunchManager {
* @return all launch configurations defined in the workspace
* @exception CoreException if an exception occurs retrieving configurations
* @since 2.0
+ * @see ILaunchConfigurationType#getPrototypes()
*/
public ILaunchConfiguration[] getLaunchConfigurations() throws CoreException;
/**
* Returns all launch configurations of the specified type defined in the workspace
- *
+ * <p>
+ * Does not include launch configuration templates.
+ * </p>
* @param type a launch configuration type
* @return all launch configurations of the specified type defined in the workspace
* @exception CoreException if an error occurs while retrieving
* a launch configuration
* @since 2.0
+ * @see ILaunchConfigurationType#getPrototypes()
*/
public ILaunchConfiguration[] getLaunchConfigurations(ILaunchConfigurationType type) throws CoreException;
/**
+ * Returns all launch configurations defined in the workspace of the specified
+ * kind(s) (configurations and/or prototypes).
+ *
+ * @param kinds bit mask of kinds of configurations to consider
+ * @return all launch configurations defined in the workspace
+ * @exception CoreException if an exception occurs retrieving configurations
+ * @since 3.12
+ * @see ILaunchConfiguration#CONFIGURATION
+ * @see ILaunchConfiguration#PROTOTYPE
+ * @see ILaunchConfiguration#getKind()
+ * @see ILaunchConfigurationType#getPrototypes()
+ */
+ public ILaunchConfiguration[] getLaunchConfigurations(int kinds) throws CoreException;
+
+ /**
+ * Returns all launch configurations of the specified type defined in the workspace
+ * of the specified kind(s) (configurations and/or prototypes).
+ *
+ * @param type a launch configuration type
+ * @param kinds bit mask of kinds of configurations to consider
+ * @return all launch configurations of the specified type defined in the workspace
+ * @exception CoreException if an error occurs while retrieving
+ * a launch configuration
+ * @since 3.12
+ * @see ILaunchConfiguration#CONFIGURATION
+ * @see ILaunchConfiguration#PROTOTYPE
+ * @see ILaunchConfiguration#getKind()
+ * @see ILaunchConfigurationType#getPrototypes()
+ */
+ public ILaunchConfiguration[] getLaunchConfigurations(ILaunchConfigurationType type, int kinds) throws CoreException;
+
+ /**
* Returns the launch configuration type extension with the specified
* id, or <code>null</code> if it does not exist.
*
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/IPrototypeAttributesLabelProvider.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/IPrototypeAttributesLabelProvider.java
new file mode 100644
index 000000000..ab98d0369
--- /dev/null
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/IPrototypeAttributesLabelProvider.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.core;
+
+/**
+ * A prototype attributes label provider is contributed as an optional attribute
+ * of a <code>launchConfigurationType</code> extension and is responsible for
+ * displaying launch configurations prototype attributes of that type.
+ *
+ * @since 3.12
+ */
+public interface IPrototypeAttributesLabelProvider {
+
+ /**
+ * Get a human readable label to associate to this attribute.
+ *
+ * @param attribute the given attribute.
+ * @return a human readable label of this attribute.
+ */
+ public String getAttributeLabel(String attribute);
+}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java
index c93185478..535a8d628 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java
@@ -8,6 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
* Anton Kosyakov (Itemis AG) - Bug 438621 - [step filtering] Provide an extension point to enhance methods step filtering.
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.core;
@@ -68,6 +69,9 @@ public class DebugCoreMessages extends NLS {
public static String LaunchConfigurationWorkingCopy_1;
public static String LaunchConfigurationWorkingCopy_2;
public static String LaunchConfigurationWorkingCopy_3;
+ public static String LaunchConfigurationWorkingCopy_6;
+ public static String LaunchConfigurationWorkingCopy_7;
+ public static String LaunchConfigurationWorkingCopy_8;
public static String LaunchDelegate_0;
public static String LaunchDelegate_1;
public static String LaunchDelegate_2;
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties
index 988bdef8a..446354429 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties
@@ -8,6 +8,7 @@
# Contributors:
# IBM Corporation - initial API and implementation
# Anton Kosyakov (Itemis AG) - Bug 438621 - [step filtering] Provide an extension point to enhance methods step filtering.
+# Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
###############################################################################
Breakpoint_no_associated_marker=Breakpoint does not have an associated marker.
@@ -79,6 +80,9 @@ LaunchConfigurationWorkingCopy_1=Writing local file
LaunchConfigurationWorkingCopy_2=Creating new file {0}.launch in workspace
LaunchConfigurationWorkingCopy_3=Setting contents of {0}.launch
LaunchConfigurationWorkingCopy_4=Unable to obtain storage to write launch configuration
+LaunchConfigurationWorkingCopy_6=The launch configuration must be a prototype
+LaunchConfigurationWorkingCopy_7=Unable to set a launch configuration prototype on a launch configuration working copy
+LaunchConfigurationWorkingCopy_8=Writing local file
LaunchManager__0__occurred_while_reading_launch_configuration_file__1___1={0} occurred while reading launch configuration file: {1}.
LaunchManager_Invalid_launch_configuration_index__18=Invalid launch configuration index.
LaunchManager_does_not_exist=Launch configuration {0} at {1} does not exist.
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/IConfigurationElementConstants.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/IConfigurationElementConstants.java
index 2e225285e..1948399de 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/IConfigurationElementConstants.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/IConfigurationElementConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2017 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.core;
@@ -341,4 +342,14 @@ public interface IConfigurationElementConstants {
* <p>Equal to the word: <code>editorInput</code></p>
*/
public static final String EDITOR_INPUT = "editorInput"; //$NON-NLS-1$
+
+ /**
+ * The allowPrototypes node name for a configuration element
+ * <p>
+ * Equal to the word: <code>allowPrototypes</code>
+ * </p>
+ *
+ * @since 3.12
+ */
+ public static final String ALLOW_PROTOTYPES = "allowPrototypes"; //$NON-NLS-1$
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java
index e6a15dfc7..df33c3472 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Sascha Radike - bug 56642
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.core;
@@ -17,6 +18,7 @@ import java.io.IOException;
import java.io.StringReader;
import java.net.URI;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -109,6 +111,22 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
public static final String ATTR_PREFERRED_LAUNCHERS = DebugPlugin.getUniqueIdentifier() + ".preferred_launchers"; //$NON-NLS-1$
/**
+ * Launch configuration attribute storing a memento identifying the prototype
+ * this configuration was made from, possibly <code>null</code>.
+ *
+ * @since 3.12
+ */
+ public static final String ATTR_PROTOTYPE = DebugPlugin.getUniqueIdentifier() + ".ATTR_PROTOTYPE"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute storing if this configuration is a
+ * prototype or not.
+ *
+ * @since 3.12
+ */
+ public static final String IS_PROTOTYPE = DebugPlugin.getUniqueIdentifier() + ".IS_PROTOTYPE"; //$NON-NLS-1$
+
+ /**
* Status handler to prompt in the UI thread
*
* @since 3.3
@@ -142,6 +160,12 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
private IContainer fContainer;
/**
+ * If this configuration is a prototype.
+ * @since 3.12
+ */
+ private boolean fIsPrototype;
+
+ /**
* Constructs a launch configuration with the given name. The configuration
* is stored in the given container or locally with workspace metadata if
* the specified container is <code>null</code>.
@@ -151,9 +175,24 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
* @since 3.5
*/
protected LaunchConfiguration(String name, IContainer container) {
+ this(name, container, false);
+ }
+
+ /**
+ * Constructs a launch configuration with the given name. The configuration
+ * is stored in the given container or locally with workspace metadata if
+ * the specified container is <code>null</code>.
+ *
+ * @param name launch configuration name
+ * @param container parent container or <code>null</code>
+ * @param prototype if the configuration is a prototype or not
+ * @since 3.12
+ */
+ protected LaunchConfiguration(String name, IContainer container, boolean prototype) {
initialize();
setName(name);
setContainer(container);
+ fIsPrototype = prototype;
}
/**
@@ -170,11 +209,11 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
* @since 3.5
*/
protected LaunchConfiguration(IFile file) {
- this(getSimpleName(file.getName()), file.getParent());
+ this(getSimpleName(file.getName()), file.getParent(), isPrototype(file));
}
/**
- * Given a name that ends with .launch, return the simple name of the configuration.
+ * Given a name that ends with .launch or .prototype, return the simple name of the configuration.
*
* @param fileName the name to parse
* @return simple name
@@ -184,6 +223,8 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
IPath path = new Path(fileName);
if(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION.equals(path.getFileExtension())) {
return path.removeFileExtension().toString();
+ } else if (ILaunchConfiguration.LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION.equals(path.getFileExtension())) {
+ return path.removeFileExtension().toString();
}
return fileName;
}
@@ -304,6 +345,23 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfiguration#delete(int)
+ */
+ @Override
+ public void delete(int flag) throws CoreException {
+ if (flag == UPDATE_PROTOTYPE_CHILDREN && isPrototype()) {
+ // clear back pointers to this configuration
+ Collection<ILaunchConfiguration> children = getPrototypeChildren();
+ for (ILaunchConfiguration child : children) {
+ ILaunchConfigurationWorkingCopy childWC = child.getWorkingCopy();
+ childWC.setPrototype(null, false);
+ childWC.doSave();
+ }
+ }
+ delete();
+ }
+
/**
* Returns whether this configuration is equal to the
* given configuration. Two configurations are equal if
@@ -449,12 +507,16 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
* Returns the simple file name of this launch configuration.
*
* @return the simple file name of this launch configuration - for example
- * "Abc.launch"
+ * "Abc.launch" or "Abc.prototype"
*/
protected String getFileName() {
StringBuffer buf = new StringBuffer(getName());
buf.append('.');
- buf.append(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION);
+ if (isPrototype()) {
+ buf.append(ILaunchConfiguration.LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION);
+ } else {
+ buf.append(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION);
+ }
return buf.toString();
}
@@ -994,5 +1056,116 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig
return getName();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfiguration#getPrototype()
+ */
+ @Override
+ public ILaunchConfiguration getPrototype() throws CoreException {
+ String memento = getAttribute(ATTR_PROTOTYPE, (String)null);
+ if (memento != null) {
+ LaunchConfiguration prototype = new LaunchConfiguration(memento);
+ prototype.setIsPrototype(true);
+ return prototype;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfiguration#getPrototypeChildren()
+ */
+ @Override
+ public Collection<ILaunchConfiguration> getPrototypeChildren() throws CoreException {
+ ILaunchConfiguration[] configurations = getLaunchManager().getLaunchConfigurations(getType());
+ List<ILaunchConfiguration> proteges = new ArrayList<ILaunchConfiguration>();
+ for (int i = 0; i < configurations.length; i++) {
+ ILaunchConfiguration config = configurations[i];
+ if (this.equals(config.getPrototype())) {
+ proteges.add(config);
+ }
+ }
+ return proteges;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfiguration#isPrototype()
+ */
+ @Override
+ public boolean isPrototype() {
+ return fIsPrototype;
+ }
+
+ /**
+ * Set the prototype state of this configuration.
+ *
+ * @param isPrototype the prototype state.
+ *
+ * @since 3.12
+ */
+ protected void setIsPrototype(boolean isPrototype) {
+ fIsPrototype = isPrototype;
+ }
+
+ /**
+ * Check if the given file is a launch configuration prototype or not.
+ *
+ * @param file the given {@link IFile}.
+ * @return <code>true</code> if the given file is a launch configuration
+ * prototype, false otherwise.
+ *
+ * @since 3.12
+ */
+ protected static boolean isPrototype(IFile file) {
+ if (ILaunchConfiguration.LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION.equals(file.getFileExtension())) {
+ return true;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfiguration#getKind()
+ */
+ @Override
+ public int getKind() throws CoreException {
+ if (fIsPrototype) {
+ return PROTOTYPE;
+ }
+ return CONFIGURATION;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfiguration#isAttributeModified(java.lang.String)
+ */
+ @Override
+ public boolean isAttributeModified(String attribute) throws CoreException {
+ ILaunchConfiguration prototype = getPrototype();
+ if (prototype != null) {
+ Object prototypeValue = prototype.getAttributes().get(attribute);
+ Object attributeValue = getAttributes().get(attribute);
+ return !LaunchConfigurationInfo.compareAttribute(attribute, prototypeValue, attributeValue);
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.debug.core.ILaunchConfiguration#getPrototypeVisibleAttributes
+ * ()
+ */
+ @Override
+ public Set<String> getPrototypeVisibleAttributes() throws CoreException {
+ return getInfo().getVisibleAttributes();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfiguration#
+ * setPrototypeAttributeVisibility(java.lang.String, boolean)
+ */
+ @Override
+ public void setPrototypeAttributeVisibility(String attribute, boolean visible) throws CoreException {
+ getInfo().setAttributeVisibility(attribute, visible);
+ }
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationInfo.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationInfo.java
index 1692d6101..72aa2114d 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationInfo.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -7,12 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.core;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -22,6 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
+import java.util.stream.Collectors;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
@@ -31,6 +34,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -60,6 +64,8 @@ public class LaunchConfigurationInfo {
private static final String INT_ATTRIBUTE = "intAttribute"; //$NON-NLS-1$
private static final String STRING_ATTRIBUTE = "stringAttribute"; //$NON-NLS-1$
private static final String TYPE = "type"; //$NON-NLS-1$
+ private static final String PROTOTYPE = "prototype"; //$NON-NLS-1$
+ private static final String VISIBLE_ATTRIBUTES = "visibleAttributes"; //$NON-NLS-1$
/**
* This configurations attribute table. Keys are <code>String</code>s and
@@ -76,6 +82,26 @@ public class LaunchConfigurationInfo {
private ILaunchConfigurationType fType;
/**
+ * Whether this configuration is a prototype
+ */
+ private boolean fIsPrototype = false;
+
+ /**
+ * This launch configuration's prototype (can be <code>null</code> if this launch configuration is already a prototype).
+ */
+ private ILaunchConfiguration fPrototype;
+
+ /**
+ * This prototype's visible attributes (can be <code>null</code> if launch configuration is not a prototype).
+ */
+ private Set<String> fVisibleAttributes;
+
+ /**
+ * Static access to the launch manager.
+ */
+ private static LaunchManager fgLaunchManager = (LaunchManager)DebugPlugin.getDefault().getLaunchManager();
+
+ /**
* Whether running on Sun 1.4 VM - see bug 110215
*/
private static boolean fgIsSun14x = false;
@@ -270,6 +296,18 @@ public class LaunchConfigurationInfo {
}
/**
+ * Returns the raw object from the attribute table or <code>null</code> if none.
+ *
+ * @param key attribute key
+ * @return raw attribute value
+ *
+ * @since 3.12
+ */
+ protected Object getObjectAttribute(String key) {
+ return getAttributeTable().get(key);
+ }
+
+ /**
* Returns the <code>java.util.Map</code> attribute with the given key or
* the given default value if undefined.
* @param key the name of the attribute
@@ -316,6 +354,28 @@ public class LaunchConfigurationInfo {
return fType;
}
+ /**
+ * Sets this configuration's prototype.
+ *
+ * @param prototype
+ * launch configuration prototype
+ *
+ * @since 3.12
+ */
+ protected void setPrototype(ILaunchConfiguration prototype) {
+ fPrototype = prototype;
+ }
+
+ /**
+ * Returns this configuration's prototype, if it exists.
+ *
+ * @return launch configuration prototype (can be <code>null</code>)
+ *
+ * @since 3.12
+ */
+ protected ILaunchConfiguration getPrototype() {
+ return fPrototype;
+ }
/**
* Returns a copy of this info object
@@ -326,6 +386,9 @@ public class LaunchConfigurationInfo {
LaunchConfigurationInfo copy = new LaunchConfigurationInfo();
copy.setType(getType());
copy.setAttributeTable(getAttributes());
+ copy.setIsPrototype(isPrototype());
+ copy.setPrototype(getPrototype());
+ copy.setVisibleAttributes(getVisibleAttributes());
return copy;
}
@@ -350,8 +413,14 @@ public class LaunchConfigurationInfo {
protected void setAttribute(String key, Object value) {
if (value == null) {
getAttributeTable().remove(key);
+ setAttributeVisibility(key, false);
} else {
- getAttributeTable().put(key, value);
+ Object attribute = getAttributeTable().put(key, value);
+ // If attribute is new in the table and the configuration is a
+ // prototype, then add it to the visible attributes
+ if (attribute == null && fIsPrototype) {
+ setAttributeVisibility(key, true);
+ }
}
}
@@ -376,6 +445,13 @@ public class LaunchConfigurationInfo {
configRootElement.setAttribute(TYPE, getType().getIdentifier());
+ ILaunchConfiguration prototype = getPrototype();
+ if (prototype != null) {
+ configRootElement.setAttribute(PROTOTYPE, prototype.getName());
+ } else if (isPrototype()) {
+ configRootElement.setAttribute(VISIBLE_ATTRIBUTES, getVisibleAttributes().stream().collect(Collectors.joining(", "))); //$NON-NLS-1$
+ }
+
for (String key : getAttributeTable().keySet()) {
if (key == null) {
throw new DebugException(
@@ -509,6 +585,19 @@ public class LaunchConfigurationInfo {
* @throws CoreException if a problem is encountered
*/
protected void initializeFromXML(Element root) throws CoreException {
+ initializeFromXML(root, false);
+ }
+
+ /**
+ * Initializes the mapping of attributes from the XML file
+ *
+ * @param root the root node from the XML document
+ * @param isPrototype if the XML file corresponds to a prototype
+ * @throws CoreException if a problem is encountered
+ *
+ * @since 3.12
+ */
+ protected void initializeFromXML(Element root, boolean isPrototype) throws CoreException {
if (!root.getNodeName().equalsIgnoreCase(LAUNCH_CONFIGURATION)) {
throw getInvalidFormatDebugException();
}
@@ -555,6 +644,27 @@ public class LaunchConfigurationInfo {
}
}
}
+
+ if (isPrototype) {
+ setIsPrototype(true);
+ String visibleAttributes = root.getAttribute(VISIBLE_ATTRIBUTES);
+ if (visibleAttributes != null && visibleAttributes.length() > 0) {
+ String[] split = visibleAttributes.split(", "); //$NON-NLS-1$
+ setVisibleAttributes(new HashSet<>(Arrays.asList(split)));
+ }
+ } else {
+ setIsPrototype(false);
+ String prototype = root.getAttribute(PROTOTYPE);
+ if (prototype != null && prototype.length() > 0) {
+ ILaunchConfiguration[] launchConfigurations = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(ILaunchConfiguration.PROTOTYPE);
+ for (ILaunchConfiguration iLaunchConfiguration : launchConfigurations) {
+ if (prototype.equals(iLaunchConfiguration.getName())) {
+ setPrototype(iLaunchConfiguration);
+ break;
+ }
+ }
+ }
+ }
}
/**
@@ -730,6 +840,13 @@ public class LaunchConfigurationInfo {
return false;
}
+ // In case of a prototype, make sure the visible attributes are the same
+ if (isPrototype() != other.isPrototype()) {
+ return false;
+ } else if (isPrototype() && !getVisibleAttributes().equals(other.getVisibleAttributes())) {
+ return false;
+ }
+
// Make sure the attributes are the same
return compareAttributes(fAttributes, other.getAttributeTable());
}
@@ -743,42 +860,63 @@ public class LaunchConfigurationInfo {
* @return whether the two attribute maps are equal
*/
protected boolean compareAttributes(TreeMap<String, Object> map1, TreeMap<String, Object> map2) {
- LaunchManager manager = (LaunchManager)DebugPlugin.getDefault().getLaunchManager();
if (map1.size() == map2.size()) {
Iterator<String> attributes = map1.keySet().iterator();
while (attributes.hasNext()) {
String key = attributes.next();
Object attr1 = map1.get(key);
Object attr2 = map2.get(key);
- if (attr2 == null) {
+ if (!compareAttribute(key, attr1, attr2)) {
return false;
}
- Comparator<Object> comp = manager.getComparator(key);
- if (comp == null) {
- if (fgIsSun14x) {
- if(attr2 instanceof String & attr1 instanceof String) {
- // this is a hack for bug 110215, on SUN 1.4.x, \r
- // is stripped off when the stream is written to the
- // DOM
- // this is not the case for 1.5.x, so to be safe we
- // are stripping \r off all strings before we
- // compare for equality
- attr1 = ((String)attr1).replaceAll("\\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
- attr2 = ((String)attr2).replaceAll("\\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- if (!attr1.equals(attr2)) {
- return false;
- }
- } else {
- if (comp.compare(attr1, attr2) != 0) {
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns whether the two attributes are equal, considering comparator extensions.
+ *
+ * @param key attribute key
+ * @param attr1 attribute value
+ * @param attr2 attribute value to compare to, possibly <code>null</code>
+ * @return whether equivalent
+ *
+ * @since 3.12
+ */
+ protected static boolean compareAttribute(String key, Object attr1, Object attr2) {
+ if (attr2 == null) {
+ return false;
+ }
+ Comparator<Object> comp = fgLaunchManager.getComparator(key);
+ if (comp == null) {
+ String strAttr1 = null;
+ String strAttr2 = null;
+ if (fgIsSun14x) {
+ if(attr2 instanceof String & attr1 instanceof String) {
+ // this is a hack for bug 110215, on SUN 1.4.x, \r
+ // is stripped off when the stream is written to the
+ // DOM
+ // this is not the case for 1.5.x, so to be safe we
+ // are stripping \r off all strings before we
+ // compare for equality
+ strAttr1 = ((String)attr1).replaceAll("\\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ strAttr2 = ((String)attr2).replaceAll("\\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ if (!strAttr1.equals(strAttr2)) {
return false;
}
}
}
- return true;
+ if (strAttr1 == null && strAttr2 == null && !attr1.equals(attr2)) {
+ return false;
+ }
+ } else {
+ if (comp.compare(attr1, attr2) != 0) {
+ return false;
+ }
}
- return false;
+ return true;
}
/**
@@ -815,5 +953,89 @@ public class LaunchConfigurationInfo {
}
return null;
}
+
+ /**
+ * Sets whether this info is a prototype.
+ *
+ * @param isPrototype
+ *
+ * @since 3.12
+ */
+ protected void setIsPrototype(boolean isPrototype) {
+ fIsPrototype = isPrototype;
+ }
+
+ /**
+ * Returns whether this info is a prototype.
+ *
+ * @return whether a prototype
+ *
+ * @since 3.12
+ */
+ protected boolean isPrototype() {
+ return fIsPrototype;
+ }
+
+ /**
+ * Get the visible attributes of this prototype (return <code>null</code> if
+ * the launch configuration is not a prototype).
+ *
+ * @return the visible attributes of this prototype (return
+ * <code>null</code> if the launch configuration is not a
+ * prototype).
+ *
+ * @since 3.12
+ */
+ protected Set<String> getVisibleAttributes() {
+ if (!isPrototype()) {
+ return null;
+ } else if (fVisibleAttributes == null) {
+ initializeVisibleAttributes();
+ }
+ return fVisibleAttributes;
+ }
+
+ /**
+ * Initialize the visible attributes of this launch configuration. All
+ * attributes are visible by default.
+ *
+ * @since 3.12
+ */
+ private void initializeVisibleAttributes() {
+ fVisibleAttributes = new HashSet<>(getAttributeTable().keySet());
+ }
+
+ /**
+ * Set the visible attributes of this prototype. Do not call this method on
+ * a launch configuration that is not a prototype.
+ *
+ * @param visibleAttributes the visible attributes
+ *
+ * @since 3.12
+ */
+ protected void setVisibleAttributes(Set<String> visibleAttributes) {
+ if (visibleAttributes != null) {
+ fVisibleAttributes = new HashSet<>(visibleAttributes);
+ }
+ }
+
+ /**
+ * Set visibility of the given attribute. Do not call this method on a
+ * launch configuration that is not a prototype.
+ *
+ * @param attribute the given attribute
+ * @param visible the visibility
+ *
+ * @since 3.12
+ */
+ protected void setAttributeVisibility(String attribute, boolean visible) {
+ if (fVisibleAttributes != null) {
+ if (visible) {
+ fVisibleAttributes.add(attribute);
+ } else {
+ fVisibleAttributes.remove(attribute);
+ }
+ }
+ }
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java
index 8848883ed..cd7595266 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.core;
@@ -518,5 +519,37 @@ public class LaunchConfigurationType extends PlatformObject implements ILaunchCo
void resetPreferredDelegates() {
fPreferredDelegates = null;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfigurationType#getPrototypes()
+ */
+ @Override
+ public ILaunchConfiguration[] getPrototypes() throws CoreException {
+ return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(this, ILaunchConfiguration.PROTOTYPE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfigurationType#newPrototypeInstance(org.eclipse.core.resources.IContainer, java.lang.String)
+ */
+ @Override
+ public ILaunchConfigurationWorkingCopy newPrototypeInstance(IContainer container, String name) throws CoreException {
+ LaunchConfigurationWorkingCopy wc = new LaunchConfigurationWorkingCopy(container, name, this, true);
+ return wc;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfigurationType#supportsPrototypes()
+ */
+ @Override
+ public boolean supportsPrototypes() {
+ String allowPrototypesString = fElement.getAttribute(IConfigurationElementConstants.ALLOW_PROTOTYPES);
+ if (allowPrototypesString != null) {
+ if (allowPrototypesString.equalsIgnoreCase("true")) { //$NON-NLS-1$
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java
index cbf77aabf..ec489c414 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.core;
@@ -16,6 +17,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -91,7 +93,7 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
* working copy's attributes based on the original configuration
*/
protected LaunchConfigurationWorkingCopy(LaunchConfiguration original) throws CoreException {
- super(original.getName(), original.getContainer());
+ super(original.getName(), original.getContainer(), original.isPrototype());
copyFrom(original);
setOriginal(original);
fSuppressChange = false;
@@ -117,7 +119,7 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
* working copy's attributes based on the original configuration
*/
protected LaunchConfigurationWorkingCopy(LaunchConfigurationWorkingCopy parent) throws CoreException {
- super(parent.getName(), parent.getContainer());
+ super(parent.getName(), parent.getContainer(), parent.isPrototype());
copyFrom(parent);
setOriginal((LaunchConfiguration) parent.getOriginal());
fParent = parent;
@@ -136,7 +138,7 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
* working copy's attributes based on the original configuration
*/
protected LaunchConfigurationWorkingCopy(LaunchConfiguration original, String name) throws CoreException {
- super(name, original.getContainer());
+ super(name, original.getContainer(), original.isPrototype());
copyFrom(original);
fSuppressChange = false;
}
@@ -151,9 +153,26 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
* @param type the type of this working copy
*/
protected LaunchConfigurationWorkingCopy(IContainer container, String name, ILaunchConfigurationType type) {
- super(name, container);
+ this(container, name, type, false);
+ }
+
+ /**
+ * Constructs a new working copy to be created in the specified
+ * location.
+ *
+ * @param container the container that the configuration will be created in
+ * or <code>null</code> if to be local
+ * @param name the name of the new launch configuration
+ * @param type the type of this working copy
+ * @param prototype if this copy is a prototype or not
+ *
+ * @since 3.12
+ */
+ protected LaunchConfigurationWorkingCopy(IContainer container, String name, ILaunchConfigurationType type, boolean prototype) {
+ super(name, container, prototype);
setInfo(new LaunchConfigurationInfo());
getInfo().setType(type);
+ getInfo().setIsPrototype(prototype);
fSuppressChange = false;
}
@@ -227,7 +246,7 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
lmonitor.done();
}
}
- return new LaunchConfiguration(getName(), getContainer());
+ return new LaunchConfiguration(getName(), getContainer(), isPrototype());
}
/**
@@ -241,7 +260,7 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
// set up from/to information if this is a move
boolean moved = (!isNew() && isMoved());
if (moved) {
- ILaunchConfiguration to = new LaunchConfiguration(getName(), getContainer());
+ ILaunchConfiguration to = new LaunchConfiguration(getName(), getContainer(), isPrototype());
ILaunchConfiguration from = getOriginal();
getLaunchManager().setMovedFromTo(from, to);
}
@@ -379,9 +398,9 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
}
// notify of add/change for both local and shared configurations - see bug 288368
if (added) {
- getLaunchManager().launchConfigurationAdded(new LaunchConfiguration(getName(), getContainer()));
+ getLaunchManager().launchConfigurationAdded(new LaunchConfiguration(getName(), getContainer(), isPrototype()));
} else {
- getLaunchManager().launchConfigurationChanged(new LaunchConfiguration(getName(), getContainer()));
+ getLaunchManager().launchConfigurationChanged(new LaunchConfiguration(getName(), getContainer(), isPrototype()));
}
}
finally {
@@ -462,6 +481,15 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
}
/**
+ * @see ILaunchConfigurationWorkingCopy#setAttribute(String, Object)
+ */
+ @Override
+ public void setAttribute(String attributeName, Object value) {
+ getInfo().setAttribute(attributeName, value);
+ setDirty();
+ }
+
+ /**
* @see ILaunchConfigurationWorkingCopy#getOriginal()
*/
@Override
@@ -755,5 +783,81 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
public Object removeAttribute(String attributeName) {
return getInfo().removeAttribute(attributeName);
}
-}
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#copyAttributes(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public void copyAttributes(ILaunchConfiguration prototype) throws CoreException {
+ Map<String, Object> map = prototype.getAttributes();
+ LaunchConfigurationInfo info = getInfo();
+ info.setPrototype(prototype);
+ Set<String> prototypeVisibleAttributes = prototype.getPrototypeVisibleAttributes();
+ if (prototypeVisibleAttributes != null) {
+ prototypeVisibleAttributes.forEach(key -> {
+ Object value = map.get(key);
+ if (value != null) {
+ info.setAttribute(key, value);
+ }
+ });
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#setTemplate(org.eclipse.debug.core.ILaunchConfiguration, boolean)
+ */
+ @Override
+ public void setPrototype(ILaunchConfiguration prototype, boolean copy) throws CoreException {
+ if (prototype != null && !prototype.isPrototype()) {
+ throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugCoreMessages.LaunchConfigurationWorkingCopy_6));
+ }
+ if (prototype != null && prototype.isWorkingCopy()) {
+ throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugCoreMessages.LaunchConfigurationWorkingCopy_7));
+ }
+ if (prototype == null) {
+ getInfo().setPrototype(null);
+ removeAttribute(ATTR_PROTOTYPE);
+ } else {
+ if (isPrototype()) {
+ throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugCoreMessages.LaunchConfigurationWorkingCopy_8));
+ }
+ getInfo().setPrototype(prototype);
+ if (copy) {
+ copyAttributes(prototype);
+ }
+ setAttribute(ATTR_PROTOTYPE, prototype.getMemento());
+ setAttribute(IS_PROTOTYPE, false);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#doSave(int)
+ */
+ @Override
+ public ILaunchConfiguration doSave(int flag) throws CoreException {
+ Collection<ILaunchConfiguration> children = null;
+ if (UPDATE_PROTOTYPE_CHILDREN == flag) {
+ if (!isNew() && isMoved() && getParent() == null) {
+ children = getOriginal().getPrototypeChildren();
+ }
+ }
+ ILaunchConfiguration saved = doSave();
+ if (children != null) {
+ for (ILaunchConfiguration child : children) {
+ ILaunchConfigurationWorkingCopy wc = child.getWorkingCopy();
+ wc.setPrototype(saved, false);
+ wc.doSave();
+ }
+ }
+ return saved;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfiguration#setAttributeVisibility(String, boolean)
+ */
+ @Override
+ public void setPrototypeAttributeVisibility(String attribute, boolean visible) throws CoreException {
+ super.setPrototypeAttributeVisibility(attribute, visible);
+ setDirty();
+ }
+}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
index 32cdb6a01..f7078181f 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -12,6 +12,7 @@
* attempt to disconnect debug targets before terminating them
* Alena Laskavaia - Bug 259281
* Marc Khouzam - Bug 313143: Preferred Launch Delegate not recovered from preferences
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.core;
@@ -34,6 +35,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -378,7 +380,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
IResource resource = delta.getResource();
if (resource instanceof IFile) {
IFile file = (IFile)resource;
- if (ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION.equals(file.getFileExtension())) {
+ if (ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION.equals(file.getFileExtension()) || ILaunchConfiguration.LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION.equals(file.getFileExtension())) {
ILaunchConfiguration handle = new LaunchConfiguration(file);
switch (delta.getKind()) {
case IResourceDelta.ADDED :
@@ -476,7 +478,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
@Override
public boolean visit(IResourceProxy proxy) {
if (proxy.getType() == IResource.FILE) {
- if (ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION.equalsIgnoreCase(proxy.requestFullPath().getFileExtension())) {
+ if (ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION.equalsIgnoreCase(proxy.requestFullPath().getFileExtension()) | ILaunchConfiguration.LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION.equalsIgnoreCase(proxy.requestFullPath().getFileExtension())) {
fList.add(proxy.requestResource());
}
return false;
@@ -947,12 +949,33 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
ParserConfigurationException,
IOException,
SAXException {
+ return createInfoFromXML(stream, false);
+ }
+
+ /**
+ * Return a LaunchConfigurationInfo object initialized from XML contained in
+ * the specified stream. Simply pass out any exceptions encountered so that
+ * caller can deal with them. This is important since caller may need access
+ * to the actual exception.
+ *
+ * @param stream the {@link InputStream} to read from
+ * @param isPrototype if the XML corresponds to a prototype
+ * @return the new {@link LaunchConfigurationInfo}
+ * @throws CoreException if a problem is encountered
+ * @throws ParserConfigurationException if the stream fails to parse
+ * @throws IOException if there is a problem handling the given stream or
+ * writing the new info file
+ * @throws SAXException if there is a SAX parse exception
+ *
+ * @since 3.12
+ */
+ protected LaunchConfigurationInfo createInfoFromXML(InputStream stream, boolean isPrototype) throws CoreException, ParserConfigurationException, IOException, SAXException {
Element root = null;
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
root = parser.parse(new InputSource(stream)).getDocumentElement();
LaunchConfigurationInfo info = new LaunchConfigurationInfo();
- info.initializeFromXML(root);
+ info.initializeFromXML(root, isPrototype);
return info;
}
@@ -1011,23 +1034,37 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
IPath containerPath = LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH;
final File directory = containerPath.toFile();
if (directory.isDirectory()) {
- FilenameFilter filter = new FilenameFilter() {
+ List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>();
+ FilenameFilter configFilter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return dir.equals(directory) &&
name.endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION);
}
};
- File[] files = directory.listFiles(filter);
- if (files.length > 0) {
- List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>(10);
+ File[] configFiles = directory.listFiles(configFilter);
+ if (configFiles.length > 0) {
+ LaunchConfiguration config = null;
+ for (int i = 0; i < configFiles.length; i++) {
+ config = new LaunchConfiguration(LaunchConfiguration.getSimpleName(configFiles[i].getName()), null, false);
+ configs.add(config);
+ }
+ }
+ FilenameFilter prototypeFilter = new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return dir.equals(directory) && name.endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION);
+ }
+ };
+ File[] prototypeFiles = directory.listFiles(prototypeFilter);
+ if (prototypeFiles.length > 0) {
LaunchConfiguration config = null;
- for (int i = 0; i < files.length; i++) {
- config = new LaunchConfiguration(LaunchConfiguration.getSimpleName(files[i].getName()), null);
+ for (int i = 0; i < prototypeFiles.length; i++) {
+ config = new LaunchConfiguration(LaunchConfiguration.getSimpleName(prototypeFiles[i].getName()), null, true);
configs.add(config);
}
- return configs;
}
+ return configs;
}
return Collections.EMPTY_LIST;
}
@@ -1160,7 +1197,8 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
*/
protected synchronized String[] getAllSortedConfigNames() {
if (fSortedConfigNames == null) {
- ILaunchConfiguration[] configs = getLaunchConfigurations();
+ List<ILaunchConfiguration> collection = getAllLaunchConfigurations();
+ ILaunchConfiguration[] configs = collection.toArray(new ILaunchConfiguration[collection.size()]);
fSortedConfigNames = new String[configs.length];
for (int i = 0; i < configs.length; i++) {
fSortedConfigNames[i] = configs[i].getName();
@@ -1368,7 +1406,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
BufferedInputStream stream = null;
try {
stream = new BufferedInputStream(store.openInputStream(EFS.NONE, null));
- info = createInfoFromXML(stream);
+ info = createInfoFromXML(stream, isPrototype(store));
synchronized (this) {
fLaunchConfigurations.put(config, info);
}
@@ -1403,6 +1441,38 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
}
/**
+ * Check if the given {@link IFileStore} is a prototype.
+ *
+ * @param store the given {@link IFileStore}
+ * @return <code>true</code> if the given {@link IFileStore} is a prototype,
+ * <code>false</code> otherwise.
+ *
+ * @since 3.12
+ */
+ private boolean isPrototype(IFileStore store) {
+ if (store.getName().endsWith("." + ILaunchConfiguration.LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION)) { //$NON-NLS-1$
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Check if the given {@link File} is a prototype.
+ *
+ * @param file the given {@link File}
+ * @return <code>true</code> if the given {@link File} is a prototype,
+ * <code>false</code> otherwise.
+ *
+ * @since 3.12
+ */
+ private boolean isPrototype(File file) {
+ if (file.getName().endsWith("." + ILaunchConfiguration.LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION)) { //$NON-NLS-1$
+ return true;
+ }
+ return false;
+ }
+
+ /**
* @see ILaunchManager#getLaunchConfiguration(IFile)
*/
@Override
@@ -1425,8 +1495,33 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
*/
@Override
public synchronized ILaunchConfiguration[] getLaunchConfigurations() {
+ return getLaunchConfigurations(ILaunchConfiguration.CONFIGURATION);
+ }
+
+ /**
+ * @see org.eclipse.debug.core.ILaunchManager#getLaunchConfigurations(int)
+ */
+ @Override
+ public ILaunchConfiguration[] getLaunchConfigurations(int kinds) {
List<ILaunchConfiguration> allConfigs = getAllLaunchConfigurations();
- return allConfigs.toArray(new ILaunchConfiguration[allConfigs.size()]);
+ if (((kinds & ILaunchConfiguration.CONFIGURATION) > 0) && ((kinds & ILaunchConfiguration.PROTOTYPE) > 0)) {
+ // all kinds
+ return allConfigs.toArray(new ILaunchConfiguration[allConfigs.size()]);
+ } else {
+ List<ILaunchConfiguration> select = new ArrayList<ILaunchConfiguration>(allConfigs.size());
+ Iterator<ILaunchConfiguration> iterator = allConfigs.iterator();
+ while (iterator.hasNext()) {
+ ILaunchConfiguration config = iterator.next();
+ try {
+ if ((config.getKind() & kinds) > 0) {
+ select.add(config);
+ }
+ } catch (CoreException e) {
+ DebugPlugin.log(e);
+ }
+ }
+ return select.toArray(new ILaunchConfiguration[select.size()]);
+ }
}
/**
@@ -1434,9 +1529,17 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
*/
@Override
public synchronized ILaunchConfiguration[] getLaunchConfigurations(ILaunchConfigurationType type) throws CoreException {
+ return getLaunchConfigurations(type, ILaunchConfiguration.CONFIGURATION);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchManager#getLaunchConfigurations(org.eclipse.debug.core.ILaunchConfigurationType, int)
+ */
+ @Override
+ public synchronized ILaunchConfiguration[] getLaunchConfigurations(ILaunchConfigurationType type, int kinds) throws CoreException {
List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>();
for (ILaunchConfiguration config : getAllLaunchConfigurations()) {
- if (config.getType().equals(type)) {
+ if (config.getType().equals(type) && ((config.getKind() & kinds) > 0)) {
configs.add(config);
}
}
@@ -2571,7 +2674,11 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
if (!config.isLocal()) {
StringBuffer buf = new StringBuffer(config.getName());
buf.append('.');
- buf.append(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION);
+ if (config.isPrototype()) {
+ buf.append(ILaunchConfiguration.LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION);
+ } else {
+ buf.append(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION);
+ }
sharedConfigs.put(buf.toString(), config);
}
}
@@ -2592,7 +2699,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe
boolean added = !target.exists();
try {
copyFile(source, target);
- ILaunchConfiguration configuration = new LaunchConfiguration(LaunchConfiguration.getSimpleName(source.getName()), null);
+ ILaunchConfiguration configuration = new LaunchConfiguration(LaunchConfiguration.getSimpleName(source.getName()), null, isPrototype(source));
ILaunchConfiguration shared = sharedConfigs.get(target.getName());
if (shared != null) {
setMovedFromTo(shared, configuration);
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupMemberChangeListener.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupMemberChangeListener.java
index 3208b538b..55d63d0ca 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupMemberChangeListener.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupMemberChangeListener.java
@@ -7,6 +7,7 @@
*
* Contributors:
* SSI Schaefer IT Solutions GmbH
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.core.groups;
@@ -40,7 +41,7 @@ public class GroupMemberChangeListener implements ILaunchConfigurationListener {
return;
}
try {
- for (ILaunchConfiguration c : DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(type)) {
+ for (ILaunchConfiguration c : DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(type, ILaunchConfiguration.CONFIGURATION | ILaunchConfiguration.PROTOTYPE)) {
List<GroupLaunchElement> elements = GroupLaunchConfigurationDelegate.createLaunchElements(c);
boolean updated = false;
for (GroupLaunchElement e : elements) {
diff --git a/org.eclipse.debug.core/pom.xml b/org.eclipse.debug.core/pom.xml
index 05b173188..dc51ec7bf 100644
--- a/org.eclipse.debug.core/pom.xml
+++ b/org.eclipse.debug.core/pom.xml
@@ -18,6 +18,6 @@
</parent>
<groupId>org.eclipse.debug</groupId>
<artifactId>org.eclipse.debug.core</artifactId>
- <version>3.11.100-SNAPSHOT</version>
+ <version>3.12.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/org.eclipse.debug.core/schema/launchConfigurationTypes.exsd b/org.eclipse.debug.core/schema/launchConfigurationTypes.exsd
index aa2db7717..aed236e9b 100644
--- a/org.eclipse.debug.core/schema/launchConfigurationTypes.exsd
+++ b/org.eclipse.debug.core/schema/launchConfigurationTypes.exsd
@@ -156,6 +156,13 @@ Since 3.3, the &lt;code&gt;sourceLocatorId&lt;/code&gt; can also be specified vi
</appinfo>
</annotation>
</attribute>
+ <attribute name="allowPrototypes" type="boolean">
+ <annotation>
+ <documentation>
+ specifies whether this launch configuration type allows prototypes or not. Defaults to &lt;code&gt;false&lt;/code&gt; if not specified. This attribute was added in 4.7 release.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java
index 65dc6c1bc..df3819c7d 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.tests.launching;
@@ -266,6 +267,38 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
}
/**
+ * Creates and returns a new launch config prototype with the given name, local
+ * or shared, with 4 attributes:
+ * - String1 = "String1"
+ * - Int1 = 1
+ * - Boolean1 = true
+ * - Boolean2 = false
+ */
+ protected ILaunchConfigurationWorkingCopy newPrototype(IContainer container, String name) throws CoreException {
+ ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE);
+ assertTrue("Should support debug mode", type.supportsMode(ILaunchManager.DEBUG_MODE)); //$NON-NLS-1$
+ assertTrue("Should support run mode", type.supportsMode(ILaunchManager.RUN_MODE)); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = type.newPrototypeInstance(container, name);
+ wc.setAttribute("String1", "String1"); //$NON-NLS-1$ //$NON-NLS-2$
+ wc.setAttribute("Int1", 1); //$NON-NLS-1$
+ wc.setAttribute("Boolean1", true); //$NON-NLS-1$
+ wc.setAttribute("Boolean2", false); //$NON-NLS-1$
+ assertTrue("Should need saving", wc.isDirty()); //$NON-NLS-1$
+ return wc;
+ }
+
+ /**
+ * Creates and returns a new launch configuration prototype with the given name, local
+ * or shared, with no attributes
+ */
+ protected ILaunchConfigurationWorkingCopy newEmptyPrototype(IContainer container, String name) throws CoreException {
+ ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE);
+ ILaunchConfigurationWorkingCopy wc = type.newPrototypeInstance(container, name);
+ assertEquals("Should have no attributes", 0, wc.getAttributes().size()); //$NON-NLS-1$
+ return wc;
+ }
+
+ /**
* Returns whether the given handle is contained in the specified
* array of handles.
*/
@@ -1560,4 +1593,177 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
config.setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_PATHS, paths);
config.setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES, types);
}
+
+ /**
+ * Test copying attributes from one configuration to another.
+ *
+ * @throws CoreException
+ */
+ public void testCopyAttributes() throws CoreException {
+ ILaunchConfigurationWorkingCopy source = newPrototype(null, "test-copy-attributes-source"); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy dest = newEmptyConfiguration(null, "test-copy-attributes-dest"); //$NON-NLS-1$
+ dest.copyAttributes(source);
+ assertTrue("String1 should be String1", dest.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", dest.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", dest.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !dest.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Tests that creation from a prototype works.
+ *
+ * @throws CoreException
+ */
+ public void testCreationFromPrototype() throws CoreException {
+ ILaunchConfigurationWorkingCopy temp = newPrototype(null, "test-creation-from-prototype"); //$NON-NLS-1$
+ temp.setAttribute("TEMPLATE", "TEMPLATE"); //$NON-NLS-1$ //$NON-NLS-2$
+ ILaunchConfiguration prototype = temp.doSave();
+ ILaunchConfigurationType type = temp.getType();
+
+ ILaunchConfigurationWorkingCopy config = type.newInstance(null, "test-scopes"); //$NON-NLS-1$
+ config.setPrototype(prototype, true);
+ assertNotNull("Made from wrong prototype", config.getAttribute("TEMPLATE", (String)null)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Should refer to creation prototype", prototype, config.getPrototype()); //$NON-NLS-1$
+ }
+
+ /**
+ * Tests setting the 'isPrototype' attribute.
+ *
+ * @throws CoreException
+ */
+ public void testIsPrototype() throws CoreException {
+ ILaunchConfigurationWorkingCopy wc = newPrototype(null, "test-is-prototype"); //$NON-NLS-1$
+ ILaunchConfiguration prototype = wc.doSave();
+ assertTrue("Should be a prototype", prototype.isPrototype()); //$NON-NLS-1$
+ ILaunchConfiguration[] prototypes = wc.getType().getPrototypes();
+ List<ILaunchConfiguration> list = new ArrayList<ILaunchConfiguration>();
+ for (int i = 0; i < prototypes.length; i++) {
+ list.add(prototypes[i]);
+ }
+ assertFalse("Expecting at least prototype", list.isEmpty()); //$NON-NLS-1$
+ assertTrue("Missing created prototype", list.contains(prototype)); //$NON-NLS-1$
+ }
+
+ /**
+ * Tests finding references to a prototype.
+ *
+ * @throws CoreException
+ */
+ public void testPrototypeChildren() throws CoreException {
+ ILaunchConfigurationWorkingCopy wc = newPrototype(null, "test-references"); //$NON-NLS-1$
+ ILaunchConfiguration prototype = wc.doSave();
+
+ ILaunchConfigurationWorkingCopy r1 = newConfiguration(null, "referee-1"); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy r2 = newConfiguration(null, "referee-2"); //$NON-NLS-1$
+
+ r1.setPrototype(prototype, false);
+ r2.setPrototype(prototype, false);
+
+ ILaunchConfiguration s1 = r1.doSave();
+ ILaunchConfiguration s2 = r2.doSave();
+
+ Iterable<ILaunchConfiguration> children = prototype.getPrototypeChildren();
+ List<ILaunchConfiguration> list = new ArrayList<ILaunchConfiguration>();
+ for (ILaunchConfiguration child : children) {
+ list.add(child);
+ }
+ assertEquals("Wrong number of prototype children", 2, list.size()); //$NON-NLS-1$
+ assertTrue("Missing reference", list.contains(s1)); //$NON-NLS-1$
+ assertTrue("Missing reference", list.contains(s2)); //$NON-NLS-1$
+ }
+
+ /**
+ * Tests that when an attribute is removed from a working copy, it does not
+ * get inherited from its prototype.
+ *
+ * @throws CoreException
+ */
+ public void testPrototypeRemoveBehavior() throws CoreException {
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "test-remove"); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy t1 = newEmptyPrototype(null, "prototype-1"); //$NON-NLS-1$
+ t1.setAttribute("COMMON", "TEMPLATE-1"); //$NON-NLS-1$ //$NON-NLS-2$
+ t1.setAttribute("T1", "T1"); //$NON-NLS-1$ //$NON-NLS-2$
+ t1.setAttribute("String1", "String2"); //$NON-NLS-1$ //$NON-NLS-2$
+ ILaunchConfiguration prototype = t1.doSave();
+
+ assertEquals("String1", wc.getAttribute("String1", "wrong")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ wc.setPrototype(prototype, true);
+ wc.removeAttribute("String1"); //$NON-NLS-1$
+ assertEquals("TEMPLATE-1", wc.getAttribute("COMMON", (String)null)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("T1", wc.getAttribute("T1", (String)null)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertNull(wc.getAttribute("String1", (String)null)); //$NON-NLS-1$
+
+ }
+
+ /**
+ * Tests that setting a configuration's prototype to null cleans its prototype
+ * association.
+ *
+ * @throws CoreException
+ */
+ public void testUnPrototype() throws CoreException {
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "test-un-prototype"); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy t1 = newEmptyPrototype(null, "prototype-un"); //$NON-NLS-1$
+ t1.setAttribute("COMMON", "PROTOTYPE-1"); //$NON-NLS-1$ //$NON-NLS-2$
+ t1.setAttribute("T1", "T1"); //$NON-NLS-1$ //$NON-NLS-2$
+ t1.setAttribute("String1", "String2"); //$NON-NLS-1$ //$NON-NLS-2$
+ ILaunchConfiguration prototype = t1.doSave();
+ wc.setPrototype(prototype, true);
+ ILaunchConfiguration configuration = wc.doSave();
+ assertEquals(prototype, configuration.getPrototype());
+ wc = configuration.getWorkingCopy();
+ wc.setPrototype(null, false);
+ configuration = wc.doSave();
+ assertNull(configuration.getPrototype());
+ Iterable<ILaunchConfiguration> children = t1.getPrototypeChildren();
+ assertFalse(children.iterator().hasNext());
+ }
+
+ /**
+ * Tests that nested prototypes are not allowed.
+ *
+ * @throws CoreException
+ */
+ public void testNestedPrototypes() throws CoreException {
+ ILaunchConfigurationWorkingCopy t1 = newPrototype(null, "test-nest-root"); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy t2 = newPrototype(null, "prototype-nested"); //$NON-NLS-1$
+ ILaunchConfiguration prototype = t1.doSave();
+ try {
+ t2.setPrototype(prototype, true);
+ } catch (CoreException e) {
+ return;
+ }
+ assertTrue("Shoud not be able to nest prototypes", false); //$NON-NLS-1$
+ }
+
+ /**
+ * Test that you cannot set a config's prototype to be a non-prototype.
+ *
+ * @throws CoreException
+ */
+ public void testIllegalPrototype() throws CoreException {
+ ILaunchConfigurationWorkingCopy c1 = newConfiguration(null, "test-config"); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy t1 = newConfiguration(null, "test-not-a-prototype"); //$NON-NLS-1$
+ ILaunchConfiguration config = t1.doSave();
+ try {
+ c1.setPrototype(config, true);
+ } catch (CoreException e) {
+ // expected
+ return;
+ }
+ assertTrue("Should not be able to set configration as prototype", false); //$NON-NLS-1$
+ }
+
+ /**
+ * Test that a prototype can be duplicated (and results in a prototype).
+ *
+ * @throws CoreException
+ */
+ public void testCopyPrototype() throws CoreException {
+ ILaunchConfigurationWorkingCopy t1 = newEmptyPrototype(null, "prototype-to-duplicate"); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy t2 = t1.copy("duplicate-prototype"); //$NON-NLS-1$
+ assertTrue(t2.isPrototype());
+ }
+
}
diff --git a/org.eclipse.debug.ui/icons/full/dlcl16/link_proto.png b/org.eclipse.debug.ui/icons/full/dlcl16/link_proto.png
new file mode 100644
index 000000000..b60db5f43
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/dlcl16/link_proto.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/dlcl16/link_proto@2x.png b/org.eclipse.debug.ui/icons/full/dlcl16/link_proto@2x.png
new file mode 100644
index 000000000..0b4e646e6
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/dlcl16/link_proto@2x.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/dlcl16/new_proto.png b/org.eclipse.debug.ui/icons/full/dlcl16/new_proto.png
new file mode 100644
index 000000000..b73907014
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/dlcl16/new_proto.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/dlcl16/new_proto@2x.png b/org.eclipse.debug.ui/icons/full/dlcl16/new_proto@2x.png
new file mode 100644
index 000000000..377b53c83
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/dlcl16/new_proto@2x.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/dlcl16/reset_proto.png b/org.eclipse.debug.ui/icons/full/dlcl16/reset_proto.png
new file mode 100644
index 000000000..3aa0a14d8
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/dlcl16/reset_proto.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/dlcl16/reset_proto@2x.png b/org.eclipse.debug.ui/icons/full/dlcl16/reset_proto@2x.png
new file mode 100644
index 000000000..253851ede
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/dlcl16/reset_proto@2x.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/dlcl16/unlink_proto.png b/org.eclipse.debug.ui/icons/full/dlcl16/unlink_proto.png
new file mode 100644
index 000000000..f46aa24ac
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/dlcl16/unlink_proto.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/dlcl16/unlink_proto@2x.png b/org.eclipse.debug.ui/icons/full/dlcl16/unlink_proto@2x.png
new file mode 100644
index 000000000..47935a8b1
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/dlcl16/unlink_proto@2x.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/elcl16/link_proto.png b/org.eclipse.debug.ui/icons/full/elcl16/link_proto.png
new file mode 100644
index 000000000..b60db5f43
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/elcl16/link_proto.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/elcl16/link_proto@2x.png b/org.eclipse.debug.ui/icons/full/elcl16/link_proto@2x.png
new file mode 100644
index 000000000..0b4e646e6
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/elcl16/link_proto@2x.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/elcl16/new_proto.png b/org.eclipse.debug.ui/icons/full/elcl16/new_proto.png
new file mode 100644
index 000000000..b73907014
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/elcl16/new_proto.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/elcl16/new_proto@2x.png b/org.eclipse.debug.ui/icons/full/elcl16/new_proto@2x.png
new file mode 100644
index 000000000..377b53c83
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/elcl16/new_proto@2x.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/elcl16/reset_proto.png b/org.eclipse.debug.ui/icons/full/elcl16/reset_proto.png
new file mode 100644
index 000000000..3aa0a14d8
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/elcl16/reset_proto.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/elcl16/reset_proto@2x.png b/org.eclipse.debug.ui/icons/full/elcl16/reset_proto@2x.png
new file mode 100644
index 000000000..253851ede
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/elcl16/reset_proto@2x.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/elcl16/unlink_proto.png b/org.eclipse.debug.ui/icons/full/elcl16/unlink_proto.png
new file mode 100644
index 000000000..f46aa24ac
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/elcl16/unlink_proto.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/elcl16/unlink_proto@2x.png b/org.eclipse.debug.ui/icons/full/elcl16/unlink_proto@2x.png
new file mode 100644
index 000000000..47935a8b1
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/elcl16/unlink_proto@2x.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/obj16/check.png b/org.eclipse.debug.ui/icons/full/obj16/check.png
new file mode 100644
index 000000000..e0e54b257
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/obj16/check.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/obj16/check@2x.png b/org.eclipse.debug.ui/icons/full/obj16/check@2x.png
new file mode 100644
index 000000000..6e345721b
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/obj16/check@2x.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/obj16/proto_tab.png b/org.eclipse.debug.ui/icons/full/obj16/proto_tab.png
new file mode 100644
index 000000000..07232835a
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/obj16/proto_tab.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/obj16/proto_tab@2x.png b/org.eclipse.debug.ui/icons/full/obj16/proto_tab@2x.png
new file mode 100644
index 000000000..a3e81c6a0
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/obj16/proto_tab@2x.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/obj16/uncheck.png b/org.eclipse.debug.ui/icons/full/obj16/uncheck.png
new file mode 100644
index 000000000..0456971ef
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/obj16/uncheck.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/obj16/uncheck@2x.png b/org.eclipse.debug.ui/icons/full/obj16/uncheck@2x.png
new file mode 100644
index 000000000..967c9f937
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/obj16/uncheck@2x.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/ovr16/prototype.png b/org.eclipse.debug.ui/icons/full/ovr16/prototype.png
new file mode 100644
index 000000000..c055c4f06
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/ovr16/prototype.png
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/ovr16/prototype@2x.png b/org.eclipse.debug.ui/icons/full/ovr16/prototype@2x.png
new file mode 100644
index 000000000..85db48979
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/ovr16/prototype@2x.png
Binary files differ
diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties
index a6d2cbe10..53ec0e661 100644
--- a/org.eclipse.debug.ui/plugin.properties
+++ b/org.eclipse.debug.ui/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2016 IBM Corporation and others.
+# Copyright (c) 2000, 2017 IBM Corporation 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
@@ -11,6 +11,7 @@
# Wind River Systems - Pawel Piech - Added Modules view (bug 211158)
# Wind River Systems - Ted Williams -[Memory View] Memory View: Workflow Enhancements (bug 215432)
# Patrick Chuong (Texas Instruments) - Move debug toolbar actions to main window (Bug 332784)
+# Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
###############################################################################
pluginName=Debug UI
@@ -400,4 +401,6 @@ console.in.label= Standard in
console.err.label= Standard error
debug.ui.component.label = Platform Debug UI
debug.core.component.label = Platform Debug Core
-GroupLaunch.description=Launch several other configurations sequentially \ No newline at end of file
+GroupLaunch.description=Launch several other configurations sequentially
+
+prototype.decorator.label = Prototype Decorator \ No newline at end of file
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index 4fa4d6646..530e48f1f 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<!--
- Copyright (c) 2005, 2016 IBM Corporation and others.
+ Copyright (c) 2005, 2017 IBM Corporation 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
@@ -10,7 +10,8 @@
Contributors:
IBM Corporation - initial API and implementation
Patrick Chuong (Texas Instruments) - Improve usability of the breakpoint view (Bug 238956)
- Patrick Chuong (Texas Instruments) - Move debug toolbar actions to main window (Bug 332784)
+ Patrick Chuong (Texas Instruments) - Move debug toolbar actions to main window (Bug 332784)
+ Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
-->
<plugin>
@@ -3284,4 +3285,20 @@ M4 = Platform-specific fourth key
contentType="org.eclipse.core.runtime.text">
</hoverProvider>
</extension>
+ <extension
+ point="org.eclipse.ui.decorators">
+ <decorator
+ class="org.eclipse.debug.ui.PrototypeDecorator"
+ id="org.eclipse.debug.ui.prototype.decorator"
+ label="%prototype.decorator.label"
+ lightweight="true"
+ location="TOP_RIGHT"
+ state="true">
+ <enablement>
+ <objectClass
+ name="org.eclipse.debug.internal.core.LaunchConfiguration">
+ </objectClass>
+ </enablement>
+ </decorator>
+ </extension>
</plugin>
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java
index b1d01231a..68ec975bd 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java
@@ -12,6 +12,7 @@
* Wind River Systems - Pawel Piech - Added Modules view (bug 211158)
* Lars.Vogel <Lars.Vogel@gmail.com> - Bug 430620
* Lucas Bullen <lbullen@redhat.com> - Bug 518652
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui;
@@ -117,6 +118,10 @@ public class DebugPluginImages {
declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_NEW_CONFIG, DLCL + "new_con.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_DELETE_CONFIG, DLCL + "rem_co.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_FILTER_CONFIGS, DLCL + "filter_ps.png"); //$NON-NLS-1$
+ declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_NEW_PROTO, DLCL + "new_proto.png"); //$NON-NLS-1$
+ declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_LINK_PROTO, DLCL + "link_proto.png"); //$NON-NLS-1$
+ declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_UNLINK_PROTO, DLCL + "unlink_proto.png"); //$NON-NLS-1$
+ declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_RESET_PROTO, DLCL + "reset_proto.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_DISCONNECT, DLCL + "disconnect_co.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_SUSPEND, DLCL + "suspend_co.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_RESUME, DLCL + "resume_co.png"); //$NON-NLS-1$
@@ -156,6 +161,10 @@ public class DebugPluginImages {
declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_DUPLICATE_CONFIG, ELCL + "copy_edit_co.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_NEW_CONFIG, ELCL + "new_con.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_DELETE_CONFIG, ELCL + "delete_config.png"); //$NON-NLS-1$
+ declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_NEW_PROTO, ELCL + "new_proto.png"); //$NON-NLS-1$
+ declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_LINK_PROTO, ELCL + "link_proto.png"); //$NON-NLS-1$
+ declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_UNLINK_PROTO, ELCL + "unlink_proto.png"); //$NON-NLS-1$
+ declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_RESET_PROTO, ELCL + "reset_proto.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_SUSPEND, ELCL + "suspend_co.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_RESUME, ELCL + "resume_co.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_STEP_RETURN, ELCL + "stepreturn_co.png"); //$NON-NLS-1$
@@ -209,12 +218,15 @@ public class DebugPluginImages {
declareRegistryImage(IInternalDebugUIConstants.IMG_OBJECT_MEMORY, OBJECT + "memory_obj.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_OBJS_BREAKPOINT_TYPE, OBJECT + "brkp_type.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_OBJS_LAUNCH_GROUP, OBJECT + "lgroup_obj.png"); //$NON-NLS-1$
+ declareRegistryImage(IInternalDebugUIConstants.IMG_OBJS_CHECK, OBJECT + "check.png"); //$NON-NLS-1$
+ declareRegistryImage(IInternalDebugUIConstants.IMG_OBJS_UNCHECK, OBJECT + "uncheck.png"); //$NON-NLS-1$
// tabs
declareRegistryImage(IInternalDebugUIConstants.IMG_OBJS_COMMON_TAB, OBJECT + "common_tab.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_OBJS_REFRESH_TAB, OBJECT + "refresh_tab.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_OBJS_PERSPECTIVE_TAB, OBJECT + "persp_tab.png"); //$NON-NLS-1$
declareRegistryImage(IDebugUIConstants.IMG_OBJS_ENVIRONMENT, OBJECT + "environment_obj.png"); //$NON-NLS-1$
+ declareRegistryImage(IInternalDebugUIConstants.IMG_OBJS_PROTO_TAB, OBJECT + "proto_tab.png"); //$NON-NLS-1$
// Views
declareRegistryImage(IDebugUIConstants.IMG_VIEW_BREAKPOINTS, VIEW + "breakpoint_view.png"); //$NON-NLS-1$
@@ -240,6 +252,7 @@ public class DebugPluginImages {
declareRegistryImage(IInternalDebugUIConstants.IMG_OVR_TRANSPARENT, OVR + "transparent.png"); //$NON-NLS-1$
declareRegistryImage(IDebugUIConstants.IMG_OVR_SKIP_BREAKPOINT, OVR + "skip_breakpoint_ov.png"); //$NON-NLS-1$
declareRegistryImage(IInternalDebugUIConstants.IMG_OVR_SHOW_LOGICAL_STRUCTURE, OVR + "var_cntnt_prvdr_ov.png"); //$NON-NLS-1$
+ declareRegistryImage(IDebugUIConstants.IMG_OVR_PROTOTYPE, OVR + "prototype.png"); //$NON-NLS-1$
//source location
declareRegistryImage(IInternalDebugUIConstants.IMG_SRC_LOOKUP_MENU, ELCL + "edtsrclkup_co.png"); //$NON-NLS-1$
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java
index aeae3b518..3ad431651 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -9,6 +9,7 @@
* IBM - Initial API and implementation
* Wind River Systems - Ted Williams - [Memory View] Memory View: Workflow Enhancements (Bug 215432)
* Remy Chi Jian Suen - Make WorkingDirectoryBlock from JDT a Debug API class (Bug 221973)
+ * Obeo - Axel Richard - Launch configurations prototypes (Bug 41353)
*******************************************************************************/
package org.eclipse.debug.internal.ui;
@@ -244,6 +245,7 @@ public class DebugUIMessages extends NLS {
public static String GroupLaunch_Error;
public static String GroupLaunchConfigurationSelectionDialog_0;
public static String GroupLaunchConfigurationSelectionDialog_1;
+ public static String GroupLaunchConfigurationSelectionDialog_2;
public static String GroupLaunchConfigurationSelectionDialog_10;
public static String GroupLaunchConfigurationSelectionDialog_11;
public static String GroupLaunchConfigurationSelectionDialog_12;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties
index 386d6fe44..6f7a9d77d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2012 IBM Corporation and others.
+# Copyright (c) 2000, 2017 IBM Corporation 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
@@ -9,6 +9,7 @@
# IBM Corporation - initial API and implementation
# Wind River Systems - Ted Williams - [Memory View] Memory View: Workflow Enhancements (Bug 215432)
# Remy Chi Jian Suen - Make WorkingDirectoryBlock from JDT a Debug API class (Bug 221973)
+# Obeo - Axel Richard - Launch configurations prototypes (Bug 41353)
###############################################################################
DebugUIPlugin_23=Build in Progress
@@ -123,6 +124,7 @@ GroupLaunchConfigurationSelectionDialog_7=Select a launch configuration
GroupLaunchConfigurationSelectionDialog_8=&Post launch action:
GroupLaunchConfigurationSelectionDialog_9=&Seconds:
GroupLaunchConfigurationSelectionDialog_1=Selected launch mode is not supported for selected launch configuration(s)
+GroupLaunchConfigurationSelectionDialog_2=The selection contains prototype(s)
GroupLaunchConfigurationSelectionDialog_10=Enter valid number of seconds
GroupLaunchConfigurationSelectionDialog_11=Select only one launch configuration
GroupLaunchConfigurationSelectionDialog_12=Add Launch Configuration
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java
index 2ae06eff4..868bbcffc 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* QNX Software Systems - Mikhail Khodjaiants - Registers View (Bug 53640)
* Wind River Systems - Pawel Piech - Added Modules view (bug 211158)
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui;
@@ -140,6 +141,7 @@ public interface IDebugHelpContextIds {
public static final String LAUNCH_CONFIGURATION_DIALOG_PERSPECTIVE_TAB = PREFIX + "launch_configuration_dialog_perspective_tab"; //$NON-NLS-1$
public static final String LAUNCH_CONFIGURATION_DIALOG_REFRESH_TAB = PREFIX + "launch_configuration_dialog_refresh_tab"; //$NON-NLS-1$
public static final String LAUNCH_CONFIGURATION_DIALOG_ENVIRONMENT_TAB = PREFIX + "launch_configuration_dialog_environment_tab"; //$NON-NLS-1$
+ public static final String LAUNCH_CONFIGURATION_DIALOG_PROTOTYPE_TAB = PREFIX + "launch_configuration_dialog_prototype_tab"; //$NON-NLS-1$
// Working set page
public static final String WORKING_SET_PAGE = PREFIX + "working_set_page_context"; //$NON-NLS-1$
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java
index 093a9648c..b404e9fa9 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java
@@ -10,6 +10,7 @@
* QNX Software Systems - Mikhail Khodjaiants - Bug 114664
* Wind River Systems - Pawel Piech - Added Modules view (bug 211158)
* Lucas Bullen (Red Hat Inc.) - Bug 518652
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui;
@@ -70,6 +71,10 @@ public interface IInternalDebugUIConstants {
public static final String IMG_DLCL_DUPLICATE_CONFIG = "IMG_DLCL_DUPLICATE_CONFIG"; //$NON-NLS-1$
public static final String IMG_DLCL_DELETE_CONFIG = "IMG_DLCL_DELETE_CONFIG"; //$NON-NLS-1$
public static final String IMG_DLCL_FILTER_CONFIGS = "IMG_DLCL_FILTER_CONFIGS"; //$NON-NLS-1$
+ public static final String IMG_DLCL_NEW_PROTO = "IMG_DLCL_NEW_PROTO"; //$NON-NLS-1$
+ public static final String IMG_DLCL_LINK_PROTO = "IMG_DLCL_LINK_PROTO"; //$NON-NLS-1$
+ public static final String IMG_DLCL_UNLINK_PROTO = "IMG_DLCL_UNLINK_PROTO"; //$NON-NLS-1$
+ public static final String IMG_DLCL_RESET_PROTO = "IMG_DLCL_RESET_PROTO"; //$NON-NLS-1$
public static final String IMG_DLCL_SUSPEND = "IMG_DLCL_SUSPEND"; //$NON-NLS-1$
public static final String IMG_DLCL_RESUME = "IMG_DLCL_RESUME"; //$NON-NLS-1$
public static final String IMG_DLCL_STEP_RETURN = "IMG_DLCL_STEP_RETURN"; //$NON-NLS-1$
@@ -114,6 +119,10 @@ public interface IInternalDebugUIConstants {
public static final String IMG_ELCL_DELETE_CONFIG = "IMG_ELCL_DELETE_CONFIG"; //$NON-NLS-1$
public static final String IMG_ELCL_FILTER_CONFIGS = "IMG_ELCL_FILTER_CONFIGS"; //$NON-NLS-1$
public static final String IMG_ELCL_DUPLICATE_CONFIG = "IMG_ELCL_DUPLICATE_CONFIG"; //$NON-NLS-1$
+ public static final String IMG_ELCL_NEW_PROTO = "IMG_ELCL_NEW_PROTO"; //$NON-NLS-1$
+ public static final String IMG_ELCL_LINK_PROTO = "IMG_ELCL_LINK_PROTO"; //$NON-NLS-1$
+ public static final String IMG_ELCL_UNLINK_PROTO = "IMG_ELCL_UNLINK_PROTO"; //$NON-NLS-1$
+ public static final String IMG_ELCL_RESET_PROTO = "IMG_ELCL_RESET_PROTO"; //$NON-NLS-1$
public static final String IMG_ELCL_SUSPEND = "IMG_ELCL_SUSPEND"; //$NON-NLS-1$
public static final String IMG_ELCL_RESUME = "IMG_ELCL_RESUME"; //$NON-NLS-1$
public static final String IMG_ELCL_STEP_RETURN = "IMG_ELCL_STEP_RETURN"; //$NON-NLS-1$
@@ -140,7 +149,10 @@ public interface IInternalDebugUIConstants {
public static final String IMG_OBJECT_MEMORY_CHANGED="IMG_OBJECT_MEMORY_CHANGED"; //$NON-NLS-1$
public static final String IMG_OBJECT_MEMORY="IMG_OBJECT_MEMORY"; //$NON-NLS-1$
public static final String IMG_OBJS_BREAKPOINT_TYPE="IMG_OBJ_BREAKPOINT_TYPE"; //$NON-NLS-1$
- public static final String IMG_OBJS_LAUNCH_GROUP = "IMG_OBJ_LAUNCH_GROUP"; //$NON-NLS-1$
+ public static final String IMG_OBJS_LAUNCH_GROUP = "IMG_OBJ_LAUNCH_GROUP"; //$NON-NLS-1$
+ public static final String IMG_OBJS_CHECK = "IMG_OBJS_CHECK"; //$NON-NLS-1$
+ public static final String IMG_OBJS_UNCHECK = "IMG_OBJS_UNCHECK"; //$NON-NLS-1$
+ public static final String IMG_OBJS_PROTO_TAB = "IMG_OBJS_PROTO_TAB"; //$NON-NLS-1$
// wizard images
public static final String IMG_WIZBAN_IMPORT_BREAKPOINTS = "IMG_WIZBAN_IMPORT_BREAKPOINTS"; //$NON-NLS-1$
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationSelectionDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationSelectionDialog.java
index 3b951a736..2b5f0ac04 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationSelectionDialog.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationSelectionDialog.java
@@ -9,6 +9,7 @@
* QNX Software Systems - initial API and implementation
* Freescale Semiconductor
* SSI Schaefer
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.groups;
@@ -104,10 +105,10 @@ class GroupLaunchConfigurationSelectionDialog extends TitleAreaDialog implements
if (type.equals(groupType)) {
// we're hiding ourselves. if we're the only group,
// don't show the type.
- return getLaunchManager().getLaunchConfigurations(type).length > 1;
+ return getLaunchManager().getLaunchConfigurations(type, ILaunchConfiguration.CONFIGURATION).length > 1;
}
- return getLaunchManager().getLaunchConfigurations(type).length > 0;
+ return getLaunchManager().getLaunchConfigurations(type, ILaunchConfiguration.CONFIGURATION).length > 0;
} else if (element instanceof ILaunchConfiguration) {
ILaunchConfiguration c = (ILaunchConfiguration) element;
if (c.getName().equals(self.getName()) && c.getType().equals(groupType)) {
@@ -388,7 +389,10 @@ class GroupLaunchConfigurationSelectionDialog extends TitleAreaDialog implements
}
setErrorMessage(isValid ? null : DebugUIMessages.GroupLaunchConfigurationSelectionDialog_1);
}
-
+ if (isValid && sel.isPrototype()) {
+ isValid = false;
+ setErrorMessage(DebugUIMessages.GroupLaunchConfigurationSelectionDialog_2);
+ }
if (!isValid) {
break;
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java
index 7425eb494..e3084a035 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* Lars Vogel <Lars.Vogel@vogella.com> - Bug 490755
* Lucas Bullen <lbullen@redhat.com> & Ian Pun <ipun@redhat.com> - Bug 518652
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.importexport.launchconfigurations;
@@ -87,7 +88,7 @@ public class ExportLaunchConfigurationsWizardPage extends WizardPage {
public Object[] getChildren(Object parentElement) {
if(parentElement instanceof ILaunchConfigurationType) {
try {
- return lm.getLaunchConfigurations((ILaunchConfigurationType) parentElement);
+ return lm.getLaunchConfigurations((ILaunchConfigurationType) parentElement, ILaunchConfiguration.CONFIGURATION | ILaunchConfiguration.PROTOTYPE);
}
catch (Exception e) {
DebugUIPlugin.logErrorMessage(e.getMessage());
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizardPage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizardPage.java
index 4cd723ce9..61703d169 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizardPage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizardPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 IBM Corporation and others.
+ * Copyright (c) 2007, 2017 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.importexport.launchconfigurations;
@@ -110,7 +111,7 @@ public class ImportLaunchConfigurationsWizardPage extends WizardResourceImportPa
if(child.isFile()) {
Path childpath = new Path(child.getAbsolutePath());
String extension = childpath.getFileExtension();
- if(extension != null && extension.equals(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION)) {
+ if (extension != null && (extension.equals(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION) || extension.equals(ILaunchConfiguration.LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION))) {
newelement = new DebugFileSystemElement(provider.getLabel(child), this, provider.isFolder(child));
newelement.setFileSystemObject(child);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationPrototypeAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationPrototypeAction.java
new file mode 100644
index 000000000..d817072d6
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationPrototypeAction.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.launchConfigurations;
+
+import org.eclipse.core.runtime.CoreException;
+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.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Creates a new launch configuration prototype based on the selection.
+ *
+ * @since 3.13
+ */
+public class CreateLaunchConfigurationPrototypeAction extends AbstractLaunchConfigurationAction {
+
+ /**
+ * Action identifier for IDebugView#getAction(String)
+ */
+ public static final String ID_CREATE_PROTOTYPE_ACTION = DebugUIPlugin.getUniqueIdentifier() + ".ID_CREATE_PROTOTYPE_ACTION"; //$NON-NLS-1$
+
+ /**
+ * Constructs an action to create a launch configuration prototype
+ *
+ * @param viewer the viewer
+ * @param mode the mode the action applies to
+ */
+ public CreateLaunchConfigurationPrototypeAction(Viewer viewer, String mode) {
+ super(LaunchConfigurationsMessages.CreateLaunchConfigurationPrototypeAction_Ne_w_1, viewer, mode);
+ }
+
+ /**
+ * @see AbstractLaunchConfigurationAction#performAction()
+ */
+ @Override
+ protected void performAction() {
+ Object object = getStructuredSelection().getFirstElement();
+ // double click with Ctrl key mask results in empty selection: bug
+ // 156087 do no work if the selection is null
+ if (object != null) {
+ ILaunchConfigurationType type = null;
+ // Construct a new configuration prototype of the selected type
+ if (object instanceof ILaunchConfiguration) {
+ ILaunchConfiguration config = (ILaunchConfiguration) object;
+ try {
+ type = config.getType();
+ } catch (CoreException e) {
+ errorDialog(e);
+ return;
+ }
+ } else {
+ type = (ILaunchConfigurationType) object;
+ }
+ try {
+ ILaunchConfigurationWorkingCopy wc = type.newPrototypeInstance(null, DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(LaunchConfigurationsMessages.CreateLaunchConfigurationPrototypeAction_New_prototype_2));
+ ILaunchConfigurationTabGroup tabGroup = LaunchConfigurationPresentationManager.getDefault().getTabGroup(wc, getMode());
+ // this only works because this action is only present when the
+ // dialog is open
+ ILaunchConfigurationDialog dialog = LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog();
+ tabGroup.createTabs(dialog, dialog.getMode());
+ ILaunchConfigurationTab[] tabs = tabGroup.getTabs();
+ for (int i = 0; i < tabs.length; i++) {
+ tabs[i].setLaunchConfigurationDialog(dialog);
+ }
+ tabGroup.setDefaults(wc);
+ tabGroup.dispose();
+ wc.doSave();
+ } catch (CoreException e) {
+ errorDialog(e);
+ return;
+ }
+ }
+ }
+
+ /**
+ * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ if (selection.size() == 1) {
+ Object object = getStructuredSelection().getFirstElement();
+ if (object != null) {
+ ILaunchConfigurationType type = null;
+ // Construct a new configuration prototype of the selected type
+ if (object instanceof ILaunchConfiguration) {
+ ILaunchConfiguration config = (ILaunchConfiguration) object;
+ try {
+ type = config.getType();
+ } catch (CoreException e) {
+ errorDialog(e);
+ }
+ } else {
+ type = (ILaunchConfigurationType) object;
+ }
+ if (type != null) {
+ return type.supportsPrototypes();
+ }
+ }
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getDisabledImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getDisabledImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_NEW_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_NEW_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getToolTipText()
+ */
+ @Override
+ public String getToolTipText() {
+ return LaunchConfigurationsMessages.LaunchConfigurationsDialog_2;
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DeleteLaunchConfigurationAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DeleteLaunchConfigurationAction.java
index 0c1eebba3..9f1ebac3f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DeleteLaunchConfigurationAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DeleteLaunchConfigurationAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.launchConfigurations;
@@ -70,7 +71,7 @@ public class DeleteLaunchConfigurationAction extends AbstractLaunchConfiguration
while (iterator.hasNext()) {
ILaunchConfiguration configuration = (ILaunchConfiguration)iterator.next();
try {
- configuration.delete();
+ configuration.delete(ILaunchConfiguration.UPDATE_PROTOTYPE_CHILDREN);
} catch (CoreException e) {
errorDialog(e);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java
index f3ba24630..2a02359e6 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java
@@ -10,6 +10,7 @@
* Mohamed Hussein (Mentor Graphics) - Added getWarningMessage (Bug 386673)
* Robert Roth - Used consistent apply button location (Bug 432832)
* Lucas Bullen (Red Hat Inc.) - Added export configuration message (Bug 518652)
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.launchConfigurations;
@@ -347,11 +348,15 @@ public class LaunchConfigurationTabGroupViewer {
int width = parent.getBounds().width - 30;
SWTFactory.createWrapLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_1, 1, width);
SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_2, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_NEW_CONFIG), 1, width);
+ SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_9, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_NEW_PROTO), 1, width);
SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_7, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_EXPORT_CONFIG), 1, width);
SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_6, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DUPLICATE_CONFIG), 1, width);
SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_4, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DELETE_CONFIG), 1, width);
- SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_8, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_FILTER_CONFIGS), 1, width);
- SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_3, DebugUITools.getImage(IInternalDebugUIConstants.IMG_OVR_TRANSPARENT), 1, width);
+ SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_8, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_FILTER_CONFIGS), 1, width);
+ SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_3, DebugUITools.getImage(IInternalDebugUIConstants.IMG_OVR_TRANSPARENT), 1, width);
+ SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_10, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_LINK_PROTO), 1, width);
+ SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_11, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_UNLINK_PROTO), 1, width);
+ SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_12, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_RESET_PROTO), 1, width);
SWTFactory.createHorizontalSpacer(parent, 2);
Link link = new Link(parent, SWT.LEFT | SWT.WRAP);
@@ -1511,7 +1516,7 @@ public class LaunchConfigurationTabGroupViewer {
getLaunchConfigurationDialog().run(true, false, runnable);
}
else {
- saved[0] = fWorkingCopy.doSave();
+ saved[0] = fWorkingCopy.doSave(ILaunchConfiguration.UPDATE_PROTOTYPE_CHILDREN);
}
}
updateButtons();
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTreeContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTreeContentProvider.java
index 14a06251d..2f655af3c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTreeContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTreeContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Lars Vogel <Lars.Vogel@vogella.com> - Bug 490755
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.launchConfigurations;
@@ -74,17 +75,30 @@ public class LaunchConfigurationTreeContentProvider implements ITreeContentProvi
*/
@Override
public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof ILaunchConfiguration) {
- return EMPTY_ARRAY;
- } else if (parentElement instanceof ILaunchConfigurationType) {
- try {
- ILaunchConfigurationType type = (ILaunchConfigurationType)parentElement;
- return getLaunchManager().getLaunchConfigurations(type);
- } catch (CoreException e) {
- DebugUIPlugin.errorDialog(getShell(), LaunchConfigurationsMessages.LaunchConfigurationDialog_Error_19, LaunchConfigurationsMessages.LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20, e); //
+ try {
+ if (parentElement instanceof ILaunchConfiguration) {
+ if (((ILaunchConfiguration) parentElement).isPrototype()) {
+ return ((ILaunchConfiguration) parentElement).getPrototypeChildren().toArray();
+ }
+ } else if (parentElement instanceof ILaunchConfigurationType) {
+ List<ILaunchConfiguration> configs = new ArrayList<>();
+ ILaunchConfigurationType type = (ILaunchConfigurationType) parentElement;
+ ILaunchConfiguration[] launchConfigurations = getLaunchManager().getLaunchConfigurations(type, ILaunchConfiguration.CONFIGURATION);
+ for (ILaunchConfiguration launchConfig : launchConfigurations) {
+ if (launchConfig.getPrototype() == null) {
+ configs.add(launchConfig);
+ }
+ }
+ ILaunchConfiguration[] prototypes = getLaunchManager().getLaunchConfigurations(type, ILaunchConfiguration.PROTOTYPE);
+ for (ILaunchConfiguration prototype : prototypes) {
+ configs.add(prototype);
+ }
+ return configs.toArray(new ILaunchConfiguration[0]);
+ } else {
+ return getLaunchManager().getLaunchConfigurationTypes();
}
- } else {
- return getLaunchManager().getLaunchConfigurationTypes();
+ } catch (CoreException e) {
+ DebugUIPlugin.errorDialog(getShell(), LaunchConfigurationsMessages.LaunchConfigurationDialog_Error_19, LaunchConfigurationsMessages.LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20, e); //
}
return EMPTY_ARRAY;
}
@@ -99,7 +113,12 @@ public class LaunchConfigurationTreeContentProvider implements ITreeContentProvi
return null;
}
try {
- return ((ILaunchConfiguration)element).getType();
+ ILaunchConfiguration prototype = ((ILaunchConfiguration) element).getPrototype();
+ if (prototype != null) {
+ return prototype;
+ } else {
+ return ((ILaunchConfiguration) element).getType();
+ }
} catch (CoreException e) {
DebugUIPlugin.errorDialog(getShell(), LaunchConfigurationsMessages.LaunchConfigurationDialog_Error_19, LaunchConfigurationsMessages.LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20, e); //
}
@@ -115,6 +134,13 @@ public class LaunchConfigurationTreeContentProvider implements ITreeContentProvi
@Override
public boolean hasChildren(Object element) {
if (element instanceof ILaunchConfiguration) {
+ if (((ILaunchConfiguration) element).isPrototype()) {
+ try {
+ return ((ILaunchConfiguration) element).getPrototypeChildren().size() > 0;
+ } catch (CoreException e) {
+ DebugUIPlugin.errorDialog(getShell(), LaunchConfigurationsMessages.LaunchConfigurationDialog_Error_19, LaunchConfigurationsMessages.LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20, e); //
+ }
+ }
return false;
}
return getChildren(element).length > 0;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java
index 73f7087c1..ab40eec23 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Ian Pun (Red Hat Inc.) - Bug 518652
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.launchConfigurations;
@@ -76,10 +77,14 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
* Actions
*/
private CreateLaunchConfigurationAction fCreateAction;
+ private CreateLaunchConfigurationPrototypeAction fCreatePrototypeAction;
private DeleteLaunchConfigurationAction fDeleteAction;
private DuplicateLaunchConfigurationAction fDuplicateAction;
private ExportLaunchConfigurationAction fExportAction;
private CollapseAllLaunchConfigurationAction fCollapseAllAction;
+ private LinkPrototypeAction fLinkPrototypeAction;
+ private UnlinkPrototypeAction fUnlinkPrototypeAction;
+ private ResetWithPrototypeValuesAction fResetWithPrototypeValuesAction;
/**
* Action for providing filtering to the Launch Configuration Dialog
@@ -196,6 +201,9 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
fCreateAction = new CreateLaunchConfigurationAction(getViewer(), getLaunchGroup().getMode());
setAction(CreateLaunchConfigurationAction.ID_CREATE_ACTION, fCreateAction);
+ fCreatePrototypeAction = new CreateLaunchConfigurationPrototypeAction(getViewer(), getLaunchGroup().getMode());
+ setAction(CreateLaunchConfigurationPrototypeAction.ID_CREATE_PROTOTYPE_ACTION, fCreatePrototypeAction);
+
fDeleteAction = new DeleteLaunchConfigurationAction(getViewer(), getLaunchGroup().getMode());
setAction(DeleteLaunchConfigurationAction.ID_DELETE_ACTION, fDeleteAction);
setAction(IDebugView.REMOVE_ACTION, fDeleteAction);
@@ -212,6 +220,14 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
fFilterAction = new FilterLaunchConfigurationAction();
setAction(FilterLaunchConfigurationAction.ID_FILTER_ACTION, fFilterAction);
+ fLinkPrototypeAction = new LinkPrototypeAction(getViewer(), getLaunchGroup().getMode());
+ setAction(LinkPrototypeAction.ID_LINK_PROTOTYPE_ACTION, fLinkPrototypeAction);
+
+ fUnlinkPrototypeAction = new UnlinkPrototypeAction(getViewer(), getLaunchGroup().getMode());
+ setAction(UnlinkPrototypeAction.ID_UNLINK_PROTOTYPE_ACTION, fUnlinkPrototypeAction);
+
+ fResetWithPrototypeValuesAction = new ResetWithPrototypeValuesAction(getViewer(), getLaunchGroup().getMode());
+ setAction(ResetWithPrototypeValuesAction.ID_RESET_WITH_PROTOTYPE_VALUES_ACTION, fResetWithPrototypeValuesAction);
}
/**
@@ -228,10 +244,14 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
@Override
protected void fillContextMenu(IMenuManager menu) {
menu.add(fCreateAction);
+ menu.add(fCreatePrototypeAction);
menu.add(fExportAction);
menu.add(fDuplicateAction);
menu.add(fDeleteAction);
menu.add(new Separator());
+ menu.add(fLinkPrototypeAction);
+ menu.add(fUnlinkPrototypeAction);
+ menu.add(fResetWithPrototypeValuesAction);
}
/**
@@ -255,11 +275,15 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
@Override
public void dispose() {
fCreateAction.dispose();
+ fCreatePrototypeAction.dispose();
fDeleteAction.dispose();
fDuplicateAction.dispose();
fExportAction.dispose();
fFilterAction = null;
fCollapseAllAction = null;
+ fLinkPrototypeAction.dispose();
+ fUnlinkPrototypeAction.dispose();
+ fResetWithPrototypeValuesAction.dispose();
getLaunchManager().removeLaunchConfigurationListener(this);
}
@@ -295,7 +319,11 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
if (viewer != null) {
try {
viewer.getControl().setRedraw(false);
- viewer.add(configuration.getType(), configuration);
+ if (configuration.getPrototype() != null) {
+ viewer.add(configuration.getPrototype(), configuration);
+ } else {
+ viewer.add(configuration.getType(), configuration);
+ }
// if moved, remove original now
if (from != null) {
viewer.remove(from);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java
index 3d3a9d78a..e889e8d76 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* Sebastian Davids - Bug 137923
* Mohamed Hussein (Mentor Graphics) - Added s/getWarningMessage (Bug 386673)
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.launchConfigurations;
@@ -516,6 +517,7 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
*/
protected void createToolbarActions(ToolBarManager tmanager) {
tmanager.add(getNewAction());
+ tmanager.add(getNewPrototypeAction());
tmanager.add(getExportAction());
tmanager.add(getDuplicateAction());
tmanager.add(getDeleteAction());
@@ -617,14 +619,22 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
getDuplicateAction().setConfirmationRequestor(requestor);
getExportAction().setConfirmationRequestor(requestor);
getNewAction().setConfirmationRequestor(requestor);
+ getNewPrototypeAction().setConfirmationRequestor(requestor);
+ getLinkPrototypeAction().setConfirmationRequestor(requestor);
+ getUnlinkPrototypeAction().setConfirmationRequestor(requestor);
+ getResetWithPrototypeValuesAction().setConfirmationRequestor(requestor);
((StructuredViewer) viewer).addPostSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
handleLaunchConfigurationSelectionChanged(event);
getNewAction().setEnabled(getNewAction().isEnabled());
+ getNewPrototypeAction().setEnabled(getNewPrototypeAction().isEnabled());
getDeleteAction().setEnabled(getDeleteAction().isEnabled());
getExportAction().setEnabled(getExportAction().isEnabled());
getDuplicateAction().setEnabled(getDuplicateAction().isEnabled());
+ getLinkPrototypeAction().setEnabled(getLinkPrototypeAction().isEnabled());
+ getUnlinkPrototypeAction().setEnabled(getUnlinkPrototypeAction().isEnabled());
+ getResetWithPrototypeValuesAction().setEnabled(getResetWithPrototypeValuesAction().isEnabled());
}
});
return comp;
@@ -875,6 +885,50 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
}
/**
+ * Gets the new prototype menu action
+ *
+ * @return the new prototype menu action
+ *
+ * @since 3.13
+ */
+ protected AbstractLaunchConfigurationAction getNewPrototypeAction() {
+ return (AbstractLaunchConfigurationAction) fLaunchConfigurationView.getAction(CreateLaunchConfigurationPrototypeAction.ID_CREATE_PROTOTYPE_ACTION);
+ }
+
+ /**
+ * Gets the link prototype menu action
+ *
+ * @return the link prototype menu action
+ *
+ * @since 3.13
+ */
+ protected AbstractLaunchConfigurationAction getLinkPrototypeAction() {
+ return (AbstractLaunchConfigurationAction) fLaunchConfigurationView.getAction(LinkPrototypeAction.ID_LINK_PROTOTYPE_ACTION);
+ }
+
+ /**
+ * Gets the unlink prototype menu action
+ *
+ * @return the unlink prototype menu action
+ *
+ * @since 3.13
+ */
+ protected AbstractLaunchConfigurationAction getUnlinkPrototypeAction() {
+ return (AbstractLaunchConfigurationAction) fLaunchConfigurationView.getAction(UnlinkPrototypeAction.ID_UNLINK_PROTOTYPE_ACTION);
+ }
+
+ /**
+ * Gets the reset with prototype values menu action
+ *
+ * @return the reset with prototype values menu action
+ *
+ * @since 3.13
+ */
+ protected AbstractLaunchConfigurationAction getResetWithPrototypeValuesAction() {
+ return (AbstractLaunchConfigurationAction) fLaunchConfigurationView.getAction(ResetWithPrototypeValuesAction.ID_RESET_WITH_PROTOTYPE_VALUES_ACTION);
+ }
+
+ /**
* Returns the reserved name set (if there is one), <code>null</code> otherwise
* @return the reserved name set or <code>null</code>
* @since 3.3
@@ -1312,6 +1366,15 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
}
/**
+ * Refresh the launch configurations' tree viewer
+ *
+ * @since 3.13
+ */
+ protected void refreshLaunchConfigurationView() {
+ fLaunchConfigurationView.getTreeViewer().refresh();
+ }
+
+ /**
* resize the dialog to show all relevant content
*/
protected void resize() {
@@ -1604,6 +1667,9 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
getExportAction().setEnabled(getExportAction().isEnabled());
getDeleteAction().setEnabled(getDeleteAction().isEnabled());
getDuplicateAction().setEnabled(getDuplicateAction().isEnabled());
+ getLinkPrototypeAction().setEnabled(getLinkPrototypeAction().isEnabled());
+ getUnlinkPrototypeAction().setEnabled(getUnlinkPrototypeAction().isEnabled());
+ getResetWithPrototypeValuesAction().setEnabled(getResetWithPrototypeValuesAction().isEnabled());
fTabViewer.refresh();
getButton(ID_LAUNCH_BUTTON).setEnabled(fTabViewer.canLaunch() & fTabViewer.canLaunchWithModes() & !fTabViewer.hasDuplicateDelegates());
} else {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java
index eacb87f84..8bbe5942a 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java
@@ -8,6 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
* Ian Pun & Lucas Bullen (Red Hat Inc.) - Bug 518652
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.launchConfigurations;
@@ -49,6 +50,15 @@ public class LaunchConfigurationsMessages extends NLS {
public static String CommonTab_8;
public static String CommonTab_9;
+ public static String CommonTab_AttributeLabel_ConsoleEncoding;
+ public static String CommonTab_AttributeLabel_CaptureOutput;
+ public static String CommonTab_AttributeLabel_CaptureInConsole;
+ public static String CommonTab_AttributeLabel_CaptureStdInFile;
+ public static String CommonTab_AttributeLabel_CaptureInFile;
+ public static String CommonTab_AttributeLabel_AppendToFile;
+ public static String CommonTab_AttributeLabel_LaunchInBackground;
+ public static String CommonTab_AttributeLabel_FavoriteGroups;
+
public static String CompileErrorProjectPromptStatusHandler_0;
public static String CompileErrorProjectPromptStatusHandler_1;
public static String CompileErrorPromptStatusHandler_0;
@@ -140,6 +150,11 @@ public class LaunchConfigurationsMessages extends NLS {
public static String CreateLaunchConfigurationAction_Ne_w_1;
public static String ExportLaunchConfigurationAction_Export_1;
public static String CreateLaunchConfigurationAction_New_configuration_2;
+ public static String CreateLaunchConfigurationPrototypeAction_Ne_w_1;
+ public static String CreateLaunchConfigurationPrototypeAction_New_prototype_2;
+ public static String LinkPrototypeAction_Link_prototype_1;
+ public static String UnlinkPrototypeAction_Unlink_prototype_1;
+ public static String ResetWithPrototypeValuesAction_Reset_with_prototype_values_1;
public static String EnvironmentTab_Variable_1;
public static String EnvironmentTab_Value_2;
@@ -158,6 +173,21 @@ public class LaunchConfigurationsMessages extends NLS {
public static String EnvironmentTab_18;
public static String EnvironmentTab_19;
public static String EnvironmentTab_20;
+ public static String EnvironmentTab_AttributeLabel_AppendEnvironmentVariables;
+ public static String EnvironmentTab_AttributeLabel_EnvironmentVariables;
+
+ public static String PrototypeTab_Prototype_1;
+ public static String PrototypeTab_Label_2;
+ public static String PrototypeTab_Link_Button_Label_3;
+ public static String PrototypeTab_Unlink_Button_Label_4;
+ public static String PrototypeTab_Select_Message_5;
+ public static String PrototypeTab_Select_Empty_Message_6;
+ public static String PrototypeTab_Select_Prototype_Error_7;
+ public static String PrototypeTab_Reset_Button_Label_8;
+ public static String PrototypeTab_Reset_Menu_Action_9;
+ public static String PrototypeTab_Explanation_Label_10;
+ public static String PrototypeTab_Explanation_Label_11;
+ public static String PrototypeTab_Explanation_Label_12;
public static String FavoritesDialog_1;
public static String FavoritesDialog_2;
@@ -189,7 +219,11 @@ public class LaunchConfigurationsMessages extends NLS {
public static String LaunchConfigurationTabGroupViewer_3;
public static String LaunchConfigurationTabGroupViewer_4;
public static String LaunchConfigurationTabGroupViewer_5;
- public static String LaunchConfigurationTabGroupViewer_6;
+ public static String LaunchConfigurationTabGroupViewer_6;
+ public static String LaunchConfigurationTabGroupViewer_9;
+ public static String LaunchConfigurationTabGroupViewer_10;
+ public static String LaunchConfigurationTabGroupViewer_11;
+ public static String LaunchConfigurationTabGroupViewer_12;
public static String LaunchConfigurationTabGroupViewer_7;
public static String SaveScopeResourcesHandler_1;
@@ -200,9 +234,13 @@ public class LaunchConfigurationsMessages extends NLS {
public static String LaunchConfigurationsDialog_0;
public static String LaunchConfigurationsDialog_1;
+ public static String LaunchConfigurationsDialog_2;
public static String LaunchConfigurationsDialog_4;
public static String LaunchConfigurationsDialog_5;
public static String LaunchConfigurationsDialog_6;
+ public static String LaunchConfigurationsDialog_7;
+ public static String LaunchConfigurationsDialog_8;
+ public static String LaunchConfigurationsDialog_9;
public static String FilterLaunchConfigurationAction_0;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
index 72d08e819..c7451e5d9 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
@@ -8,6 +8,7 @@
# Contributors:
# IBM Corporation - initial API and implementation
# Ian Pun & Lucas Bullen (Red Hat Inc.) - Bug 518652
+# Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
###############################################################################
CommonTab__Browse_6=&Browse...
@@ -41,6 +42,14 @@ CommonTab_6=Output Fi&le:
CommonTab_7=File &System...
CommonTab_8=No file specified for process output
CommonTab_9=Variables...
+CommonTab_AttributeLabel_ConsoleEncoding=Console encoding
+CommonTab_AttributeLabel_CaptureOutput=Capture output
+CommonTab_AttributeLabel_CaptureInConsole=Capture in console
+CommonTab_AttributeLabel_CaptureStdInFile=Capture standard input file
+CommonTab_AttributeLabel_CaptureInFile=Capture in file
+CommonTab_AttributeLabel_AppendToFile=Append to file
+CommonTab_AttributeLabel_LaunchInBackground=Launch in background
+CommonTab_AttributeLabel_FavoriteGroups=Favorite groups
CompileErrorPromptStatusHandler_0=Errors in Workspace
CompileErrorPromptStatusHandler_1=Errors exist in a required project. Continue launch?
@@ -56,13 +65,17 @@ LaunchConfigurationDialog__Name__16=&Name:
LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20=An exception occurred while retrieving launch configurations
LaunchConfigurationTabGroupViewer_1=Configure launch settings from this dialog:
-LaunchConfigurationTabGroupViewer_2=- Press the 'New' button to create a configuration of the selected type.
+LaunchConfigurationTabGroupViewer_2=- Press the 'New configuration' button to create a configuration of the selected type.
LaunchConfigurationTabGroupViewer_3=- Edit or view an existing configuration by selecting it.
LaunchConfigurationTabGroupViewer_4=- Press the 'Delete' button to remove the selected configuration.
LaunchConfigurationTabGroupViewer_6=- Press the 'Duplicate' button to copy the selected configuration.
LaunchConfigurationTabGroupViewer_5=Configure launch perspective settings from the <a>'Perspectives'</a> preference page.
LaunchConfigurationTabGroupViewer_7=- Press the 'Export' button to export the selected configurations.
LaunchConfigurationTabGroupViewer_8=- Press the 'Filter' button to configure filtering options.
+LaunchConfigurationTabGroupViewer_9=- Press the 'New prototype' button to create a launch configuration prototype of the selected type.
+LaunchConfigurationTabGroupViewer_10=- Select launch configuration(s) and then select 'Link prototype' menu item to link a prototype.
+LaunchConfigurationTabGroupViewer_11=- Select launch configuration(s) and then select 'Unlink prototype' menu item to unlink a prototype.
+LaunchConfigurationTabGroupViewer_12=- Select launch configuration(s) and then select 'Reset with prototype values' menu item to reset with prototype values.
LaunchConfigurationTabGroupViewer_13=Select a supported <a>launch mode</a>.
LaunchConfigurationTabGroupViewer_14=This configuration does not support some of the launch modes: {0}
LaunchConfigurationTabGroupViewer_15=More than one launcher available - <a>Select other...</a>
@@ -104,9 +117,13 @@ LaunchConfigurationsDialog_Warning_2=Warning
LaunchConfigurationsDialog_Information_3=Information
LaunchConfigurationsDialog_0=New launch configuration
LaunchConfigurationsDialog_1=Delete selected launch configuration(s)
+LaunchConfigurationsDialog_2=New launch configuration prototype
LaunchConfigurationsDialog_4=Filter launch configurations...
LaunchConfigurationsDialog_5=Duplicates the currently selected launch configuration
LaunchConfigurationsDialog_6=Export launch configuration
+LaunchConfigurationsDialog_7=Link prototype
+LaunchConfigurationsDialog_8=Unlink prototype
+LaunchConfigurationsDialog_9=Reset with prototype values
LaunchConfigurationSelectionDialog_0=Select Configuration
LaunchConfigurationSelectionDialog_1=&Select a configuration to launch:
LaunchConfigurationView_0=Filter matched {0} of {1} items
@@ -150,9 +167,14 @@ DuplicateLaunchConfigurationAction__Duplicate_1=&Duplicate
DeleteLaunchConfigurationAction_Dele_te_1=Dele&te
-CreateLaunchConfigurationAction_Ne_w_1=Ne&w
+CreateLaunchConfigurationAction_Ne_w_1=Ne&w configuration
ExportLaunchConfigurationAction_Export_1=E&xport
CreateLaunchConfigurationAction_New_configuration_2=New_configuration
+CreateLaunchConfigurationPrototypeAction_Ne_w_1=New &prototype
+CreateLaunchConfigurationPrototypeAction_New_prototype_2=New_prototype
+LinkPrototypeAction_Link_prototype_1=&Link prototype
+UnlinkPrototypeAction_Unlink_prototype_1=&Unlink prototype
+ResetWithPrototypeValuesAction_Reset_with_prototype_values_1=&Reset with prototype values
EnvironmentTab_Variable_1=Variable
EnvironmentTab_Value_2=Value
@@ -177,6 +199,22 @@ EnvironmentTab_17=Re&place native environment with specified environment
EnvironmentTab_18=Se&lect...
EnvironmentTab_19=Select &environment variables to add:
EnvironmentTab_20=Select Environment Variables
+EnvironmentTab_AttributeLabel_AppendEnvironmentVariables=Append environment to native environment
+EnvironmentTab_AttributeLabel_EnvironmentVariables=Environment variables
+
+#PrototypeTab
+PrototypeTab_Prototype_1=Prototype
+PrototypeTab_Label_2=Prototype:
+PrototypeTab_Link_Button_Label_3=Link...
+PrototypeTab_Unlink_Button_Label_4=Unlink
+PrototypeTab_Select_Message_5=Please select a prototype
+PrototypeTab_Select_Empty_Message_6=You have to select a prototype
+PrototypeTab_Select_Prototype_Error_7=The prototype doesn't exists. Please select a valid prototype.
+PrototypeTab_Reset_Button_Label_8=Reset
+PrototypeTab_Reset_Menu_Action_9=Reset selected checked attribute(s) with prototype value(s)
+PrototypeTab_Explanation_Label_10=- Values of checked attributes from prototype are applied on associated launch configurations.
+PrototypeTab_Explanation_Label_11=- Values of unchecked attributes from prototype are not applied on associated launch configurations.
+PrototypeTab_Explanation_Label_12=- Grayed state attributes have different values in the launch configuration and the associated prototype.
FavoritesDialog_1=Organize {0} Favorites
FavoritesDialog_2=Fa&vorites:
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LinkPrototypeAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LinkPrototypeAction.java
new file mode 100644
index 000000000..a1b28b72d
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LinkPrototypeAction.java
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.launchConfigurations;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+/**
+ * Link attributes from a prototype to the selected launch configuration(s).
+ *
+ * @since 3.13
+ */
+public class LinkPrototypeAction extends AbstractLaunchConfigurationAction {
+
+ /**
+ * Action identifier for IDebugView#getAction(String)
+ */
+ public static final String ID_LINK_PROTOTYPE_ACTION = DebugUIPlugin.getUniqueIdentifier() + ".ID_LINK_PROTOTYPE_ACTION"; //$NON-NLS-1$
+
+ /**
+ * Constructs an action to apply a prototype to a launch configuration
+ *
+ * @param viewer the viewer
+ * @param mode the mode the action applies to
+ */
+ public LinkPrototypeAction(Viewer viewer, String mode) {
+ super(LaunchConfigurationsMessages.LinkPrototypeAction_Link_prototype_1, viewer, mode);
+ }
+
+ /**
+ * @see AbstractLaunchConfigurationAction#performAction()
+ */
+ @Override
+ protected void performAction() {
+ try {
+ ILaunchConfiguration firstLaunchConfiguration = (ILaunchConfiguration) getStructuredSelection().getFirstElement();
+ ILaunchConfigurationType type = firstLaunchConfiguration.getType();
+ ILaunchConfiguration[] prototypes = type.getPrototypes();
+ // Select the prototype
+ DecoratingLabelProvider labelProvider = new DecoratingLabelProvider(DebugUITools.newDebugModelPresentation(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator());
+ ElementListSelectionDialog selectPrototypeDialog = new ElementListSelectionDialog(getShell(), labelProvider);
+ selectPrototypeDialog.setElements(prototypes);
+ selectPrototypeDialog.setMultipleSelection(false);
+ selectPrototypeDialog.setEmptySelectionMessage("You have to select a prototype."); //$NON-NLS-1$
+ selectPrototypeDialog.setTitle("Please select a prototype"); //$NON-NLS-1$
+ int open = selectPrototypeDialog.open();
+ if (open == Window.OK) {
+ Object selectedPrototype = selectPrototypeDialog.getFirstResult();
+ for (Object launchConfiguration : getStructuredSelection().toList()) {
+ if (launchConfiguration instanceof ILaunchConfiguration) {
+ // Link the prototype attributes to the selected launch
+ // configuration
+ ILaunchConfigurationWorkingCopy workingCopy = ((ILaunchConfiguration) launchConfiguration).getWorkingCopy();
+ workingCopy.setPrototype((ILaunchConfiguration) selectedPrototype, true);
+ workingCopy.doSave();
+ // if only one configuration is selected, refresh the
+ // tabs to display visible attributes values from the
+ // prototype
+ if (getStructuredSelection().size() == 1) {
+ ILaunchConfigurationDialog dialog = LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog();
+ if (dialog instanceof LaunchConfigurationsDialog) {
+ ((LaunchConfigurationsDialog) dialog).getTabViewer().setInput(workingCopy);
+ }
+ }
+ }
+ }
+ getViewer().refresh();
+ }
+ } catch (CoreException e) {
+ errorDialog(e);
+ }
+ }
+
+ /**
+ * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ // Enable action only if launch configuration(s) of the same type
+ // is(are) selected and the launch configuration type allows prototypes
+ Collection<ILaunchConfigurationType> launchConfigurationTypes = new HashSet<>();
+ for (Object object : selection.toList()) {
+ if (object instanceof ILaunchConfiguration) {
+ if (((ILaunchConfiguration) object).isPrototype()) {
+ return false;
+ } else {
+ ILaunchConfigurationType type = null;
+ try {
+ type = ((ILaunchConfiguration) object).getType();
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ if (type != null) {
+ launchConfigurationTypes.add(type);
+ } else {
+ return false;
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+ if (launchConfigurationTypes.size() == 1) {
+ return launchConfigurationTypes.iterator().next().supportsPrototypes();
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getDisabledImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getDisabledImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_LINK_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_LINK_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getToolTipText()
+ */
+ @Override
+ public String getToolTipText() {
+ return LaunchConfigurationsMessages.LaunchConfigurationsDialog_7;
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ResetWithPrototypeValuesAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ResetWithPrototypeValuesAction.java
new file mode 100644
index 000000000..944182212
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ResetWithPrototypeValuesAction.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.launchConfigurations;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Reset selected launch configuration(s) attributes with values from associated
+ * prototype(s).
+ *
+ * @since 3.13
+ */
+public class ResetWithPrototypeValuesAction extends AbstractLaunchConfigurationAction {
+
+ /**
+ * Action identifier for IDebugView#getAction(String)
+ */
+ public static final String ID_RESET_WITH_PROTOTYPE_VALUES_ACTION = DebugUIPlugin.getUniqueIdentifier() + ".ID_RESET_WITH_PROTOTYPE_VALUES_ACTION"; //$NON-NLS-1$
+
+ /**
+ * Constructs an action to reset a launch configuration with prototype
+ * values
+ *
+ * @param viewer the viewer
+ * @param mode the mode the action applies to
+ */
+ public ResetWithPrototypeValuesAction(Viewer viewer, String mode) {
+ super(LaunchConfigurationsMessages.ResetWithPrototypeValuesAction_Reset_with_prototype_values_1, viewer, mode);
+ }
+
+ /**
+ * @see AbstractLaunchConfigurationAction#performAction()
+ */
+ @Override
+ protected void performAction() {
+ try {
+ for (Object launchConfiguration : getStructuredSelection().toList()) {
+ if (launchConfiguration instanceof ILaunchConfiguration) {
+ ILaunchConfigurationWorkingCopy workingCopy = ((ILaunchConfiguration) launchConfiguration).getWorkingCopy();
+ workingCopy.setPrototype(((ILaunchConfiguration) launchConfiguration).getPrototype(), true);
+ workingCopy.doSave();
+ // if only one configuration is selected, refresh the
+ // tabs to display visible attributes values from the
+ // prototype
+ if (getStructuredSelection().size() == 1) {
+ ILaunchConfigurationDialog dialog = LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog();
+ if (dialog instanceof LaunchConfigurationsDialog) {
+ ((LaunchConfigurationsDialog) dialog).getTabViewer().setInput(workingCopy);
+ }
+ }
+ }
+ }
+ } catch (CoreException e) {
+ errorDialog(e);
+ }
+ }
+
+ /**
+ * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ boolean onlyLaunchConfigurationWithPrototypeSelected = false;
+ for (Object object : selection.toList()) {
+ if (object instanceof ILaunchConfiguration) {
+ if (((ILaunchConfiguration) object).isPrototype()) {
+ return false;
+ } else {
+ try {
+ if (((ILaunchConfiguration) object).getPrototype() != null) {
+ onlyLaunchConfigurationWithPrototypeSelected = true;
+ } else {
+ return false;
+ }
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+ return onlyLaunchConfigurationWithPrototypeSelected;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getDisabledImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getDisabledImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_RESET_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_RESET_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getToolTipText()
+ */
+ @Override
+ public String getToolTipText() {
+ return LaunchConfigurationsMessages.LaunchConfigurationsDialog_9;
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/UnlinkPrototypeAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/UnlinkPrototypeAction.java
new file mode 100644
index 000000000..f1cbc5d50
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/UnlinkPrototypeAction.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.launchConfigurations;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Unlink prototype to the selected launch configuration(s).
+ *
+ * @since 3.13
+ */
+public class UnlinkPrototypeAction extends AbstractLaunchConfigurationAction {
+
+ /**
+ * Action identifier for IDebugView#getAction(String)
+ */
+ public static final String ID_UNLINK_PROTOTYPE_ACTION = DebugUIPlugin.getUniqueIdentifier() + ".ID_UNLINK_PROTOTYPE_ACTION"; //$NON-NLS-1$
+
+ /**
+ * Constructs an action to unlink a prototype to a launch configuration
+ *
+ * @param viewer the viewer
+ * @param mode the mode the action applies to
+ */
+ public UnlinkPrototypeAction(Viewer viewer, String mode) {
+ super(LaunchConfigurationsMessages.UnlinkPrototypeAction_Unlink_prototype_1, viewer, mode);
+ }
+
+ /**
+ * @see AbstractLaunchConfigurationAction#performAction()
+ */
+ @Override
+ protected void performAction() {
+ try {
+ for (Object launchConfiguration : getStructuredSelection().toList()) {
+ if (launchConfiguration instanceof ILaunchConfiguration) {
+ ILaunchConfigurationWorkingCopy workingCopy = ((ILaunchConfiguration) launchConfiguration).getWorkingCopy();
+ workingCopy.setPrototype(null, false);
+ workingCopy.doSave();
+ // if only one configuration is selected, refresh the
+ // tabs to display visible attributes values from the
+ // prototype
+ if (getStructuredSelection().size() == 1) {
+ ILaunchConfigurationDialog dialog = LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog();
+ if (dialog instanceof LaunchConfigurationsDialog) {
+ ((LaunchConfigurationsDialog) dialog).getTabViewer().setInput(workingCopy);
+ }
+ }
+ }
+ }
+ getViewer().refresh();
+ } catch (CoreException e) {
+ errorDialog(e);
+ }
+ }
+
+ /**
+ * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ boolean onlyLaunchConfigurationWithPrototypeSelected = false;
+ for (Object object : selection.toList()) {
+ if (object instanceof ILaunchConfiguration) {
+ if (((ILaunchConfiguration) object).isPrototype()) {
+ return false;
+ } else {
+ try {
+ if (((ILaunchConfiguration) object).getPrototype() != null) {
+ onlyLaunchConfigurationWithPrototypeSelected = true;
+ } else {
+ return false;
+ }
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+ return onlyLaunchConfigurationWithPrototypeSelected;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getDisabledImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getDisabledImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_UNLINK_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_UNLINK_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getToolTipText()
+ */
+ @Override
+ public String getToolTipText() {
+ return LaunchConfigurationsMessages.LaunchConfigurationsDialog_8;
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java
index a4e9ef95e..696d7c0b3 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2009 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 IBM Corporation 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
* QNX Software Systems - Mikhail Khodjaiants - Bug 114664
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.sourcelookup;
@@ -37,6 +38,9 @@ public class SourceLookupUIMessages extends NLS {
public static String sourceTab_tabTitle;
public static String sourceTab_defaultButton;
+ public static String sourceTab_AttributeLabel_SourceLocatorMemento;
+ public static String sourceTab_AttributeLabel_SourceLocatorID;
+
public static String addSourceLocation_title;
public static String addSourceLocation_description;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties
index 5c56dd2f3..3158c2f3d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2003, 2013 IBM Corporation and others.
+# Copyright (c) 2003, 2017 IBM Corporation 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
@@ -8,6 +8,7 @@
# Contributors:
# IBM Corporation - initial API and implementation
# QNX Software Systems - Mikhail Khodjaiants - Bug 114664
+# Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
###############################################################################
# Source search launch configuration tab/errors/dialogs
@@ -21,6 +22,9 @@ sourceTab_addButton = &Add...
sourceTab_tabTitle = Source
sourceTab_defaultButton = Restore Defa&ult
+sourceTab_AttributeLabel_SourceLocatorMemento=Source locator memento
+sourceTab_AttributeLabel_SourceLocatorID=Source locator ID
+
addSourceLocation_title = Add Source
addSourceLocation_description = Add a container to the source lookup path
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTab.java
index 5503ed937..cbe4e76f3 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTab.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTab.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -8,10 +8,14 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Mohamed Hussein (Mentor Graphics) - Added s/getWarningMessage (Bug 386673)
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.ui;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -21,6 +25,7 @@ import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.IPrototypeAttributesLabelProvider;
import org.eclipse.debug.internal.ui.SWTFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
@@ -40,7 +45,7 @@ import org.eclipse.ui.progress.WorkbenchJob;
* @see ILaunchConfigurationTab
* @since 2.0
*/
-public abstract class AbstractLaunchConfigurationTab implements ILaunchConfigurationTab2 {
+public abstract class AbstractLaunchConfigurationTab implements ILaunchConfigurationTab2, IPrototypeAttributesLabelProvider {
/**
* The control for this page, or <code>null</code>
@@ -92,8 +97,46 @@ public abstract class AbstractLaunchConfigurationTab implements ILaunchConfigura
private String fHelpContextId = null;
/**
- * Returns the dialog this tab is contained in, or
- * <code>null</code> if not yet set.
+ * Attributes labels for prototype tab.
+ *
+ * @since 3.13
+ */
+ private Map<String, String> fAttributesLabelsForPrototype;
+
+ /**
+ * Default constructor.
+ *
+ * @since 3.13
+ */
+ public AbstractLaunchConfigurationTab() {
+ fAttributesLabelsForPrototype = new HashMap<>();
+ initializeAttributes();
+ }
+
+ /**
+ * Initialize attributes labels.
+ *
+ * @since 3.13
+ */
+ protected void initializeAttributes() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.core.IPrototypeAttributesLabelProvider#getLabel(java.lang.String)
+ */
+ @Override
+ public String getAttributeLabel(String attribute) {
+ String label = fAttributesLabelsForPrototype.get(attribute);
+ if (label != null) {
+ return label;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the dialog this tab is contained in, or <code>null</code> if not
+ * yet set.
*
* @return launch configuration dialog, or <code>null</code>
*/
@@ -513,5 +556,15 @@ public abstract class AbstractLaunchConfigurationTab implements ILaunchConfigura
public String getHelpContextId() {
return fHelpContextId;
}
+
+ /**
+ * Get the attributes labels for prototype tab.
+ *
+ * @return the attributes labels for prototype tab.
+ * @since 3.13
+ */
+ protected Map<String, String> getAttributesLabelsForPrototype() {
+ return fAttributesLabelsForPrototype;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java
index 6ed04e176..1c482fd7e 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Wahlbrink <sw@wahlbrink.eu> - Bug 471829
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.ui;
@@ -160,6 +161,7 @@ public class CommonTab extends AbstractLaunchConfigurationTab {
* Constructs a new tab with default context help.
*/
public CommonTab() {
+ super();
setHelpContextId(IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_COMMON_TAB);
}
@@ -1101,6 +1103,24 @@ public class CommonTab extends AbstractLaunchConfigurationTab {
@Override
public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#initializeAttributes()
+ * @since 3.13
+ */
+ @Override
+ protected void initializeAttributes() {
+ super.initializeAttributes();
+ getAttributesLabelsForPrototype().put(DebugPlugin.ATTR_CONSOLE_ENCODING, LaunchConfigurationsMessages.CommonTab_AttributeLabel_ConsoleEncoding);
+ getAttributesLabelsForPrototype().put(DebugPlugin.ATTR_CAPTURE_OUTPUT, LaunchConfigurationsMessages.CommonTab_AttributeLabel_CaptureOutput);
+ getAttributesLabelsForPrototype().put(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, LaunchConfigurationsMessages.CommonTab_AttributeLabel_CaptureInConsole);
+ getAttributesLabelsForPrototype().put(IDebugUIConstants.ATTR_CAPTURE_STDIN_FILE, LaunchConfigurationsMessages.CommonTab_AttributeLabel_CaptureStdInFile);
+ getAttributesLabelsForPrototype().put(IDebugUIConstants.ATTR_CAPTURE_IN_FILE, LaunchConfigurationsMessages.CommonTab_AttributeLabel_CaptureInFile);
+ getAttributesLabelsForPrototype().put(IDebugUIConstants.ATTR_APPEND_TO_FILE, LaunchConfigurationsMessages.CommonTab_AttributeLabel_AppendToFile);
+ getAttributesLabelsForPrototype().put(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, LaunchConfigurationsMessages.CommonTab_AttributeLabel_LaunchInBackground);
+ getAttributesLabelsForPrototype().put(IDebugUIConstants.ATTR_FAVORITE_GROUPS, LaunchConfigurationsMessages.CommonTab_AttributeLabel_FavoriteGroups);
+ }
+
/**
* Content provider for the favorites table
*/
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java
index b307bcf90..b19a779ac 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 Keith Seitz and others.
+ * Copyright (c) 2000, 2017 Keith Seitz 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
@@ -9,6 +9,7 @@
* Keith Seitz (keiths@redhat.com) - initial implementation
* IBM Corporation - integration and code cleanup
* Jan Opacki (jan.opacki@gmail.com) bug 307139
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.ui;
@@ -191,6 +192,7 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab {
* Constructs a new tab with default context help.
*/
public EnvironmentTab() {
+ super();
setHelpContextId(IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_ENVIRONMENT_TAB);
}
@@ -603,6 +605,18 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab {
// do nothing when deactivated
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#initializeAttributes()
+ * @since 3.13
+ */
+ @Override
+ protected void initializeAttributes() {
+ super.initializeAttributes();
+ getAttributesLabelsForPrototype().put(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, LaunchConfigurationsMessages.EnvironmentTab_AttributeLabel_AppendEnvironmentVariables);
+ getAttributesLabelsForPrototype().put(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, LaunchConfigurationsMessages.EnvironmentTab_AttributeLabel_EnvironmentVariables);
+ }
+
/**
* This dialog allows users to select one or more known native environment variables from a list.
*/
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
index 04659d962..467afa298 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* QNX Software Systems - Mikhail Khodjaiants - Registers View (Bug 53640)
* Wind River Systems - Pawel Piech - Added Modules view (bug 211158)
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.ui;
@@ -619,6 +620,13 @@ public interface IDebugUIConstants {
public static final String IMG_OVR_SKIP_BREAKPOINT = "IMG_OVR_SKIP_BREAKPOINT"; //$NON-NLS-1$
/**
+ * Prototype image overlay identifier.
+ *
+ * @since 3.13
+ */
+ public static final String IMG_OVR_PROTOTYPE = "IMG_OVR_PROTOTYPE"; //$NON-NLS-1$
+
+ /**
* Debug action set identifier (value <code>"org.eclipse.debug.ui.debugActionSet"</code>).
*/
public static final String DEBUG_ACTION_SET= PLUGIN_ID + ".debugActionSet"; //$NON-NLS-1$
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/PrototypeDecorator.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/PrototypeDecorator.java
new file mode 100644
index 000000000..e39b2dc2f
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/PrototypeDecorator.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.ui;
+
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.internal.core.LaunchConfiguration;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+
+/**
+ * Decorator for {@link ILaunchConfiguration} prototypes.
+ *
+ * @since 3.13
+ *
+ */
+public class PrototypeDecorator implements ILightweightLabelDecorator {
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ @Override
+ public void decorate(Object element, IDecoration decoration) {
+ if (element instanceof LaunchConfiguration) {
+ if (((LaunchConfiguration) element).isPrototype()) {
+ decoration.addOverlay(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OVR_PROTOTYPE));
+ }
+ }
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ProtoypeTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ProtoypeTab.java
new file mode 100644
index 000000000..84d243876
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/ProtoypeTab.java
@@ -0,0 +1,760 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.ui;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.internal.core.LaunchConfiguration;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.internal.ui.SWTFactory;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsMessages;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ICheckStateProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+/**
+ * Launch configuration tab used to specify the prototype associated with a
+ * launch configuration, and also listed attributes from prototype shared with
+ * the launch configuration.
+ * <p>
+ * Clients may call {@link #setHelpContextId(String)} on this tab prior to
+ * control creation to alter the default context help associated with this tab.
+ * </p>
+ * <p>
+ * Clients may instantiate this class only if the associated launch
+ * configuration type allows prototypes.
+ *
+ * @see ILaunchConfigurationType#supportsPrototypes()
+ * </p>
+ *
+ * @since 3.13
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ProtoypeTab extends AbstractLaunchConfigurationTab {
+
+ private static final String PROTOTYPE_TAB_ID = "org.eclipse.debug.ui.prototypeTab"; //$NON-NLS-1$
+
+ private static final String ATTRIBUTE = "Attribute"; //$NON-NLS-1$
+
+ private static final String MODIFIED = "Modified"; //$NON-NLS-1$
+
+ private static final String PROTOTYPE_VALUE = "Prototype Value"; //$NON-NLS-1$
+
+ private ILaunchConfiguration fSelectedLaunchConfiguration;
+
+ private ILaunchConfiguration fAppliedPrototype;
+
+ private Composite fPrototypeComposite;
+
+ private Text fPrototypeText;
+
+ private ControlDecoration fPrototypeTextDecoration;
+
+ private Button fLinkPrototypeButton;
+
+ private Button fUnlinkPrototypeButton;
+
+ private Button fResetPrototypeButton;
+
+ private CheckboxTreeViewer fAttributesTreeViewer;
+
+ /**
+ * Constructs a new tab with default context help.
+ */
+ public ProtoypeTab() {
+ setHelpContextId(IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_PROTOTYPE_TAB);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.
+ * swt.widgets.Composite)
+ */
+ @Override
+ public void createControl(Composite parent) {
+ Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH);
+ setControl(comp);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), getHelpContextId());
+
+ createConfigPrototypeComponent(comp);
+ createPrototypeExplanationsComponent(comp);
+ createPrototypeAttributesTreeComponent(comp);
+ }
+
+ /**
+ * Creates the config prototype location component
+ *
+ * @param parent the parent composite to add this component to
+ */
+ private void createConfigPrototypeComponent(Composite parent) {
+ fPrototypeComposite = new Composite(parent, SWT.NONE);
+ fPrototypeComposite.setLayout(new GridLayout(5, false));
+ fPrototypeComposite.setFont(parent.getFont());
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ fPrototypeComposite.setLayoutData(gd);
+ SWTFactory.createLabel(fPrototypeComposite, LaunchConfigurationsMessages.PrototypeTab_Label_2, 1);
+ fPrototypeText = SWTFactory.createSingleText(fPrototypeComposite, 1);
+ fPrototypeText.setEditable(false);
+ fPrototypeTextDecoration = new ControlDecoration(fPrototypeText, SWT.TOP | SWT.LEFT);
+ FieldDecoration errorDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
+ fPrototypeTextDecoration.setDescriptionText(LaunchConfigurationsMessages.PrototypeTab_Select_Prototype_Error_7);
+ fPrototypeTextDecoration.setImage(errorDecoration.getImage());
+ fLinkPrototypeButton = SWTFactory.createPushButton(fPrototypeComposite, LaunchConfigurationsMessages.PrototypeTab_Link_Button_Label_3, null);
+ fLinkPrototypeButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent evt) {
+ handleLinkPrototypeButtonSelected();
+ }
+ });
+ fUnlinkPrototypeButton = SWTFactory.createPushButton(fPrototypeComposite, LaunchConfigurationsMessages.PrototypeTab_Unlink_Button_Label_4, null);
+ fUnlinkPrototypeButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent evt) {
+ handleUnlinkPrototypeButtonSelected();
+ }
+ });
+ fResetPrototypeButton = SWTFactory.createPushButton(fPrototypeComposite, LaunchConfigurationsMessages.PrototypeTab_Reset_Button_Label_8, null);
+ fResetPrototypeButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent evt) {
+ handleResetPrototypeButtonSelected();
+ }
+ });
+ }
+
+ /**
+ * Creates the prototype explanations component
+ *
+ * @param parent the parent composite to add this component to
+ */
+ private void createPrototypeExplanationsComponent(Composite parent) {
+ SWTFactory.createLabel(parent, LaunchConfigurationsMessages.PrototypeTab_Explanation_Label_10, 1);
+ SWTFactory.createLabel(parent, LaunchConfigurationsMessages.PrototypeTab_Explanation_Label_11, 1);
+ }
+
+ /**
+ * Creates the prototype attributes tree component
+ *
+ * @param parent the parent composite to add this one to
+ */
+ private void createPrototypeAttributesTreeComponent(Composite parent) {
+ Composite attributesPrototypeTableComposite = new Composite(parent, SWT.NONE);
+ attributesPrototypeTableComposite.setLayout(new GridLayout(1, false));
+ attributesPrototypeTableComposite.setFont(parent.getFont());
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ attributesPrototypeTableComposite.setLayoutData(gd);
+
+ fAttributesTreeViewer = createCheckboxTreeViewer(attributesPrototypeTableComposite);
+ }
+
+ /**
+ * Update prototype text widget decorator.
+ */
+ private void updateProductDecorator() {
+ if (fAppliedPrototype != null && !fAppliedPrototype.exists()) {
+ fPrototypeTextDecoration.show();
+ } else {
+ fPrototypeTextDecoration.hide();
+ }
+ }
+
+ /**
+ * Handles the config prototype apply button being selected
+ */
+ private void handleLinkPrototypeButtonSelected() {
+ String currentSelectedPrototypeString = fPrototypeText.getText();
+ DecoratingLabelProvider labelProvider = new DecoratingLabelProvider(DebugUITools.newDebugModelPresentation(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator());
+ ElementListSelectionDialog selectPrototypeDialog = new ElementListSelectionDialog(getShell(), labelProvider);
+ try {
+ ILaunchConfigurationType type = fSelectedLaunchConfiguration.getType();
+ ILaunchConfiguration[] prototypes = type.getPrototypes();
+ selectPrototypeDialog.setElements(prototypes);
+ selectPrototypeDialog.setMultipleSelection(false);
+ selectPrototypeDialog.setTitle(LaunchConfigurationsMessages.PrototypeTab_Select_Message_5);
+ selectPrototypeDialog.setEmptySelectionMessage(LaunchConfigurationsMessages.PrototypeTab_Select_Empty_Message_6);
+ selectPrototypeDialog.setInitialSelections(getPrototype(prototypes, currentSelectedPrototypeString));
+ int open = selectPrototypeDialog.open();
+ if (open == Window.OK) {
+ Object selectedPrototype = selectPrototypeDialog.getFirstResult();
+ if (selectedPrototype instanceof ILaunchConfiguration) {
+ fAppliedPrototype = (ILaunchConfiguration) selectedPrototype;
+ ILaunchConfigurationWorkingCopy workingCopy = getWorkingCopy();
+ workingCopy.setPrototype(fAppliedPrototype, true);
+ fPrototypeText.setText(((ILaunchConfiguration) selectedPrototype).getName());
+ fAttributesTreeViewer.setInput(fAppliedPrototype);
+ fUnlinkPrototypeButton.setEnabled(true);
+ fResetPrototypeButton.setEnabled(true);
+ updateColumnsWidth();
+ updateProductDecorator();
+ setDirty(true);
+ updateLaunchConfigurationDialog();
+ reinitTabs(workingCopy);
+ }
+ }
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ }
+
+ /**
+ * Handles the config prototype unapply button being selected
+ */
+ private void handleUnlinkPrototypeButtonSelected() {
+ try {
+ fAppliedPrototype = null;
+ ILaunchConfigurationWorkingCopy workingCopy = getWorkingCopy();
+ workingCopy.setPrototype(null, false);
+ fPrototypeText.setText(""); //$NON-NLS-1$
+ fAttributesTreeViewer.setInput(null);
+ fUnlinkPrototypeButton.setEnabled(false);
+ fResetPrototypeButton.setEnabled(false);
+ updateProductDecorator();
+ setDirty(true);
+ updateLaunchConfigurationDialog();
+ reinitTabs(workingCopy);
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ }
+
+ /**
+ * Handles the config prototype reset button being selected
+ */
+ private void handleResetPrototypeButtonSelected() {
+ try {
+ ILaunchConfigurationWorkingCopy workingCopy = getWorkingCopy();
+ workingCopy.setPrototype(fAppliedPrototype, true);
+ fAttributesTreeViewer.refresh();
+ setDirty(true);
+ updateLaunchConfigurationDialog();
+ reinitTabs(workingCopy);
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ }
+
+ /**
+ * Get the working copy of the launch configuration associated with this
+ * tab.
+ *
+ * @return an {@link ILaunchConfigurationWorkingCopy}.
+ * @throws CoreException
+ */
+ private ILaunchConfigurationWorkingCopy getWorkingCopy() throws CoreException {
+ ILaunchConfigurationWorkingCopy workingCopy;
+ if (fSelectedLaunchConfiguration instanceof ILaunchConfigurationWorkingCopy) {
+ workingCopy = (ILaunchConfigurationWorkingCopy) fSelectedLaunchConfiguration;
+ } else {
+ workingCopy = fSelectedLaunchConfiguration.getWorkingCopy();
+ }
+ return workingCopy;
+ }
+
+ /**
+ * Reinit the tabs of the launch configuration dialog.
+ *
+ * @param launchConfiguration the {@link LaunchConfiguration}.
+ */
+ private void reinitTabs(ILaunchConfiguration launchConfiguration) {
+ ILaunchConfigurationTab[] tabs = getLaunchConfigurationDialog().getTabs();
+ for (ILaunchConfigurationTab configTab : tabs) {
+ configTab.initializeFrom(launchConfiguration);
+ }
+ }
+
+ /**
+ * Get the prototype with the given name in the given prototypes list.
+ *
+ * @param prototypes the prototypes list
+ * @param name the prototype to get
+ * @return the prototype with the given name in the given prototypes list.
+ */
+ private Object[] getPrototype(ILaunchConfiguration[] prototypes, String name) {
+ for (ILaunchConfiguration prototype : prototypes) {
+ if (name.equals(prototype.getName())) {
+ return new Object[] { prototype };
+ }
+ }
+ return new Object[0];
+ }
+
+ /**
+ * Creates the checkbox tree viewer that contains attributes.
+ *
+ * @param parent the parent composite to add this one to
+ * @return a {@link CheckboxTreeViewer}
+ */
+ private CheckboxTreeViewer createCheckboxTreeViewer(Composite parent) {
+ Tree tree = new Tree(parent, SWT.MULTI | SWT.CHECK | SWT.H_SCROLL | SWT.V_SCROLL);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ tree.setLayoutData(gd);
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
+
+ CheckboxTreeViewer treeViewer = new CheckboxTreeViewer(tree);
+
+ treeViewer.setContentProvider(new PrototypeAttributesContentProvider());
+ treeViewer.setCheckStateProvider(new AttributesTreeCheckStateProvider());
+ treeViewer.addCheckStateListener(new AttributesTreeCheckStateListener());
+
+ MenuManager menuMgr = new MenuManager();
+ Menu contextMenu = menuMgr.createContextMenu(tree);
+ menuMgr.addMenuListener(new ResetMenuListener());
+ menuMgr.setRemoveAllWhenShown(true);
+ tree.setMenu(contextMenu);
+
+ return treeViewer;
+ }
+
+ /**
+ * Add columns to the given {@link CheckboxTreeViewer}.
+ *
+ * @param treeViewer the given {@link CheckboxTreeViewer}.
+ */
+ private void addColumnsToTreeViewer(CheckboxTreeViewer treeViewer) {
+ for (TreeColumn treeColumn : treeViewer.getTree().getColumns()) {
+ treeColumn.dispose();
+ }
+ TreeViewerColumn columnLabel = new TreeViewerColumn(treeViewer, SWT.LEFT, 0);
+ columnLabel.setLabelProvider(new ColumnAttributeLabelProvider());
+ columnLabel.getColumn().setText(ATTRIBUTE);
+ if (fSelectedLaunchConfiguration != null && !fSelectedLaunchConfiguration.isPrototype()) {
+ TreeViewerColumn columnModified = new TreeViewerColumn(treeViewer, SWT.CENTER, 1);
+ columnModified.setLabelProvider(new ColumnModifiedLabelProvider());
+ columnModified.getColumn().setText(MODIFIED);
+ }
+ TreeViewerColumn columnValue = new TreeViewerColumn(treeViewer, SWT.LEFT, fSelectedLaunchConfiguration != null && !fSelectedLaunchConfiguration.isPrototype() ? 2 : 1);
+ columnValue.setLabelProvider(new ColumnValueLabelProvider());
+ columnValue.getColumn().setText(PROTOTYPE_VALUE);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.
+ * debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ initialize(configuration);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#dispose()
+ */
+ @Override
+ public void dispose() {
+ super.dispose();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.
+ * core.ILaunchConfigurationWorkingCopy)
+ */
+ @Override
+ public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
+ initialize(workingCopy);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse.
+ * debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ @Override
+ public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {
+ }
+
+ /**
+ * Initialize this tab with the given configuration.
+ *
+ * @param configuration the given configuration
+ * @see ProtoypeTab#activated(ILaunchConfigurationWorkingCopy)
+ * @see ProtoypeTab#initializeFrom(ILaunchConfiguration)
+ */
+ private void initialize(ILaunchConfiguration configuration) {
+ try {
+ if (configuration.isPrototype()) {
+ fPrototypeComposite.setVisible(false);
+ GridData gridData = (GridData) fPrototypeComposite.getLayoutData();
+ gridData.exclude = true;
+ fAppliedPrototype = configuration;
+ fSelectedLaunchConfiguration = configuration;
+ addColumnsToTreeViewer(fAttributesTreeViewer);
+ fAttributesTreeViewer.setInput(fAppliedPrototype);
+ fAttributesTreeViewer.getTree().setEnabled(true);
+ } else {
+ fPrototypeComposite.setVisible(true);
+ GridData gridData = (GridData) fPrototypeComposite.getLayoutData();
+ gridData.exclude = false;
+ fSelectedLaunchConfiguration = configuration;
+ fAppliedPrototype = configuration.getPrototype();
+ addColumnsToTreeViewer(fAttributesTreeViewer);
+ fAttributesTreeViewer.getTree().setEnabled(false);
+ if (fAppliedPrototype == null) {
+ fPrototypeText.setText(""); //$NON-NLS-1$
+ fUnlinkPrototypeButton.setEnabled(false);
+ fResetPrototypeButton.setEnabled(false);
+ fAttributesTreeViewer.setInput(null);
+ } else if (!fAppliedPrototype.exists()) {
+ fPrototypeText.setText(fAppliedPrototype.getName());
+ fUnlinkPrototypeButton.setEnabled(true);
+ fResetPrototypeButton.setEnabled(true);
+ fAttributesTreeViewer.setInput(null);
+ } else {
+ fPrototypeText.setText(fAppliedPrototype.getName());
+ fUnlinkPrototypeButton.setEnabled(true);
+ fResetPrototypeButton.setEnabled(true);
+ fAttributesTreeViewer.setInput(fAppliedPrototype);
+ }
+ }
+ updateProductDecorator();
+ updateColumnsWidth();
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ }
+
+ /**
+ * Set columns tree widths dynamically
+ */
+ private void updateColumnsWidth() {
+ getShell().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ TreeColumn[] columns = fAttributesTreeViewer.getTree().getColumns();
+ for (TreeColumn treeColumn : columns) {
+ treeColumn.pack();
+ }
+ }
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.
+ * core.ILaunchConfiguration)
+ */
+ @Override
+ public boolean isValid(ILaunchConfiguration config) {
+ setMessage(null);
+ setErrorMessage(null);
+
+ if (fAppliedPrototype != null && !fAppliedPrototype.exists()) {
+ setErrorMessage(LaunchConfigurationsMessages.PrototypeTab_Select_Prototype_Error_7);
+ return false;
+ }
+ return !config.isPrototype();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.
+ * debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ @Override
+ public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.
+ * debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ @Override
+ public String getName() {
+ return LaunchConfigurationsMessages.PrototypeTab_Prototype_1;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
+ */
+ @Override
+ public Image getImage() {
+ return DebugUITools.getImage(IInternalDebugUIConstants.IMG_OBJS_PROTO_TAB);
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getId()
+ *
+ */
+ @Override
+ public String getId() {
+ return PROTOTYPE_TAB_ID;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#canSave()
+ */
+ @Override
+ public boolean canSave() {
+ return true;
+ }
+
+ /**
+ * Check if an attribute from the selected launch configuration is different
+ * from its prototype.
+ *
+ * @param element the given attribute.
+ */
+ private boolean isAttributeModified(Entry<String, Object> element) {
+ try {
+ if (fSelectedLaunchConfiguration != null && !fSelectedLaunchConfiguration.isPrototype()) {
+ return fSelectedLaunchConfiguration.isAttributeModified(element.getKey());
+ }
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ return false;
+ }
+
+ /**
+ * Content provider for the prototype attributes table
+ */
+ private class PrototypeAttributesContentProvider implements ITreeContentProvider {
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof ILaunchConfiguration) {
+ try {
+ Map<String, Object> attributes = ((ILaunchConfiguration) inputElement).getAttributes();
+ return attributes.entrySet().toArray();
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ }
+ return new Object[0];
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ return null;
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+ }
+
+ /**
+ * Label provider for the prototype attributes tree column "Edited"
+ */
+ private class ColumnModifiedLabelProvider extends ColumnLabelProvider {
+ @SuppressWarnings("unchecked")
+ @Override
+ public String getText(Object element) {
+ if (fSelectedLaunchConfiguration != null && !fSelectedLaunchConfiguration.isPrototype()) {
+ if (element instanceof Entry && isAttributeModified((Entry<String, Object>) element)) {
+ return "true"; //$NON-NLS-1$
+ }
+ }
+ return "false"; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Label provider for the prototype attributes tree column "Attribute"
+ */
+ @SuppressWarnings({ "unchecked" })
+ private class ColumnAttributeLabelProvider extends ColumnLabelProvider {
+ @Override
+ public String getText(Object element) {
+ String key = ((Entry<String, Object>) element).getKey();
+ ILaunchConfigurationTab[] tabs = getLaunchConfigurationDialog().getTabs();
+ for (ILaunchConfigurationTab tab : tabs) {
+ if (tab instanceof AbstractLaunchConfigurationTab) {
+ String attributeLabel = ((AbstractLaunchConfigurationTab) tab).getAttributeLabel(key);
+ if (attributeLabel != null) {
+ return attributeLabel;
+ }
+ }
+ }
+ return key;
+ }
+ }
+
+ /**
+ * Label provider for the prototype attributes tree column "Value"
+ */
+ @SuppressWarnings({ "unchecked" })
+ private class ColumnValueLabelProvider extends ColumnLabelProvider {
+ @Override
+ public String getText(Object element) {
+ Object value = ((Entry<String, Object>) element).getValue();
+ if (value instanceof Boolean) {
+ return ((Boolean) value).toString();
+ } else if (value instanceof String) {
+ return (String) value;
+ } else if (value instanceof Integer) {
+ return value.toString();
+ } else if (value instanceof List) {
+ return "[" + ((List<String>) value).stream().collect(Collectors.joining(", ")) + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } else if (value instanceof Set) {
+ return "[" + ((Set<String>) value).stream().collect(Collectors.joining(", ")) + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } else if (value instanceof Map) {
+ return "[" + ((Map<String, String>) value).entrySet().stream().map(i -> "[" + i.getKey() + ", " + i.getValue() + "]").collect(Collectors.joining(", ")) + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ }
+ return super.getText(element);
+ }
+ }
+
+ /**
+ * Check state provider for attributes tree.
+ */
+ @SuppressWarnings("unchecked")
+ private class AttributesTreeCheckStateProvider implements ICheckStateProvider {
+ @Override
+ public boolean isGrayed(Object element) {
+ return false;
+ }
+
+ @Override
+ public boolean isChecked(Object element) {
+ try {
+ if (element instanceof Entry) {
+ return fAppliedPrototype.getPrototypeVisibleAttributes().contains(((Entry<String, Object>) element).getKey());
+ }
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Check state listener for attributes tree.
+ */
+ @SuppressWarnings("unchecked")
+ private class AttributesTreeCheckStateListener implements ICheckStateListener {
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ try {
+ Object data = event.getElement();
+ if (data instanceof Entry) {
+ fAppliedPrototype.setPrototypeAttributeVisibility(((Entry<String, Object>) data).getKey(), event.getChecked());
+ setDirty(true);
+ updateLaunchConfigurationDialog();
+ }
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ }
+ }
+
+ /**
+ * Menu Listener for attributes table.
+ */
+ private class ResetMenuListener implements IMenuListener {
+
+ @Override
+ public void menuAboutToShow(IMenuManager manager) {
+ if (fSelectedLaunchConfiguration != null && !fSelectedLaunchConfiguration.isPrototype()) {
+ manager.add(new ResetAction());
+ }
+ }
+ }
+
+ /**
+ * Reset attribute menu action.
+ */
+ @SuppressWarnings("unchecked")
+ private class ResetAction extends Action {
+
+ @Override
+ public String getText() {
+ return LaunchConfigurationsMessages.PrototypeTab_Reset_Menu_Action_9;
+ }
+
+ @Override
+ public void run() {
+ IStructuredSelection selection = (IStructuredSelection) fAttributesTreeViewer.getSelection();
+ try {
+ ILaunchConfigurationWorkingCopy workingCopy = getWorkingCopy();
+ for (Object element : selection.toList()) {
+ if (element instanceof Entry) {
+ String key = ((Entry<String, Object>) element).getKey();
+ if (fAppliedPrototype.getPrototypeVisibleAttributes().contains(key)) {
+ Object prototypeValue = fAppliedPrototype.getAttributes().get(key);
+ workingCopy.setAttribute(key, prototypeValue);
+ }
+ }
+ }
+ setDirty(true);
+ updateLaunchConfigurationDialog();
+ reinitTabs(workingCopy);
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ }
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupTab.java
index e908e70d0..173a13668 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupTab.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupTab.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2010 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.ui.sourcelookup;
@@ -50,6 +51,7 @@ public class SourceLookupTab extends AbstractLaunchConfigurationTab {
* Constructs a new tab with default context help.
*/
public SourceLookupTab() {
+ super();
setHelpContextId(IDebugHelpContextIds.SOURCELOOKUP_TAB);
}
@@ -169,4 +171,16 @@ public class SourceLookupTab extends AbstractLaunchConfigurationTab {
}
return super.getMessage();
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#initializeAttributes()
+ * @since 3.13
+ */
+ @Override
+ protected void initializeAttributes() {
+ super.initializeAttributes();
+ getAttributesLabelsForPrototype().put(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, SourceLookupUIMessages.sourceTab_AttributeLabel_SourceLocatorMemento);
+ getAttributesLabelsForPrototype().put(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, SourceLookupUIMessages.sourceTab_AttributeLabel_SourceLocatorID);
+ }
}

Back to the top