1 11 package org.eclipse.pde.ui.launcher; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.debug.core.ILaunchConfiguration; 15 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 16 import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; 17 import org.eclipse.debug.ui.ILaunchConfigurationTab; 18 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 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.LaunchPluginValidator; 23 import org.eclipse.swt.custom.BusyIndicator; 24 import org.eclipse.swt.widgets.Display; 25 26 34 public abstract class AbstractPDELaunchConfigurationTabGroup extends 35 AbstractLaunchConfigurationTabGroup { 36 37 44 public void initializeFrom(ILaunchConfiguration configuration) { 45 final ILaunchConfiguration config = configuration; 46 final ILaunchConfigurationTab[] tabs = getTabs(); 47 BusyIndicator.showWhile(Display.getCurrent(), new Runnable () { 48 public void run() { 49 try { 50 if (config instanceof ILaunchConfigurationWorkingCopy) { 51 checkBackwardCompatibility( 52 (ILaunchConfigurationWorkingCopy) config); 53 } 54 } catch (CoreException e) { 55 } 56 for (int i = 0; i < tabs.length; i++) { 57 tabs[i].initializeFrom(config); 58 } 59 } 60 }); 61 } 62 63 72 private void checkBackwardCompatibility(ILaunchConfigurationWorkingCopy wc) throws CoreException { 73 String id = wc.getAttribute( 74 IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, 75 (String ) null); 76 if (id == null) { 77 wc.setAttribute( 78 IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, 79 PDESourcePathProvider.ID); 80 } 81 82 String value = wc.getAttribute("vmargs", (String )null); if (value != null) { 84 wc.setAttribute("vmargs", (String )null); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, value); 86 } 87 88 value = wc.getAttribute("progargs", (String )null); if (value != null) { 90 wc.setAttribute("progargs", (String )null); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, value); 92 } 93 94 value = wc.getAttribute(IPDELauncherConstants.LOCATION + "0", (String )null); if (value != null) { 96 wc.setAttribute(IPDELauncherConstants.LOCATION + "0", (String )null); wc.setAttribute(IPDELauncherConstants.LOCATION, value); 98 } 99 100 LaunchPluginValidator.checkBackwardCompatibility(wc, false); 101 wc.doSave(); 102 } 103 104 111 public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { 112 super.setDefaults(configuration); 113 if (TargetPlatformHelper.usesNewApplicationModel()) 114 configuration.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.3"); else if (TargetPlatformHelper.getTargetVersion() >= 3.2) 116 configuration.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.2a"); 118 configuration.setAttribute( 119 IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, 120 PDESourcePathProvider.ID); 121 122 String programArgs = LaunchArgumentsHelper.getInitialProgramArguments().trim(); 124 if (programArgs.length() > 0) 125 configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArgs); 126 127 String vmArgs = LaunchArgumentsHelper.getInitialVMArguments().trim(); 128 if (vmArgs.length() > 0) 129 configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs); 130 131 configuration.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true); 132 } 133 134 } 135 | Popular Tags |