1 11 package org.eclipse.pde.ui.launcher; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 15 import org.eclipse.jdt.core.IJavaElement; 16 import org.eclipse.jdt.junit.launcher.JUnitLaunchShortcut; 17 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 18 import org.eclipse.pde.core.plugin.TargetPlatform; 19 import org.eclipse.pde.internal.core.TargetPlatformHelper; 20 import org.eclipse.pde.internal.ui.IPDEUIConstants; 21 import org.eclipse.pde.internal.ui.launcher.LaunchArgumentsHelper; 22 import org.eclipse.pde.internal.ui.launcher.LauncherUtils; 23 24 31 public class JUnitWorkbenchLaunchShortcut extends JUnitLaunchShortcut { 32 33 36 protected String getLaunchConfigurationTypeId() { 37 return "org.eclipse.pde.ui.JunitLaunchConfig"; } 39 40 43 protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(IJavaElement element) throws CoreException { 44 ILaunchConfigurationWorkingCopy configuration = super.createLaunchConfiguration(element); 45 if (TargetPlatformHelper.usesNewApplicationModel()) 46 configuration.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.3"); else if (TargetPlatformHelper.getTargetVersion() >= 3.2) 48 configuration.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.2a"); configuration.setAttribute(IPDELauncherConstants.LOCATION, LaunchArgumentsHelper.getDefaultJUnitWorkspaceLocation()); 50 configuration.setAttribute(IPDELauncherConstants.DOCLEAR, true); 51 configuration.setAttribute(IPDELauncherConstants.ASKCLEAR, false); 52 configuration.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true); 53 54 if (LauncherUtils.requiresUI(configuration)) { 56 String product = TargetPlatform.getDefaultProduct(); 57 if (product != null) { 58 configuration.setAttribute(IPDELauncherConstants.USE_PRODUCT, true); 59 configuration.setAttribute(IPDELauncherConstants.PRODUCT, product); 60 } 61 } else { 62 configuration.setAttribute(IPDELauncherConstants.APPLICATION, IPDEUIConstants.CORE_TEST_APPLICATION); 63 } 64 65 configuration.setAttribute(IPDELauncherConstants.USE_DEFAULT, true); 67 68 String programArgs = LaunchArgumentsHelper.getInitialProgramArguments(); 70 if (programArgs.length() > 0) 71 configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArgs); 72 73 String vmArgs = LaunchArgumentsHelper.getInitialVMArguments(); 75 if (vmArgs.length() > 0) 76 configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs); 77 78 79 configuration.setAttribute(IPDELauncherConstants.CONFIG_GENERATE_DEFAULT, true); 81 configuration.setAttribute(IPDELauncherConstants.CONFIG_USE_DEFAULT_AREA, false); 82 configuration.setAttribute(IPDELauncherConstants.CONFIG_LOCATION, LaunchArgumentsHelper.getDefaultJUnitConfigurationLocation()); 83 configuration.setAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, true); 84 85 configuration.setAttribute(IPDELauncherConstants.TRACING_CHECKED, IPDELauncherConstants.TRACING_NONE); 87 88 configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, 90 PDESourcePathProvider.ID); 91 92 return configuration; 93 } 94 95 } 96 | Popular Tags |