Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2009-11-04 21:01:35 +0000
committerDarin Wright2009-11-04 21:01:35 +0000
commit537a9b593757a8012df704ed968f9c48243496a2 (patch)
treeacd5d8313662009cdb4d149ab9fad1593a96bff2
parent7f796b755f58d4614db2ff3938811245e06177f5 (diff)
downloadeclipse.platform.debug-537a9b593757a8012df704ed968f9c48243496a2.tar.gz
eclipse.platform.debug-537a9b593757a8012df704ed968f9c48243496a2.tar.xz
eclipse.platform.debug-537a9b593757a8012df704ed968f9c48243496a2.zip
Bug 41353 - [launching] Launch config templates
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java13
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java2
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties1
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java38
5 files changed, 59 insertions, 5 deletions
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 3487530a0..4302c67a9 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
@@ -278,9 +278,11 @@ public interface ILaunchConfigurationWorkingCopy extends ILaunchConfiguration, I
* Sets whether this configuration is to be considered as a template.
*
* @param isTemplate whether this configuration is to be considered as a template
+ * @exception CoreException if an attempt is made to nest templates - this configuration
+ * cannot already be associated with a template
* @since 3.6
*/
- public void setTemplate(boolean isTemplate);
+ public void setTemplate(boolean isTemplate) throws CoreException;
/**
* Sets the template that this configuration is based on, possibly <code>null</code>,
@@ -292,8 +294,13 @@ public interface ILaunchConfigurationWorkingCopy extends ILaunchConfiguration, I
* @param template template or <code>null</code>
* @param copy whether to copy attributes from the template to this working copy. Has
* no effect when template is <code>null</code>
- * @exception CoreException if unable to generate a memento for the given configuration
- * or copy its attributes
+ * @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 template attribute on an existing template - templates
+ * cannot be nested</li>
+ * </ul>
* @since 3.6
*/
public void setTemplate(ILaunchConfiguration template, boolean copy) throws CoreException;
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 93286c7dc..0c4c7eacf 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
@@ -102,6 +102,8 @@ public class DebugCoreMessages extends NLS {
public static String LaunchConfigurationWorkingCopy_5;
public static String LaunchConfigurationWorkingCopy_6;
+
+ public static String LaunchConfigurationWorkingCopy_7;
public static String LaunchManager__0__occurred_while_reading_launch_configuration_file__1___1;
public static String LaunchManager_Invalid_launch_configuration_index__18;
public static String LaunchManager_does_not_exist;
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 6565c83e1..78a8a36ab 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
@@ -66,6 +66,7 @@ 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=Template cannot be a working copy.
+LaunchConfigurationWorkingCopy_7=Templates cannot be nested
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/LaunchConfigurationWorkingCopy.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java
index a3b50009b..e8c1292b2 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
@@ -735,10 +735,13 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#setTemplate(boolean)
*/
- public void setTemplate(boolean isTemplate) {
+ public void setTemplate(boolean isTemplate) throws CoreException {
if (!isTemplate) {
removeAttribute(ATTR_IS_TEMPLATE);
} else {
+ if (getTemplate() != null) {
+ throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugCoreMessages.LaunchConfigurationWorkingCopy_7));
+ }
setAttribute(ATTR_IS_TEMPLATE, isTemplate);
}
}
@@ -750,13 +753,16 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen
if (template != null && template.isWorkingCopy()) {
throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugCoreMessages.LaunchConfigurationWorkingCopy_6));
}
+ if (isTemplate()) {
+ throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugCoreMessages.LaunchConfigurationWorkingCopy_7));
+ }
if (template == null) {
removeAttribute(ATTR_TEMPLATE);
} else {
- setAttribute(ATTR_TEMPLATE, template.getMemento());
if (copy) {
copyAttributes(template);
}
+ setAttribute(ATTR_TEMPLATE, template.getMemento());
}
}
}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java
index 6f64069ea..d9daa016e 100644
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java
@@ -1171,6 +1171,44 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
ILaunchConfiguration[] children = t1.getTemplateChildren();
assertEquals(0, children.length);
}
+
+ /**
+ * Tests that nested templates are not allowed.
+ *
+ * @throws CoreException
+ */
+ public void testNestedTemplates() throws CoreException {
+ ILaunchConfigurationWorkingCopy t1 = newConfiguration(null, "test-nest-root");
+ ILaunchConfigurationWorkingCopy t2 = newConfiguration(null, "template-nested");
+ t1.setTemplate(true);
+ ILaunchConfiguration template = t1.doSave();
+ t2.setTemplate(true);
+ try {
+ t2.setTemplate(template, true);
+ } catch (CoreException e) {
+ return;
+ }
+ assertTrue("Shoud not be able to nest templates", false);
+ }
+
+ /**
+ * Tests that nested templates are not allowed.
+ *
+ * @throws CoreException
+ */
+ public void testNestedTemplates2() throws CoreException {
+ ILaunchConfigurationWorkingCopy t1 = newConfiguration(null, "test-nest-root");
+ ILaunchConfigurationWorkingCopy t2 = newConfiguration(null, "template-nested");
+ t1.setTemplate(true);
+ ILaunchConfiguration template = t1.doSave();
+ t2.setTemplate(template, true);
+ try {
+ t2.setTemplate(true);
+ } catch (CoreException e) {
+ return;
+ }
+ assertTrue("Shoud not be able to nest templates", false);
+ }
}

Back to the top