1 11 package org.eclipse.pde.internal.ui.launcher; 12 13 import java.util.TreeSet ; 14 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.debug.core.ILaunchConfiguration; 17 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 18 import org.eclipse.pde.internal.ui.IPDEUIConstants; 19 import org.eclipse.pde.internal.ui.PDEUIMessages; 20 import org.eclipse.pde.ui.launcher.AbstractLauncherTab; 21 import org.eclipse.pde.ui.launcher.IPDELauncherConstants; 22 23 public class JUnitProgramBlock extends ProgramBlock { 24 25 public JUnitProgramBlock(AbstractLauncherTab tab) { 26 super(tab); 27 } 28 29 protected String getApplicationAttribute() { 30 return IPDELauncherConstants.APP_TO_TEST; 31 } 32 33 public void setDefaults(ILaunchConfigurationWorkingCopy config) { 34 if (!LauncherUtils.requiresUI(config)) 35 config.setAttribute(IPDELauncherConstants.APPLICATION, 36 IPDEUIConstants.CORE_TEST_APPLICATION); 37 else 38 super.setDefaults(config); 39 } 40 41 protected String [] getApplicationNames() { 42 TreeSet result = new TreeSet (); 43 result.add(PDEUIMessages.JUnitProgramBlock_headless); 44 String [] appNames = super.getApplicationNames(); 45 for (int i = 0; i < appNames.length; i++) { 46 result.add(appNames[i]); 47 } 48 return (String [])result.toArray(new String [result.size()]); 49 } 50 51 54 protected void initializeApplicationSection(ILaunchConfiguration config) 55 throws CoreException { 56 String application = config.getAttribute(IPDELauncherConstants.APPLICATION, (String )null); 57 if (IPDEUIConstants.CORE_TEST_APPLICATION.equals(application)) 58 fApplicationCombo.setText(PDEUIMessages.JUnitProgramBlock_headless); 59 else 60 super.initializeApplicationSection(config); 61 } 62 63 66 protected void saveApplicationSection(ILaunchConfigurationWorkingCopy config) { 67 if (fApplicationCombo.getText().equals(PDEUIMessages.JUnitProgramBlock_headless)) { 68 String appName = fApplicationCombo.isEnabled() ? IPDEUIConstants.CORE_TEST_APPLICATION : null; 69 config.setAttribute(IPDELauncherConstants.APPLICATION, appName); 70 config.setAttribute(IPDELauncherConstants.APP_TO_TEST, (String )null); 71 } else { 72 config.setAttribute(IPDELauncherConstants.APPLICATION, (String )null); 73 super.saveApplicationSection(config); 74 } 75 } 76 77 } 78 | Popular Tags |