01: /*******************************************************************************
02: * Copyright (c) 2005, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.launcher;
11:
12: import java.util.TreeSet;
13:
14: import org.eclipse.core.runtime.CoreException;
15: import org.eclipse.debug.core.ILaunchConfiguration;
16: import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17: import org.eclipse.pde.internal.ui.IPDEUIConstants;
18: import org.eclipse.pde.internal.ui.PDEUIMessages;
19: import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
20: import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
21:
22: public class JUnitProgramBlock extends ProgramBlock {
23:
24: public JUnitProgramBlock(AbstractLauncherTab tab) {
25: super (tab);
26: }
27:
28: protected String getApplicationAttribute() {
29: return IPDELauncherConstants.APP_TO_TEST;
30: }
31:
32: public void setDefaults(ILaunchConfigurationWorkingCopy config) {
33: if (!LauncherUtils.requiresUI(config))
34: config.setAttribute(IPDELauncherConstants.APPLICATION,
35: IPDEUIConstants.CORE_TEST_APPLICATION);
36: else
37: super .setDefaults(config);
38: }
39:
40: protected String[] getApplicationNames() {
41: TreeSet result = new TreeSet();
42: result.add(PDEUIMessages.JUnitProgramBlock_headless);
43: String[] appNames = super .getApplicationNames();
44: for (int i = 0; i < appNames.length; i++) {
45: result.add(appNames[i]);
46: }
47: return (String[]) result.toArray(new String[result.size()]);
48: }
49:
50: /* (non-Javadoc)
51: * @see org.eclipse.pde.internal.ui.launcher.BasicLauncherTab#initializeApplicationSection(org.eclipse.debug.core.ILaunchConfiguration)
52: */
53: protected void initializeApplicationSection(
54: ILaunchConfiguration config) throws CoreException {
55: String application = config.getAttribute(
56: IPDELauncherConstants.APPLICATION, (String) null);
57: if (IPDEUIConstants.CORE_TEST_APPLICATION.equals(application))
58: fApplicationCombo
59: .setText(PDEUIMessages.JUnitProgramBlock_headless);
60: else
61: super .initializeApplicationSection(config);
62: }
63:
64: /* (non-Javadoc)
65: * @see org.eclipse.pde.internal.ui.launcher.BasicLauncherTab#saveApplicationSection(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
66: */
67: protected void saveApplicationSection(
68: ILaunchConfigurationWorkingCopy config) {
69: if (fApplicationCombo.getText().equals(
70: PDEUIMessages.JUnitProgramBlock_headless)) {
71: String appName = fApplicationCombo.isEnabled() ? IPDEUIConstants.CORE_TEST_APPLICATION
72: : null;
73: config.setAttribute(IPDELauncherConstants.APPLICATION,
74: appName);
75: config.setAttribute(IPDELauncherConstants.APP_TO_TEST,
76: (String) null);
77: } else {
78: config.setAttribute(IPDELauncherConstants.APPLICATION,
79: (String) null);
80: super.saveApplicationSection(config);
81: }
82: }
83:
84: }
|