01: package org.eclipse.pde.internal.junit.launcher;
02:
03: import org.eclipse.core.runtime.CoreException;
04: import org.eclipse.debug.core.DebugPlugin;
05: import org.eclipse.debug.core.ILaunchConfiguration;
06: import org.eclipse.debug.core.ILaunchConfigurationType;
07: import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
08: import org.eclipse.debug.core.ILaunchManager;
09: import org.eclipse.debug.ui.IDebugUIConstants;
10: import org.eclipse.jdt.core.IJavaProject;
11: import org.eclipse.jdt.debug.ui.JavaUISourceLocator;
12: import org.eclipse.jdt.internal.junit.launcher.JUnitBaseLaunchConfiguration;
13: import org.eclipse.jdt.internal.junit.launcher.JUnitLaunchShortcut;
14: import org.eclipse.jdt.internal.junit.ui.JUnitPlugin;
15: import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
16:
17: /*
18: * (c) Copyright IBM Corp. 2000, 2001.
19: * All Rights Reserved.
20: */
21: public class JUnitPluginLaunchShortcut extends JUnitLaunchShortcut {
22:
23: /**
24: * Returns the local java launch config type
25: */
26: protected ILaunchConfigurationType getJUnitLaunchConfigType() {
27: ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
28: return lm
29: .getLaunchConfigurationType(JUnitPdeLaunchConfiguration.ID_PLUGIN_JUNIT);
30: }
31:
32: protected ILaunchConfiguration createConfiguration(
33: IJavaProject project, String name, String mainType,
34: String container, String testName) {
35: ILaunchConfiguration config = null;
36: try {
37: ILaunchConfigurationType configType = getJUnitLaunchConfigType();
38: ILaunchConfigurationWorkingCopy wc = configType
39: .newInstance(null, getLaunchManager()
40: .generateUniqueLaunchConfigurationNameFrom(
41: name));
42: wc
43: .setAttribute(
44: IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
45: project.getElementName());
46: wc
47: .setAttribute(
48: IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
49: mainType);
50: wc.setAttribute(
51: JUnitPdeLaunchConfiguration.APPLICATION_NAME_ATTR,
52: JUnitPdeLaunchConfiguration.fgDefaultApp);
53: wc.setAttribute(
54: IDebugUIConstants.ATTR_TARGET_DEBUG_PERSPECTIVE,
55: IDebugUIConstants.PERSPECTIVE_DEFAULT);
56: wc.setAttribute(
57: IDebugUIConstants.ATTR_TARGET_RUN_PERSPECTIVE,
58: IDebugUIConstants.PERSPECTIVE_NONE);
59: wc
60: .setAttribute(
61: ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID,
62: JavaUISourceLocator.ID_PROMPTING_JAVA_SOURCE_LOCATOR);
63: wc.setAttribute(JUnitPdeLaunchConfiguration.WORKSPACE_ATTR,
64: JUnitPdeLaunchConfiguration.getDefaultWorkspace());
65: wc
66: .setAttribute(
67: IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
68: JUnitPdeTabGroup
69: .getDefaultProgramArguments());
70: wc.setAttribute(
71: JUnitBaseLaunchConfiguration.ATTR_KEEPRUNNING,
72: false);
73: wc.setAttribute(
74: JUnitBaseLaunchConfiguration.LAUNCH_CONTAINER_ATTR,
75: container);
76: if (testName.length() > 0)
77: wc.setAttribute(
78: JUnitBaseLaunchConfiguration.TESTNAME_ATTR,
79: testName);
80: config = wc.doSave();
81: } catch (CoreException ce) {
82: JUnitPlugin.log(ce);
83: }
84: return config;
85: }
86:
87: }
|