Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2009-10-15 13:52:17 +0000
committerDarin Wright2009-10-15 13:52:17 +0000
commitd4166175b34e76a23f5effa0f869ae7582357283 (patch)
tree1145b9768f2c548402176afcc24f14f3b1f50424
parent0c7c758321cae2823cc925c614fd85a90636846f (diff)
downloadeclipse.platform.debug-d4166175b34e76a23f5effa0f869ae7582357283.tar.gz
eclipse.platform.debug-d4166175b34e76a23f5effa0f869ae7582357283.tar.xz
eclipse.platform.debug-d4166175b34e76a23f5effa0f869ae7582357283.zip
Bug 41353 - [launching] Launch config templates
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationType.java37
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java41
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java34
3 files changed, 61 insertions, 51 deletions
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 4cf7e9c82..4f8ff9cc3 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
@@ -310,27 +310,40 @@ public interface ILaunchConfigurationType extends IAdaptable {
public String getContributorName();
/**
- * Sets the template for this launch configuration type in the specified scope,
- * or removes the template for the scope when the specified configuration is
+ * Sets the default template for this launch configuration type in the specified scope,
+ * or removes the default template for the scope when the specified configuration is
* <code>null</code>.
*
- * @param configuration template for the specified scope, or <code>null</code> if none
+ * @param configuration default template for the specified scope, or <code>null</code> if none
* @param scope scope
- * @throws CoreException if unable to to set/remove the template for the given scope
+ * @throws CoreException if unable to to set/remove the default template for the given scope
* @since 3.6
*/
- public void setTemplate(ILaunchConfiguration configuration, IScopeContext scope) throws CoreException;
+ public void setDefaultTemplate(ILaunchConfiguration configuration, IScopeContext scope) throws CoreException;
/**
- * Returns the template for this launch configuration type in the specified scope
- * or <code>null</code> if no template has been set for the scope.
+ * Returns the default template for this launch configuration type in the specified scope
+ * or <code>null</code> if no default template has been set for the scope.
*
* @param scope scope
- * @return template for the scope or <code>null</code>
- * @throws CoreException if unable to retrieve the template for the scope
+ * @return default template for the scope or <code>null</code>
+ * @throws CoreException if unable to retrieve the default template for the scope
* @since 3.6
*/
- public ILaunchConfiguration getTemplate(IScopeContext scope) throws CoreException;
+ public ILaunchConfiguration getDefaultTemplate(IScopeContext scope) throws CoreException;
+
+ /**
+ * Resolves and returns the first default template found in the given canonical scope order
+ * or <code>null</code> if none.
+ *
+ * @param scopes context objects to determine which scopes are searched
+ * for a default launch configuration template
+ * @return default template found in the given canonical scope order
+ * or <code>null</code> if none
+ * @exception CoreException if an exception occurs retrieving a default template
+ * @since 3.6
+ */
+ public ILaunchConfiguration resolveDefaultTemplate(IScopeContext[] scopes) throws CoreException;
/**
* Returns all launch configuration templates of the this type, possibly
@@ -345,7 +358,7 @@ public interface ILaunchConfigurationType extends IAdaptable {
/**
* Returns a new launch configuration working copy of this type,
* that resides in the specified container, with the given name, initialized
- * with values in the first template found in the given canonical scope order.
+ * with values from the first default template found in the given canonical scope order.
* 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.
@@ -355,7 +368,7 @@ public interface ILaunchConfigurationType extends IAdaptable {
* locally with the metadata.
* @param name name for the launch configuration
* @param scopes optional context objects to determine which scopes are search
- * for a launch configuration template, or <code>null</code> if template scopes
+ * for a default launch configuration template, or <code>null</code> if template scopes
* should not be considered
* @return a new launch configuration working copy instance of this type
* @exception CoreException if an instance of this type
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 f976c1466..e9fa9c9ed 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
@@ -503,7 +503,7 @@ public class LaunchConfigurationType extends PlatformObject implements ILaunchCo
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchConfigurationType#getTemplate(org.eclipse.core.runtime.preferences.IScopeContext)
*/
- public ILaunchConfiguration getTemplate(IScopeContext scope) throws CoreException {
+ public ILaunchConfiguration getDefaultTemplate(IScopeContext scope) throws CoreException {
IEclipsePreferences node = scope.getNode(DebugPlugin.getUniqueIdentifier());
try {
if (node.nodeExists(TEMPLATES_NODE)) {
@@ -538,7 +538,10 @@ public class LaunchConfigurationType extends PlatformObject implements ILaunchCo
* @see org.eclipse.debug.core.ILaunchConfigurationType#newInstance(org.eclipse.core.resources.IContainer, java.lang.String, org.eclipse.core.runtime.preferences.IScopeContext[])
*/
public ILaunchConfigurationWorkingCopy newInstance(IContainer container, String name, IScopeContext[] scopes) throws CoreException {
- ILaunchConfiguration template = findTemplate(scopes);
+ ILaunchConfiguration template = null;
+ if (scopes != null) {
+ template = resolveDefaultTemplate(scopes);
+ }
ILaunchConfigurationWorkingCopy wc = new LaunchConfigurationWorkingCopy(container, name, this);
if (template != null) {
wc.copyAttributes(template);
@@ -546,30 +549,11 @@ public class LaunchConfigurationType extends PlatformObject implements ILaunchCo
}
return wc;
}
-
- /**
- * Returns the first template found in the given scopes or <code>null</code> if none.
- *
- * @param contexts scopes to search in or <code>null</code>
- * @return template or <code>null</code>
- * @throws CoreException if unable to retrieve template
- */
- private ILaunchConfiguration findTemplate(IScopeContext[] contexts) throws CoreException {
- if (contexts != null) {
- for (int i = 0; i < contexts.length; i++) {
- ILaunchConfiguration template = getTemplate(contexts[i]);
- if (template != null) {
- return template;
- }
- }
- }
- return null;
- }
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchConfigurationType#setTemplate(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.preferences.IScopeContext)
*/
- public void setTemplate(ILaunchConfiguration configuration, IScopeContext scope) throws CoreException {
+ public void setDefaultTemplate(ILaunchConfiguration configuration, IScopeContext scope) throws CoreException {
IEclipsePreferences node = scope.getNode(DebugPlugin.getUniqueIdentifier());
Preferences templates = node.node(TEMPLATES_NODE);
if (configuration == null) {
@@ -591,5 +575,18 @@ public class LaunchConfigurationType extends PlatformObject implements ILaunchCo
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchConfigurationType#resolveDefaultTemplate(org.eclipse.core.runtime.preferences.IScopeContext[])
+ */
+ public ILaunchConfiguration resolveDefaultTemplate(IScopeContext[] scopes) throws CoreException {
+ for (int i = 0; i < scopes.length; i++) {
+ ILaunchConfiguration template = getDefaultTemplate(scopes[i]);
+ if (template != null) {
+ return template;
+ }
+ }
+ return null;
+ }
+
}
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 c341c0d7c..d8bf5e72c 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
@@ -1074,13 +1074,13 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
ILaunchConfiguration template = wc.doSave();
ILaunchConfigurationType type = template.getType();
IScopeContext scope = new ProjectScope(getProject());
- type.setTemplate(template, scope);
- ILaunchConfiguration configuration = type.getTemplate(scope);
+ type.setDefaultTemplate(template, scope);
+ ILaunchConfiguration configuration = type.getDefaultTemplate(scope);
assertNotNull("No template found", configuration);
assertEquals("Wrong template", template, configuration);
// test removing scope
- type.setTemplate(null, scope);
- configuration = type.getTemplate(scope);
+ type.setDefaultTemplate(null, scope);
+ configuration = type.getDefaultTemplate(scope);
assertNull("Should no longer be a template", configuration);
}
@@ -1094,13 +1094,13 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
ILaunchConfiguration template = wc.doSave();
ILaunchConfigurationType type = template.getType();
IScopeContext scope = new InstanceScope();
- type.setTemplate(template, scope);
- ILaunchConfiguration configuration = type.getTemplate(scope);
+ type.setDefaultTemplate(template, scope);
+ ILaunchConfiguration configuration = type.getDefaultTemplate(scope);
assertNotNull("No template found", configuration);
assertEquals("Wrong template", template, configuration);
// test removing scope
- type.setTemplate(null, scope);
- configuration = type.getTemplate(scope);
+ type.setDefaultTemplate(null, scope);
+ configuration = type.getDefaultTemplate(scope);
assertNull("Should no longer be a template", configuration);
}
@@ -1120,8 +1120,8 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
ILaunchConfigurationType type = ptemplate.getType();
IScopeContext pscope = new ProjectScope(getProject());
IScopeContext wscope = new InstanceScope();
- type.setTemplate(ptemplate, pscope);
- type.setTemplate(itemplate, wscope);
+ type.setDefaultTemplate(ptemplate, pscope);
+ type.setDefaultTemplate(itemplate, wscope);
// create a new configuration in project scope priority
ILaunchConfigurationWorkingCopy config = type.newInstance(null, "test-scopes", new IScopeContext[]{pscope, wscope});
@@ -1129,11 +1129,11 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
assertEquals("Should refer to creation template", ptemplate, config.getTemplate());
// Removing defaults
- type.setTemplate(null, pscope);
- type.setTemplate(null, wscope);
- ILaunchConfiguration configuration = type.getTemplate(pscope);
+ type.setDefaultTemplate(null, pscope);
+ type.setDefaultTemplate(null, wscope);
+ ILaunchConfiguration configuration = type.getDefaultTemplate(pscope);
assertNull("Should no longer be a project template", configuration);
- configuration = type.getTemplate(wscope);
+ configuration = type.getDefaultTemplate(wscope);
assertNull("Should no longer be a workspace template", configuration);
}
@@ -1150,7 +1150,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
ILaunchConfigurationType type = itemplate.getType();
IScopeContext pscope = new ProjectScope(getProject());
IScopeContext wscope = new InstanceScope();
- type.setTemplate(itemplate, wscope);
+ type.setDefaultTemplate(itemplate, wscope);
// create a new configuration in project scope priority, but picks up workspace scope
ILaunchConfigurationWorkingCopy config = type.newInstance(null, "test-scopes", new IScopeContext[]{pscope, wscope});
@@ -1158,8 +1158,8 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
assertEquals("Should refer to creation template", itemplate, config.getTemplate());
// Removing defaults
- type.setTemplate(null, wscope);
- ILaunchConfiguration configuration = type.getTemplate(wscope);
+ type.setDefaultTemplate(null, wscope);
+ ILaunchConfiguration configuration = type.getDefaultTemplate(wscope);
assertNull("Should no longer be a workspace template", configuration);
}

Back to the top