1 11 package org.eclipse.pde.internal.ui.launcher; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.Preferences; 15 import org.eclipse.debug.core.ILaunchConfiguration; 16 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 17 import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; 18 import org.eclipse.debug.ui.ILaunchConfigurationTab; 19 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 20 import org.eclipse.pde.internal.core.ICoreConstants; 21 import org.eclipse.pde.internal.core.PDECore; 22 import org.eclipse.pde.ui.launcher.IPDELauncherConstants; 23 import org.eclipse.swt.custom.BusyIndicator; 24 import org.eclipse.swt.widgets.Display; 25 26 public abstract class AbstractPDELaunchConfigurationTabGroup extends 27 AbstractLaunchConfigurationTabGroup { 28 29 32 public void initializeFrom(ILaunchConfiguration configuration) { 33 final ILaunchConfiguration config = configuration; 34 final ILaunchConfigurationTab[] tabs = getTabs(); 35 BusyIndicator.showWhile(Display.getCurrent(), new Runnable () { 36 public void run() { 37 try { 38 if (config instanceof ILaunchConfigurationWorkingCopy) { 39 checkBackwardCompatibility( 40 (ILaunchConfigurationWorkingCopy) config); 41 } 42 } catch (CoreException e) { 43 } 44 for (int i = 0; i < tabs.length; i++) { 45 tabs[i].initializeFrom(config); 46 } 47 } 48 }); 49 } 50 51 private void checkBackwardCompatibility(ILaunchConfigurationWorkingCopy wc) throws CoreException { 52 String id = wc.getAttribute( 53 IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, 54 (String ) null); 55 if (id == null) { 56 wc.setAttribute( 57 IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, 58 "org.eclipse.pde.ui.workbenchClasspathProvider"); } 60 61 String value = wc.getAttribute("vmargs", (String )null); if (value != null) { 63 wc.setAttribute("vmargs", (String )null); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, value); 65 } 66 67 value = wc.getAttribute("progargs", (String )null); if (value != null) { 69 wc.setAttribute("progargs", (String )null); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, value); 71 } 72 73 value = wc.getAttribute(IPDELauncherConstants.LOCATION + "0", (String )null); if (value != null) { 75 wc.setAttribute(IPDELauncherConstants.LOCATION + "0", (String )null); wc.setAttribute(IPDELauncherConstants.LOCATION, value); 77 } 78 79 LaunchPluginValidator.checkBackwardCompatibility(wc, false); 80 wc.doSave(); 81 } 82 83 86 public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { 87 super.setDefaults(configuration); 88 configuration.setAttribute( 89 IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, 90 "org.eclipse.pde.ui.workbenchClasspathProvider"); 92 Preferences preferences = PDECore.getDefault().getPluginPreferences(); 94 String programArgs = preferences.getString(ICoreConstants.PROGRAM_ARGS); 95 if (programArgs.length() > 0) 96 configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArgs); 97 String vmArgs = preferences.getString(ICoreConstants.VM_ARGS); 98 if (vmArgs.length() > 0) 99 configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs); 100 } 101 102 } 103 | Popular Tags |