### Eclipse Workspace Patch 1.0 #P org.eclipse.pde.ui Index: src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfigurationTabGroup.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfigurationTabGroup.java,v retrieving revision 1.13 diff -u -r1.13 AbstractPDELaunchConfigurationTabGroup.java --- src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfigurationTabGroup.java 13 Apr 2009 14:10:29 -0000 1.13 +++ src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfigurationTabGroup.java 21 Sep 2009 18:33:50 -0000 @@ -11,6 +11,9 @@ *******************************************************************************/ package org.eclipse.pde.ui.launcher; +import org.eclipse.pde.launching.IPDELauncherConstants; +import org.eclipse.pde.launching.PDESourcePathProvider; + import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; @@ -18,9 +21,9 @@ import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; import org.eclipse.pde.internal.core.TargetPlatformHelper; -import org.eclipse.pde.internal.ui.IPDEUIConstants; -import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper; -import org.eclipse.pde.internal.ui.launcher.LaunchArgumentsHelper; +import org.eclipse.pde.internal.launching.IPDEConstants; +import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper; +import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.widgets.Display; @@ -110,9 +113,9 @@ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { super.setDefaults(configuration); if (TargetPlatformHelper.usesNewApplicationModel()) - configuration.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$ + configuration.setAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$ else if (TargetPlatformHelper.getTargetVersion() >= 3.2) - configuration.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.2a"); //$NON-NLS-1$ + configuration.setAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, "3.2a"); //$NON-NLS-1$ configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, PDESourcePathProvider.ID); @@ -125,7 +128,7 @@ if (vmArgs.length() > 0) configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs); - configuration.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true); + configuration.setAttribute(IPDEConstants.APPEND_ARGS_EXPLICITLY, true); } } Index: src/org/eclipse/pde/ui/launcher/PDESourcePathProvider.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/PDESourcePathProvider.java,v retrieving revision 1.7 diff -u -r1.7 PDESourcePathProvider.java --- src/org/eclipse/pde/ui/launcher/PDESourcePathProvider.java 27 May 2009 20:38:25 -0000 1.7 +++ src/org/eclipse/pde/ui/launcher/PDESourcePathProvider.java 21 Sep 2009 18:33:50 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,130 +10,15 @@ *******************************************************************************/ package org.eclipse.pde.ui.launcher; -import java.util.ArrayList; -import java.util.List; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.jdt.core.*; -import org.eclipse.jdt.launching.*; -import org.eclipse.pde.internal.core.util.PDEJavaHelper; -import org.eclipse.pde.internal.ui.PDEPlugin; -import org.eclipse.pde.internal.ui.launcher.LaunchPluginValidator; -import org.eclipse.pde.internal.ui.launcher.VMHelper; - /** * Generates a source lookup path for all PDE-based launch configurations *
* Clients may subclass this class. *
* @since 3.3 + * @deprecated + * @see org.eclipse.pde.launching.PDESourcePathProvider */ -public class PDESourcePathProvider extends StandardSourcePathProvider { - - public static final String ID = "org.eclipse.pde.ui.workbenchClasspathProvider"; //$NON-NLS-1$ - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.launching.StandardSourcePathProvider#computeUnresolvedClasspath(org.eclipse.debug.core.ILaunchConfiguration) - */ - public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException { - List sourcePath = new ArrayList(); - sourcePath.add(getJREEntry(configuration)); - IProject[] projects = getJavaProjects(configuration); - for (int i = 0; i < projects.length; i++) { - sourcePath.add(JavaRuntime.newProjectRuntimeClasspathEntry(JavaCore.create(projects[i]))); - } - return (IRuntimeClasspathEntry[]) sourcePath.toArray(new IRuntimeClasspathEntry[sourcePath.size()]); - } - - /** - * Returns a JRE runtime classpath entry - * - * @param configuration - * the launch configuration - * @return a JRE runtime classpath entry - * @throws CoreException - * if the JRE associated with the launch configuration cannot be found - * or if unable to retrieve the launch configuration attributes - */ - private IRuntimeClasspathEntry getJREEntry(ILaunchConfiguration configuration) throws CoreException { - IVMInstall jre = VMHelper.createLauncher(configuration); - IPath containerPath = new Path(JavaRuntime.JRE_CONTAINER); - containerPath = containerPath.append(jre.getVMInstallType().getId()); - containerPath = containerPath.append(jre.getName()); - return JavaRuntime.newRuntimeContainerClasspathEntry(containerPath, IRuntimeClasspathEntry.BOOTSTRAP_CLASSES); - } - - /** - * Returns an array of sorted plug-in projects that represent plug-ins participating - * in the launch - * - * @param configuration - * the launch configuration - * @return an array of ordered projects - * @throws CoreException - * if unable to retrieve attributes from the launch configuration or if - * an error occurs when checking the nature of the project - * - */ - private IProject[] getJavaProjects(ILaunchConfiguration configuration) throws CoreException { - IProject[] projects = LaunchPluginValidator.getAffectedProjects(configuration); - return PDEPlugin.getWorkspace().computeProjectOrder(projects).projects; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.launching.StandardSourcePathProvider#resolveClasspath(org.eclipse.jdt.launching.IRuntimeClasspathEntry[], org.eclipse.debug.core.ILaunchConfiguration) - */ - public IRuntimeClasspathEntry[] resolveClasspath(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration) throws CoreException { - List all = new ArrayList(entries.length); - for (int i = 0; i < entries.length; i++) { - if (entries[i].getType() == IRuntimeClasspathEntry.PROJECT) { - // a project resolves to itself for source lookup (rather than - // the class file output locations) - all.add(entries[i]); - // also add non-JRE libraries - IResource resource = entries[i].getResource(); - if (resource instanceof IProject) { - addBinaryPackageFragmentRoots(JavaCore.create((IProject) resource), all); - } - } else { - IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveRuntimeClasspathEntry(entries[i], configuration); - for (int j = 0; j < resolved.length; j++) { - all.add(resolved[j]); - } - } - } - return (IRuntimeClasspathEntry[]) all.toArray(new IRuntimeClasspathEntry[all.size()]); - } - - /** - * Adds runtime classpath entries for binary package fragment roots contained within - * the project - * - * @param jProject - * the Java project whose roots are to be enumerated - * @param all - * a list of accumulated runtime classpath entries - * @throws CoreException - * if unable to evaluate the package fragment roots - */ - private void addBinaryPackageFragmentRoots(IJavaProject jProject, List all) throws CoreException { - IPackageFragmentRoot[] roots = jProject.getPackageFragmentRoots(); - for (int j = 0; j < roots.length; j++) { - if (roots[j].getKind() == IPackageFragmentRoot.K_BINARY && !PDEJavaHelper.isJRELibrary(roots[j])) { - IRuntimeClasspathEntry rte = JavaRuntime.newArchiveRuntimeClasspathEntry(roots[j].getPath()); - IPath path = roots[j].getSourceAttachmentPath(); - if (path != null) { - rte.setSourceAttachmentPath(path); - rte.setSourceAttachmentRootPath(roots[j].getSourceAttachmentRootPath()); - } - if (!all.contains(rte)) - all.add(rte); - } - } +public class PDESourcePathProvider extends org.eclipse.pde.launching.PDESourcePathProvider { - } } \ No newline at end of file Index: src/org/eclipse/pde/ui/launcher/ConfigurationTab.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/ConfigurationTab.java,v retrieving revision 1.13 diff -u -r1.13 ConfigurationTab.java --- src/org/eclipse/pde/ui/launcher/ConfigurationTab.java 30 Jul 2008 20:44:34 -0000 1.13 +++ src/org/eclipse/pde/ui/launcher/ConfigurationTab.java 21 Sep 2009 18:33:50 -0000 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.pde.ui.launcher; +import org.eclipse.pde.launching.IPDELauncherConstants; + import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; Index: src/org/eclipse/pde/ui/launcher/OSGiSettingsTab.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/OSGiSettingsTab.java,v retrieving revision 1.8 diff -u -r1.8 OSGiSettingsTab.java --- src/org/eclipse/pde/ui/launcher/OSGiSettingsTab.java 30 Jul 2008 20:44:34 -0000 1.8 +++ src/org/eclipse/pde/ui/launcher/OSGiSettingsTab.java 21 Sep 2009 18:33:50 -0000 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.pde.ui.launcher; +import org.eclipse.pde.launching.IPDELauncherConstants; + import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; Index: src/org/eclipse/pde/ui/launcher/PluginJUnitMainTab.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/PluginJUnitMainTab.java,v retrieving revision 1.9 diff -u -r1.9 PluginJUnitMainTab.java --- src/org/eclipse/pde/ui/launcher/PluginJUnitMainTab.java 30 Jul 2008 20:44:34 -0000 1.9 +++ src/org/eclipse/pde/ui/launcher/PluginJUnitMainTab.java 21 Sep 2009 18:33:50 -0000 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.pde.ui.launcher; +import org.eclipse.pde.launching.IPDELauncherConstants; + import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.pde.internal.ui.launcher.JUnitProgramBlock; Index: src/org/eclipse/pde/ui/launcher/OSGiLaunchShortcut.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/OSGiLaunchShortcut.java,v retrieving revision 1.5 diff -u -r1.5 OSGiLaunchShortcut.java --- src/org/eclipse/pde/ui/launcher/OSGiLaunchShortcut.java 25 Feb 2009 17:18:44 -0000 1.5 +++ src/org/eclipse/pde/ui/launcher/OSGiLaunchShortcut.java 21 Sep 2009 18:33:50 -0000 @@ -10,11 +10,13 @@ *******************************************************************************/ package org.eclipse.pde.ui.launcher; +import org.eclipse.pde.launching.IPDELauncherConstants; + import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.pde.internal.ui.PDEPlugin; -import org.eclipse.pde.internal.ui.launcher.OSGiFrameworkManager; +import org.eclipse.pde.internal.launching.PDELaunchingPlugin; +import org.eclipse.pde.internal.launching.launcher.OSGiFrameworkManager; import org.eclipse.ui.IEditorPart; /** @@ -59,7 +61,7 @@ * @see org.eclipse.pde.ui.launcher.AbstractLaunchShortcut#initializeConfiguration(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ protected void initializeConfiguration(ILaunchConfigurationWorkingCopy configuration) { - OSGiFrameworkManager manager = PDEPlugin.getDefault().getOSGiFrameworkManager(); + OSGiFrameworkManager manager = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager(); manager.getDefaultInitializer().initialize(configuration); } Index: src/org/eclipse/pde/ui/launcher/EquinoxLaunchConfiguration.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/EquinoxLaunchConfiguration.java,v retrieving revision 1.36 diff -u -r1.36 EquinoxLaunchConfiguration.java --- src/org/eclipse/pde/ui/launcher/EquinoxLaunchConfiguration.java 13 Apr 2009 14:10:29 -0000 1.36 +++ src/org/eclipse/pde/ui/launcher/EquinoxLaunchConfiguration.java 21 Sep 2009 18:33:50 -0000 @@ -11,20 +11,6 @@ *******************************************************************************/ package org.eclipse.pde.ui.launcher; -import java.io.File; -import java.net.URL; -import java.util.*; -import org.eclipse.core.runtime.*; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.pde.core.plugin.*; -import org.eclipse.pde.internal.build.IPDEBuildConstants; -import org.eclipse.pde.internal.core.ClasspathHelper; -import org.eclipse.pde.internal.core.P2Utils; -import org.eclipse.pde.internal.core.util.CoreUtility; -import org.eclipse.pde.internal.ui.IPDEUIConstants; -import org.eclipse.pde.internal.ui.PDEUIMessages; -import org.eclipse.pde.internal.ui.launcher.*; /** * A launch delegate for launching the Equinox framework @@ -32,174 +18,9 @@ * Clients may subclass and instantiate this class. * * @since 3.2 + * @deprecated + * @see org.eclipse.pde.launching.EquinoxLaunchConfiguration */ -public class EquinoxLaunchConfiguration extends AbstractPDELaunchConfiguration { - - // used to generate the dev classpath entries - // key is bundle ID, value is a model - protected Map fAllBundles; - - // key is a model, value is startLevel:autoStart - private Map fModels; - - /* - * (non-Javadoc) - * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#getProgramArguments(org.eclipse.debug.core.ILaunchConfiguration) - */ - public String[] getProgramArguments(ILaunchConfiguration configuration) throws CoreException { - ArrayList programArgs = new ArrayList(); - - programArgs.add("-dev"); //$NON-NLS-1$ - programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", fAllBundles)); //$NON-NLS-1$ - - saveConfigurationFile(configuration); - programArgs.add("-configuration"); //$NON-NLS-1$ - programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$ - - String[] args = super.getProgramArguments(configuration); - for (int i = 0; i < args.length; i++) { - programArgs.add(args[i]); - } - return (String[]) programArgs.toArray(new String[programArgs.size()]); - } - - private void saveConfigurationFile(ILaunchConfiguration configuration) throws CoreException { - Properties properties = new Properties(); - properties.setProperty("osgi.install.area", "file:" + TargetPlatform.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$ - properties.setProperty("osgi.configuration.cascaded", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - properties.put("osgi.framework", LaunchConfigurationHelper.getBundleURL(IPDEBuildConstants.BUNDLE_OSGI, fAllBundles, false)); //$NON-NLS-1$ - int start = configuration.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4); - properties.put("osgi.bundles.defaultStartLevel", Integer.toString(start)); //$NON-NLS-1$ - boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, true); - - String bundles = null; - if (fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) { - // If simple configurator is being used, we need to write out the bundles.txt instead of writing out the list in the config.ini - URL bundlesTxt = P2Utils.writeBundlesTxt(fModels, start, autostart, getConfigDir(configuration), null); - if (bundlesTxt != null) { - properties.setProperty("org.eclipse.equinox.simpleconfigurator.configUrl", bundlesTxt.toString()); //$NON-NLS-1$ - if (fAllBundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) { - properties.setProperty("org.eclipse.update.reconcile", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - StringBuffer buffer = new StringBuffer(); - IPluginModelBase model = (IPluginModelBase) fAllBundles.get(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR); - buffer.append(LaunchConfigurationHelper.getBundleURL(model, true)); - appendStartData(buffer, (String) fModels.get(model), autostart); - bundles = buffer.toString(); - } else { - bundles = getBundles(autostart); - } - if (bundles.length() > 0) - properties.put("osgi.bundles", bundles); //$NON-NLS-1$ - - if (!"3.3".equals(configuration.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, ""))) { //$NON-NLS-1$ //$NON-NLS-2$ - properties.put("eclipse.ignoreApp", "true"); //$NON-NLS-1$ //$NON-NLS-2$ - properties.put("osgi.noShutdown", "true"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - LaunchConfigurationHelper.save(new File(getConfigDir(configuration), "config.ini"), properties); //$NON-NLS-1$ - } - - private String getBundles(boolean defaultAuto) { - StringBuffer buffer = new StringBuffer(); - Iterator iter = fModels.keySet().iterator(); - while (iter.hasNext()) { - IPluginModelBase model = (IPluginModelBase) iter.next(); - String id = model.getPluginBase().getId(); - if (!IPDEBuildConstants.BUNDLE_OSGI.equals(id)) { - if (buffer.length() > 0) - buffer.append(","); //$NON-NLS-1$ - buffer.append(LaunchConfigurationHelper.getBundleURL(model, true)); - - // fragments must not be started or have a start level - if (model instanceof IFragmentModel) - continue; - - String data = fModels.get(model).toString(); - appendStartData(buffer, data, defaultAuto); - } - } - return buffer.toString(); - } - - /** - * Convenience method to parses the startData ("startLevel:autoStart"), convert it to the - * format expected by the OSGi bundles property, and append to a StringBuffer. - * @param buffer buffer to append the data to - * @param startData data to parse ("startLevel:autoStart") - * @param defaultAuto default auto start setting - */ - private void appendStartData(StringBuffer buffer, String startData, boolean defaultAuto) { - int index = startData.indexOf(':'); - String level = index > 0 ? startData.substring(0, index) : "default"; //$NON-NLS-1$ - String auto = index > 0 && index < startData.length() - 1 ? startData.substring(index + 1) : "default"; //$NON-NLS-1$ - if ("default".equals(auto)) //$NON-NLS-1$ - auto = Boolean.toString(defaultAuto); - if (!level.equals("default") || "true".equals(auto)) //$NON-NLS-1$ //$NON-NLS-2$ - buffer.append("@"); //$NON-NLS-1$ - - if (!level.equals("default")) { //$NON-NLS-1$ - buffer.append(level); - if ("true".equals(auto)) //$NON-NLS-1$ - buffer.append(":"); //$NON-NLS-1$ - } - if ("true".equals(auto)) { //$NON-NLS-1$ - buffer.append("start"); //$NON-NLS-1$ - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException { - fModels = BundleLauncherHelper.getMergedBundleMap(configuration, true); - fAllBundles = new HashMap(fModels.size()); - Iterator iter = fModels.keySet().iterator(); - while (iter.hasNext()) { - IPluginModelBase model = (IPluginModelBase) iter.next(); - fAllBundles.put(model.getPluginBase().getId(), model); - } - - if (!fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_OSGI)) { - // implicitly add it - IPluginModelBase model = PluginRegistry.findModel(IPDEBuildConstants.BUNDLE_OSGI); - if (model != null) { - fModels.put(model, "default:default"); //$NON-NLS-1$ - fAllBundles.put(IPDEBuildConstants.BUNDLE_OSGI, model); - } else { - String message = PDEUIMessages.EquinoxLaunchConfiguration_oldTarget; - throw new CoreException(LauncherUtils.createErrorStatus(message)); - } - } - super.preLaunchCheck(configuration, launch, monitor); - } - - /* - * (non-Javadoc) - * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#validatePluginDependencies(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { - OSGiValidationOperation op = new OSGiValidationOperation(configuration); - LaunchPluginValidator.runValidationOperation(op, monitor); - } - - /** - * Clears the configuration area if the area exists and that option is selected. - * - * @param configuration - * the launch configuration - * @param monitor - * the progress monitor - * @throws CoreException - * if unable to retrieve launch attribute values - * @since 3.3 - */ - protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { - // clear config area, if necessary - if (configuration.getAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false)) - CoreUtility.deleteContent(getConfigDir(configuration)); - } +public class EquinoxLaunchConfiguration extends org.eclipse.pde.launching.EquinoxLaunchConfiguration { } Index: src/org/eclipse/pde/ui/launcher/OSGiLauncherTabGroup.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/OSGiLauncherTabGroup.java,v retrieving revision 1.3 diff -u -r1.3 OSGiLauncherTabGroup.java --- src/org/eclipse/pde/ui/launcher/OSGiLauncherTabGroup.java 25 Feb 2009 17:18:44 -0000 1.3 +++ src/org/eclipse/pde/ui/launcher/OSGiLauncherTabGroup.java 21 Sep 2009 18:33:50 -0000 @@ -13,8 +13,8 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.*; import org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab; -import org.eclipse.pde.internal.ui.PDEPlugin; -import org.eclipse.pde.internal.ui.launcher.OSGiFrameworkManager; +import org.eclipse.pde.internal.launching.PDELaunchingPlugin; +import org.eclipse.pde.internal.launching.launcher.OSGiFrameworkManager; /** * Creates and initializes the tabs on the OSGi Framework launch configuration. @@ -49,7 +49,7 @@ */ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { super.setDefaults(configuration); - OSGiFrameworkManager manager = PDEPlugin.getDefault().getOSGiFrameworkManager(); + OSGiFrameworkManager manager = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager(); manager.getDefaultInitializer().initialize(configuration); } Index: src/org/eclipse/pde/ui/launcher/JUnitLaunchConfigurationDelegate.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/JUnitLaunchConfigurationDelegate.java,v retrieving revision 1.30 diff -u -r1.30 JUnitLaunchConfigurationDelegate.java --- src/org/eclipse/pde/ui/launcher/JUnitLaunchConfigurationDelegate.java 13 Apr 2009 14:10:29 -0000 1.30 +++ src/org/eclipse/pde/ui/launcher/JUnitLaunchConfigurationDelegate.java 21 Sep 2009 18:33:50 -0000 @@ -13,480 +13,13 @@ *******************************************************************************/ package org.eclipse.pde.ui.launcher; -import java.io.File; -import java.util.*; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.*; -import org.eclipse.debug.core.*; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.internal.junit.launcher.*; -import org.eclipse.jdt.launching.*; -import org.eclipse.osgi.service.resolver.BundleDescription; -import org.eclipse.osgi.util.NLS; -import org.eclipse.pde.core.plugin.*; -import org.eclipse.pde.internal.core.*; -import org.eclipse.pde.internal.core.util.CoreUtility; -import org.eclipse.pde.internal.core.util.VersionUtil; -import org.eclipse.pde.internal.ui.*; -import org.eclipse.pde.internal.ui.launcher.*; -import org.osgi.framework.Version; - /** * A launch delegate for launching JUnit Plug-in tests. * * @since 3.3 + * @deprecated + * @see org.eclipse.pde.launching.JUnitLaunchConfigurationDelegate */ -public class JUnitLaunchConfigurationDelegate extends org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate { - - /** - * To avoid duplicating variable substitution (and duplicate prompts) - * this variable will store the substituted workspace location. - */ - private String fWorkspaceLocation; - - protected File fConfigDir = null; - - // used to generate the dev classpath entries - // key is bundle ID, value is a model - private Map fAllBundles; - - // key is a model, value is startLevel:autoStart - private Map fModels; - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getVMRunner(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String) - */ - public IVMRunner getVMRunner(ILaunchConfiguration configuration, String mode) throws CoreException { - IVMInstall launcher = VMHelper.createLauncher(configuration); - return launcher.getVMRunner(mode); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate#verifyMainTypeName(org.eclipse.debug.core.ILaunchConfiguration) - */ - public String verifyMainTypeName(ILaunchConfiguration configuration) throws CoreException { - if (TargetPlatformHelper.getTargetVersion() >= 3.3) - return "org.eclipse.equinox.launcher.Main"; //$NON-NLS-1$ - return "org.eclipse.core.launcher.Main"; //$NON-NLS-1$ - } - - private String getTestPluginId(ILaunchConfiguration configuration) throws CoreException { - IJavaProject javaProject = getJavaProject(configuration); - IPluginModelBase model = PluginRegistry.findModel(javaProject.getProject()); - if (model == null) - abort(NLS.bind(PDEUIMessages.JUnitLaunchConfiguration_error_notaplugin, javaProject.getProject().getName()), null, IStatus.OK); - if (model instanceof IFragmentModel) - return ((IFragmentModel) model).getFragment().getPluginId(); - - return model.getPluginBase().getId(); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.internal.junit.launcher.JUnitBaseLaunchConfiguration#abort(java.lang.String, java.lang.Throwable, int) - */ - protected void abort(String message, Throwable exception, int code) throws CoreException { - throw new CoreException(new Status(IStatus.ERROR, IPDEUIConstants.PLUGIN_ID, code, message, exception)); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate#collectExecutionArguments(org.eclipse.debug.core.ILaunchConfiguration, java.util.List, java.util.List) - */ - protected void collectExecutionArguments(ILaunchConfiguration configuration, List/*String*/vmArguments, List/*String*/programArgs) throws CoreException { - super.collectExecutionArguments(configuration, vmArguments, programArgs); - - // Specify the JUnit Plug-in test application to launch - programArgs.add("-application"); //$NON-NLS-1$ - String application = getApplication(configuration); - - programArgs.add(application); - - // If a product is specified, then add it to the program args - if (configuration.getAttribute(IPDELauncherConstants.USE_PRODUCT, false)) { - programArgs.add("-product"); //$NON-NLS-1$ - programArgs.add(configuration.getAttribute(IPDELauncherConstants.PRODUCT, "")); //$NON-NLS-1$ - } else { - // Specify the application to test - String defaultApplication = IPDEUIConstants.CORE_TEST_APPLICATION.equals(application) ? null : TargetPlatform.getDefaultApplication(); - String testApplication = configuration.getAttribute(IPDELauncherConstants.APP_TO_TEST, defaultApplication); - if (testApplication != null) { - programArgs.add("-testApplication"); //$NON-NLS-1$ - programArgs.add(testApplication); - } - } - - // Specify the location of the runtime workbench - if (fWorkspaceLocation == null) { - fWorkspaceLocation = LaunchArgumentsHelper.getWorkspaceLocation(configuration); - } - if (fWorkspaceLocation.length() > 0) { - programArgs.add("-data"); //$NON-NLS-1$ - programArgs.add(fWorkspaceLocation); - } - - // Create the platform configuration for the runtime workbench - String productID = LaunchConfigurationHelper.getProductID(configuration); - LaunchConfigurationHelper.createConfigIniFile(configuration, productID, fAllBundles, fModels, getConfigurationDirectory(configuration)); - String brandingId = LaunchConfigurationHelper.getContributingPlugin(productID); - TargetPlatform.createPlatformConfiguration(getConfigurationDirectory(configuration), (IPluginModelBase[]) fAllBundles.values().toArray(new IPluginModelBase[fAllBundles.size()]), brandingId != null ? (IPluginModelBase) fAllBundles.get(brandingId) : null); - TargetPlatformHelper.checkPluginPropertiesConsistency(fAllBundles, getConfigurationDirectory(configuration)); - - programArgs.add("-configuration"); //$NON-NLS-1$ - programArgs.add("file:" + new Path(getConfigurationDirectory(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$ - - // Specify the output folder names - programArgs.add("-dev"); //$NON-NLS-1$ - programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigurationDirectory(configuration).toString() + "/dev.properties", fAllBundles)); //$NON-NLS-1$ - - // necessary for PDE to know how to load plugins when target platform = host platform - // see PluginPathFinder.getPluginPaths() - IPluginModelBase base = findPlugin(PDECore.PLUGIN_ID); - if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) < 0) //$NON-NLS-1$ - programArgs.add("-pdelaunch"); //$NON-NLS-1$ - - // Create the .options file if tracing is turned on - if (configuration.getAttribute(IPDELauncherConstants.TRACING, false) && !IPDELauncherConstants.TRACING_NONE.equals(configuration.getAttribute(IPDELauncherConstants.TRACING_CHECKED, (String) null))) { - programArgs.add("-debug"); //$NON-NLS-1$ - String path = getConfigurationDirectory(configuration).getPath() + IPath.SEPARATOR + ".options"; //$NON-NLS-1$ - programArgs.add(LaunchArgumentsHelper.getTracingFileArgument(configuration, path)); - } - - // add the program args specified by the user - String[] userArgs = LaunchArgumentsHelper.getUserProgramArgumentArray(configuration); - for (int i = 0; i < userArgs.length; i++) { - // be forgiving if people have tracing turned on and forgot - // to remove the -debug from the program args field. - if (userArgs[i].equals("-debug") && programArgs.contains("-debug")) //$NON-NLS-1$ //$NON-NLS-2$ - continue; - programArgs.add(userArgs[i]); - } - - if (!configuration.getAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, false)) { - if (!programArgs.contains("-os")) { //$NON-NLS-1$ - programArgs.add("-os"); //$NON-NLS-1$ - programArgs.add(TargetPlatform.getOS()); - } - if (!programArgs.contains("-ws")) { //$NON-NLS-1$ - programArgs.add("-ws"); //$NON-NLS-1$ - programArgs.add(TargetPlatform.getWS()); - } - if (!programArgs.contains("-arch")) { //$NON-NLS-1$ - programArgs.add("-arch"); //$NON-NLS-1$ - programArgs.add(TargetPlatform.getOSArch()); - } - } - - programArgs.add("-testpluginname"); //$NON-NLS-1$ - programArgs.add(getTestPluginId(configuration)); - } - - /** - * Returns the application to launch plug-in tests with - * - * @since 3.5 - * - * @param configuration - * @return the application - */ - protected String getApplication(ILaunchConfiguration configuration) { - String application = null; - - boolean shouldRunInUIThread = true; - try { - shouldRunInUIThread = configuration.getAttribute(IPDELauncherConstants.RUN_IN_UI_THREAD, true); - } catch (CoreException e) { - } - - if (!shouldRunInUIThread) { - return IPDEUIConstants.NON_UI_THREAD_APPLICATION; - } - - try { - // if application is set, it must be a headless app. - application = configuration.getAttribute(IPDELauncherConstants.APPLICATION, (String) null); - } catch (CoreException e) { - } - - // if application is not set, we should launch the default UI test app - // Check to see if we should launch the legacy UI app - if (application == null) { - IPluginModelBase model = (IPluginModelBase) fAllBundles.get("org.eclipse.pde.junit.runtime"); //$NON-NLS-1$ - BundleDescription desc = model != null ? model.getBundleDescription() : null; - if (desc != null) { - Version version = desc.getVersion(); - int major = version.getMajor(); - // launch legacy UI app only if we are launching a target that does - // not use the new application model and we are launching with a - // org.eclipse.pde.junit.runtime whose version is >= 3.3 - if (major >= 3 && version.getMinor() >= 3 && !TargetPlatformHelper.usesNewApplicationModel()) { - application = IPDEUIConstants.LEGACY_UI_TEST_APPLICATION; - } - } - } - - // launch the UI test application - if (application == null) - application = IPDEUIConstants.UI_TEST_APPLICATION; - return application; - } - - private IPluginModelBase findPlugin(String id) throws CoreException { - IPluginModelBase model = PluginRegistry.findModel(id); - if (model == null) - model = PDECore.getDefault().findPluginInHost(id); - if (model == null) - abort(NLS.bind(PDEUIMessages.JUnitLaunchConfiguration_error_missingPlugin, id), null, IStatus.OK); - return model; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getProgramArguments(org.eclipse.debug.core.ILaunchConfiguration) - */ - public String getProgramArguments(ILaunchConfiguration configuration) throws CoreException { - return LaunchArgumentsHelper.getUserProgramArguments(configuration); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getVMArguments(org.eclipse.debug.core.ILaunchConfiguration) - */ - public String getVMArguments(ILaunchConfiguration configuration) throws CoreException { - String vmArgs = LaunchArgumentsHelper.getUserVMArguments(configuration); - - // necessary for PDE to know how to load plugins when target platform = host platform - IPluginModelBase base = (IPluginModelBase) fAllBundles.get(PDECore.PLUGIN_ID); - if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) >= 0) { //$NON-NLS-1$ - vmArgs = concatArg(vmArgs, "-Declipse.pde.launch=true"); //$NON-NLS-1$ - } - // For p2 target, add "-Declipse.p2.data.area=@config.dir/p2" unless already specified by user - if (fAllBundles.containsKey("org.eclipse.equinox.p2.core")) { //$NON-NLS-1$ - if (vmArgs.indexOf("-Declipse.p2.data.area=") < 0) { //$NON-NLS-1$ - vmArgs = concatArg(vmArgs, "-Declipse.p2.data.area=@config.dir" + File.separator + "p2"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - return vmArgs; - } - - /** - * Returns the result of concatenating the given argument to the - * specified vmArgs. - * - * @param vmArgs existing VM arguments - * @param arg argument to concatenate - * @return result of concatenation - */ - private String concatArg(String vmArgs, String arg) { - if (vmArgs.length() > 0 && !vmArgs.endsWith(" ")) //$NON-NLS-1$ - vmArgs = vmArgs.concat(" "); //$NON-NLS-1$ - return vmArgs.concat(arg); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getEnvironment(org.eclipse.debug.core.ILaunchConfiguration) - */ - public String[] getEnvironment(ILaunchConfiguration configuration) throws CoreException { - return DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getClasspath(org.eclipse.debug.core.ILaunchConfiguration) - */ - public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException { - String[] classpath = LaunchArgumentsHelper.constructClasspath(configuration); - if (classpath == null) { - abort(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_noStartup, null, IStatus.OK); - } - return classpath; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getWorkingDirectory(org.eclipse.debug.core.ILaunchConfiguration) - */ - public File getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException { - return LaunchArgumentsHelper.getWorkingDirectory(configuration); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getVMSpecificAttributesMap(org.eclipse.debug.core.ILaunchConfiguration) - */ - public Map getVMSpecificAttributesMap(ILaunchConfiguration configuration) throws CoreException { - return LaunchArgumentsHelper.getVMSpecificAttributesMap(configuration); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#setDefaultSourceLocator(org.eclipse.debug.core.ILaunch, org.eclipse.debug.core.ILaunchConfiguration) - */ - protected void setDefaultSourceLocator(ILaunch launch, ILaunchConfiguration configuration) throws CoreException { - ILaunchConfigurationWorkingCopy wc = null; - if (configuration.isWorkingCopy()) { - wc = (ILaunchConfigurationWorkingCopy) configuration; - } else { - wc = configuration.getWorkingCopy(); - } - String id = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, (String) null); - if (!PDESourcePathProvider.ID.equals(id)) { - wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, PDESourcePathProvider.ID); - wc.doSave(); - } - - manageLaunch(launch); - } - - /** - * Returns the location of the configuration area - * - * @param configuration - * the launch configuration - * @return a directory where the configuration area is located - */ - protected File getConfigurationDirectory(ILaunchConfiguration configuration) { - if (fConfigDir == null) - fConfigDir = LaunchConfigurationHelper.getConfigurationArea(configuration); - return fConfigDir; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String) - */ - protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException { - return computeBuildOrder(LaunchPluginValidator.getAffectedProjects(configuration)); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getProjectsForProblemSearch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String) - */ - protected IProject[] getProjectsForProblemSearch(ILaunchConfiguration configuration, String mode) throws CoreException { - return LaunchPluginValidator.getAffectedProjects(configuration); - } - - /** - * Adds a listener to the launch to be notified at interesting launch lifecycle - * events such as when the launch terminates. - * - * @param launch - * the launch - */ - protected void manageLaunch(ILaunch launch) { - PDEPlugin.getDefault().getLaunchListener().manage(launch); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException { - fWorkspaceLocation = null; - fModels = BundleLauncherHelper.getMergedBundleMap(configuration, false); - fAllBundles = new HashMap(fModels.size()); - Iterator iter = fModels.keySet().iterator(); - while (iter.hasNext()) { - IPluginModelBase model = (IPluginModelBase) iter.next(); - fAllBundles.put(model.getPluginBase().getId(), model); - } - - // implicitly add the plug-ins required for JUnit testing if necessary - String[] requiredPlugins = getRequiredPlugins(configuration); - for (int i = 0; i < requiredPlugins.length; i++) { - String id = requiredPlugins[i]; - if (!fAllBundles.containsKey(id)) { - IPluginModelBase model = findPlugin(id); - fAllBundles.put(id, model); - fModels.put(model, "default:default"); //$NON-NLS-1$ - } - } - - boolean autoValidate = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, false); - monitor.beginTask("", autoValidate ? 3 : 4); //$NON-NLS-1$ - if (autoValidate) - validatePluginDependencies(configuration, new SubProgressMonitor(monitor, 1)); - validateProjectDependencies(configuration, new SubProgressMonitor(monitor, 1)); - clear(configuration, new SubProgressMonitor(monitor, 1)); - launch.setAttribute(IPDELauncherConstants.CONFIG_LOCATION, getConfigurationDirectory(configuration).toString()); - synchronizeManifests(configuration, new SubProgressMonitor(monitor, 1)); - } - - private String[] getRequiredPlugins(ILaunchConfiguration configuration) { - // if we are using JUnit4, we need to include the junit4 specific bundles - ITestKind testKind = JUnitLaunchConfigurationConstants.getTestRunnerKind(configuration); - if (TestKindRegistry.JUNIT4_TEST_KIND_ID.equals(testKind.getId())) - return new String[] {"org.junit", "org.eclipse.jdt.junit.runtime", "org.eclipse.pde.junit.runtime", "org.junit4", "org.eclipse.jdt.junit4.runtime"}; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - return new String[] {"org.junit", "org.eclipse.jdt.junit.runtime", "org.eclipse.pde.junit.runtime"}; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - } - - /** - * Checks for old-style plugin.xml files that have become stale since the last launch. - * For any stale plugin.xml files found, the corresponding MANIFEST.MF is deleted - * from the runtime configuration area so that it gets regenerated upon startup. - * - * @param configuration - * the launch configuration - * @param monitor - * the progress monitor - */ - protected void synchronizeManifests(ILaunchConfiguration configuration, IProgressMonitor monitor) { - LaunchConfigurationHelper.synchronizeManifests(configuration, getConfigurationDirectory(configuration)); - monitor.done(); - } - - /** - * Clears the workspace prior to launching if the workspace exists and the option to - * clear it is turned on. Also clears the configuration area if that option is chosen. - * - * @param configuration - * the launch configuration - * @param monitor - * the progress monitor - * @throws CoreException - * if unable to retrieve launch attribute values - * @since 3.3 - */ - protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { - if (fWorkspaceLocation == null) { - fWorkspaceLocation = LaunchArgumentsHelper.getWorkspaceLocation(configuration); - } - // Clear workspace and prompt, if necessary - if (!LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, new SubProgressMonitor(monitor, 1))) { - monitor.setCanceled(true); - return; - } - - // clear config area, if necessary - if (configuration.getAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false)) - CoreUtility.deleteContent(getConfigurationDirectory(configuration)); - } - - /** - * Checks if the Automated Management of Dependencies option is turned on. - * If so, it makes aure all manifests are updated with the correct dependencies. - * - * @param configuration - * the launch configuration - * @param monitor - * a progress monitor - */ - protected void validateProjectDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) { - LauncherUtils.validateProjectDependencies(configuration, monitor); - } +public class JUnitLaunchConfigurationDelegate extends org.eclipse.pde.launching.JUnitLaunchConfigurationDelegate { - /** - * Validates inter-bundle dependencies automatically prior to launching - * if that option is turned on. - * - * @param configuration - * the launch configuration - * @param monitor - * a progress monitor - */ - protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { - EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration); - LaunchPluginValidator.runValidationOperation(op, monitor); - } } Index: src/org/eclipse/pde/ui/launcher/OSGiLaunchConfigurationInitializer.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/OSGiLaunchConfigurationInitializer.java,v retrieving revision 1.8 diff -u -r1.8 OSGiLaunchConfigurationInitializer.java --- src/org/eclipse/pde/ui/launcher/OSGiLaunchConfigurationInitializer.java 25 Feb 2009 17:18:44 -0000 1.8 +++ src/org/eclipse/pde/ui/launcher/OSGiLaunchConfigurationInitializer.java 21 Sep 2009 18:33:50 -0000 @@ -10,12 +10,6 @@ *******************************************************************************/ package org.eclipse.pde.ui.launcher; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; -import org.eclipse.pde.core.plugin.IPluginModelBase; -import org.eclipse.pde.core.plugin.PluginRegistry; -import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper; - /** * Initializes launch configuration attributes for newly-created OSGi Framework * launch configurations @@ -25,90 +19,9 @@ * * * @since 3.3 + * @deprecated + * @see org.eclipse.pde.launching.OSGiLaunchConfigurationInitializer */ -public class OSGiLaunchConfigurationInitializer { - - protected static final String DEFAULT = "default"; //$NON-NLS-1$ - - /** - * Initializes some attributes on a newly-created launch configuration - * - * @param configuration - * the launch configuration - */ - public void initialize(ILaunchConfigurationWorkingCopy configuration) { - initializeFrameworkDefaults(configuration); - initializeBundleState(configuration); - initializeSourcePathProvider(configuration); - } - - /** - * Sets the source provider ID - * - * @param configuration - * the launch configuration - */ - protected void initializeSourcePathProvider(ILaunchConfigurationWorkingCopy configuration) { - configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, PDESourcePathProvider.ID); - } - - /** - * Initializes the start level and auto-start attributes - * - * @param configuration - * the launch configuration - */ - protected void initializeFrameworkDefaults(ILaunchConfigurationWorkingCopy configuration) { - configuration.setAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, true); - configuration.setAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4); - } - - /** - * Initializes the checked/unchecked state of bundles - * - * @param configuration - * the launch configuration - */ - protected void initializeBundleState(ILaunchConfigurationWorkingCopy configuration) { - StringBuffer explugins = new StringBuffer(); - StringBuffer wsplugins = new StringBuffer(); - IPluginModelBase[] models = PluginRegistry.getActiveModels(); - for (int i = 0; i < models.length; i++) { - boolean inWorkspace = models[i].getUnderlyingResource() != null; - appendBundle(inWorkspace ? wsplugins : explugins, models[i]); - } - configuration.setAttribute(IPDELauncherConstants.WORKSPACE_BUNDLES, wsplugins.toString()); - configuration.setAttribute(IPDELauncherConstants.TARGET_BUNDLES, explugins.toString()); - configuration.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); - } - - private void appendBundle(StringBuffer buffer, IPluginModelBase model) { - if (buffer.length() > 0) - buffer.append(","); //$NON-NLS-1$ - String id = model.getPluginBase().getId(); - String value = BundleLauncherHelper.writeBundleEntry(model, getStartLevel(id), getAutoStart(id)); - buffer.append(value); - } - - /** - * Returns the bundle's start level - * - * @param bundleID - * the bundle ID - * @return the start level for the given bundle or the stringdefault
- */
- protected String getStartLevel(String bundleID) {
- return DEFAULT;
- }
-
- /**
- * Returns whether the bundle should be started automatically
- * @param bundleID
- * the bundle ID
- * @return true
, false
, or default
- */
- protected String getAutoStart(String bundleID) {
- return DEFAULT;
- }
+public class OSGiLaunchConfigurationInitializer extends org.eclipse.pde.launching.OSGiLaunchConfigurationInitializer {
}
Index: src/org/eclipse/pde/ui/launcher/TestTab.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/TestTab.java,v
retrieving revision 1.1
diff -u -r1.1 TestTab.java
--- src/org/eclipse/pde/ui/launcher/TestTab.java 7 Jan 2009 19:54:56 -0000 1.1
+++ src/org/eclipse/pde/ui/launcher/TestTab.java 21 Sep 2009 18:33:50 -0000
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.pde.ui.launcher;
+import org.eclipse.pde.launching.IPDELauncherConstants;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
Index: src/org/eclipse/pde/ui/launcher/EclipseApplicationLaunchConfiguration.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/EclipseApplicationLaunchConfiguration.java,v
retrieving revision 1.35
diff -u -r1.35 EclipseApplicationLaunchConfiguration.java
--- src/org/eclipse/pde/ui/launcher/EclipseApplicationLaunchConfiguration.java 15 Apr 2009 19:17:09 -0000 1.35
+++ src/org/eclipse/pde/ui/launcher/EclipseApplicationLaunchConfiguration.java 21 Sep 2009 18:33:50 -0000
@@ -11,22 +11,6 @@
*******************************************************************************/
package org.eclipse.pde.ui.launcher;
-import java.io.File;
-import java.util.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.variables.IStringVariableManager;
-import org.eclipse.core.variables.VariablesPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.pde.core.plugin.IPluginModelBase;
-import org.eclipse.pde.core.plugin.TargetPlatform;
-import org.eclipse.pde.internal.core.*;
-import org.eclipse.pde.internal.core.util.CoreUtility;
-import org.eclipse.pde.internal.core.util.VersionUtil;
-import org.eclipse.pde.internal.ui.PDEPlugin;
-import org.eclipse.pde.internal.ui.PDEUIMessages;
-import org.eclipse.pde.internal.ui.launcher.*;
-import org.osgi.framework.Version;
/**
* A launch delegate for launching Eclipse applications
@@ -34,257 +18,9 @@
* Clients may subclass and instantiate this class.
*
* @since 3.2
+ * @deprecated
+ * @see org.eclipse.pde.launching.EclipseApplicationLaunchConfiguration
*/
-public class EclipseApplicationLaunchConfiguration extends AbstractPDELaunchConfiguration {
-
- // used to generate the dev classpath entries
- // key is bundle ID, value is a model
- private Map fAllBundles;
-
- // key is a model, value is startLevel:autoStart
- private Map fModels;
-
- /**
- * To avoid duplicating variable substitution (and duplicate prompts)
- * this variable will store the substituted workspace location.
- */
- private String fWorkspaceLocation;
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#getProgramArguments(org.eclipse.debug.core.ILaunchConfiguration)
- */
- public String[] getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
- ArrayList programArgs = new ArrayList();
-
- // If a product is specified, then add it to the program args
- if (configuration.getAttribute(IPDELauncherConstants.USE_PRODUCT, false)) {
- String product = configuration.getAttribute(IPDELauncherConstants.PRODUCT, ""); //$NON-NLS-1$
- if (product.length() > 0) {
- programArgs.add("-product"); //$NON-NLS-1$
- programArgs.add(product);
- } else { // TODO product w/o an application and product... how to handle gracefully?
- programArgs.add("-application"); //$NON-NLS-1$
- programArgs.add(configuration.getAttribute(IPDELauncherConstants.APPLICATION, "")); //$NON-NLS-1$
- }
- } else {
- // specify the application to launch
- programArgs.add("-application"); //$NON-NLS-1$
- programArgs.add(configuration.getAttribute(IPDELauncherConstants.APPLICATION, TargetPlatform.getDefaultApplication()));
- }
-
- // specify the workspace location for the runtime workbench
- if (fWorkspaceLocation == null) {
- fWorkspaceLocation = LaunchArgumentsHelper.getWorkspaceLocation(configuration);
- }
- if (fWorkspaceLocation.length() > 0) {
- programArgs.add("-data"); //$NON-NLS-1$
- programArgs.add(fWorkspaceLocation);
- }
-
- boolean showSplash = true;
- if (configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false)) {
- validateFeatures();
- IPath installPath = PDEPlugin.getWorkspace().getRoot().getLocation();
- programArgs.add("-install"); //$NON-NLS-1$
- programArgs.add("file:" + installPath.removeLastSegments(1).addTrailingSeparator().toString()); //$NON-NLS-1$
- if (!configuration.getAttribute(IPDELauncherConstants.CONFIG_USE_DEFAULT_AREA, true)) {
- programArgs.add("-configuration"); //$NON-NLS-1$
- programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
- }
- programArgs.add("-update"); //$NON-NLS-1$
- // add the output folder names
- programArgs.add("-dev"); //$NON-NLS-1$
- programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", true)); //$NON-NLS-1$
- } else {
- String productID = LaunchConfigurationHelper.getProductID(configuration);
- Properties prop = LaunchConfigurationHelper.createConfigIniFile(configuration, productID, fAllBundles, fModels, getConfigDir(configuration));
- showSplash = prop.containsKey("osgi.splashPath") || prop.containsKey("splashLocation"); //$NON-NLS-1$ //$NON-NLS-2$
- String brandingId = LaunchConfigurationHelper.getContributingPlugin(productID);
- TargetPlatform.createPlatformConfiguration(getConfigDir(configuration), (IPluginModelBase[]) fAllBundles.values().toArray(new IPluginModelBase[fAllBundles.size()]), brandingId != null ? (IPluginModelBase) fAllBundles.get(brandingId) : null);
- TargetPlatformHelper.checkPluginPropertiesConsistency(fAllBundles, getConfigDir(configuration));
- programArgs.add("-configuration"); //$NON-NLS-1$
- programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
-
- // add the output folder names
- programArgs.add("-dev"); //$NON-NLS-1$
- programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", fAllBundles)); //$NON-NLS-1$
- }
- // necessary for PDE to know how to load plugins when target platform = host platform
- // see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode()
- IPluginModelBase base = (IPluginModelBase) fAllBundles.get(PDECore.PLUGIN_ID);
- if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) < 0) //$NON-NLS-1$
- programArgs.add("-pdelaunch"); //$NON-NLS-1$
-
- String[] args = super.getProgramArguments(configuration);
- for (int i = 0; i < args.length; i++) {
- programArgs.add(args[i]);
- }
-
- if (!programArgs.contains("-nosplash") && showSplash) { //$NON-NLS-1$
- if (TargetPlatformHelper.getTargetVersion() >= 3.1) {
- programArgs.add(0, "-launcher"); //$NON-NLS-1$
-
- IPath path = null;
- if (TargetPlatform.getOS().equals("macosx")) { //$NON-NLS-1$
- path = new Path(TargetPlatform.getLocation()).append("Eclipse.app/Contents/MacOS/eclipse"); //$NON-NLS-1$
- } else {
- path = new Path(TargetPlatform.getLocation()).append("eclipse"); //$NON-NLS-1$
- if (TargetPlatform.getOS().equals("win32")) { //$NON-NLS-1$
- path = path.addFileExtension("exe"); //$NON-NLS-1$
- }
- }
-
- programArgs.add(1, path.toOSString()); //This could be the branded launcher if we want (also this does not bring much)
- programArgs.add(2, "-name"); //$NON-NLS-1$
- programArgs.add(3, "Eclipse"); //This should be the name of the product //$NON-NLS-1$
- programArgs.add(4, "-showsplash"); //$NON-NLS-1$
- programArgs.add(5, "600"); //$NON-NLS-1$
- } else {
- programArgs.add(0, "-showsplash"); //$NON-NLS-1$
- programArgs.add(1, computeShowsplashArgument());
- }
- }
- return (String[]) programArgs.toArray(new String[programArgs.size()]);
- }
-
- private void validateFeatures() throws CoreException {
- IPath installPath = PDEPlugin.getWorkspace().getRoot().getLocation();
- String lastSegment = installPath.lastSegment();
- boolean badStructure = lastSegment == null;
- if (!badStructure) {
- IPath featuresPath = installPath.removeLastSegments(1).append("features"); //$NON-NLS-1$
- badStructure = !lastSegment.equalsIgnoreCase("plugins") //$NON-NLS-1$
- || !featuresPath.toFile().exists();
- }
- if (badStructure) {
- throw new CoreException(LauncherUtils.createErrorStatus(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_badFeatureSetup));
- }
- // Ensure important files are present
- ensureProductFilesExist(getProductPath());
- }
-
- private IPath getProductPath() {
- return PDEPlugin.getWorkspace().getRoot().getLocation().removeLastSegments(1);
- }
-
- private String computeShowsplashArgument() {
- IPath eclipseHome = new Path(TargetPlatform.getLocation());
- IPath fullPath = eclipseHome.append("eclipse"); //$NON-NLS-1$
- return fullPath.toOSString() + " -showsplash 600"; //$NON-NLS-1$
- }
-
- private void ensureProductFilesExist(IPath productArea) {
- File productDir = productArea.toFile();
- File marker = new File(productDir, ".eclipseproduct"); //$NON-NLS-1$
- IPath eclipsePath = new Path(TargetPlatform.getLocation());
- if (!marker.exists())
- CoreUtility.copyFile(eclipsePath, ".eclipseproduct", marker); //$NON-NLS-1$
-
- File configDir = new File(productDir, "configuration"); //$NON-NLS-1$
- if (!configDir.exists())
- configDir.mkdirs();
- File ini = new File(configDir, "config.ini"); //$NON-NLS-1$
- if (!ini.exists())
- CoreUtility.copyFile(eclipsePath.append("configuration"), "config.ini", ini); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#getConfigDir(org.eclipse.debug.core.ILaunchConfiguration)
- */
- protected File getConfigDir(ILaunchConfiguration config) {
- if (fConfigDir == null) {
- try {
- if (config.getAttribute(IPDELauncherConstants.USEFEATURES, false) && config.getAttribute(IPDELauncherConstants.CONFIG_USE_DEFAULT_AREA, true)) {
- String root = getProductPath().toString();
- root += "/configuration"; //$NON-NLS-1$
- fConfigDir = new File(root);
- if (!fConfigDir.exists())
- fConfigDir.mkdirs();
- } else {
- fConfigDir = LaunchConfigurationHelper.getConfigurationArea(config);
- }
- } catch (CoreException e) {
- fConfigDir = LaunchConfigurationHelper.getConfigurationArea(config);
- }
- }
- return fConfigDir;
- }
-
- /**
- * Clears the workspace prior to launching if the workspace exists and the option to
- * clear it is turned on. Also clears the configuration area if that option is chosen.
- *
- * @param configuration
- * the launch configuration
- * @param monitor
- * the progress monitor
- * @throws CoreException
- * if unable to retrieve launch attribute values
- * @since 3.3
- */
- protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
- if (fWorkspaceLocation == null) {
- fWorkspaceLocation = LaunchArgumentsHelper.getWorkspaceLocation(configuration);
- }
- // Clear workspace and prompt, if necessary
- if (!LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, monitor))
- throw new CoreException(Status.CANCEL_STATUS);
-
- // clear config area, if necessary
- if (configuration.getAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false))
- CoreUtility.deleteContent(getConfigDir(configuration));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
- fWorkspaceLocation = null;
-
- fModels = BundleLauncherHelper.getMergedBundleMap(configuration, false);
- fAllBundles = new HashMap(fModels.size());
- Iterator iter = fModels.keySet().iterator();
- while (iter.hasNext()) {
- IPluginModelBase model = (IPluginModelBase) iter.next();
- fAllBundles.put(model.getPluginBase().getId(), model);
- }
- validateConfigIni(configuration);
- super.preLaunchCheck(configuration, launch, monitor);
- }
-
- private void validateConfigIni(ILaunchConfiguration configuration) throws CoreException {
- if (!configuration.getAttribute(IPDELauncherConstants.CONFIG_GENERATE_DEFAULT, true)) {
- String templateLoc = configuration.getAttribute(IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, ""); //$NON-NLS-1$
- IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
- templateLoc = mgr.performStringSubstitution(templateLoc);
-
- File templateFile = new File(templateLoc);
- if (!templateFile.exists()) {
- if (!LauncherUtils.generateConfigIni())
- throw new CoreException(Status.CANCEL_STATUS);
- // with the way the launcher works, if a config.ini file is not found one will be generated automatically.
- // This check was to warn the user a config.ini needs to be generated. - bug 161265, comment #7
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#getVMArguments(org.eclipse.debug.core.ILaunchConfiguration)
- */
- public String[] getVMArguments(ILaunchConfiguration configuration) throws CoreException {
- String[] vmArgs = super.getVMArguments(configuration);
- IPluginModelBase base = (IPluginModelBase) fAllBundles.get(PDECore.PLUGIN_ID);
- if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) >= 0) { //$NON-NLS-1$
- // necessary for PDE to know how to load plugins when target platform = host platform
- // see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode()
- String[] result = new String[vmArgs.length + 1];
- System.arraycopy(vmArgs, 0, result, 0, vmArgs.length);
- result[vmArgs.length] = "-Declipse.pde.launch=true"; //$NON-NLS-1$
- return result;
- }
- return vmArgs;
- }
+public class EclipseApplicationLaunchConfiguration extends org.eclipse.pde.launching.EclipseApplicationLaunchConfiguration {
}
Index: src/org/eclipse/pde/ui/launcher/EclipseLauncherTabGroup.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/EclipseLauncherTabGroup.java,v
retrieving revision 1.7
diff -u -r1.7 EclipseLauncherTabGroup.java
--- src/org/eclipse/pde/ui/launcher/EclipseLauncherTabGroup.java 15 Apr 2008 16:44:15 -0000 1.7
+++ src/org/eclipse/pde/ui/launcher/EclipseLauncherTabGroup.java 21 Sep 2009 18:33:50 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.*;
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab;
+import org.eclipse.pde.internal.launching.IPDEConstants;
import org.eclipse.pde.internal.ui.IPDEUIConstants;
/**
@@ -51,8 +52,8 @@
// is present in the original copy. We do this by querying the config twice, with different default values. If the values == eachother, we
// we know the value is present. Since generated configs don't contain DOCLEARLOG, we know if DOCLEARLOG is present in the original copy the
// perform apply so save the initialization values has already been run and this is a user modification.
- boolean firstQuery = original.getAttribute(IPDEUIConstants.DOCLEARLOG, false);
- boolean secondQuery = original.getAttribute(IPDEUIConstants.DOCLEARLOG, true);
+ boolean firstQuery = original.getAttribute(IPDEConstants.DOCLEARLOG, false);
+ boolean secondQuery = original.getAttribute(IPDEConstants.DOCLEARLOG, true);
if (original != null && firstQuery == secondQuery)
configuration.setAttribute(IPDEUIConstants.GENERATED_CONFIG, false);
} catch (CoreException e) {
Index: src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfiguration.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfiguration.java,v
retrieving revision 1.31
diff -u -r1.31 AbstractPDELaunchConfiguration.java
--- src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfiguration.java 27 May 2009 20:38:25 -0000 1.31
+++ src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfiguration.java 21 Sep 2009 18:33:50 -0000
@@ -10,414 +10,15 @@
*******************************************************************************/
package org.eclipse.pde.ui.launcher;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Map;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.*;
-import org.eclipse.debug.core.*;
-import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
-import org.eclipse.jdt.core.IJavaModelMarker;
-import org.eclipse.jdt.launching.*;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.pde.core.plugin.TargetPlatform;
-import org.eclipse.pde.internal.core.TargetPlatformHelper;
-import org.eclipse.pde.internal.core.builders.PDEMarkerFactory;
-import org.eclipse.pde.internal.ui.*;
-import org.eclipse.pde.internal.ui.launcher.*;
-
/**
* An abstract launch delegate for PDE-based launch configurations
* * Clients may subclass this class. *
* @since 3.2 + * @deprecated + * @see org.eclipse.pde.launching.AbstractPDELaunchConfiguration */ -public abstract class AbstractPDELaunchConfiguration extends LaunchConfigurationDelegate { - - protected File fConfigDir = null; - - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#isLaunchProblem(org.eclipse.core.resources.IMarker) - */ - protected boolean isLaunchProblem(IMarker problemMarker) throws CoreException { - return super.isLaunchProblem(problemMarker) && (problemMarker.getType().equals(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER) || problemMarker.getType().equals(PDEMarkerFactory.MARKER_ID)); - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) - */ - public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { - try { - fConfigDir = null; - monitor.beginTask("", 4); //$NON-NLS-1$ - try { - preLaunchCheck(configuration, launch, new SubProgressMonitor(monitor, 2)); - } catch (CoreException e) { - if (e.getStatus().getSeverity() == IStatus.CANCEL) { - monitor.setCanceled(true); - return; - } - throw e; - } - // if restarting, remove the restart flag from the launch config - if (configuration.getAttribute(IPDEUIConstants.RESTART, false) && configuration instanceof ILaunchConfigurationWorkingCopy) { - ((ILaunchConfigurationWorkingCopy) configuration).setAttribute(IPDEUIConstants.RESTART, false); - ((ILaunchConfigurationWorkingCopy) configuration).doSave(); - } - VMRunnerConfiguration runnerConfig = new VMRunnerConfiguration(getMainClass(), getClasspath(configuration)); - runnerConfig.setVMArguments(getVMArguments(configuration)); - runnerConfig.setProgramArguments(getProgramArguments(configuration)); - runnerConfig.setWorkingDirectory(getWorkingDirectory(configuration).getAbsolutePath()); - runnerConfig.setEnvironment(getEnvironment(configuration)); - runnerConfig.setVMSpecificAttributesMap(getVMSpecificAttributesMap(configuration)); - - monitor.worked(1); - - setDefaultSourceLocator(configuration); - manageLaunch(launch); - IVMRunner runner = getVMRunner(configuration, mode); - if (runner != null) - runner.run(runnerConfig, launch, monitor); - else - monitor.setCanceled(true); - monitor.done(); - } catch (final CoreException e) { - monitor.setCanceled(true); - LauncherUtils.getDisplay().syncExec(new Runnable() { - public void run() { - MessageDialog.openError(LauncherUtils.getActiveShell(), PDEUIMessages.Launcher_error_title, e.getMessage()); - } - }); - } - } - - /** - * Returns the VM runner for the given launch mode to use when launching the - * given configuration. - * - * @param configuration launch configuration - * @param mode launch node - * @return VM runner to use when launching the given configuration in the given mode - * @throws CoreException if a VM runner cannot be determined - */ - public IVMRunner getVMRunner(ILaunchConfiguration configuration, String mode) throws CoreException { - IVMInstall launcher = VMHelper.createLauncher(configuration); - return launcher.getVMRunner(mode); - } - - /** - * Assigns a default source locator to the given launch if a source locator - * has not yet been assigned to it, and the associated launch configuration - * does not specify a source locator. - * - * @param configuration - * configuration being launched - * @exception CoreException - * if unable to set the source locator - */ - protected void setDefaultSourceLocator(ILaunchConfiguration configuration) throws CoreException { - ILaunchConfigurationWorkingCopy wc = null; - if (configuration.isWorkingCopy()) { - wc = (ILaunchConfigurationWorkingCopy) configuration; - } else { - wc = configuration.getWorkingCopy(); - } - String id = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, (String) null); - if (!PDESourcePathProvider.ID.equals(id)) { - wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, PDESourcePathProvider.ID); - wc.doSave(); - } - } - - /** - * Returns the entries that should appear on boot classpath. - * - * @param configuration - * launch configuration - * @return the location of startup.jar and - * the bootstrap classpath specified by the given launch configuration - * - * @exception CoreException - * if unable to find startup.jar - */ - public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException { - String[] classpath = LaunchArgumentsHelper.constructClasspath(configuration); - if (classpath == null) { - String message = PDEUIMessages.WorkbenchLauncherConfigurationDelegate_noStartup; - throw new CoreException(LauncherUtils.createErrorStatus(message)); - } - return classpath; - } - - /** - * Returns an array of environment variables to be used when - * launching the given configuration ornull
if unspecified.
- *
- * @param configuration launch configuration
- * @throws CoreException if unable to access associated attribute or if
- * unable to resolve a variable in an environment variable's value
- */
- public String[] getEnvironment(ILaunchConfiguration configuration) throws CoreException {
- return DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
- }
-
- /**
- * Returns the working directory path specified by the given launch
- * configuration, or null
if none.
- *
- * @param configuration
- * launch configuration
- * @return the working directory path specified by the given launch
- * configuration, or null
if none
- * @exception CoreException
- * if unable to retrieve the attribute
- */
- public File getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
- return LaunchArgumentsHelper.getWorkingDirectory(configuration);
- }
-
- /**
- * Returns the Map of VM-specific attributes specified by the given launch
- * configuration, or null
if none.
- *
- * @param configuration
- * launch configuration
- * @return the Map
of VM-specific attributes
- * @exception CoreException
- * if unable to retrieve the attribute
- */
- public Map getVMSpecificAttributesMap(ILaunchConfiguration configuration) throws CoreException {
- return LaunchArgumentsHelper.getVMSpecificAttributesMap(configuration);
- }
-
- /**
- * Returns the VM arguments specified by the given launch configuration, as
- * an array of strings.
- *
- * @param configuration
- * launch configuration
- * @return the VM arguments specified by the given launch configuration,
- * possibly an empty array
- * @exception CoreException
- * if unable to retrieve the attribute
- */
- public String[] getVMArguments(ILaunchConfiguration configuration) throws CoreException {
- String[] vmArgs = new ExecutionArguments(LaunchArgumentsHelper.getUserVMArguments(configuration), "").getVMArgumentsArray(); //$NON-NLS-1$
- // For p2 target, add "-Declipse.p2.data.area=@config.dir/p2" unless already specified by user
- Map bundleMap = BundleLauncherHelper.getMergedBundleMap(configuration, false);
- if (bundleMap.containsKey("org.eclipse.equinox.p2.core")) { //$NON-NLS-1$
- for (int i = 0; i < vmArgs.length; i++) {
- String arg = vmArgs[i];
- if (arg.startsWith("-Declipse.p2.data.area=")) { //$NON-NLS-1$
- return vmArgs;
- }
- }
- String[] temp = new String[vmArgs.length + 1];
- System.arraycopy(vmArgs, 0, temp, 0, vmArgs.length);
- temp[vmArgs.length] = "-Declipse.p2.data.area=@config.dir" + File.separator + "p2"; //$NON-NLS-1$ //$NON-NLS-2$
- return temp;
- }
- return vmArgs;
- }
-
- /**
- * Returns the program arguments to launch with.
- * This list is a combination of arguments computed by PDE based on attributes
- * specified in the given launch configuration, followed by the program arguments
- * that the entered directly into the launch configuration.
- *
- * @param configuration
- * launch configuration
- * @return the program arguments necessary for launching
- *
- * @exception CoreException
- * if unable to retrieve the attribute or create the
- * necessary configuration files
- */
- public String[] getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
- ArrayList programArgs = new ArrayList();
-
- // add tracing, if turned on
- if (configuration.getAttribute(IPDELauncherConstants.TRACING, false) && !IPDELauncherConstants.TRACING_NONE.equals(configuration.getAttribute(IPDELauncherConstants.TRACING_CHECKED, (String) null))) {
- programArgs.add("-debug"); //$NON-NLS-1$
- programArgs.add(LaunchArgumentsHelper.getTracingFileArgument(configuration, getConfigDir(configuration).toString() + IPath.SEPARATOR + ".options")); //$NON-NLS-1$
- }
-
- // add the program args specified by the user
- String[] userArgs = LaunchArgumentsHelper.getUserProgramArgumentArray(configuration);
- ArrayList userDefined = new ArrayList();
- for (int i = 0; i < userArgs.length; i++) {
- // be forgiving if people have tracing turned on and forgot
- // to remove the -debug from the program args field.
- if (userArgs[i].equals("-debug") && programArgs.contains("-debug")) //$NON-NLS-1$ //$NON-NLS-2$
- continue;
- userDefined.add(userArgs[i]);
- }
-
- if (!configuration.getAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, false)) {
-
- if (!userDefined.contains("-os")) { //$NON-NLS-1$
- programArgs.add("-os"); //$NON-NLS-1$
- programArgs.add(TargetPlatform.getOS());
- }
- if (!userDefined.contains("-ws")) { //$NON-NLS-1$
- programArgs.add("-ws"); //$NON-NLS-1$
- programArgs.add(TargetPlatform.getWS());
- }
- if (!userDefined.contains("-arch")) { //$NON-NLS-1$
- programArgs.add("-arch"); //$NON-NLS-1$
- programArgs.add(TargetPlatform.getOSArch());
- }
- }
-
- if (userDefined.size() > 0) {
- programArgs.addAll(userDefined);
- }
-
- return (String[]) programArgs.toArray(new String[programArgs.size()]);
- }
-
- /**
- * Does sanity checking before launching. The criteria whether the launch should
- * proceed or not is specific to the launch configuration type.
- *
- * @param configuration launch configuration
- * @param launch the launch object to contribute processes and debug targets to
- * @param monitor a progress monitor
- *
- * @throws CoreException exception thrown if launch fails or canceled or if unable to retrieve attributes
- * from the launch configuration
- *
- */
- protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
- boolean autoValidate = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, false);
- monitor.beginTask("", autoValidate ? 3 : 4); //$NON-NLS-1$
- if (autoValidate)
- validatePluginDependencies(configuration, new SubProgressMonitor(monitor, 1));
- validateProjectDependencies(configuration, new SubProgressMonitor(monitor, 1));
- clear(configuration, new SubProgressMonitor(monitor, 1));
- launch.setAttribute(IPDELauncherConstants.CONFIG_LOCATION, getConfigDir(configuration).toString());
- synchronizeManifests(configuration, new SubProgressMonitor(monitor, 1));
- }
-
- /**
- * Returns the configuration area specified by the given launch
- * configuration.
- *
- * @param configuration
- * launch configuration
- * @return the directory path specified by the given launch
- * configuration
- */
- protected File getConfigDir(ILaunchConfiguration configuration) {
- if (fConfigDir == null)
- fConfigDir = LaunchConfigurationHelper.getConfigurationArea(configuration);
- return fConfigDir;
- }
-
- /*
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
- */
- protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
- return computeBuildOrder(LaunchPluginValidator.getAffectedProjects(configuration));
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getProjectsForProblemSearch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
- */
- protected IProject[] getProjectsForProblemSearch(ILaunchConfiguration configuration, String mode) throws CoreException {
- return LaunchPluginValidator.getAffectedProjects(configuration);
- }
-
- /**
- * Returns the fully-qualified name of the class to launch.
- *
- * @return the fully-qualified name of the class to launch. Must not return null
.
- * @since 3.3
- */
- public String getMainClass() {
- if (TargetPlatformHelper.getTargetVersion() >= 3.3)
- return "org.eclipse.equinox.launcher.Main"; //$NON-NLS-1$
- return "org.eclipse.core.launcher.Main"; //$NON-NLS-1$
- }
-
- /**
- * Adds a listener to the launch to be notified at interesting launch lifecycle
- * events such as when the launch terminates.
- *
- * @param launch
- * the launch
- *
- * @since 3.3
- */
- protected void manageLaunch(ILaunch launch) {
- PDEPlugin.getDefault().getLaunchListener().manage(launch);
- }
-
- /**
- * Checks for old-style plugin.xml files that have become stale since the last launch.
- * For any stale plugin.xml files found, the corresponding MANIFEST.MF is deleted
- * from the runtime configuration area so that it gets regenerated upon startup.
- *
- * @param configuration
- * the launch configuration
- * @param monitor
- * a progress monitor
- *
- * @since 3.3
- */
- protected void synchronizeManifests(ILaunchConfiguration configuration, IProgressMonitor monitor) {
- LaunchConfigurationHelper.synchronizeManifests(configuration, getConfigDir(configuration));
- monitor.done();
- }
-
- /**
- * Checks if the Automated Management of Dependencies option is turned on.
- * If so, it makes aure all manifests are updated with the correct dependencies.
- *
- * @param configuration
- * the launch configuration
- * @param monitor
- * a progress monitor
- *
- * @since 3.3
- */
- protected void validateProjectDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) {
- LauncherUtils.validateProjectDependencies(configuration, monitor);
- }
-
- /**
- * By default, this method does nothing. Clients should override, if appropriate.
- *
- * @param configuration
- * the launch configuration
- * @param monitor
- * the progress monitor
- * @throws CoreException
- * if unable to retrieve launch attribute values
- * @since 3.3
- */
- protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
- }
-
- /**
- * Validates inter-bundle dependencies automatically prior to launching
- * if that option is turned on.
- *
- * @param configuration
- * the launch configuration
- * @param monitor
- * a progress monitor
- * @since 3.3
- */
- protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
- EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration);
- LaunchPluginValidator.runValidationOperation(op, monitor);
- }
+public abstract class AbstractPDELaunchConfiguration extends org.eclipse.pde.launching.AbstractPDELaunchConfiguration {
}
Index: src/org/eclipse/pde/ui/launcher/JUnitWorkbenchLaunchShortcut.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/JUnitWorkbenchLaunchShortcut.java,v
retrieving revision 1.12
diff -u -r1.12 JUnitWorkbenchLaunchShortcut.java
--- src/org/eclipse/pde/ui/launcher/JUnitWorkbenchLaunchShortcut.java 25 Feb 2009 17:18:44 -0000 1.12
+++ src/org/eclipse/pde/ui/launcher/JUnitWorkbenchLaunchShortcut.java 21 Sep 2009 18:33:50 -0000
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.pde.ui.launcher;
+import org.eclipse.pde.launching.IPDELauncherConstants;
+import org.eclipse.pde.launching.PDESourcePathProvider;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jdt.core.IJavaElement;
@@ -17,9 +20,9 @@
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.pde.core.plugin.TargetPlatform;
import org.eclipse.pde.internal.core.TargetPlatformHelper;
-import org.eclipse.pde.internal.ui.IPDEUIConstants;
-import org.eclipse.pde.internal.ui.launcher.LaunchArgumentsHelper;
-import org.eclipse.pde.internal.ui.launcher.LauncherUtils;
+import org.eclipse.pde.internal.launching.IPDEConstants;
+import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper;
+import org.eclipse.pde.internal.launching.launcher.LauncherUtils;
/**
* A launch shortcut capable of launching a Plug-in JUnit test.
@@ -43,13 +46,13 @@
protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(IJavaElement element) throws CoreException {
ILaunchConfigurationWorkingCopy configuration = super.createLaunchConfiguration(element);
if (TargetPlatformHelper.usesNewApplicationModel())
- configuration.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$
+ configuration.setAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$
else if (TargetPlatformHelper.getTargetVersion() >= 3.2)
- configuration.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.2a"); //$NON-NLS-1$
+ configuration.setAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, "3.2a"); //$NON-NLS-1$
configuration.setAttribute(IPDELauncherConstants.LOCATION, LaunchArgumentsHelper.getDefaultJUnitWorkspaceLocation());
configuration.setAttribute(IPDELauncherConstants.DOCLEAR, true);
configuration.setAttribute(IPDELauncherConstants.ASKCLEAR, false);
- configuration.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true);
+ configuration.setAttribute(IPDEConstants.APPEND_ARGS_EXPLICITLY, true);
// Program to launch
if (LauncherUtils.requiresUI(configuration)) {
@@ -59,7 +62,7 @@
configuration.setAttribute(IPDELauncherConstants.PRODUCT, product);
}
} else {
- configuration.setAttribute(IPDELauncherConstants.APPLICATION, IPDEUIConstants.CORE_TEST_APPLICATION);
+ configuration.setAttribute(IPDELauncherConstants.APPLICATION, IPDEConstants.CORE_TEST_APPLICATION);
}
// Plug-ins to launch
Index: src/org/eclipse/pde/ui/launcher/IPDELauncherConstants.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/IPDELauncherConstants.java,v
retrieving revision 1.19
diff -u -r1.19 IPDELauncherConstants.java
--- src/org/eclipse/pde/ui/launcher/IPDELauncherConstants.java 7 Jan 2009 19:54:56 -0000 1.19
+++ src/org/eclipse/pde/ui/launcher/IPDELauncherConstants.java 21 Sep 2009 18:33:50 -0000
@@ -19,380 +19,9 @@
*
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
+ * @deprecated
+ * @see org.eclipse.pde.launching.IPDELauncherConstants
*/
-public interface IPDELauncherConstants {
+public interface IPDELauncherConstants extends org.eclipse.pde.launching.IPDELauncherConstants {
- /**
- * Launch configuration attribute key. The value is a string specifying
- * workspace data location for an Eclipse application.
- */
- String LOCATION = "location"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * workspace data location for an Eclipse application should be cleared
- * prior to launching.
- */
- String DOCLEAR = "clearws"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * whether the user should be prompted prior to clearing the workspace.
- *
- * @see IPDELauncherConstants#DOCLEAR
- */
- String ASKCLEAR = "askclear"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * the application to run. If the value is null
, the default
- * application as specified in the target platform will be used.
- */
- String APPLICATION = "application"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * the product to run.
- *
- * @see IPDELauncherConstants#APPLICATION
- */
- String PRODUCT = "product"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * if the launch should appear in product-mode. If the value is false
,
- * the launch takes place in application-mode.
- *
- * @see IPDELauncherConstants#PRODUCT
- * @see IPDELauncherConstants#APPLICATION
- */
- String USE_PRODUCT = "useProduct"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key used in Plug-in JUnit launch configurations only.
- * The value is a string specifying the application to be tested.
- * If the value is null
, the default UI workbench application is tested.
- */
- String APP_TO_TEST = "testApplication"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * the name of the VM to launch with. If the value is null
,
- * the default workspace VM is used.
- *
- * @deprecated use IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH
- */
- String VMINSTALL = "vminstall"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * the user-entered bootstrap classpath entries.
- */
- String BOOTSTRAP_ENTRIES = "bootstrap"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * if the default self-hosting mode should be used when launching.
- * The default being to launch with all workspace plug-ins and all the
- * plug-ins that are explicitly checked on the Target Platform preference page.
- */
- String USE_DEFAULT = "default"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * if the feature-based self-hosting mode should be used.
- * The workspace must be set up properly for the feature-based self-hosting
- * to succeed.
- * Check the PDE Tips and Tricks section for how to set up feature-based self-hosting.
- */
- String USEFEATURES = "usefeatures"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * a comma-separated list of IDs of workspace plug-ins to launch with.
- * This value is only used when the Automatic Add option is off.
- *
- * @see IPDELauncherConstants#AUTOMATIC_ADD
- */
- String SELECTED_WORKSPACE_PLUGINS = "selected_workspace_plugins"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * a comma-separated list of IDs of workspace plug-ins that are to be excluded from
- * the launch.
- * This value is only used when the Automatic Add option is on.
- *
- * @see IPDELauncherConstants#AUTOMATIC_ADD
- */
- String DESELECTED_WORKSPACE_PLUGINS = "deselected_workspace_plugins"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * whether workspace plug-in created after the creation of a launch configuration
- * should be added to the list of plug-ins to launch with.
- *
- * If the value is true
, then DESELECTED_WORKSPACE_PLUGINS should be used.
- * Otherwise, SELECTED_WORKSPACE_PLUGINS should be used.
- *
- * @see IPDELauncherConstants#DESELECTED_WORKSPACE_PLUGINS
- * @see IPDELauncherConstants#SELECTED_WORKSPACE_PLUGINS
- */
- String AUTOMATIC_ADD = "automaticAdd"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * whether the list of plug-ins to run should be validate prior to launching.
- * If problems are found, they will be reported and the user will be able to cancel or
- * continue.
- * If no problems are found, the launch continues as normal.
- */
- String AUTOMATIC_VALIDATE = "automaticValidate"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * a comma-separated list of IDs of target platform plug-ins to launch with.
- * This value is only used when the Automatic Add option is off.
- */
- String SELECTED_TARGET_PLUGINS = "selected_target_plugins"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean indicating
- * whether the computation of required plug-ins on the Plug-ins tab should include
- * the traversal of optional dependencies.
- */
- String INCLUDE_OPTIONAL = "includeOptional"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean indicating
- * whether tracing is enabled or disabled.
- */
- String TRACING = "tracing"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a map containing the list
- * of options to debug with.
- */
- String TRACING_OPTIONS = "tracingOptions"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is the id of the last plug-in
- * that was selected on the Tracing tab.
- */
- String TRACING_SELECTED_PLUGIN = "selectedPlugin"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is the IDs of all plug-ins
- * checked on the Tracing tab. The value may also be "[NONE]"
- *
- * @see IPDELauncherConstants#TRACING_NONE
- */
- String TRACING_CHECKED = "checked"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute value indicating that, although tracing is enabled,
- * no plug-ins have been selected to be traced.
- */
- String TRACING_NONE = "[NONE]"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * if PDE should generate a default configuration area for the launch.
- *
- * If true
, a configuration location in the PDE metadata area
- * is created. Otherwise, the user is expected to specify a location.
- *
- * @see IPDELauncherConstants#CONFIG_LOCATION
- */
- String CONFIG_USE_DEFAULT_AREA = "useDefaultConfigArea"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * the configuration area location for an Eclipse application launch.
- *
- * This key is only used when CONFIG_USE_DEFAULT_AREA is false
.
- *
- * @see IPDELauncherConstants#CONFIG_USE_DEFAULT_AREA
- */
- String CONFIG_LOCATION = "configLocation"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * if the configuration area location should be cleared prior to launching
- */
- String CONFIG_CLEAR_AREA = "clearConfig"; //$NON-NLS-1$
-
- /**
- * Launch configuration atribute key. The value is a boolean specifying
- * if PDE should generate a default config.ini file for the launch.
- *
- * If true
, a configuration file is created.
- * Otherwise, the user is expected to specify a config.ini to be used as a template.
- *
- * @see IPDELauncherConstants#CONFIG_TEMPLATE_LOCATION
- */
- String CONFIG_GENERATE_DEFAULT = "useDefaultConfig"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * the location of the config.ini file to be used as a template for an
- * Eclipse application launch.
- *
- * This key is only used when CONFIG_GENERATE_DEFAULT is false
.
- *
- * @see IPDELauncherConstants#CONFIG_GENERATE_DEFAULT
- */
- String CONFIG_TEMPLATE_LOCATION = "templateConfig"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * the location of the .product file with which this launch configuration
- * is associated.
- */
- String PRODUCT_FILE = "productFile"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is the ID of an OSGi framework
- * declared in an org.eclipse.pde.ui.osgiLaunchers
extension point.
- *
- * @since 3.3
- */
- String OSGI_FRAMEWORK_ID = "osgi_framework_id"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * if the default Auto-Start for an OSGi Framework launch configuration
- * is true
or false
- *
- * @see IPDELauncherConstants#DEFAULT_START_LEVEL
- */
- String DEFAULT_AUTO_START = "default_auto_start"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is an integer specifying
- * the default start level for bundles in an OSGi Framework launch configuration.
- *
- * @see IPDELauncherConstants#DEFAULT_AUTO_START
- */
- String DEFAULT_START_LEVEL = "default_start_level"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a comma-separated list
- * of workspace bundles to launch with the OSGi framework.
- *
- * Each token in the list is of the format:
- * true
- *
- * @since 3.5
- */
- String RUN_IN_UI_THREAD = "run_in_ui_thread"; //$NON-NLS-1$
}
Index: src/org/eclipse/pde/ui/launcher/MainTab.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/MainTab.java,v
retrieving revision 1.17
diff -u -r1.17 MainTab.java
--- src/org/eclipse/pde/ui/launcher/MainTab.java 30 Jul 2008 20:44:34 -0000 1.17
+++ src/org/eclipse/pde/ui/launcher/MainTab.java 21 Sep 2009 18:33:50 -0000
@@ -11,6 +11,8 @@
*******************************************************************************/
package org.eclipse.pde.ui.launcher;
+import org.eclipse.pde.launching.IPDELauncherConstants;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
Index: src/org/eclipse/pde/ui/launcher/OSGiLaunchConfigurationDelegate.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/OSGiLaunchConfigurationDelegate.java,v
retrieving revision 1.5
diff -u -r1.5 OSGiLaunchConfigurationDelegate.java
--- src/org/eclipse/pde/ui/launcher/OSGiLaunchConfigurationDelegate.java 25 Feb 2009 17:18:44 -0000 1.5
+++ src/org/eclipse/pde/ui/launcher/OSGiLaunchConfigurationDelegate.java 21 Sep 2009 18:33:50 -0000
@@ -10,52 +10,15 @@
*******************************************************************************/
package org.eclipse.pde.ui.launcher;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.*;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.pde.internal.ui.*;
-import org.eclipse.pde.internal.ui.launcher.LaunchPluginValidator;
-import org.eclipse.pde.internal.ui.launcher.OSGiFrameworkManager;
-
/**
* A launch delegate for launching OSGi frameworks
* * Clients may subclass and instantiate this class. *
* @since 3.3 + * @deprecated + * @see */ -public class OSGiLaunchConfigurationDelegate extends LaunchConfigurationDelegate { - - /** - * Delegates to the launcher delegate associated with the OSGi framework - * selected in the launch configuration. - * - * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) - */ - public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { - OSGiFrameworkManager manager = PDEPlugin.getDefault().getOSGiFrameworkManager(); - String id = configuration.getAttribute(IPDELauncherConstants.OSGI_FRAMEWORK_ID, manager.getDefaultFramework()); - LaunchConfigurationDelegate launcher = manager.getFrameworkLauncher(id); - if (launcher != null) { - launcher.launch(configuration, mode, launch, monitor); - } else { - String name = manager.getFrameworkName(id); - if (name == null) - name = PDEUIMessages.OSGiLaunchConfiguration_selected; - String message = NLS.bind(PDEUIMessages.OSGiLaunchConfiguration_cannotFindLaunchConfiguration, name); - IStatus status = new Status(IStatus.ERROR, IPDEUIConstants.PLUGIN_ID, IStatus.OK, message, null); - throw new CoreException(status); - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String) - */ - protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException { - return computeBuildOrder(LaunchPluginValidator.getAffectedProjects(configuration)); - } +public class OSGiLaunchConfigurationDelegate extends org.eclipse.pde.launching.OSGiLaunchConfigurationDelegate { } Index: src/org/eclipse/pde/ui/launcher/BundlesTab.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/BundlesTab.java,v retrieving revision 1.13 diff -u -r1.13 BundlesTab.java --- src/org/eclipse/pde/ui/launcher/BundlesTab.java 30 Jul 2008 20:44:34 -0000 1.13 +++ src/org/eclipse/pde/ui/launcher/BundlesTab.java 21 Sep 2009 18:33:50 -0000 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.pde.ui.launcher; +import org.eclipse.pde.launching.IPDELauncherConstants; + import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; Index: src/org/eclipse/pde/ui/launcher/PluginsTab.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/PluginsTab.java,v retrieving revision 1.22 diff -u -r1.22 PluginsTab.java --- src/org/eclipse/pde/ui/launcher/PluginsTab.java 20 Mar 2009 15:21:44 -0000 1.22 +++ src/org/eclipse/pde/ui/launcher/PluginsTab.java 21 Sep 2009 18:33:50 -0000 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.pde.ui.launcher; +import org.eclipse.pde.launching.IPDELauncherConstants; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.debug.core.ILaunchConfiguration; Index: src/org/eclipse/pde/ui/launcher/EclipseLaunchShortcut.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/EclipseLaunchShortcut.java,v retrieving revision 1.19 diff -u -r1.19 EclipseLaunchShortcut.java --- src/org/eclipse/pde/ui/launcher/EclipseLaunchShortcut.java 25 Feb 2009 17:18:44 -0000 1.19 +++ src/org/eclipse/pde/ui/launcher/EclipseLaunchShortcut.java 21 Sep 2009 18:33:50 -0000 @@ -10,6 +10,9 @@ *******************************************************************************/ package org.eclipse.pde.ui.launcher; +import org.eclipse.pde.launching.IPDELauncherConstants; +import org.eclipse.pde.launching.PDESourcePathProvider; + import java.util.*; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -25,9 +28,13 @@ import org.eclipse.pde.internal.core.TargetPlatformHelper; import org.eclipse.pde.internal.core.product.WorkspaceProductModel; import org.eclipse.pde.internal.core.util.IdUtil; +import org.eclipse.pde.internal.launching.IPDEConstants; +import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper; +import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper; import org.eclipse.pde.internal.ui.IPDEUIConstants; import org.eclipse.pde.internal.ui.PDEPlugin; -import org.eclipse.pde.internal.ui.launcher.*; +import org.eclipse.pde.internal.ui.launcher.ApplicationSelectionDialog; +import org.eclipse.pde.internal.ui.launcher.LaunchAction; import org.eclipse.ui.IEditorPart; /** @@ -41,7 +48,7 @@ */ public class EclipseLaunchShortcut extends AbstractLaunchShortcut { - public static final String CONFIGURATION_TYPE = "org.eclipse.pde.ui.RuntimeWorkbench"; //$NON-NLS-1$ + public static final String CONFIGURATION_TYPE = IPDELauncherConstants.ECLIPSE_APPLICATION_LAUNCH_CONFIGURATION_TYPE; private IPluginModelBase fModel = null; @@ -214,16 +221,16 @@ */ protected void initializeConfiguration(ILaunchConfigurationWorkingCopy wc) { if (TargetPlatformHelper.usesNewApplicationModel()) - wc.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$ + wc.setAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$ else if (TargetPlatformHelper.getTargetVersion() >= 3.2) - wc.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.2a"); //$NON-NLS-1$ + wc.setAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, "3.2a"); //$NON-NLS-1$ wc.setAttribute(IPDELauncherConstants.LOCATION, LaunchArgumentsHelper.getDefaultWorkspaceLocation(wc.getName())); initializeProgramArguments(wc); initializeVMArguments(wc); wc.setAttribute(IPDELauncherConstants.USEFEATURES, false); wc.setAttribute(IPDELauncherConstants.DOCLEAR, false); wc.setAttribute(IPDELauncherConstants.ASKCLEAR, true); - wc.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true); + wc.setAttribute(IPDEConstants.APPEND_ARGS_EXPLICITLY, true); wc.setAttribute(IPDELauncherConstants.TRACING_CHECKED, IPDELauncherConstants.TRACING_NONE); wc.setAttribute(IPDELauncherConstants.USE_DEFAULT, fApplicationName == null); if (fApplicationName != null) { Index: src/org/eclipse/pde/ui/launcher/TracingTab.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/TracingTab.java,v retrieving revision 1.7 diff -u -r1.7 TracingTab.java --- src/org/eclipse/pde/ui/launcher/TracingTab.java 30 Jul 2008 20:44:34 -0000 1.7 +++ src/org/eclipse/pde/ui/launcher/TracingTab.java 21 Sep 2009 18:33:50 -0000 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.pde.ui.launcher; +import org.eclipse.pde.launching.IPDELauncherConstants; + import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.jface.dialogs.Dialog; Index: src/org/eclipse/pde/ui/launcher/AbstractLaunchShortcut.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/AbstractLaunchShortcut.java,v retrieving revision 1.8 diff -u -r1.8 AbstractLaunchShortcut.java --- src/org/eclipse/pde/ui/launcher/AbstractLaunchShortcut.java 27 May 2009 20:38:25 -0000 1.8 +++ src/org/eclipse/pde/ui/launcher/AbstractLaunchShortcut.java 21 Sep 2009 18:33:50 -0000 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.pde.ui.launcher; +import org.eclipse.pde.launching.IPDELauncherConstants; + import java.util.ArrayList; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.*; Index: src/org/eclipse/pde/internal/ui/preferences/PreferenceInitializer.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/PreferenceInitializer.java,v retrieving revision 1.13 diff -u -r1.13 PreferenceInitializer.java --- src/org/eclipse/pde/internal/ui/preferences/PreferenceInitializer.java 8 Jun 2007 16:45:07 -0000 1.13 +++ src/org/eclipse/pde/internal/ui/preferences/PreferenceInitializer.java 21 Sep 2009 18:33:50 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,7 +15,6 @@ import org.eclipse.pde.internal.ui.IPreferenceConstants; import org.eclipse.pde.internal.ui.PDEPlugin; import org.eclipse.pde.internal.ui.editor.text.ColorManager; -import org.eclipse.pde.internal.ui.launcher.OSGiFrameworkManager; public class PreferenceInitializer extends AbstractPreferenceInitializer { @@ -27,7 +26,6 @@ ColorManager.initializeDefaults(store); store.setDefault(IPreferenceConstants.PROP_SHOW_OBJECTS, IPreferenceConstants.VALUE_USE_IDS); store.setDefault(IPreferenceConstants.EDITOR_FOLDING_ENABLED, false); - store.setDefault(IPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK, OSGiFrameworkManager.DEFAULT_FRAMEWORK); } } Index: src/org/eclipse/pde/internal/ui/preferences/OSGiFrameworkPreferencePage.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/OSGiFrameworkPreferencePage.java,v retrieving revision 1.11 diff -u -r1.11 OSGiFrameworkPreferencePage.java --- src/org/eclipse/pde/internal/ui/preferences/OSGiFrameworkPreferencePage.java 28 Jul 2009 20:16:27 -0000 1.11 +++ src/org/eclipse/pde/internal/ui/preferences/OSGiFrameworkPreferencePage.java 21 Sep 2009 18:33:50 -0000 @@ -13,16 +13,18 @@ package org.eclipse.pde.internal.ui.preferences; import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.preferences.*; import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.viewers.*; import org.eclipse.pde.core.plugin.IPluginExtensionPoint; import org.eclipse.pde.internal.core.PDECore; +import org.eclipse.pde.internal.core.PDEPreferencesManager; import org.eclipse.pde.internal.core.schema.SchemaRegistry; +import org.eclipse.pde.internal.launching.*; +import org.eclipse.pde.internal.launching.launcher.OSGiFrameworkManager; import org.eclipse.pde.internal.ui.*; -import org.eclipse.pde.internal.ui.launcher.OSGiFrameworkManager; import org.eclipse.pde.internal.ui.search.ShowDescriptionAction; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -31,6 +33,7 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.*; import org.eclipse.ui.*; +import org.osgi.service.prefs.BackingStoreException; /** * Provides the preference page for managing the default OSGi framework to use. @@ -106,8 +109,8 @@ * Restores the default framework setting from the PDE preferences */ private void setDefaultFramework() { - IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore(); - fDefaultFramework = store.getString(IPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK); + PDEPreferencesManager preferenceManager = PDELaunchingPlugin.getDefault().getPreferenceManager(); + fDefaultFramework = preferenceManager.getString(ILaunchingPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK); } /* (non-Javadoc) @@ -132,7 +135,7 @@ fTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); fTableViewer.setContentProvider(ArrayContentProvider.getInstance()); fTableViewer.setLabelProvider(new FrameworkLabelProvider()); - fTableViewer.setInput(PDEPlugin.getDefault().getOSGiFrameworkManager().getSortedFrameworks()); + fTableViewer.setInput(PDELaunchingPlugin.getDefault().getOSGiFrameworkManager().getSortedFrameworks()); fTableViewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { IConfigurationElement element = (IConfigurationElement) event.getElement(); @@ -142,7 +145,7 @@ } }); if (fDefaultFramework != null) { - IConfigurationElement element = PDEPlugin.getDefault().getOSGiFrameworkManager().getFramework(fDefaultFramework); + IConfigurationElement element = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager().getFramework(fDefaultFramework); if (element != null) { fTableViewer.setCheckedElements(new Object[] {element}); } @@ -156,9 +159,19 @@ * @see org.eclipse.jface.preference.PreferencePage#performOk() */ public boolean performOk() { - IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore(); - store.setValue(IPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK, fDefaultFramework); - PDEPlugin.getDefault().getPreferenceManager().savePluginPreferences(); + IEclipsePreferences instancePrefs = new InstanceScope().getNode(IPDEConstants.PLUGIN_ID); + IEclipsePreferences defaultPrefs = new DefaultScope().getNode(IPDEConstants.PLUGIN_ID); + if (defaultPrefs.get(ILaunchingPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK, "").equals(fDefaultFramework)) { //$NON-NLS-1$ + instancePrefs.remove(ILaunchingPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK); + } else { + instancePrefs.put(ILaunchingPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK, fDefaultFramework); + } + try { + instancePrefs.flush(); + } catch (BackingStoreException e) { + PDEPlugin.log(e); + } + return super.performOk(); } Index: src/org/eclipse/pde/internal/ui/preferences/MainPreferencePage.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/MainPreferencePage.java,v retrieving revision 1.30 diff -u -r1.30 MainPreferencePage.java --- src/org/eclipse/pde/internal/ui/preferences/MainPreferencePage.java 14 Apr 2009 21:36:31 -0000 1.30 +++ src/org/eclipse/pde/internal/ui/preferences/MainPreferencePage.java 21 Sep 2009 18:33:50 -0000 @@ -11,10 +11,13 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.preferences; +import org.eclipse.core.runtime.preferences.*; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.MessageDialogWithToggle; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.pde.internal.core.PDEPreferencesManager; +import org.eclipse.pde.internal.launching.*; import org.eclipse.pde.internal.ui.*; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -23,6 +26,7 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; import org.eclipse.ui.*; +import org.osgi.service.prefs.BackingStoreException; public class MainPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { private Button fUseID; @@ -39,6 +43,7 @@ protected Control createContents(Composite parent) { IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore(); + PDEPreferencesManager launchingStore = PDELaunchingPlugin.getDefault().getPreferenceManager(); Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); @@ -63,7 +68,7 @@ fAutoManage = new Button(group, SWT.CHECK); fAutoManage.setText(PDEUIMessages.MainPreferencePage_updateStale); - fAutoManage.setSelection(store.getBoolean(IPreferenceConstants.PROP_AUTO_MANAGE)); + fAutoManage.setSelection(launchingStore.getBoolean(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE)); group = SWTFactory.createGroup(composite, PDEUIMessages.MainPreferencePage_exportingGroup, 1, 1, GridData.FILL_HORIZONTAL); @@ -107,10 +112,24 @@ } else { store.setValue(IPreferenceConstants.PROP_SHOW_OBJECTS, IPreferenceConstants.VALUE_USE_NAMES); } - store.setValue(IPreferenceConstants.PROP_AUTO_MANAGE, fAutoManage.getSelection()); store.setValue(IPreferenceConstants.OVERWRITE_BUILD_FILES_ON_EXPORT, fOverwriteBuildFiles.getSelection() ? MessageDialogWithToggle.PROMPT : MessageDialogWithToggle.ALWAYS); store.setValue(IPreferenceConstants.PROP_SHOW_SOURCE_BUNDLES, fShowSourceBundles.getSelection()); PDEPlugin.getDefault().getPreferenceManager().savePluginPreferences(); + + // write AUTO_MANAGE setting to pde.launching instance scope + IEclipsePreferences instancePrefs = new InstanceScope().getNode(IPDEConstants.PLUGIN_ID); + IEclipsePreferences defaultPrefs = new DefaultScope().getNode(IPDEConstants.PLUGIN_ID); + if (defaultPrefs.getBoolean(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE, false) == fAutoManage.getSelection()) { + instancePrefs.remove(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE); + } else { + instancePrefs.putBoolean(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE, fAutoManage.getSelection()); + } + try { + instancePrefs.flush(); + } catch (BackingStoreException e) { + PDEPlugin.log(e); + } + return super.performOk(); } Index: src/org/eclipse/pde/internal/ui/launcher/PDEMigrationDelegate.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/launcher/PDEMigrationDelegate.java diff -N src/org/eclipse/pde/internal/ui/launcher/PDEMigrationDelegate.java --- src/org/eclipse/pde/internal/ui/launcher/PDEMigrationDelegate.java 27 May 2009 20:38:24 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.ui.launcher; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.debug.core.*; -import org.eclipse.jdt.launching.*; -import org.eclipse.pde.internal.ui.IPDEUIConstants; -import org.eclipse.pde.ui.launcher.IPDELauncherConstants; - -public class PDEMigrationDelegate implements ILaunchConfigurationMigrationDelegate { - - public boolean isCandidate(ILaunchConfiguration candidate) throws CoreException { - return !candidate.getAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, false) || candidate.hasAttribute(IPDELauncherConstants.VMINSTALL); - } - - public void migrate(ILaunchConfiguration candidate) throws CoreException { - ILaunchConfigurationWorkingCopy wc = candidate.getWorkingCopy(); - migrate(wc); - wc.doSave(); - } - - public void migrate(ILaunchConfigurationWorkingCopy candidate) throws CoreException { - if (!candidate.getAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, false)) { - candidate.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true); - String args = candidate.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$ - StringBuffer buffer = new StringBuffer(LaunchArgumentsHelper.getInitialProgramArguments()); - if (args.length() > 0) { - buffer.append(" "); //$NON-NLS-1$ - buffer.append(args); - } - candidate.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, buffer.toString()); - } - if (candidate.hasAttribute(IPDELauncherConstants.VMINSTALL)) { - String name = candidate.getAttribute(IPDELauncherConstants.VMINSTALL, (String) null); - if (name != null) { - IVMInstall vm = VMHelper.getVMInstall(name); - if (vm != null) { - IPath path = JavaRuntime.newJREContainerPath(vm); - candidate.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, path.toPortableString()); - } - } - candidate.removeAttribute(IPDELauncherConstants.VMINSTALL); - } - } - -} Index: src/org/eclipse/pde/internal/ui/launcher/OpenLogDialog.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OpenLogDialog.java,v retrieving revision 1.10 diff -u -r1.10 OpenLogDialog.java --- src/org/eclipse/pde/internal/ui/launcher/OpenLogDialog.java 18 Aug 2008 15:39:50 -0000 1.10 +++ src/org/eclipse/pde/internal/ui/launcher/OpenLogDialog.java 21 Sep 2009 18:33:50 -0000 @@ -27,6 +27,8 @@ * Displays the error log in non-Win32 platforms - see bug 55314. */ public final class OpenLogDialog extends TrayDialog { + // maximum log file size + public static final long MAX_FILE_LENGTH = 1024 * 1024; // input log file private File logFile; // location/size configuration @@ -90,7 +92,7 @@ private String getLogSummary() { StringWriter out = new StringWriter(); PrintWriter writer = new PrintWriter(out); - if (logFile.length() > LaunchListener.MAX_FILE_LENGTH) { + if (logFile.length() > MAX_FILE_LENGTH) { readLargeFileWithMonitor(writer); } else { readFileWithMonitor(writer); @@ -112,7 +114,7 @@ boolean hasStarted = false; try { random = new RandomAccessFile(logFile, "r"); //$NON-NLS-1$ - random.seek(logFile.length() - LaunchListener.MAX_FILE_LENGTH); + random.seek(logFile.length() - MAX_FILE_LENGTH); for (;;) { String line = random.readLine(); if (line == null) Index: src/org/eclipse/pde/internal/ui/launcher/LaunchConfigurationHelper.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/launcher/LaunchConfigurationHelper.java diff -N src/org/eclipse/pde/internal/ui/launcher/LaunchConfigurationHelper.java --- src/org/eclipse/pde/internal/ui/launcher/LaunchConfigurationHelper.java 19 Aug 2009 20:51:03 -0000 1.50 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,453 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.ui.launcher; - -import java.io.*; -import java.net.URL; -import java.util.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.variables.IStringVariableManager; -import org.eclipse.core.variables.VariablesPlugin; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; -import org.eclipse.osgi.service.resolver.BundleDescription; -import org.eclipse.pde.core.plugin.IPluginModelBase; -import org.eclipse.pde.core.plugin.TargetPlatform; -import org.eclipse.pde.internal.build.IPDEBuildConstants; -import org.eclipse.pde.internal.core.*; -import org.eclipse.pde.internal.ui.PDEPlugin; -import org.eclipse.pde.ui.launcher.IPDELauncherConstants; - -/** - * Contains helper methods for launching an Eclipse Runtime Workbench - */ -public class LaunchConfigurationHelper { - - private static final String PROP_OSGI_FRAMEWORK = "osgi.framework"; //$NON-NLS-1$ - private static final String PROP_OSGI_BUNDLES = "osgi.bundles"; //$NON-NLS-1$ - private static final String PROP_P2_DATA_AREA = "eclipse.p2.data.area"; //$NON-NLS-1$ - - public static void synchronizeManifests(ILaunchConfiguration config, File configDir) { - try { - String programArgs = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$ - if (programArgs.indexOf("-clean") != -1) //$NON-NLS-1$ - return; - } catch (CoreException e) { - } - File dir = new File(configDir, "org.eclipse.osgi/manifests"); //$NON-NLS-1$ - if (dir.exists() && dir.isDirectory()) { - PDECore.getDefault().getJavaElementChangeListener().synchronizeManifests(dir); - } - } - - public static File getConfigurationArea(ILaunchConfiguration config) { - File dir = getConfigurationLocation(config); - if (!dir.exists()) - dir.mkdirs(); - return dir; - } - - public static File getConfigurationLocation(ILaunchConfiguration config) { - //bug 170213 change config location if config name contains # - String configName = config.getName(); - configName = configName.replace('#', 'h'); - File dir = new File(PDECore.getDefault().getStateLocation().toOSString(), configName); - try { - if (!config.getAttribute(IPDELauncherConstants.CONFIG_USE_DEFAULT_AREA, true)) { - String userPath = config.getAttribute(IPDELauncherConstants.CONFIG_LOCATION, (String) null); - if (userPath != null) { - userPath = getSubstitutedString(userPath); - dir = new File(userPath).getAbsoluteFile(); - } - } - } catch (CoreException e) { - } - return dir; - } - - private static String getSubstitutedString(String text) throws CoreException { - if (text == null) - return ""; //$NON-NLS-1$ - IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager(); - return mgr.performStringSubstitution(text); - } - - public static Properties createConfigIniFile(ILaunchConfiguration configuration, String productID, Map bundles, Map bundlesWithStartLevels, File directory) throws CoreException { - Properties properties = null; - // if we are to generate a config.ini, start with the values in the target platform's config.ini - bug 141918 - if (configuration.getAttribute(IPDELauncherConstants.CONFIG_GENERATE_DEFAULT, true)) { - properties = TargetPlatformHelper.getConfigIniProperties(); - // if target's config.ini does not exist, lets try to fill in default values - if (properties == null) - properties = new Properties(); - // keep properties only if we are launching the default product (bug 175437) - else if (productID == null || !productID.equals(properties.get("eclipse.product"))) //$NON-NLS-1$ - properties.clear(); - // if target's config.ini has the osgi.bundles header, then parse and compute the proper osgi.bundles value - String bundleList = properties.getProperty(PROP_OSGI_BUNDLES); - if (bundleList != null) - properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatformHelper.stripPathInformation(bundleList), bundles, bundlesWithStartLevels)); - String dataArea = properties.getProperty(PROP_P2_DATA_AREA); - if (dataArea != null) { - // Make the p2 data area in the configuration area itself, rather than a sibling of the configuration - // area (which is a the root pde.core shared metadata area) @see bug 272810 - properties.setProperty(PROP_P2_DATA_AREA, "@config.dir/.p2"); //$NON-NLS-1$ - } - } else { - String templateLoc = configuration.getAttribute(IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, (String) null); - if (templateLoc != null) { - properties = loadFromTemplate(getSubstitutedString(templateLoc)); - // if template contains osgi.bundles, then only strip the path, do not compute the value - String osgiBundles = properties.getProperty(PROP_OSGI_BUNDLES); - if (osgiBundles != null) - properties.setProperty(PROP_OSGI_BUNDLES, TargetPlatformHelper.stripPathInformation(osgiBundles)); - } - } - // whether we create a new config.ini or read from one as a template, we should add the required properties - bug 161265 - if (properties != null) { - addRequiredProperties(properties, productID, bundles, bundlesWithStartLevels); - } else { - properties = new Properties(); - } - if (!directory.exists()) { - directory.mkdirs(); - } - String osgiBundles = properties.getProperty(PROP_OSGI_BUNDLES); - int start = configuration.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4); - properties.put("osgi.bundles.defaultStartLevel", Integer.toString(start)); //$NON-NLS-1$ - boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, false); - - // if we are launching using P2, write out P2 files (bundles.txt) and add P2 property to config.ini - if (osgiBundles != null && osgiBundles.indexOf(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR) != -1 && bundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) { - URL bundlesTxt = null; - boolean usedefault = configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true); - boolean useFeatures = configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false); - if (usedefault || useFeatures) { - bundlesTxt = P2Utils.writeBundlesTxt(bundlesWithStartLevels, 4, false, directory, osgiBundles); - } else { - bundlesTxt = P2Utils.writeBundlesTxt(bundlesWithStartLevels, start, autostart, directory, null); - } - - if (bundlesTxt != null) { - properties.setProperty("org.eclipse.equinox.simpleconfigurator.configUrl", bundlesTxt.toString()); //$NON-NLS-1$ - // if we have simple configurator and update configurator together, ensure update doesn't reconcile - if (bundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) { - properties.setProperty("org.eclipse.update.reconcile", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - - setBundleLocations(bundles, properties, autostart); - - save(new File(directory, "config.ini"), properties); //$NON-NLS-1$ - return properties; - } - - private static void addRequiredProperties(Properties properties, String productID, Map bundles, Map bundlesWithStartLevels) { - if (!properties.containsKey("osgi.install.area")) //$NON-NLS-1$ - properties.setProperty("osgi.install.area", "file:" + TargetPlatform.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$ - if (!properties.containsKey("osgi.configuration.cascaded")) //$NON-NLS-1$ - properties.setProperty("osgi.configuration.cascaded", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - if (!properties.containsKey(PROP_OSGI_FRAMEWORK)) - properties.setProperty(PROP_OSGI_FRAMEWORK, IPDEBuildConstants.BUNDLE_OSGI); - if (!properties.containsKey("osgi.splashPath") && productID != null) //$NON-NLS-1$ - addSplashLocation(properties, productID, bundles); - // if osgi.splashPath is set, try to resolve relative paths to absolute paths - if (properties.containsKey("osgi.splashPath")) //$NON-NLS-1$ - resolveLocationPath(properties.getProperty("osgi.splashPath"), properties, bundles); //$NON-NLS-1$ - if (!properties.containsKey(PROP_OSGI_BUNDLES)) - properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatform.getBundleList(), bundles, bundlesWithStartLevels)); - if (!properties.containsKey("osgi.bundles.defaultStartLevel")) //$NON-NLS-1$ - properties.setProperty("osgi.bundles.defaultStartLevel", "4"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Computes a list of osgi bundles to be put into the osgi.bundles property based - * on the bundles from the target platform config.ini and a map of bundles we are - * launching with. The list of bundles must have already had it's path information - * removed. - * @param bundleList list of bundles without path information - * @param bundles map of bundle id to bundle model, contains all bundles being launched with - * @param bundlesWithStartLevels map of bundles of start level - * @return string list of osgi bundles - */ - private static String computeOSGiBundles(String bundleList, Map bundles, Map bundlesWithStartLevels) { - - // if p2 and only simple configurator and - // if simple configurator isn't selected & isn't in bundle list... hack it - - // if using p2's simple configurator, a bundles.txt will be written, so we only need simple configurator in the config.ini - if (bundles.get(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR) != null) - return "org.eclipse.equinox.simpleconfigurator@1:start"; //$NON-NLS-1$ - - StringBuffer buffer = new StringBuffer(); - Set initialBundleSet = new HashSet(); - StringTokenizer tokenizer = new StringTokenizer(bundleList, ","); //$NON-NLS-1$ - while (tokenizer.hasMoreTokens()) { - String token = tokenizer.nextToken(); - int index = token.indexOf('@'); - String id = index != -1 ? token.substring(0, index) : token; - if (bundles.containsKey(id)) { - if (buffer.length() > 0) - buffer.append(','); - buffer.append(id); - if (index != -1 && index < token.length() - 1) - buffer.append(token.substring(index)); - initialBundleSet.add(id); - } - } - - // if org.eclipse.update.configurator is not included (LIKE IN BASIC RCP APPLICATION), then write out all bundles in osgi.bundles - bug 170772 - if (!initialBundleSet.contains(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR)) { - initialBundleSet.add(IPDEBuildConstants.BUNDLE_OSGI); - Iterator iter = bundlesWithStartLevels.keySet().iterator(); - while (iter.hasNext()) { - IPluginModelBase model = (IPluginModelBase) iter.next(); - String id = model.getPluginBase().getId(); - if (!initialBundleSet.contains(id)) { - if (buffer.length() > 0) - buffer.append(','); - - String slinfo = (String) bundlesWithStartLevels.get(model); - buffer.append(id); - buffer.append('@'); - buffer.append(slinfo); - } - } - } - return buffer.toString(); - } - - private static Properties loadFromTemplate(String templateLoc) throws CoreException { - Properties properties = new Properties(); - File templateFile = new File(templateLoc); - if (templateFile.exists() && templateFile.isFile()) { - FileInputStream stream = null; - try { - stream = new FileInputStream(templateFile); - properties.load(stream); - } catch (Exception e) { - String message = e.getMessage(); - if (message != null) - throw new CoreException(new Status(IStatus.ERROR, PDEPlugin.getPluginId(), IStatus.ERROR, message, e)); - } finally { - if (stream != null) { - try { - stream.close(); - } catch (IOException e) { - } - } - } - } - return properties; - } - - private static void addSplashLocation(Properties properties, String productID, Map map) { - Properties targetConfig = TargetPlatformHelper.getConfigIniProperties(); - String targetProduct = targetConfig == null ? null : targetConfig.getProperty("eclipse.product"); //$NON-NLS-1$ - String targetSplash = targetConfig == null ? null : targetConfig.getProperty("osgi.splashPath"); //$NON-NLS-1$ - if (!productID.equals(targetProduct) || targetSplash == null) { - ArrayList locations = new ArrayList(); - String plugin = getContributingPlugin(productID); - locations.add(plugin); - IPluginModelBase model = (IPluginModelBase) map.get(plugin); - if (model != null) { - BundleDescription desc = model.getBundleDescription(); - if (desc != null) { - BundleDescription[] fragments = desc.getFragments(); - for (int i = 0; i < fragments.length; i++) - locations.add(fragments[i].getSymbolicName()); - } - } - resolveLocationPath(locations, properties, map); - } else - resolveLocationPath(targetSplash, properties, map); - } - - private static void resolveLocationPath(String splashPath, Properties properties, Map map) { - ArrayList locations = new ArrayList(); - StringTokenizer tok = new StringTokenizer(splashPath, ","); //$NON-NLS-1$ - while (tok.hasMoreTokens()) - locations.add(tok.nextToken()); - resolveLocationPath(locations, properties, map); - } - - private static void resolveLocationPath(ArrayList locations, Properties properties, Map map) { - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < locations.size(); i++) { - String location = (String) locations.get(i); - if (location.startsWith("platform:/base/plugins/")) { //$NON-NLS-1$ - location = location.replaceFirst("platform:/base/plugins/", ""); //$NON-NLS-1$ //$NON-NLS-2$ - } - String url = getBundleURL(location, map, false); - if (url == null) - continue; - if (buffer.length() > 0) - buffer.append(","); //$NON-NLS-1$ - buffer.append(url); - } - if (buffer.length() > 0) - properties.setProperty("osgi.splashPath", buffer.toString()); //$NON-NLS-1$ - } - - /** - * Returns a string url representing the install location of the bundle model with the - * specified id. The model is obtained using the provided map. - * @param id the id of the bundle - * @param pluginMap mapping of bundle ids to bundle models - * @param includeReference whether to prefix the url with 'reference:' - * @return string url for the bundle location - */ - public static String getBundleURL(String id, Map pluginMap, boolean includeReference) { - IPluginModelBase model = (IPluginModelBase) pluginMap.get(id.trim()); - return getBundleURL(model, includeReference); - } - - /** - * Returns a string url representing the install location of the given bundle model - * @param model the model to create the url for - * @param includeReference whether to prefix the url with 'reference:' - * @return string url for bundle location - */ - public static String getBundleURL(IPluginModelBase model, boolean includeReference) { - if (model == null || model.getInstallLocation() == null) - return null; - StringBuffer buf = new StringBuffer(); - if (includeReference) { - buf.append(TargetPlatformHelper.REFERENCE_PREFIX); - } - buf.append(TargetPlatformHelper.FILE_URL_PREFIX); - buf.append(new Path(model.getInstallLocation()).removeTrailingSeparator().toString()); - return buf.toString(); - } - - /** - * Use the map of bundles we are launching with to update the osgi.framework - * and osgi.bundles properties with the correct info. - * @param map map of bundles being launched (id mapped to model) - * @param properties properties for config.ini - */ - private static void setBundleLocations(Map map, Properties properties, boolean defaultAuto) { - String framework = properties.getProperty(PROP_OSGI_FRAMEWORK); - if (framework != null) { - framework = TargetPlatformHelper.stripPathInformation(framework); - String url = getBundleURL(framework, map, false); - if (url != null) - properties.setProperty(PROP_OSGI_FRAMEWORK, url); - } - - String bundles = properties.getProperty(PROP_OSGI_BUNDLES); - if (bundles != null) { - StringBuffer buffer = new StringBuffer(); - StringTokenizer tokenizer = new StringTokenizer(bundles, ","); //$NON-NLS-1$ - while (tokenizer.hasMoreTokens()) { - String token = tokenizer.nextToken().trim(); - String url = getBundleURL(token, map, false); - int i = -1; - if (url == null) { - i = token.indexOf('@'); - if (i != -1) { - url = getBundleURL(token.substring(0, i), map, false); - } - if (url == null) { - i = token.indexOf(':'); - if (i != -1) - url = getBundleURL(token.substring(0, i), map, false); - } - } - if (url != null) { - if (buffer.length() > 0) { - buffer.append(","); //$NON-NLS-1$ - } - buffer.append("reference:" + url); //$NON-NLS-1$ - if (i != -1) { - String slinfo = token.substring(i + 1); - buffer.append(getStartData(slinfo, defaultAuto)); - } - } - } - properties.setProperty(PROP_OSGI_BUNDLES, buffer.toString()); - } - } - - /** - * Convenience method to parses the startData ("startLevel:autoStart"), convert it to the - * format expected by the OSGi bundles property, and append to a StringBuffer. - * @param startData data to parse ("startLevel:autoStart") - * @param defaultAuto default auto start setting - */ - public static String getStartData(String startData, boolean defaultAuto) { - StringBuffer buffer = new StringBuffer(); - int index = startData.indexOf(':'); - String level = index > 0 ? startData.substring(0, index) : "default"; //$NON-NLS-1$ - String auto = startData; - if (!startData.equals("start")) //$NON-NLS-1$ - auto = index >= 0 && index < startData.length() - 1 ? startData.substring(index + 1) : "default"; //$NON-NLS-1$ - if ("default".equals(auto)) //$NON-NLS-1$ - auto = Boolean.toString(defaultAuto); - if (!level.equals("default") || "true".equals(auto) || "start".equals(auto)) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - buffer.append("@"); //$NON-NLS-1$ - - if (!level.equals("default")) { //$NON-NLS-1$ - buffer.append(level); - if ("start".equals(auto) || "true".equals(auto)) //$NON-NLS-1$ //$NON-NLS-2$ - buffer.append(":"); //$NON-NLS-1$ - } - if ("start".equals(auto) || "true".equals(auto)) { //$NON-NLS-1$ //$NON-NLS-2$ - buffer.append("start"); //$NON-NLS-1$ - } - return buffer.toString(); - } - - public static void save(File file, Properties properties) { - try { - FileOutputStream stream = new FileOutputStream(file); - properties.store(stream, "Configuration File"); //$NON-NLS-1$ - stream.flush(); - stream.close(); - } catch (IOException e) { - PDECore.logException(e); - } - } - - public static String getContributingPlugin(String productID) { - if (productID == null) - return null; - int index = productID.lastIndexOf('.'); - return index == -1 ? productID : productID.substring(0, index); - } - - public static String getProductID(ILaunchConfiguration configuration) throws CoreException { - if (configuration.getAttribute(IPDELauncherConstants.USE_PRODUCT, false)) { - return configuration.getAttribute(IPDELauncherConstants.PRODUCT, (String) null); - } - - // find the product associated with the application, and return its - // contributing plug-in - String appID = configuration.getAttribute(IPDELauncherConstants.APPLICATION, TargetPlatform.getDefaultApplication()); - IExtension[] extensions = PDECore.getDefault().getExtensionsRegistry().findExtensions("org.eclipse.core.runtime.products", true); //$NON-NLS-1$ - for (int i = 0; i < extensions.length; i++) { - String id = extensions[i].getUniqueIdentifier(); - if (id == null) - continue; - IConfigurationElement[] children = extensions[i].getConfigurationElements(); - if (children.length != 1) - continue; - if (!"product".equals(children[0].getName())) //$NON-NLS-1$ - continue; - if (appID.equals(children[0].getAttribute("application"))) //$NON-NLS-1$ - return id; - } - return null; - - } - -} Index: src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkManager.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkManager.java diff -N src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkManager.java --- src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkManager.java 14 Apr 2009 20:58:41 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,141 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.ui.launcher; - -import java.util.*; -import org.eclipse.core.runtime.*; -import org.eclipse.debug.core.model.LaunchConfigurationDelegate; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.pde.internal.ui.IPreferenceConstants; -import org.eclipse.pde.internal.ui.PDEPlugin; -import org.eclipse.pde.ui.launcher.OSGiLaunchConfigurationInitializer; - -public class OSGiFrameworkManager implements IRegistryChangeListener { - - public static final String POINT_ID = "org.eclipse.pde.ui.osgiFrameworks"; //$NON-NLS-1$ - public static final String DEFAULT_FRAMEWORK = "org.eclipse.pde.ui.EquinoxFramework"; //$NON-NLS-1$ - - public static final String ATT_ID = "id"; //$NON-NLS-1$ - public static final String ATT_NAME = "name"; //$NON-NLS-1$ - public static final String ATT_DELEGATE = "launcherDelegate"; //$NON-NLS-1$ - public static final String ATT_INITIALIZER = "initializer"; //$NON-NLS-1$ - - public static final String ELEMENT_FRAMEWORK = "framework"; //$NON-NLS-1$ - - private Map fFrameworks; - - public IConfigurationElement[] getFrameworks() { - if (fFrameworks == null) - loadElements(); - return (IConfigurationElement[]) fFrameworks.values().toArray(new IConfigurationElement[fFrameworks.size()]); - } - - public IConfigurationElement[] getSortedFrameworks() { - IConfigurationElement[] elements = getFrameworks(); - return orderElements(elements); - } - - private void loadElements() { - fFrameworks = new HashMap(); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] elements = registry.getConfigurationElementsFor(POINT_ID); - for (int i = 0; i < elements.length; i++) { - String id = elements[i].getAttribute(ATT_ID); - if (id == null || elements[i].getAttribute(ATT_NAME) == null || elements[i].getAttribute(ATT_DELEGATE) == null) - continue; - fFrameworks.put(id, elements[i]); - } - } - - private IConfigurationElement[] orderElements(IConfigurationElement[] elems) { - Arrays.sort(elems, new Comparator() { - public int compare(Object o1, Object o2) { - String name1 = ((IConfigurationElement) o1).getAttribute(ATT_NAME); - String name2 = ((IConfigurationElement) o2).getAttribute(ATT_NAME); - if (name1 != null) - return name1.compareToIgnoreCase(name2); - return 1; - } - }); - return elems; - } - - public void registryChanged(IRegistryChangeEvent event) { - //TODO implement - } - - public String getDefaultFramework() { - IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore(); - return store.getString(IPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK); - } - - public OSGiLaunchConfigurationInitializer getDefaultInitializer() { - return getInitializer(getDefaultFramework()); - } - - public OSGiLaunchConfigurationInitializer getInitializer(String frameworkID) { - if (fFrameworks == null) - loadElements(); - if (fFrameworks.containsKey(frameworkID)) { - try { - IConfigurationElement element = (IConfigurationElement) fFrameworks.get(frameworkID); - if (element.getAttribute(ATT_INITIALIZER) != null) { - Object result = element.createExecutableExtension(ATT_INITIALIZER); - if (result instanceof OSGiLaunchConfigurationInitializer) - return (OSGiLaunchConfigurationInitializer) result; - } - } catch (CoreException e) { - } - } - return new OSGiLaunchConfigurationInitializer(); - } - - public LaunchConfigurationDelegate getFrameworkLauncher(String frameworkID) { - if (fFrameworks == null) - loadElements(); - if (fFrameworks.containsKey(frameworkID)) { - try { - IConfigurationElement element = (IConfigurationElement) fFrameworks.get(frameworkID); - Object result = element.createExecutableExtension(ATT_DELEGATE); - if (result instanceof LaunchConfigurationDelegate) - return (LaunchConfigurationDelegate) result; - } catch (CoreException e) { - } - } - return null; - } - - public String getFrameworkName(String frameworkID) { - if (fFrameworks == null) - loadElements(); - if (fFrameworks.containsKey(frameworkID)) { - IConfigurationElement element = (IConfigurationElement) fFrameworks.get(frameworkID); - return element.getAttribute(ATT_NAME); - } - return null; - } - - /** - * Returns the {@link IConfigurationElement} for the framework with the given ID - * ornull
if no element exists with that ID.
- * @param frameworkId
- * @return the {@link IConfigurationElement} for the framework with the given ID or null
- *
- * @since 3.5
- */
- public IConfigurationElement getFramework(String frameworkId) {
- if (fFrameworks == null) {
- loadElements();
- }
- return (IConfigurationElement) fFrameworks.get(frameworkId);
- }
-
-}
Index: src/org/eclipse/pde/internal/ui/launcher/LaunchListener.java
===================================================================
RCS file: src/org/eclipse/pde/internal/ui/launcher/LaunchListener.java
diff -N src/org/eclipse/pde/internal/ui/launcher/LaunchListener.java
--- src/org/eclipse/pde/internal/ui/launcher/LaunchListener.java 31 Jan 2008 15:58:44 -0000 1.26
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.launcher;
-
-import java.io.File;
-import java.util.ArrayList;
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.runtime.*;
-import org.eclipse.debug.core.*;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.pde.internal.ui.*;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.*;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.internal.views.log.LogView;
-
-public class LaunchListener implements ILaunchListener, IDebugEventSetListener {
- private ArrayList managedLaunches;
- // maximum log file size
- public static final long MAX_FILE_LENGTH = 1024 * 1024;
- // different ways to open the error log
- public static final int OPEN_IN_ERROR_LOG_VIEW = 0;
- public static final int OPEN_IN_SYSTEM_EDITOR = 1;
-
- public LaunchListener() {
- managedLaunches = new ArrayList();
- }
-
- public void manage(ILaunch launch) {
- if (managedLaunches.size() == 0)
- hookListener(true);
- if (!managedLaunches.contains(launch))
- managedLaunches.add(launch);
- }
-
- /**
- * @see org.eclipse.debug.core.ILaunchesListener#launchesRemoved(org.eclipse.debug.core.ILaunch)
- */
- public void launchRemoved(ILaunch launch) {
- update(launch, true);
- }
-
- /**
- * @see org.eclipse.debug.core.ILaunchesListener#launchesAdded(org.eclipse.debug.core.ILaunch)
- */
- public void launchAdded(ILaunch launch) {
- }
-
- /**
- * @see org.eclipse.debug.core.ILaunchesListener#launchesChanged(org.eclipse.debug.core.ILaunch)
- */
- public void launchChanged(ILaunch launch) {
- }
-
- private void update(ILaunch launch, boolean remove) {
- if (managedLaunches.contains(launch)) {
- if (remove || launch.isTerminated()) {
- managedLaunches.remove(launch);
- if (managedLaunches.size() == 0) {
- hookListener(false);
- }
- }
- }
- }
-
- private void hookListener(boolean add) {
- DebugPlugin debugPlugin = DebugPlugin.getDefault();
- ILaunchManager launchManager = debugPlugin.getLaunchManager();
- if (add) {
- launchManager.addLaunchListener(this);
- debugPlugin.addDebugEventListener(this);
- } else {
- launchManager.removeLaunchListener(this);
- debugPlugin.removeDebugEventListener(this);
- }
- }
-
- private void doRestart(ILaunch launch) {
- ILaunchConfiguration config = launch.getLaunchConfiguration();
- try {
- ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy();
- copy.setAttribute(IPDEUIConstants.RESTART, true);
- copy.launch(launch.getLaunchMode(), new NullProgressMonitor());
- } catch (CoreException e) {
- PDEPlugin.logException(e);
- }
- }
-
- public void shutdown() {
- hookListener(false);
- }
-
- /**
- * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent)
- */
- public void handleDebugEvents(DebugEvent[] events) {
- for (int i = 0; i < events.length; i++) {
- DebugEvent event = events[i];
- Object source = event.getSource();
- if (source instanceof IProcess && event.getKind() == DebugEvent.TERMINATE) {
- IProcess process = (IProcess) source;
- ILaunch launch = process.getLaunch();
- if (launch != null) {
- try {
- launchTerminated(launch, process.getExitValue());
- } catch (DebugException e) {
- }
- }
- }
- }
- }
-
- private void launchTerminated(final ILaunch launch, int returnValue) {
- if (managedLaunches.contains(launch)) {
- update(launch, true);
- if (returnValue == 23) {
- doRestart(launch);
- return;
- }
- // launch failed because the associated workspace is in use
- if (returnValue == 15) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- MessageDialog.openError(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.Launcher_error_title, PDEUIMessages.Launcher_error_code15);
- }
- });
- return;
- }
- // launch failed for reasons printed to the log.
- if (returnValue == 13) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- File log = getMostRecentLogFile(launch.getLaunchConfiguration());
- if (log != null && log.exists()) {
- MessageDialog dialog = new MessageDialog(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.Launcher_error_title, null, // accept the default window icon
- PDEUIMessages.Launcher_error_code13, MessageDialog.ERROR, new String[] {PDEUIMessages.Launcher_error_displayInLogView, PDEUIMessages.Launcher_error_displayInSystemEditor, IDialogConstants.NO_LABEL}, OPEN_IN_ERROR_LOG_VIEW);
- int dialog_value = dialog.open();
- if (dialog_value == OPEN_IN_ERROR_LOG_VIEW) {
- LogView errlog = (LogView) PDEPlugin.getActivePage().showView("org.eclipse.pde.runtime.LogView"); //$NON-NLS-1$
- errlog.handleImportPath(log.getAbsolutePath());
- errlog.sortByDateDescending();
- } else if (dialog_value == OPEN_IN_SYSTEM_EDITOR) {
- openInEditor(log);
- }
- }
- } catch (CoreException e) {
- }
- }
- });
- }
- }
- }
-
- private void openInEditor(File log) {
- IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(log.getAbsolutePath()));
- if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) {
- IWorkbenchWindow ww = PDEPlugin.getActiveWorkbenchWindow();
- IWorkbenchPage page = ww.getActivePage();
- try {
- IDE.openEditorOnFileStore(page, fileStore);
- } catch (PartInitException e) {
- }
- }
- }
-
- /**
- * Returns latest log file for Launch Configuration.
- * It's ".metadala/.log", file with most recent timestamp ending with ".log"
- * in configuration location or null if none found.
- *
- * @returns log file or null
- * @throws CoreException
- * @since 3.4
- */
- static File getMostRecentLogFile(ILaunchConfiguration configuration) throws CoreException {
- File latest = null;
- String workspace = LaunchArgumentsHelper.getWorkspaceLocation(configuration);
- if (workspace.length() > 0) {
- latest = new File(workspace, ".metadata/.log"); //$NON-NLS-1$
- if (!latest.exists())
- latest = null;
- }
- File configDir = LaunchConfigurationHelper.getConfigurationLocation(configuration);
- File[] children = configDir.listFiles();
- if (children != null) {
- for (int i = 0; i < children.length; i++) {
- if (!children[i].isDirectory() && children[i].getName().endsWith(".log")) { //$NON-NLS-1$
- if (latest == null || latest.lastModified() < children[i].lastModified())
- latest = children[i];
- }
- }
- }
- return latest;
- }
-
-}
Index: src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkBlock.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkBlock.java,v
retrieving revision 1.10
diff -u -r1.10 OSGiFrameworkBlock.java
--- src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkBlock.java 27 May 2009 20:38:24 -0000 1.10
+++ src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkBlock.java 21 Sep 2009 18:33:49 -0000
@@ -10,14 +10,16 @@
*******************************************************************************/
package org.eclipse.pde.internal.ui.launcher;
+import org.eclipse.pde.launching.IPDELauncherConstants;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.pde.internal.ui.PDEPlugin;
+import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
+import org.eclipse.pde.internal.launching.launcher.OSGiFrameworkManager;
import org.eclipse.pde.internal.ui.PDEUIMessages;
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
-import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.GridData;
@@ -46,7 +48,7 @@
public OSGiFrameworkBlock(AbstractLauncherTab tab) {
fTab = tab;
- fConfigElements = PDEPlugin.getDefault().getOSGiFrameworkManager().getSortedFrameworks();
+ fConfigElements = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager().getSortedFrameworks();
fListener = new Listener();
}
@@ -106,7 +108,7 @@
}
private void initializeFramework(ILaunchConfiguration config) throws CoreException {
- OSGiFrameworkManager manager = PDEPlugin.getDefault().getOSGiFrameworkManager();
+ OSGiFrameworkManager manager = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager();
String id = config.getAttribute(IPDELauncherConstants.OSGI_FRAMEWORK_ID, manager.getDefaultFramework());
for (int i = 0; i < fConfigElements.length; i++) {
@@ -125,7 +127,7 @@
int index = fLauncherCombo.getSelectionIndex();
String id = index > -1 ? fConfigElements[index].getAttribute(OSGiFrameworkManager.ATT_ID) : null;
- OSGiFrameworkManager manager = PDEPlugin.getDefault().getOSGiFrameworkManager();
+ OSGiFrameworkManager manager = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager();
// no need to persist the default OSGi framework
if (manager.getDefaultFramework().equals(id))
Index: src/org/eclipse/pde/internal/ui/launcher/OSGiBundleBlock.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiBundleBlock.java,v
retrieving revision 1.23
diff -u -r1.23 OSGiBundleBlock.java
--- src/org/eclipse/pde/internal/ui/launcher/OSGiBundleBlock.java 25 Mar 2009 15:36:44 -0000 1.23
+++ src/org/eclipse/pde/internal/ui/launcher/OSGiBundleBlock.java 21 Sep 2009 18:33:49 -0000
@@ -11,13 +11,16 @@
*******************************************************************************/
package org.eclipse.pde.internal.ui.launcher;
+import org.eclipse.pde.launching.IPDELauncherConstants;
+
+import org.eclipse.pde.internal.launching.launcher.*;
+
import java.util.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.ui.launcher.BundlesTab;
-import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
public class OSGiBundleBlock extends AbstractPluginBlock {
Index: src/org/eclipse/pde/internal/ui/launcher/AbstractPluginBlock.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/AbstractPluginBlock.java,v
retrieving revision 1.43
diff -u -r1.43 AbstractPluginBlock.java
--- src/org/eclipse/pde/internal/ui/launcher/AbstractPluginBlock.java 19 Aug 2009 19:50:58 -0000 1.43
+++ src/org/eclipse/pde/internal/ui/launcher/AbstractPluginBlock.java 21 Sep 2009 18:33:49 -0000
@@ -12,6 +12,11 @@
*******************************************************************************/
package org.eclipse.pde.internal.ui.launcher;
+import org.eclipse.pde.launching.IPDELauncherConstants;
+
+import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper;
+import org.eclipse.pde.internal.launching.launcher.LaunchValidationOperation;
+
import java.util.*;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -35,7 +40,6 @@
import org.eclipse.pde.internal.ui.util.*;
import org.eclipse.pde.internal.ui.wizards.ListUtil;
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
-import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.custom.CCombo;
Index: src/org/eclipse/pde/internal/ui/launcher/PDESourceLookupDirector.java
===================================================================
RCS file: src/org/eclipse/pde/internal/ui/launcher/PDESourceLookupDirector.java
diff -N src/org/eclipse/pde/internal/ui/launcher/PDESourceLookupDirector.java
--- src/org/eclipse/pde/internal/ui/launcher/PDESourceLookupDirector.java 2 May 2009 18:52:10 -0000 1.12
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,242 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Code 9 Corporation - ongoing enhancements
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.launcher;
-
-import java.io.File;
-import java.util.*;
-import org.eclipse.core.filesystem.URIUtil;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.debug.core.sourcelookup.*;
-import org.eclipse.debug.core.sourcelookup.containers.*;
-import org.eclipse.debug.ui.sourcelookup.WorkingSetSourceContainer;
-import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.debug.core.*;
-import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jdt.launching.sourcelookup.containers.JavaSourceLookupParticipant;
-import org.eclipse.pde.core.plugin.*;
-import org.eclipse.pde.internal.core.PDEClasspathContainer;
-import org.eclipse.pde.internal.core.TargetPlatformHelper;
-import org.eclipse.pde.internal.ui.PDEPlugin;
-
-public class PDESourceLookupDirector extends AbstractSourceLookupDirector {
-
- /**
- * Cache of source containers by location and id (String & String)
- */
- private Map fSourceContainerMap = new HashMap();
-
- private static Set fFilteredTypes;
-
- static {
- fFilteredTypes = new HashSet(3);
- fFilteredTypes.add(ProjectSourceContainer.TYPE_ID);
- fFilteredTypes.add(WorkspaceSourceContainer.TYPE_ID);
- fFilteredTypes.add(WorkingSetSourceContainer.TYPE_ID);
- }
-
- /**
- * Lazily initialized.
- */
- private double fOSGiRuntimeVersion = Double.MIN_VALUE;
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.core.sourcelookup.ISourceLookupDirector#initializeParticipants()
- */
- public void initializeParticipants() {
- addParticipants(new ISourceLookupParticipant[] {new JavaSourceLookupParticipant()});
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.core.sourcelookup.ISourceLookupDirector#supportsSourceContainerType(org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType)
- */
- public boolean supportsSourceContainerType(ISourceContainerType type) {
- return !fFilteredTypes.contains(type.getId());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#getSourceElement(java.lang.Object)
- */
- public Object getSourceElement(Object element) {
- PDESourceLookupQuery query = new PDESourceLookupQuery(this, element);
- SafeRunner.run(query);
- Object result = query.getResult();
- return result != null ? result : super.getSourceElement(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#findSourceElements(java.lang.Object)
- */
- public Object[] findSourceElements(Object object) throws CoreException {
- Object[] sourceElements = null;
- if (object instanceof IJavaStackFrame || object instanceof IJavaObject || object instanceof IJavaReferenceType) {
- sourceElements = new Object[] {getSourceElement(object)};
- }
- if (sourceElements == null) {
- sourceElements = super.findSourceElements(object);
- }
- return sourceElements;
- }
-
- ISourceContainer[] getSourceContainers(String location, String id) throws CoreException {
-
- ISourceContainer[] containers = (ISourceContainer[]) fSourceContainerMap.get(location);
- if (containers != null) {
- return containers;
- }
-
- ArrayList result = new ArrayList();
- ModelEntry entry = PluginRegistry.findEntry(id);
-
- boolean match = false;
-
- IPluginModelBase[] models = entry.getWorkspaceModels();
- for (int i = 0; i < models.length; i++) {
- if (isPerfectMatch(models[i], new Path(location))) {
- IResource resource = models[i].getUnderlyingResource();
- // if the plug-in matches a workspace model,
- // add the project and any libraries not coming via a container
- // to the list of source containers, in that order
- if (resource != null) {
- addProjectSourceContainers(resource.getProject(), result);
- }
- match = true;
- break;
- }
- }
-
- if (!match) {
- File file = new File(location);
- if (file.isFile()) {
- // in case of linked plug-in projects that map to an external JARd plug-in,
- // use source container that maps to the library in the linked project.
- ISourceContainer container = getArchiveSourceContainer(location);
- if (container != null) {
- containers = new ISourceContainer[] {container};
- fSourceContainerMap.put(location, containers);
- return containers;
- }
- }
-
- models = entry.getExternalModels();
- for (int i = 0; i < models.length; i++) {
- if (isPerfectMatch(models[i], new Path(location))) {
- // try all source zips found in the source code locations
- IClasspathEntry[] entries = PDEClasspathContainer.getExternalEntries(models[i]);
- for (int j = 0; j < entries.length; j++) {
- IRuntimeClasspathEntry rte = convertClasspathEntry(entries[j]);
- if (rte != null)
- result.add(rte);
- }
- break;
- }
- }
- }
-
- IRuntimeClasspathEntry[] entries = (IRuntimeClasspathEntry[]) result.toArray(new IRuntimeClasspathEntry[result.size()]);
- containers = JavaRuntime.getSourceContainers(entries);
- fSourceContainerMap.put(location, containers);
- return containers;
- }
-
- private boolean isPerfectMatch(IPluginModelBase model, IPath path) {
- return model == null ? false : path.equals(new Path(model.getInstallLocation()));
- }
-
- private IRuntimeClasspathEntry convertClasspathEntry(IClasspathEntry entry) {
- if (entry == null)
- return null;
-
- IPath srcPath = entry.getSourceAttachmentPath();
- if (srcPath != null && srcPath.segmentCount() > 0) {
- IRuntimeClasspathEntry rte = JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath());
- rte.setSourceAttachmentPath(srcPath);
- rte.setSourceAttachmentRootPath(entry.getSourceAttachmentRootPath());
- return rte;
- }
- return null;
- }
-
- private ISourceContainer getArchiveSourceContainer(String location) throws JavaModelException {
- IWorkspaceRoot root = PDEPlugin.getWorkspace().getRoot();
- IFile[] containers = root.findFilesForLocationURI(URIUtil.toURI(location));
- for (int i = 0; i < containers.length; i++) {
- IJavaElement element = JavaCore.create(containers[i]);
- if (element instanceof IPackageFragmentRoot) {
- IPackageFragmentRoot archive = (IPackageFragmentRoot) element;
- IPath path = archive.getSourceAttachmentPath();
- if (path == null || path.segmentCount() == 0)
- continue;
-
- IPath rootPath = archive.getSourceAttachmentRootPath();
- boolean detectRootPath = rootPath != null && rootPath.segmentCount() > 0;
-
- IFile archiveFile = root.getFile(path);
- if (archiveFile.exists())
- return new ArchiveSourceContainer(archiveFile, detectRootPath);
-
- File file = path.toFile();
- if (file.exists())
- return new ExternalArchiveSourceContainer(file.getAbsolutePath(), detectRootPath);
- }
- }
- return null;
- }
-
- private void addProjectSourceContainers(IProject project, ArrayList result) throws CoreException {
- if (project == null || !project.hasNature(JavaCore.NATURE_ID))
- return;
-
- IJavaProject jProject = JavaCore.create(project);
- result.add(JavaRuntime.newProjectRuntimeClasspathEntry(jProject));
-
- IClasspathEntry[] entries = jProject.getRawClasspath();
- for (int i = 0; i < entries.length; i++) {
- IClasspathEntry entry = entries[i];
- if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
- IRuntimeClasspathEntry rte = convertClasspathEntry(entry);
- if (rte != null)
- result.add(rte);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#dispose()
- */
- public synchronized void dispose() {
- Iterator iterator = fSourceContainerMap.values().iterator();
- while (iterator.hasNext()) {
- ISourceContainer[] containers = (ISourceContainer[]) iterator.next();
- for (int i = 0; i < containers.length; i++) {
- containers[i].dispose();
- }
- }
- fSourceContainerMap.clear();
- super.dispose();
- }
-
- /**
- * Returns the version of the OSGi runtime being debugged, based on the target platform.
- * Cached per source lookup director.
- *
- * @return OSGi runtime version
- */
- double getOSGiRuntimeVersion() {
- if (fOSGiRuntimeVersion == Double.MIN_VALUE) {
- fOSGiRuntimeVersion = TargetPlatformHelper.getTargetVersion();
- }
- return fOSGiRuntimeVersion;
- }
-
-}
Index: src/org/eclipse/pde/internal/ui/launcher/ConfigurationTemplateBlock.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/ConfigurationTemplateBlock.java,v
retrieving revision 1.13
diff -u -r1.13 ConfigurationTemplateBlock.java
--- src/org/eclipse/pde/internal/ui/launcher/ConfigurationTemplateBlock.java 19 Nov 2008 15:15:30 -0000 1.13
+++ src/org/eclipse/pde/internal/ui/launcher/ConfigurationTemplateBlock.java 21 Sep 2009 18:33:49 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.pde.internal.ui.launcher;
+import org.eclipse.pde.launching.IPDELauncherConstants;
+
import java.io.File;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.*;
@@ -23,7 +25,6 @@
import org.eclipse.pde.internal.ui.PDEUIMessages;
import org.eclipse.pde.internal.ui.util.FileNameFilter;
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
-import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
Index: src/org/eclipse/pde/internal/ui/launcher/ProductValidationOperation.java
===================================================================
RCS file: src/org/eclipse/pde/internal/ui/launcher/ProductValidationOperation.java
diff -N src/org/eclipse/pde/internal/ui/launcher/ProductValidationOperation.java
--- src/org/eclipse/pde/internal/ui/launcher/ProductValidationOperation.java 13 Apr 2009 16:20:07 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 EclipseSource Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * EclipseSource Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.launcher;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
-import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
-import org.eclipse.pde.core.plugin.IPluginModelBase;
-
-public class ProductValidationOperation extends LaunchValidationOperation {
-
- private IPluginModelBase[] fModels;
-
- public ProductValidationOperation(IPluginModelBase[] models) {
- super(null);
- fModels = models;
- }
-
- protected IPluginModelBase[] getModels() throws CoreException {
- return fModels;
- }
-
- protected IExecutionEnvironment[] getMatchingEnvironments() throws CoreException {
- IVMInstall install = JavaRuntime.getDefaultVMInstall();
-
- IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
- IExecutionEnvironment[] envs = manager.getExecutionEnvironments();
- List result = new ArrayList(envs.length);
- for (int i = 0; i < envs.length; i++) {
- IExecutionEnvironment env = envs[i];
- IVMInstall[] compatible = env.getCompatibleVMs();
- for (int j = 0; j < compatible.length; j++) {
- if (compatible[j].equals(install)) {
- result.add(env);
- break;
- }
- }
- }
- return (IExecutionEnvironment[]) result.toArray(new IExecutionEnvironment[result.size()]);
- }
-
-}
Index: src/org/eclipse/pde/internal/ui/launcher/PDELogFileProvider.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/PDELogFileProvider.java,v
retrieving revision 1.3
diff -u -r1.3 PDELogFileProvider.java
--- src/org/eclipse/pde/internal/ui/launcher/PDELogFileProvider.java 30 Jul 2008 21:25:34 -0000 1.3
+++ src/org/eclipse/pde/internal/ui/launcher/PDELogFileProvider.java 21 Sep 2009 18:33:50 -0000
@@ -15,6 +15,7 @@
import java.util.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.*;
+import org.eclipse.pde.internal.launching.launcher.LaunchListener;
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
import org.eclipse.ui.internal.views.log.ILogFileProvider;
import org.eclipse.ui.statushandlers.StatusManager;
Index: src/org/eclipse/pde/internal/ui/launcher/WorkspaceDataBlock.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/WorkspaceDataBlock.java,v
retrieving revision 1.13
diff -u -r1.13 WorkspaceDataBlock.java
--- src/org/eclipse/pde/internal/ui/launcher/WorkspaceDataBlock.java 19 Aug 2009 19:39:32 -0000 1.13
+++ src/org/eclipse/pde/internal/ui/launcher/WorkspaceDataBlock.java 21 Sep 2009 18:33:50 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,13 +10,15 @@
*******************************************************************************/
package org.eclipse.pde.internal.ui.launcher;
+import org.eclipse.pde.launching.IPDELauncherConstants;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.pde.internal.ui.IPDEUIConstants;
+import org.eclipse.pde.internal.launching.IPDEConstants;
+import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper;
import org.eclipse.pde.internal.ui.PDEUIMessages;
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
-import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -96,7 +98,7 @@
config.setAttribute(IPDELauncherConstants.LOCATION, getLocation());
config.setAttribute(IPDELauncherConstants.DOCLEAR, fClearWorkspaceCheck.getSelection());
config.setAttribute(IPDELauncherConstants.ASKCLEAR, fAskClearCheck.getSelection());
- config.setAttribute(IPDEUIConstants.DOCLEARLOG, fClearWorkspaceLogRadio.getSelection());
+ config.setAttribute(IPDEConstants.DOCLEARLOG, fClearWorkspaceLogRadio.getSelection());
}
public void initializeFrom(ILaunchConfiguration configuration) throws CoreException {
@@ -105,9 +107,9 @@
fAskClearCheck.setSelection(configuration.getAttribute(IPDELauncherConstants.ASKCLEAR, true));
fAskClearCheck.setEnabled(fClearWorkspaceCheck.getSelection());
fClearWorkspaceLogRadio.setEnabled(fClearWorkspaceCheck.getSelection());
- fClearWorkspaceLogRadio.setSelection(configuration.getAttribute(IPDEUIConstants.DOCLEARLOG, false));
+ fClearWorkspaceLogRadio.setSelection(configuration.getAttribute(IPDEConstants.DOCLEARLOG, false));
fClearWorkspaceRadio.setEnabled(fClearWorkspaceCheck.getSelection());
- fClearWorkspaceRadio.setSelection(!configuration.getAttribute(IPDEUIConstants.DOCLEARLOG, false));
+ fClearWorkspaceRadio.setSelection(!configuration.getAttribute(IPDEConstants.DOCLEARLOG, false));
}
public void setDefaults(ILaunchConfigurationWorkingCopy configuration, boolean isJUnit) {
@@ -118,7 +120,7 @@
}
configuration.setAttribute(IPDELauncherConstants.DOCLEAR, isJUnit);
configuration.setAttribute(IPDELauncherConstants.ASKCLEAR, !isJUnit);
- configuration.setAttribute(IPDEUIConstants.DOCLEARLOG, false);
+ configuration.setAttribute(IPDEConstants.DOCLEARLOG, false);
}
protected String getName() {
Index: src/org/eclipse/pde/internal/ui/launcher/LaunchArgumentsHelper.java
===================================================================
RCS file: src/org/eclipse/pde/internal/ui/launcher/LaunchArgumentsHelper.java
diff -N src/org/eclipse/pde/internal/ui/launcher/LaunchArgumentsHelper.java
--- src/org/eclipse/pde/internal/ui/launcher/LaunchArgumentsHelper.java 13 Apr 2009 14:52:48 -0000 1.32
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,332 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.launcher;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.*;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.variables.IStringVariableManager;
-import org.eclipse.core.variables.VariablesPlugin;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.launching.ExecutionArguments;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.pde.core.plugin.*;
-import org.eclipse.pde.internal.build.IPDEBuildConstants;
-import org.eclipse.pde.internal.core.*;
-import org.eclipse.pde.internal.core.target.provisional.ITargetHandle;
-import org.eclipse.pde.internal.core.target.provisional.ITargetPlatformService;
-import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
-import org.osgi.framework.Bundle;
-
-public class LaunchArgumentsHelper {
-
- /**
- * Returns the location that will be used as the workspace when launching. Will
- * replace variables, so this method should only be called
- * when variable substitution (may prompt the user) is appropriate.
- * @param configuration the launch configuration to get the workspace value for
- * @return workspace location path as a string
- * @throws CoreException if there is a problem with the configuration
- */
- public static String getWorkspaceLocation(ILaunchConfiguration configuration) throws CoreException {
- String location = configuration.getAttribute(IPDELauncherConstants.LOCATION, (String) null);
- if (location == null) {
- // backward compatibility
- location = configuration.getAttribute(IPDELauncherConstants.LOCATION + "0", (String) null); //$NON-NLS-1$
- if (location != null) {
- ILaunchConfigurationWorkingCopy wc = null;
- if (configuration.isWorkingCopy()) {
- wc = (ILaunchConfigurationWorkingCopy) configuration;
- } else {
- wc = configuration.getWorkingCopy();
- }
- wc.setAttribute(IPDELauncherConstants.LOCATION + "0", (String) null); //$NON-NLS-1$
- wc.setAttribute(IPDELauncherConstants.LOCATION, location);
- wc.doSave();
- }
- }
- return getSubstitutedString(location);
- }
-
- public static String[] getUserProgramArgumentArray(ILaunchConfiguration configuration) throws CoreException {
- String args = getUserProgramArguments(configuration);
- return new ExecutionArguments("", args).getProgramArgumentsArray(); //$NON-NLS-1$
- }
-
- public static String getUserProgramArguments(ILaunchConfiguration configuration) throws CoreException {
- String args = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null);
- if (args == null) {
- // backward compatibility
- args = configuration.getAttribute("progargs", (String) null); //$NON-NLS-1$
- if (args != null) {
- ILaunchConfigurationWorkingCopy wc = null;
- if (configuration.isWorkingCopy()) {
- wc = (ILaunchConfigurationWorkingCopy) configuration;
- } else {
- wc = configuration.getWorkingCopy();
- }
- wc.setAttribute("progargs", (String) null); //$NON-NLS-1$
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args);
- wc.doSave();
- }
- }
- return args == null ? "" : getSubstitutedString(args); //$NON-NLS-1$
- }
-
- public static String getUserVMArguments(ILaunchConfiguration configuration) throws CoreException {
- String args = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String) null);
- if (args == null) {
- // backward compatibility
- args = configuration.getAttribute("vmargs", (String) null); //$NON-NLS-1$
- if (args != null) {
- ILaunchConfigurationWorkingCopy wc = null;
- if (configuration.isWorkingCopy()) {
- wc = (ILaunchConfigurationWorkingCopy) configuration;
- } else {
- wc = configuration.getWorkingCopy();
- }
- wc.setAttribute("vmargs", (String) null); //$NON-NLS-1$
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, args);
- wc.doSave();
- }
- }
- return args == null ? "" : getSubstitutedString(args); //$NON-NLS-1$
- }
-
- /**
- * Fetches the VM Arguments from the current Target Platform
- *
- * @return VM Arguments from the current Target Platform or empty string if none found
- */
- public static String getInitialVMArguments() {
-
- try {
- ITargetPlatformService service = (ITargetPlatformService) PDECore.getDefault().acquireService(ITargetPlatformService.class.getName());
- if (service != null) {
- ITargetHandle target = service.getWorkspaceTargetHandle();
- if (target != null) {
- String result = target.getTargetDefinition().getVMArguments();
- result = result != null ? result : ""; //$NON-NLS-1$
- return result;
- }
- }
- } catch (CoreException e) {
- }
-
- // TODO: Generally, once the new preference target platform preference page is in use,
- // this code path will not be used. Once we decide to remove support for old targets/preferences
- // this code can be removed.
- PDEPreferencesManager preferences = PDECore.getDefault().getPreferencesManager();
- StringBuffer result = new StringBuffer(preferences.getString(ICoreConstants.VM_ARGS));
-
- if (preferences.getBoolean(ICoreConstants.VM_LAUNCHER_INI)) {
- // hack on the arguments from eclipse.ini
- result.append(TargetPlatformHelper.getIniVMArgs());
- }
- return result.toString();
- }
-
- public static String getInitialProgramArguments() {
- StringBuffer buffer = new StringBuffer("-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"); //$NON-NLS-1$
-
- PDEPreferencesManager preferences = PDECore.getDefault().getPreferencesManager();
- String programArgs = preferences.getString(ICoreConstants.PROGRAM_ARGS);
- if (programArgs.length() > 0) {
- buffer.append(" "); //$NON-NLS-1$
- buffer.append(programArgs);
- }
- return buffer.toString();
- }
-
- public static File getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
- String working;
- try {
- working = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, new File(".").getCanonicalPath()); //$NON-NLS-1$
- } catch (IOException e) {
- working = "${workspace_loc}/../"; //$NON-NLS-1$
- }
- File dir = new File(getSubstitutedString(working));
- if (!dir.exists())
- dir.mkdirs();
- return dir;
- }
-
- public static Map getVMSpecificAttributesMap(ILaunchConfiguration config) throws CoreException {
- Map map = new HashMap(2);
- String javaCommand = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_JAVA_COMMAND, (String) null);
- map.put(IJavaLaunchConfigurationConstants.ATTR_JAVA_COMMAND, javaCommand);
- if (TargetPlatform.getOS().equals("macosx")) { //$NON-NLS-1$
- ModelEntry entry = PluginRegistry.findEntry("org.eclipse.jdt.debug"); //$NON-NLS-1$
- if (entry != null) {
- IPluginModelBase[] models = entry.getExternalModels();
- for (int i = 0; i < models.length; i++) {
- File file = new File(models[i].getInstallLocation());
- if (!file.isFile())
- file = new File(file, "jdi.jar"); //$NON-NLS-1$
- if (file.exists()) {
- map.put(IJavaLaunchConfigurationConstants.ATTR_BOOTPATH_PREPEND, new String[] {file.getAbsolutePath()});
- break;
- }
- }
- }
- }
- return map;
- }
-
- public static String getTracingFileArgument(ILaunchConfiguration config, String optionsFileName) throws CoreException {
- try {
- TracingOptionsManager mng = PDECore.getDefault().getTracingOptionsManager();
- Map options = config.getAttribute(IPDELauncherConstants.TRACING_OPTIONS, (Map) null);
- String selected = config.getAttribute(IPDELauncherConstants.TRACING_CHECKED, (String) null);
- if (selected == null) {
- mng.save(optionsFileName, options);
- } else if (!selected.equals(IPDELauncherConstants.TRACING_NONE)) {
- HashSet result = new HashSet();
- StringTokenizer tokenizer = new StringTokenizer(selected, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- result.add(tokenizer.nextToken());
- }
- mng.save(optionsFileName, options, result);
- }
- } catch (CoreException e) {
- return ""; //$NON-NLS-1$
- }
- return optionsFileName;
- }
-
- public static String[] constructClasspath(ILaunchConfiguration configuration) throws CoreException {
- double targetVersion = TargetPlatformHelper.getTargetVersion();
- String jarPath = targetVersion >= 3.3 ? getEquinoxStartupPath(IPDEBuildConstants.BUNDLE_EQUINOX_LAUNCHER) : getStartupJarPath();
- if (jarPath == null && targetVersion < 3.3)
- jarPath = getEquinoxStartupPath("org.eclipse.core.launcher"); //$NON-NLS-1$
-
- if (jarPath == null)
- return null;
-
- ArrayList entries = new ArrayList();
- entries.add(jarPath);
-
- String bootstrap = configuration.getAttribute(IPDELauncherConstants.BOOTSTRAP_ENTRIES, ""); //$NON-NLS-1$
- StringTokenizer tok = new StringTokenizer(getSubstitutedString(bootstrap), ","); //$NON-NLS-1$
- while (tok.hasMoreTokens())
- entries.add(tok.nextToken().trim());
- return (String[]) entries.toArray(new String[entries.size()]);
- }
-
- private static String getEquinoxStartupPath(String packageName) throws CoreException {
- IPluginModelBase model = PluginRegistry.findModel(IPDEBuildConstants.BUNDLE_EQUINOX_LAUNCHER);
- if (model != null) {
- IResource resource = model.getUnderlyingResource();
- // found in the target
- if (resource == null)
- return model.getInstallLocation();
-
- // find it in the workspace
- IProject project = resource.getProject();
- if (project.hasNature(JavaCore.NATURE_ID)) {
- IJavaProject jProject = JavaCore.create(project);
- IClasspathEntry[] entries = jProject.getRawClasspath();
- for (int i = 0; i < entries.length; i++) {
- int kind = entries[i].getEntryKind();
- if (kind == IClasspathEntry.CPE_SOURCE || kind == IClasspathEntry.CPE_LIBRARY) {
- IPackageFragmentRoot[] roots = jProject.findPackageFragmentRoots(entries[i]);
- for (int j = 0; j < roots.length; j++) {
- if (roots[j].getPackageFragment(packageName).exists()) {
- // if source folder, find the output folder
- if (kind == IClasspathEntry.CPE_SOURCE) {
- IPath path = entries[i].getOutputLocation();
- if (path == null)
- path = jProject.getOutputLocation();
- path = path.removeFirstSegments(1);
- return project.getLocation().append(path).toOSString();
- }
- // else if is a library jar, then get the location of the jar itself
- IResource jar = roots[j].getResource();
- if (jar != null) {
- return jar.getLocation().toOSString();
- }
- }
- }
- }
- }
- }
- }
- Bundle bundle = Platform.getBundle(IPDEBuildConstants.BUNDLE_EQUINOX_LAUNCHER);
- if (bundle != null) {
- try {
- URL url = FileLocator.resolve(bundle.getEntry("/")); //$NON-NLS-1$
- url = FileLocator.toFileURL(url);
- String path = url.getFile();
- if (path.startsWith("file:")) //$NON-NLS-1$
- path = path.substring(5);
- path = new File(path).getAbsolutePath();
- if (path.endsWith("!")) //$NON-NLS-1$
- path = path.substring(0, path.length() - 1);
- return path;
- } catch (IOException e) {
- }
- }
- return null;
- }
-
- private static String getStartupJarPath() throws CoreException {
- IPluginModelBase model = PluginRegistry.findModel("org.eclipse.platform"); //$NON-NLS-1$
- if (model != null && model.getUnderlyingResource() != null) {
- IProject project = model.getUnderlyingResource().getProject();
- if (project.hasNature(JavaCore.NATURE_ID)) {
- IJavaProject jProject = JavaCore.create(project);
- IPackageFragmentRoot[] roots = jProject.getPackageFragmentRoots();
- for (int i = 0; i < roots.length; i++) {
- if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE && roots[i].getPackageFragment("org.eclipse.core.launcher").exists()) { //$NON-NLS-1$
- IPath path = jProject.getOutputLocation().removeFirstSegments(1);
- return project.getLocation().append(path).toOSString();
- }
- }
- }
- if (project.getFile("startup.jar").exists()) //$NON-NLS-1$
- return project.getFile("startup.jar").getLocation().toOSString(); //$NON-NLS-1$
- }
- File startupJar = new Path(TargetPlatform.getLocation()).append("startup.jar").toFile(); //$NON-NLS-1$
-
- // if something goes wrong with the preferences, fall back on the startup.jar
- // in the running eclipse.
- if (!startupJar.exists())
- startupJar = new Path(TargetPlatform.getDefaultLocation()).append("startup.jar").toFile(); //$NON-NLS-1$
-
- return startupJar.exists() ? startupJar.getAbsolutePath() : null;
- }
-
- private static String getSubstitutedString(String text) throws CoreException {
- if (text == null)
- return ""; //$NON-NLS-1$
- IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
- return mgr.performStringSubstitution(text);
- }
-
- public static String getDefaultWorkspaceLocation(String uniqueName) {
- return "${workspace_loc}/../runtime-" + uniqueName.replaceAll("\\s", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public static String getDefaultJUnitWorkspaceLocation() {
- return "${workspace_loc}/../junit-workspace"; //$NON-NLS-1$
- }
-
- public static String getDefaultJUnitConfigurationLocation() {
- return "${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"; //$NON-NLS-1$
- }
-
-}
Index: src/org/eclipse/pde/internal/ui/launcher/TracingBlock.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/TracingBlock.java,v
retrieving revision 1.17
diff -u -r1.17 TracingBlock.java
--- src/org/eclipse/pde/internal/ui/launcher/TracingBlock.java 6 May 2009 20:13:58 -0000 1.17
+++ src/org/eclipse/pde/internal/ui/launcher/TracingBlock.java 21 Sep 2009 18:33:50 -0000
@@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.pde.internal.ui.launcher;
+import org.eclipse.pde.launching.IPDELauncherConstants;
+
import java.util.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -25,7 +27,8 @@
import org.eclipse.pde.internal.ui.PDEUIMessages;
import org.eclipse.pde.internal.ui.util.SWTUtil;
import org.eclipse.pde.internal.ui.wizards.ListUtil;
-import org.eclipse.pde.ui.launcher.*;
+import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
+import org.eclipse.pde.ui.launcher.TracingTab;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
Index: src/org/eclipse/pde/internal/ui/launcher/PDESourceLookupQuery.java
===================================================================
RCS file: src/org/eclipse/pde/internal/ui/launcher/PDESourceLookupQuery.java
diff -N src/org/eclipse/pde/internal/ui/launcher/PDESourceLookupQuery.java
--- src/org/eclipse/pde/internal/ui/launcher/PDESourceLookupQuery.java 16 Sep 2009 20:11:52 -0000 1.15
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,261 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Stephan Herrmann - Bug 242461 - JSR045 support
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.launcher;
-
-import java.io.File;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IValue;
-import org.eclipse.debug.core.sourcelookup.ISourceContainer;
-import org.eclipse.jdt.debug.core.*;
-import org.eclipse.osgi.service.resolver.BundleDescription;
-import org.eclipse.osgi.service.resolver.State;
-import org.eclipse.pde.core.plugin.IPluginModelBase;
-import org.eclipse.pde.internal.core.PDECore;
-import org.eclipse.pde.internal.core.TargetPlatformHelper;
-
-public class PDESourceLookupQuery implements ISafeRunnable {
-
- protected static String OSGI_CLASSLOADER = "org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader"; //$NON-NLS-1$
- private static String LEGACY_ECLIPSE_CLASSLOADER = "org.eclipse.core.runtime.adaptor.EclipseClassLoader"; //$NON-NLS-1$
- private static String MAIN_CLASS = "org.eclipse.core.launcher.Main"; //$NON-NLS-1$
- private static String MAIN_PLUGIN = "org.eclipse.platform"; //$NON-NLS-1$
-
- private Object fElement;
- private Object fResult;
- private PDESourceLookupDirector fDirector;
-
- public PDESourceLookupQuery(PDESourceLookupDirector director, Object object) {
- fElement = object;
- fDirector = director;
- }
-
- public void handleException(Throwable exception) {
- }
-
- public void run() throws Exception {
- IJavaReferenceType declaringType = null;
- String sourcePath = null;
- if (fElement instanceof IJavaStackFrame) {
- IJavaStackFrame stackFrame = (IJavaStackFrame) fElement;
- declaringType = stackFrame.getReferenceType();
- // under JSR 45 source path from the stack frame is more precise than anything derived from the type:
- sourcePath = stackFrame.getSourcePath();
- } else if (fElement instanceof IJavaObject) {
- IJavaType javaType = ((IJavaObject) fElement).getJavaType();
- if (javaType instanceof IJavaReferenceType) {
- declaringType = (IJavaReferenceType) javaType;
- }
- } else if (fElement instanceof IJavaReferenceType) {
- declaringType = (IJavaReferenceType) fElement;
- }
- if (declaringType != null) {
- IJavaObject classLoaderObject = declaringType.getClassLoaderObject();
- String declaringTypeName = declaringType.getName();
- if (sourcePath == null) {
- String[] sourcePaths = declaringType.getSourcePaths(null);
- if (sourcePaths != null) {
- sourcePath = sourcePaths[0];
- }
- if (sourcePath == null) {
- sourcePath = generateSourceName(declaringTypeName);
- }
- }
-
- if (classLoaderObject != null) {
- IJavaClassType type = (IJavaClassType) classLoaderObject.getJavaType();
- if (OSGI_CLASSLOADER.equals(type.getName())) {
- if (fDirector.getOSGiRuntimeVersion() < 3.5) {
- fResult = findSourceElement34(classLoaderObject, sourcePath);
- } else {
- fResult = findSourceElement(classLoaderObject, sourcePath);
- }
- } else if (LEGACY_ECLIPSE_CLASSLOADER.equals(type.getName())) {
- fResult = findSourceElement_legacy(classLoaderObject, sourcePath);
- } else if (MAIN_CLASS.equals(declaringTypeName)) {
- IPluginModelBase model = PDECore.getDefault().getModelManager().findModel(MAIN_PLUGIN);
- if (model != null)
- fResult = getSourceElement(model.getInstallLocation(), MAIN_PLUGIN, sourcePath);
- }
- }
- }
- }
-
- protected Object getResult() {
- return fResult;
- }
-
- private String getValue(IJavaObject object, String variable) throws DebugException {
- IJavaFieldVariable var = object.getField(variable, false);
- return var == null ? null : var.getValue().getValueString();
- }
-
- /**
- * Finds a source element in a 3.4 OSGi runtime.
- *
- * @param object Bundle class loader object
- * @param typeName fully qualified name of the source type being searched for
- * @return source element
- * @throws CoreException
- */
- protected Object findSourceElement34(IJavaObject object, String typeName) throws CoreException {
- IJavaObject manager = getObject(object, "manager", false); //$NON-NLS-1$
- if (manager != null) {
- IJavaObject data = getObject(manager, "data", false); //$NON-NLS-1$
- if (data != null) {
- String location = getValue(data, "fileName"); //$NON-NLS-1$
- String id = getValue(data, "symbolicName"); //$NON-NLS-1$
- return getSourceElement(location, id, typeName);
- }
- }
- return null;
- }
-
- /**
- * Finds source in a 3.5 runtime. In 3.5, the OSGi runtime provides hooks to properly
- * lookup source in fragments that replace/prepend jars in their host.
- *
- * @param object Bundle class loader object
- * @param typeName fully qualified name of the source type being searched for
- * @return source element
- * @throws CoreException
- */
- protected Object findSourceElement(IJavaObject object, String typeName) throws CoreException {
- IJavaObject manager = getObject(object, "manager", false); //$NON-NLS-1$
- if (manager != null) {
- IJavaObject data = getObject(manager, "data", false); //$NON-NLS-1$
- if (data != null) {
- String id = getValue(data, "symbolicName"); //$NON-NLS-1$
- // search manager's class path for location
- Object result = searchClasspathEntries(manager, id, typeName);
- if (result != null) {
- return result;
- }
- // then check its fragments
- IJavaObject frgArray = getObject(manager, "fragments", false); //$NON-NLS-1$
- if (frgArray instanceof IJavaArray) {
- IJavaArray fragments = (IJavaArray) frgArray;
- for (int i = 0; i < fragments.getLength(); i++) {
- IJavaObject fragment = (IJavaObject) fragments.getValue(i);
- if (!fragment.isNull()) {
- // search fragment class path
- result = searchClasspathEntries(fragment, id, typeName);
- if (result != null) {
- return result;
- }
- }
-
- }
- }
- }
- }
- return null;
- }
-
- private Object searchClasspathEntries(IJavaObject entriesOwner, String id, String typeName) throws CoreException {
- IJavaObject cpeArray = getObject(entriesOwner, "entries", false); //$NON-NLS-1$
- if (cpeArray instanceof IJavaArray) {
- IJavaArray entries = (IJavaArray) cpeArray;
- for (int i = 0; i < entries.getLength(); i++) {
- IJavaObject entry = (IJavaObject) entries.getValue(i);
- if (!entry.isNull()) {
- IJavaObject baseData = getObject(entry, "data", false); //$NON-NLS-1$
- if (baseData != null && !baseData.isNull()) {
- IJavaObject fileName = getObject(baseData, "fileName", false); //$NON-NLS-1$
- if (fileName != null && !fileName.isNull()) {
- String location = fileName.getValueString();
- Object el = getSourceElement(location, id, typeName);
- if (el != null) {
- return el;
- }
- }
- }
- }
- }
- }
- return null;
- }
-
- private IJavaObject getObject(IJavaObject object, String field, boolean superfield) throws DebugException {
- IJavaFieldVariable variable = object.getField(field, superfield);
- if (variable != null) {
- IValue value = variable.getValue();
- if (value instanceof IJavaObject)
- return (IJavaObject) value;
- }
- return null;
- }
-
- private Object findSourceElement_legacy(IJavaObject object, String typeName) throws CoreException {
- IJavaObject hostdata = getObject(object, "hostdata", true); //$NON-NLS-1$
- if (hostdata != null) {
- String location = getValue(hostdata, "fileName"); //$NON-NLS-1$
- String id = getValue(hostdata, "symbolicName"); //$NON-NLS-1$
- return getSourceElement(location, id, typeName);
- }
- return null;
- }
-
- private Object getSourceElement(String location, String id, String typeName) throws CoreException {
- if (location != null && id != null) {
- Object result = findSourceElement(getSourceContainers(location, id), typeName);
- if (result != null)
- return result;
-
- // don't give up yet, search fragments attached to this host
- State state = TargetPlatformHelper.getState();
- BundleDescription desc = state.getBundle(id, null);
- if (desc != null) {
- BundleDescription[] fragments = desc.getFragments();
- for (int i = 0; i < fragments.length; i++) {
- location = fragments[i].getLocation();
- id = fragments[i].getSymbolicName();
- result = findSourceElement(getSourceContainers(location, id), typeName);
- if (result != null)
- return result;
- }
- }
- }
- return null;
- }
-
- private Object findSourceElement(ISourceContainer[] containers, String typeName) throws CoreException {
- for (int i = 0; i < containers.length; i++) {
- Object[] result = containers[i].findSourceElements(typeName);
- if (result.length > 0)
- return result[0];
- }
- return null;
- }
-
- protected ISourceContainer[] getSourceContainers(String location, String id) throws CoreException {
- return fDirector.getSourceContainers(location, id);
- }
-
- /**
- * Generates and returns a source file path based on a qualified type name.
- * For example, when java.lang.String
is provided,
- * the returned source name is java/lang/String.java
.
- *
- * @param qualifiedTypeName fully qualified type name that may contain inner types
- * denoted with $
character
- * @return a source file path corresponding to the type name
- */
- private static String generateSourceName(String qualifiedTypeName) {
- int index = qualifiedTypeName.indexOf('$');
- if (index >= 0)
- qualifiedTypeName = qualifiedTypeName.substring(0, index);
- return qualifiedTypeName.replace('.', File.separatorChar) + ".java"; //$NON-NLS-1$
- }
-
-}
\ No newline at end of file
Index: src/org/eclipse/pde/internal/ui/launcher/JUnitProgramBlock.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/JUnitProgramBlock.java,v
retrieving revision 1.8
diff -u -r1.8 JUnitProgramBlock.java
--- src/org/eclipse/pde/internal/ui/launcher/JUnitProgramBlock.java 27 May 2009 20:38:24 -0000 1.8
+++ src/org/eclipse/pde/internal/ui/launcher/JUnitProgramBlock.java 21 Sep 2009 18:33:49 -0000
@@ -10,14 +10,16 @@
*******************************************************************************/
package org.eclipse.pde.internal.ui.launcher;
+import org.eclipse.pde.launching.IPDELauncherConstants;
+
import java.util.TreeSet;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.pde.internal.ui.IPDEUIConstants;
+import org.eclipse.pde.internal.launching.IPDEConstants;
+import org.eclipse.pde.internal.launching.launcher.LauncherUtils;
import org.eclipse.pde.internal.ui.PDEUIMessages;
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
-import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
public class JUnitProgramBlock extends ProgramBlock {
@@ -31,7 +33,7 @@
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
if (!LauncherUtils.requiresUI(config))
- config.setAttribute(IPDELauncherConstants.APPLICATION, IPDEUIConstants.CORE_TEST_APPLICATION);
+ config.setAttribute(IPDELauncherConstants.APPLICATION, IPDEConstants.CORE_TEST_APPLICATION);
else
super.setDefaults(config);
}
@@ -51,7 +53,7 @@
*/
protected void initializeApplicationSection(ILaunchConfiguration config) throws CoreException {
String application = config.getAttribute(IPDELauncherConstants.APPLICATION, (String) null);
- if (IPDEUIConstants.CORE_TEST_APPLICATION.equals(application))
+ if (IPDEConstants.CORE_TEST_APPLICATION.equals(application))
fApplicationCombo.setText(PDEUIMessages.JUnitProgramBlock_headless);
else
super.initializeApplicationSection(config);
@@ -62,7 +64,7 @@
*/
protected void saveApplicationSection(ILaunchConfigurationWorkingCopy config) {
if (fApplicationCombo.getText().equals(PDEUIMessages.JUnitProgramBlock_headless)) {
- String appName = fApplicationCombo.isEnabled() ? IPDEUIConstants.CORE_TEST_APPLICATION : null;
+ String appName = fApplicationCombo.isEnabled() ? IPDEConstants.CORE_TEST_APPLICATION : null;
config.setAttribute(IPDELauncherConstants.APPLICATION, appName);
config.setAttribute(IPDELauncherConstants.APP_TO_TEST, (String) null);
} else {
Index: src/org/eclipse/pde/internal/ui/launcher/OSGiValidationOperation.java
===================================================================
RCS file: src/org/eclipse/pde/internal/ui/launcher/OSGiValidationOperation.java
diff -N src/org/eclipse/pde/internal/ui/launcher/OSGiValidationOperation.java
--- src/org/eclipse/pde/internal/ui/launcher/OSGiValidationOperation.java 13 Apr 2009 14:10:29 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * EclipseSource Corporation - ongoing enhancements
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.launcher;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.pde.core.plugin.IPluginModelBase;
-
-public class OSGiValidationOperation extends LaunchValidationOperation {
-
- public OSGiValidationOperation(ILaunchConfiguration configuration) {
- super(configuration);
- }
-
- protected IPluginModelBase[] getModels() throws CoreException {
- return BundleLauncherHelper.getMergedBundles(fLaunchConfiguration, true);
- }
-
-}
Index: src/org/eclipse/pde/internal/ui/launcher/LaunchAction.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/LaunchAction.java,v
retrieving revision 1.32
diff -u -r1.32 LaunchAction.java
--- src/org/eclipse/pde/internal/ui/launcher/LaunchAction.java 15 Apr 2009 19:01:58 -0000 1.32
+++ src/org/eclipse/pde/internal/ui/launcher/LaunchAction.java 21 Sep 2009 18:33:49 -0000
@@ -11,6 +11,9 @@
*******************************************************************************/
package org.eclipse.pde.internal.ui.launcher;
+import org.eclipse.pde.launching.*;
+import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
+
import java.io.File;
import java.util.*;
import org.eclipse.core.resources.IResource;
@@ -28,8 +31,11 @@
import org.eclipse.pde.internal.core.iproduct.*;
import org.eclipse.pde.internal.core.iproduct.IProduct;
import org.eclipse.pde.internal.core.util.CoreUtility;
-import org.eclipse.pde.internal.ui.*;
-import org.eclipse.pde.ui.launcher.*;
+import org.eclipse.pde.internal.launching.IPDEConstants;
+import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper;
+import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper;
+import org.eclipse.pde.internal.ui.PDEPlugin;
+import org.eclipse.pde.internal.ui.PDEUIMessages;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
public class LaunchAction extends Action {
@@ -263,8 +269,8 @@
wc.setAttribute(IPDELauncherConstants.USEFEATURES, false);
wc.setAttribute(IPDELauncherConstants.USE_DEFAULT, false);
wc.setAttribute(IPDELauncherConstants.DOCLEAR, false);
- wc.setAttribute(IPDEUIConstants.DOCLEARLOG, false);
- wc.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true);
+ wc.setAttribute(IPDEConstants.DOCLEARLOG, false);
+ wc.setAttribute(IPDEConstants.APPEND_ARGS_EXPLICITLY, true);
wc.setAttribute(IPDELauncherConstants.ASKCLEAR, true);
wc.setAttribute(IPDELauncherConstants.USE_PRODUCT, true);
wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, false);
Index: src/org/eclipse/pde/internal/ui/launcher/EquinoxInitializer.java
===================================================================
RCS file: src/org/eclipse/pde/internal/ui/launcher/EquinoxInitializer.java
diff -N src/org/eclipse/pde/internal/ui/launcher/EquinoxInitializer.java
--- src/org/eclipse/pde/internal/ui/launcher/EquinoxInitializer.java 13 Apr 2009 14:52:48 -0000 1.9
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.launcher;
-
-import java.util.*;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.pde.internal.core.*;
-import org.eclipse.pde.internal.ui.IPDEUIConstants;
-import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
-import org.eclipse.pde.ui.launcher.OSGiLaunchConfigurationInitializer;
-
-public class EquinoxInitializer extends OSGiLaunchConfigurationInitializer {
-
- private Map fStartLevels;
-
- public void initialize(ILaunchConfigurationWorkingCopy configuration) {
- super.initialize(configuration);
- initializeProgramArguments(configuration);
- initializeVMArguments(configuration);
- initializeTracing(configuration);
- }
-
- private void initializeProgramArguments(ILaunchConfigurationWorkingCopy configuration) {
- StringBuffer buffer = new StringBuffer(LaunchArgumentsHelper.getInitialProgramArguments());
- if (buffer.length() > 0) {
- if (buffer.indexOf("-console") == -1) { //$NON-NLS-1$
- buffer.append(" -console"); //$NON-NLS-1$
- }
- } else {
- buffer.append("-console"); //$NON-NLS-1$
- }
- configuration.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true);
- configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, buffer.toString());
- }
-
- private void initializeVMArguments(ILaunchConfigurationWorkingCopy configuration) {
- configuration.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$
- PDEPreferencesManager preferences = PDECore.getDefault().getPreferencesManager();
- StringBuffer vmArgs = new StringBuffer(preferences.getString(ICoreConstants.VM_ARGS));
- if (vmArgs.indexOf("-Declipse.ignoreApp") == -1) { //$NON-NLS-1$
- if (vmArgs.length() > 0)
- vmArgs.append(" "); //$NON-NLS-1$
- vmArgs.append("-Declipse.ignoreApp=true"); //$NON-NLS-1$
- }
- if (vmArgs.indexOf("-Dosgi.noShutdown") == -1) { //$NON-NLS-1$
- vmArgs.append(" -Dosgi.noShutdown=true"); //$NON-NLS-1$
- }
- configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.toString());
- }
-
- private void initializeTracing(ILaunchConfigurationWorkingCopy configuration) {
- configuration.setAttribute(IPDELauncherConstants.TRACING_CHECKED, IPDELauncherConstants.TRACING_NONE);
- }
-
- protected void initializeBundleState(ILaunchConfigurationWorkingCopy configuration) {
- initializeBundleState();
- super.initializeBundleState(configuration);
- }
-
- protected String getAutoStart(String bundleID) {
- if (fStartLevels.containsKey(bundleID)) {
- String value = fStartLevels.get(bundleID).toString();
- return value.substring(value.indexOf(":") + 1); //$NON-NLS-1$
- }
- return super.getAutoStart(bundleID);
- }
-
- protected String getStartLevel(String bundleID) {
- if (fStartLevels.containsKey(bundleID)) {
- String value = fStartLevels.get(bundleID).toString();
- return value.substring(0, value.indexOf(":")); //$NON-NLS-1$
- }
- return super.getStartLevel(bundleID);
- }
-
- private void initializeBundleState() {
- if (fStartLevels == null)
- fStartLevels = new HashMap();
- Properties props = TargetPlatformHelper.getConfigIniProperties();
- if (props != null) {
- String value = (String) props.get("osgi.bundles"); //$NON-NLS-1$
- if (value != null) {
- StringTokenizer tokenizer = new StringTokenizer(value, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String tokenValue = tokenizer.nextToken();
- int index = tokenValue.indexOf("@"); //$NON-NLS-1$
- if (index > 0) {
- String bundle = tokenValue.substring(0, index).trim();
- fStartLevels.put(bundle, getStartValue(tokenValue.substring(index)));
- }
- }
- }
- }
- }
-
- private String getStartValue(String value) {
- StringBuffer buffer = new StringBuffer(value);
- StringBuffer result = new StringBuffer(":"); //$NON-NLS-1$
-
- int index = value.indexOf("start"); //$NON-NLS-1$
- result.append(Boolean.toString(index != -1));
-
- if (index != -1)
- buffer.delete(index, index + 5);
-
- int colon = value.indexOf(':');
- if (colon != -1)
- buffer.deleteCharAt(colon);
-
- // delete the first char '@'
- buffer.deleteCharAt(0);
-
- try {
- result.insert(0, Integer.parseInt(buffer.toString().trim()));
- } catch (NumberFormatException e) {
- result.insert(0, DEFAULT);
- }
- return result.toString();
- }
-
-}
Index: src/org/eclipse/pde/internal/ui/launcher/BundleLauncherHelper.java
===================================================================
RCS file: src/org/eclipse/pde/internal/ui/launcher/BundleLauncherHelper.java
diff -N src/org/eclipse/pde/internal/ui/launcher/BundleLauncherHelper.java
--- src/org/eclipse/pde/internal/ui/launcher/BundleLauncherHelper.java 28 Apr 2009 20:41:31 -0000 1.13
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * EclipseSource Corporation - ongoing enhancements
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.launcher;
-
-import java.util.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.osgi.service.resolver.BundleDescription;
-import org.eclipse.pde.core.plugin.*;
-import org.eclipse.pde.internal.build.IPDEBuildConstants;
-import org.eclipse.pde.internal.core.TargetPlatformHelper;
-import org.eclipse.pde.internal.ui.IPDEUIConstants;
-import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
-
-public class BundleLauncherHelper {
-
- public static final char VERSION_SEPARATOR = '*';
-
- public static Map getWorkspaceBundleMap(ILaunchConfiguration configuration) throws CoreException {
- return getWorkspaceBundleMap(configuration, null, IPDELauncherConstants.WORKSPACE_BUNDLES);
- }
-
- public static Map getTargetBundleMap(ILaunchConfiguration configuration) throws CoreException {
- return getTargetBundleMap(configuration, null, IPDELauncherConstants.TARGET_BUNDLES);
- }
-
- public static Map getMergedBundleMap(ILaunchConfiguration configuration, boolean osgi) throws CoreException {
- Set set = new HashSet();
- Map map = new HashMap();
-
- // if we are using the eclipse-based launcher, we need special checks
- if (!osgi) {
-
- checkBackwardCompatibility(configuration, true);
-
- if (configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true)) {
- IPluginModelBase[] models = PluginRegistry.getActiveModels();
- for (int i = 0; i < models.length; i++) {
- addBundleToMap(map, models[i], "default:default"); //$NON-NLS-1$
- }
- return map;
- }
-
- if (configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false)) {
- IPluginModelBase[] models = PluginRegistry.getWorkspaceModels();
- for (int i = 0; i < models.length; i++) {
- addBundleToMap(map, models[i], "default:default"); //$NON-NLS-1$
- }
- return map;
- }
- }
-
- String workspace = osgi == false ? IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS : IPDELauncherConstants.WORKSPACE_BUNDLES;
- String target = osgi == false ? IPDELauncherConstants.SELECTED_TARGET_PLUGINS : IPDELauncherConstants.TARGET_BUNDLES;
- map = getWorkspaceBundleMap(configuration, set, workspace);
- map.putAll(getTargetBundleMap(configuration, set, target));
- return map;
- }
-
- public static IPluginModelBase[] getMergedBundles(ILaunchConfiguration configuration, boolean osgi) throws CoreException {
- Map map = getMergedBundleMap(configuration, osgi);
- return (IPluginModelBase[]) map.keySet().toArray(new IPluginModelBase[map.size()]);
- }
-
- public static Map getWorkspaceBundleMap(ILaunchConfiguration configuration, Set set, String attribute) throws CoreException {
- String selected = configuration.getAttribute(attribute, ""); //$NON-NLS-1$
- Map map = new HashMap();
- StringTokenizer tok = new StringTokenizer(selected, ","); //$NON-NLS-1$
- while (tok.hasMoreTokens()) {
- String token = tok.nextToken();
- int index = token.indexOf('@');
- if (index < 0) { // if no start levels, assume default
- token = token.concat("@default:default"); //$NON-NLS-1$
- index = token.indexOf('@');
- }
- String idVersion = token.substring(0, index);
- int versionIndex = idVersion.indexOf(VERSION_SEPARATOR);
- String id = (versionIndex > 0) ? idVersion.substring(0, versionIndex) : idVersion;
- String version = (versionIndex > 0) ? idVersion.substring(versionIndex + 1) : null;
- if (set != null)
- set.add(id);
- ModelEntry entry = PluginRegistry.findEntry(id);
- if (entry != null) {
- IPluginModelBase[] models = entry.getWorkspaceModels();
- for (int i = 0; i < models.length; i++) {
- IPluginBase base = models[i].getPluginBase();
-
- // match only if...
- // a) if we have the same version
- // b) no version
- // c) all else fails, if there's just one bundle available, use it
- if (base.getVersion().equals(version) || version == null || models.length == 1)
- addBundleToMap(map, models[i], token.substring(index + 1));
- }
- }
- }
-
- if (configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true)) {
- Set deselectedPlugins = LaunchPluginValidator.parsePlugins(configuration, IPDELauncherConstants.DESELECTED_WORKSPACE_PLUGINS);
- IPluginModelBase[] models = PluginRegistry.getWorkspaceModels();
- for (int i = 0; i < models.length; i++) {
- String id = models[i].getPluginBase().getId();
- if (id == null)
- continue;
- if (!deselectedPlugins.contains(models[i])) {
- if (set != null)
- set.add(id);
- if (!map.containsKey(models[i]))
- addBundleToMap(map, models[i], "default:default"); //$NON-NLS-1$
- }
- }
- }
- return map;
- }
-
- /**
- * Adds the given bundle and start information to the map. This will override anything set
- * for system bundles, and set their start level to the appropriate level
- * @param map The map to add the bundles too
- * @param bundle The bundle to add
- * @param substring the start information in the form level:autostart
- */
- private static void addBundleToMap(Map map, IPluginModelBase bundle, String sl) {
- BundleDescription desc = bundle.getBundleDescription();
- boolean defaultsl = (sl == null || sl.equals("default:default")); //$NON-NLS-1$
- if (desc != null && defaultsl) {
- String modelName = desc.getSymbolicName();
- if (IPDEBuildConstants.BUNDLE_DS.equals(modelName)) {
- map.put(bundle, "1:true"); //$NON-NLS-1$
- } else if (IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR.equals(modelName)) {
- map.put(bundle, "1:true"); //$NON-NLS-1$
- } else if (IPDEBuildConstants.BUNDLE_EQUINOX_COMMON.equals(modelName)) {
- map.put(bundle, "2:true"); //$NON-NLS-1$
- } else if (IPDEBuildConstants.BUNDLE_OSGI.equals(modelName)) {
- map.put(bundle, "-1:true"); //$NON-NLS-1$
- } else if (IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR.equals(modelName)) {
- map.put(bundle, "3:true"); //$NON-NLS-1$
- } else if (IPDEBuildConstants.BUNDLE_CORE_RUNTIME.equals(modelName)) {
- if (TargetPlatformHelper.getTargetVersion() > 3.1) {
- map.put(bundle, "default:true"); //$NON-NLS-1$
- } else {
- map.put(bundle, "2:true"); //$NON-NLS-1$
- }
- } else {
- map.put(bundle, sl);
- }
- } else {
- map.put(bundle, sl);
- }
-
- }
-
- public static Map getTargetBundleMap(ILaunchConfiguration configuration, Set set, String attribute) throws CoreException {
- String selected = configuration.getAttribute(attribute, ""); //$NON-NLS-1$
- Map map = new HashMap();
- StringTokenizer tok = new StringTokenizer(selected, ","); //$NON-NLS-1$
- while (tok.hasMoreTokens()) {
- String token = tok.nextToken();
- int index = token.indexOf('@');
- if (index < 0) { // if no start levels, assume default
- token = token.concat("@default:default"); //$NON-NLS-1$
- index = token.indexOf('@');
- }
- String idVersion = token.substring(0, index);
- int versionIndex = idVersion.indexOf(VERSION_SEPARATOR);
- String id = (versionIndex > 0) ? idVersion.substring(0, versionIndex) : idVersion;
- String version = (versionIndex > 0) ? idVersion.substring(versionIndex + 1) : null;
- if (set != null && set.contains(id))
- continue;
- ModelEntry entry = PluginRegistry.findEntry(id);
- if (entry != null) {
- IPluginModelBase[] models = entry.getExternalModels();
- for (int i = 0; i < models.length; i++) {
- if (models[i].isEnabled()) {
- IPluginBase base = models[i].getPluginBase();
- // match only if...
- // a) if we have the same version
- // b) no version
- // c) all else fails, if there's just one bundle available, use it
- if (base.getVersion().equals(version) || version == null || models.length == 1)
- addBundleToMap(map, models[i], token.substring(index + 1));
- }
- }
- }
- }
- return map;
- }
-
- public static String writeBundleEntry(IPluginModelBase model, String startLevel, String autoStart) {
- IPluginBase base = model.getPluginBase();
- String id = base.getId();
- StringBuffer buffer = new StringBuffer(id);
-
- ModelEntry entry = PluginRegistry.findEntry(id);
- if (entry.getActiveModels().length > 1) {
- buffer.append(VERSION_SEPARATOR);
- buffer.append(model.getPluginBase().getVersion());
- }
-
- boolean hasStartLevel = (startLevel != null && startLevel.length() > 0);
- boolean hasAutoStart = (autoStart != null && autoStart.length() > 0);
-
- if (hasStartLevel || hasAutoStart)
- buffer.append('@');
- if (hasStartLevel)
- buffer.append(startLevel);
- if (hasStartLevel || hasAutoStart)
- buffer.append(':');
- if (hasAutoStart)
- buffer.append(autoStart);
- return buffer.toString();
- }
-
- public static void checkBackwardCompatibility(ILaunchConfiguration configuration, boolean save) throws CoreException {
- ILaunchConfigurationWorkingCopy wc = null;
- if (configuration.isWorkingCopy()) {
- wc = (ILaunchConfigurationWorkingCopy) configuration;
- } else {
- wc = configuration.getWorkingCopy();
- }
-
- String value = configuration.getAttribute("wsproject", (String) null); //$NON-NLS-1$
- if (value != null) {
- wc.setAttribute("wsproject", (String) null); //$NON-NLS-1$
- if (value.indexOf(';') != -1) {
- value = value.replace(';', ',');
- } else if (value.indexOf(':') != -1) {
- value = value.replace(':', ',');
- }
- value = (value.length() == 0 || value.equals(",")) //$NON-NLS-1$
- ? null
- : value.substring(0, value.length() - 1);
-
- boolean automatic = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
- String attr = automatic ? IPDELauncherConstants.DESELECTED_WORKSPACE_PLUGINS : IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS;
- wc.setAttribute(attr, value);
- }
-
- String value2 = configuration.getAttribute("extplugins", (String) null); //$NON-NLS-1$
- if (value2 != null) {
- wc.setAttribute("extplugins", (String) null); //$NON-NLS-1$
- if (value2.indexOf(';') != -1) {
- value2 = value2.replace(';', ',');
- } else if (value2.indexOf(':') != -1) {
- value2 = value2.replace(':', ',');
- }
- value2 = (value2.length() == 0 || value2.equals(",")) ? null : value2.substring(0, value2.length() - 1); //$NON-NLS-1$
- wc.setAttribute(IPDELauncherConstants.SELECTED_TARGET_PLUGINS, value2);
- }
-
- String version = configuration.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, (String) null);
- boolean newApp = TargetPlatformHelper.usesNewApplicationModel();
- boolean upgrade = !"3.3".equals(version) && newApp; //$NON-NLS-1$
- if (!upgrade)
- upgrade = TargetPlatformHelper.getTargetVersion() >= 3.2 && version == null;
- if (upgrade) {
- wc.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, newApp ? "3.3" : "3.2a"); //$NON-NLS-1$ //$NON-NLS-2$
- boolean usedefault = configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true);
- boolean useFeatures = configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false);
- boolean automaticAdd = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
- if (!usedefault && !useFeatures) {
- ArrayList list = new ArrayList();
- if (version == null) {
- list.add("org.eclipse.core.contenttype"); //$NON-NLS-1$
- list.add("org.eclipse.core.jobs"); //$NON-NLS-1$
- list.add(IPDEBuildConstants.BUNDLE_EQUINOX_COMMON);
- list.add("org.eclipse.equinox.preferences"); //$NON-NLS-1$
- list.add("org.eclipse.equinox.registry"); //$NON-NLS-1$
- list.add("org.eclipse.core.runtime.compatibility.registry"); //$NON-NLS-1$
- }
- if (!"3.3".equals(version) && newApp) //$NON-NLS-1$
- list.add("org.eclipse.equinox.app"); //$NON-NLS-1$
- StringBuffer extensions = new StringBuffer(configuration.getAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS, "")); //$NON-NLS-1$
- StringBuffer target = new StringBuffer(configuration.getAttribute(IPDELauncherConstants.SELECTED_TARGET_PLUGINS, "")); //$NON-NLS-1$
- for (int i = 0; i < list.size(); i++) {
- String plugin = list.get(i).toString();
- IPluginModelBase model = PluginRegistry.findModel(plugin);
- if (model == null)
- continue;
- if (model.getUnderlyingResource() != null) {
- if (automaticAdd)
- continue;
- if (extensions.length() > 0)
- extensions.append(","); //$NON-NLS-1$
- extensions.append(plugin);
- } else {
- if (target.length() > 0)
- target.append(","); //$NON-NLS-1$
- target.append(plugin);
- }
- }
- if (extensions.length() > 0)
- wc.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS, extensions.toString());
- if (target.length() > 0)
- wc.setAttribute(IPDELauncherConstants.SELECTED_TARGET_PLUGINS, target.toString());
- }
- }
-
- if (save && (value != null || value2 != null || upgrade))
- wc.doSave();
- }
-
-}
Index: src/org/eclipse/pde/internal/ui/launcher/OSGiMigrationDelegate.java
===================================================================
RCS file: src/org/eclipse/pde/internal/ui/launcher/OSGiMigrationDelegate.java
diff -N src/org/eclipse/pde/internal/ui/launcher/OSGiMigrationDelegate.java
--- src/org/eclipse/pde/internal/ui/launcher/OSGiMigrationDelegate.java 27 May 2009 20:38:24 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ui.launcher;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.pde.internal.ui.IPDEUIConstants;
-
-public class OSGiMigrationDelegate extends PDEMigrationDelegate {
-
- public boolean isCandidate(ILaunchConfiguration candidate) throws CoreException {
- return super.isCandidate(candidate) || !candidate.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "").equals("3.3"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void migrate(ILaunchConfigurationWorkingCopy wc) throws CoreException {
- if (!wc.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "").equals("3.3")) { //$NON-NLS-1$ //$NON-NLS-2$
- wc.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$
- StringBuffer vmArgs = new StringBuffer(wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "")); //$NON-NLS-1$
- if (vmArgs.indexOf("-Declipse.ignoreApp") == -1) { //$NON-NLS-1$
- if (vmArgs.length() > 0)
- vmArgs.append(" "); //$NON-NLS-1$
- vmArgs.append("-Declipse.ignoreApp=true"); //$NON-NLS-1$
- }
- if (vmArgs.indexOf("-Dosgi.noShutdown") == -1) { //$NON-NLS-1$
- vmArgs.append(" -Dosgi.noShutdown=true"); //$NON-NLS-1$
- }
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.toString());
- }
- super.migrate(wc);
- }
-
-}
Index: src/org/eclipse/pde/internal/ui/launcher/VMHelper.java
===================================================================
RCS file: src/org/eclipse/pde/internal/ui/launcher/VMHelper.java
diff -N src/org/eclipse/pde/internal/ui/launcher/VMHelper.java
--- src/org/eclipse/pde/internal/ui/launcher/VMHelper.java 8 Jul 2008 16:53:27 -0000 1.15
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Les Jones - * Clients may instantiate or subclass this class - *
- * - * @since 3.3 - */ -public class OSGiLaunchConfigurationInitializer { - - protected static final String DEFAULT = "default"; //$NON-NLS-1$ - - /** - * Initializes some attributes on a newly-created launch configuration - * - * @param configuration - * the launch configuration - */ - public void initialize(ILaunchConfigurationWorkingCopy configuration) { - initializeFrameworkDefaults(configuration); - initializeBundleState(configuration); - initializeSourcePathProvider(configuration); - } - - /** - * Sets the source provider ID - * - * @param configuration - * the launch configuration - */ - protected void initializeSourcePathProvider(ILaunchConfigurationWorkingCopy configuration) { - configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, PDESourcePathProvider.ID); - } - - /** - * Initializes the start level and auto-start attributes - * - * @param configuration - * the launch configuration - */ - protected void initializeFrameworkDefaults(ILaunchConfigurationWorkingCopy configuration) { - configuration.setAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, true); - configuration.setAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4); - } - - /** - * Initializes the checked/unchecked state of bundles - * - * @param configuration - * the launch configuration - */ - protected void initializeBundleState(ILaunchConfigurationWorkingCopy configuration) { - StringBuffer explugins = new StringBuffer(); - StringBuffer wsplugins = new StringBuffer(); - IPluginModelBase[] models = PluginRegistry.getActiveModels(); - for (int i = 0; i < models.length; i++) { - boolean inWorkspace = models[i].getUnderlyingResource() != null; - appendBundle(inWorkspace ? wsplugins : explugins, models[i]); - } - configuration.setAttribute(IPDELauncherConstants.WORKSPACE_BUNDLES, wsplugins.toString()); - configuration.setAttribute(IPDELauncherConstants.TARGET_BUNDLES, explugins.toString()); - configuration.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); - } - - private void appendBundle(StringBuffer buffer, IPluginModelBase model) { - if (buffer.length() > 0) - buffer.append(","); //$NON-NLS-1$ - String id = model.getPluginBase().getId(); - String value = BundleLauncherHelper.writeBundleEntry(model, getStartLevel(id), getAutoStart(id)); - buffer.append(value); - } - - /** - * Returns the bundle's start level - * - * @param bundleID - * the bundle ID - * @return the start level for the given bundle or the stringdefault
- */
- protected String getStartLevel(String bundleID) {
- return DEFAULT;
- }
-
- /**
- * Returns whether the bundle should be started automatically
- * @param bundleID
- * the bundle ID
- * @return true
, false
, or default
- */
- protected String getAutoStart(String bundleID) {
- return DEFAULT;
- }
-
-}
Index: src/org/eclipse/pde/ui/launcher/EclipseApplicationLaunchConfiguration.java
===================================================================
RCS file: src/org/eclipse/pde/ui/launcher/EclipseApplicationLaunchConfiguration.java
diff -N src/org/eclipse/pde/ui/launcher/EclipseApplicationLaunchConfiguration.java
--- src/org/eclipse/pde/ui/launcher/EclipseApplicationLaunchConfiguration.java 16 Sep 2009 16:44:44 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,290 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * EclipseSource Corporation - ongoing enhancements
- *******************************************************************************/
-package org.eclipse.pde.ui.launcher;
-
-import java.io.File;
-import java.util.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.variables.IStringVariableManager;
-import org.eclipse.core.variables.VariablesPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.pde.core.plugin.IPluginModelBase;
-import org.eclipse.pde.core.plugin.TargetPlatform;
-import org.eclipse.pde.internal.core.*;
-import org.eclipse.pde.internal.core.util.CoreUtility;
-import org.eclipse.pde.internal.core.util.VersionUtil;
-import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
-import org.eclipse.pde.internal.launching.PDEMessages;
-import org.eclipse.pde.internal.launching.launcher.*;
-import org.osgi.framework.Version;
-
-/**
- * A launch delegate for launching Eclipse applications
- * - * Clients may subclass and instantiate this class. - *
- * @since 3.2 - */ -public class EclipseApplicationLaunchConfiguration extends AbstractPDELaunchConfiguration { - - // used to generate the dev classpath entries - // key is bundle ID, value is a model - private Map fAllBundles; - - // key is a model, value is startLevel:autoStart - private Map fModels; - - /** - * To avoid duplicating variable substitution (and duplicate prompts) - * this variable will store the substituted workspace location. - */ - private String fWorkspaceLocation; - - /* - * (non-Javadoc) - * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#getProgramArguments(org.eclipse.debug.core.ILaunchConfiguration) - */ - public String[] getProgramArguments(ILaunchConfiguration configuration) throws CoreException { - ArrayList programArgs = new ArrayList(); - - // If a product is specified, then add it to the program args - if (configuration.getAttribute(IPDELauncherConstants.USE_PRODUCT, false)) { - String product = configuration.getAttribute(IPDELauncherConstants.PRODUCT, ""); //$NON-NLS-1$ - if (product.length() > 0) { - programArgs.add("-product"); //$NON-NLS-1$ - programArgs.add(product); - } else { // TODO product w/o an application and product... how to handle gracefully? - programArgs.add("-application"); //$NON-NLS-1$ - programArgs.add(configuration.getAttribute(IPDELauncherConstants.APPLICATION, "")); //$NON-NLS-1$ - } - } else { - // specify the application to launch - programArgs.add("-application"); //$NON-NLS-1$ - programArgs.add(configuration.getAttribute(IPDELauncherConstants.APPLICATION, TargetPlatform.getDefaultApplication())); - } - - // specify the workspace location for the runtime workbench - if (fWorkspaceLocation == null) { - fWorkspaceLocation = LaunchArgumentsHelper.getWorkspaceLocation(configuration); - } - if (fWorkspaceLocation.length() > 0) { - programArgs.add("-data"); //$NON-NLS-1$ - programArgs.add(fWorkspaceLocation); - } - - boolean showSplash = true; - if (configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false)) { - validateFeatures(); - IPath installPath = PDELaunchingPlugin.getWorkspace().getRoot().getLocation(); - programArgs.add("-install"); //$NON-NLS-1$ - programArgs.add("file:" + installPath.removeLastSegments(1).addTrailingSeparator().toString()); //$NON-NLS-1$ - if (!configuration.getAttribute(IPDELauncherConstants.CONFIG_USE_DEFAULT_AREA, true)) { - programArgs.add("-configuration"); //$NON-NLS-1$ - programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$ - } - programArgs.add("-update"); //$NON-NLS-1$ - // add the output folder names - programArgs.add("-dev"); //$NON-NLS-1$ - programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", true)); //$NON-NLS-1$ - } else { - String productID = LaunchConfigurationHelper.getProductID(configuration); - Properties prop = LaunchConfigurationHelper.createConfigIniFile(configuration, productID, fAllBundles, fModels, getConfigDir(configuration)); - showSplash = prop.containsKey("osgi.splashPath") || prop.containsKey("splashLocation"); //$NON-NLS-1$ //$NON-NLS-2$ - String brandingId = LaunchConfigurationHelper.getContributingPlugin(productID); - TargetPlatform.createPlatformConfiguration(getConfigDir(configuration), (IPluginModelBase[]) fAllBundles.values().toArray(new IPluginModelBase[fAllBundles.size()]), brandingId != null ? (IPluginModelBase) fAllBundles.get(brandingId) : null); - TargetPlatformHelper.checkPluginPropertiesConsistency(fAllBundles, getConfigDir(configuration)); - programArgs.add("-configuration"); //$NON-NLS-1$ - programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$ - - // add the output folder names - programArgs.add("-dev"); //$NON-NLS-1$ - programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", fAllBundles)); //$NON-NLS-1$ - } - // necessary for PDE to know how to load plugins when target platform = host platform - // see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode() - IPluginModelBase base = (IPluginModelBase) fAllBundles.get(PDECore.PLUGIN_ID); - if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) < 0) //$NON-NLS-1$ - programArgs.add("-pdelaunch"); //$NON-NLS-1$ - - String[] args = super.getProgramArguments(configuration); - for (int i = 0; i < args.length; i++) { - programArgs.add(args[i]); - } - - if (!programArgs.contains("-nosplash") && showSplash) { //$NON-NLS-1$ - if (TargetPlatformHelper.getTargetVersion() >= 3.1) { - programArgs.add(0, "-launcher"); //$NON-NLS-1$ - - IPath path = null; - if (TargetPlatform.getOS().equals("macosx")) { //$NON-NLS-1$ - path = new Path(TargetPlatform.getLocation()).append("Eclipse.app/Contents/MacOS/eclipse"); //$NON-NLS-1$ - } else { - path = new Path(TargetPlatform.getLocation()).append("eclipse"); //$NON-NLS-1$ - if (TargetPlatform.getOS().equals("win32")) { //$NON-NLS-1$ - path = path.addFileExtension("exe"); //$NON-NLS-1$ - } - } - - programArgs.add(1, path.toOSString()); //This could be the branded launcher if we want (also this does not bring much) - programArgs.add(2, "-name"); //$NON-NLS-1$ - programArgs.add(3, "Eclipse"); //This should be the name of the product //$NON-NLS-1$ - programArgs.add(4, "-showsplash"); //$NON-NLS-1$ - programArgs.add(5, "600"); //$NON-NLS-1$ - } else { - programArgs.add(0, "-showsplash"); //$NON-NLS-1$ - programArgs.add(1, computeShowsplashArgument()); - } - } - return (String[]) programArgs.toArray(new String[programArgs.size()]); - } - - private void validateFeatures() throws CoreException { - IPath installPath = PDELaunchingPlugin.getWorkspace().getRoot().getLocation(); - String lastSegment = installPath.lastSegment(); - boolean badStructure = lastSegment == null; - if (!badStructure) { - IPath featuresPath = installPath.removeLastSegments(1).append("features"); //$NON-NLS-1$ - badStructure = !lastSegment.equalsIgnoreCase("plugins") //$NON-NLS-1$ - || !featuresPath.toFile().exists(); - } - if (badStructure) { - throw new CoreException(LauncherUtils.createErrorStatus(PDEMessages.WorkbenchLauncherConfigurationDelegate_badFeatureSetup)); - } - // Ensure important files are present - ensureProductFilesExist(getProductPath()); - } - - private IPath getProductPath() { - return PDELaunchingPlugin.getWorkspace().getRoot().getLocation().removeLastSegments(1); - } - - private String computeShowsplashArgument() { - IPath eclipseHome = new Path(TargetPlatform.getLocation()); - IPath fullPath = eclipseHome.append("eclipse"); //$NON-NLS-1$ - return fullPath.toOSString() + " -showsplash 600"; //$NON-NLS-1$ - } - - private void ensureProductFilesExist(IPath productArea) { - File productDir = productArea.toFile(); - File marker = new File(productDir, ".eclipseproduct"); //$NON-NLS-1$ - IPath eclipsePath = new Path(TargetPlatform.getLocation()); - if (!marker.exists()) - CoreUtility.copyFile(eclipsePath, ".eclipseproduct", marker); //$NON-NLS-1$ - - File configDir = new File(productDir, "configuration"); //$NON-NLS-1$ - if (!configDir.exists()) - configDir.mkdirs(); - File ini = new File(configDir, "config.ini"); //$NON-NLS-1$ - if (!ini.exists()) - CoreUtility.copyFile(eclipsePath.append("configuration"), "config.ini", ini); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /* - * (non-Javadoc) - * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#getConfigDir(org.eclipse.debug.core.ILaunchConfiguration) - */ - protected File getConfigDir(ILaunchConfiguration config) { - if (fConfigDir == null) { - try { - if (config.getAttribute(IPDELauncherConstants.USEFEATURES, false) && config.getAttribute(IPDELauncherConstants.CONFIG_USE_DEFAULT_AREA, true)) { - String root = getProductPath().toString(); - root += "/configuration"; //$NON-NLS-1$ - fConfigDir = new File(root); - if (!fConfigDir.exists()) - fConfigDir.mkdirs(); - } else { - fConfigDir = LaunchConfigurationHelper.getConfigurationArea(config); - } - } catch (CoreException e) { - fConfigDir = LaunchConfigurationHelper.getConfigurationArea(config); - } - } - return fConfigDir; - } - - /** - * Clears the workspace prior to launching if the workspace exists and the option to - * clear it is turned on. Also clears the configuration area if that option is chosen. - * - * @param configuration - * the launch configuration - * @param monitor - * the progress monitor - * @throws CoreException - * if unable to retrieve launch attribute values - * @since 3.3 - */ - protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { - if (fWorkspaceLocation == null) { - fWorkspaceLocation = LaunchArgumentsHelper.getWorkspaceLocation(configuration); - } - // Clear workspace and prompt, if necessary - if (!LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, monitor)) - throw new CoreException(Status.CANCEL_STATUS); - - // clear config area, if necessary - if (configuration.getAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false)) - CoreUtility.deleteContent(getConfigDir(configuration)); - } - - /* (non-Javadoc) - * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException { - fWorkspaceLocation = null; - - fModels = BundleLauncherHelper.getMergedBundleMap(configuration, false); - fAllBundles = new HashMap(fModels.size()); - Iterator iter = fModels.keySet().iterator(); - while (iter.hasNext()) { - IPluginModelBase model = (IPluginModelBase) iter.next(); - fAllBundles.put(model.getPluginBase().getId(), model); - } - validateConfigIni(configuration); - super.preLaunchCheck(configuration, launch, monitor); - } - - private void validateConfigIni(ILaunchConfiguration configuration) throws CoreException { - if (!configuration.getAttribute(IPDELauncherConstants.CONFIG_GENERATE_DEFAULT, true)) { - String templateLoc = configuration.getAttribute(IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, ""); //$NON-NLS-1$ - IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager(); - templateLoc = mgr.performStringSubstitution(templateLoc); - - File templateFile = new File(templateLoc); - if (!templateFile.exists()) { - if (!LauncherUtils.generateConfigIni()) - throw new CoreException(Status.CANCEL_STATUS); - // with the way the launcher works, if a config.ini file is not found one will be generated automatically. - // This check was to warn the user a config.ini needs to be generated. - bug 161265, comment #7 - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#getVMArguments(org.eclipse.debug.core.ILaunchConfiguration) - */ - public String[] getVMArguments(ILaunchConfiguration configuration) throws CoreException { - String[] vmArgs = super.getVMArguments(configuration); - IPluginModelBase base = (IPluginModelBase) fAllBundles.get(PDECore.PLUGIN_ID); - if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) >= 0) { //$NON-NLS-1$ - // necessary for PDE to know how to load plugins when target platform = host platform - // see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode() - String[] result = new String[vmArgs.length + 1]; - System.arraycopy(vmArgs, 0, result, 0, vmArgs.length); - result[vmArgs.length] = "-Declipse.pde.launch=true"; //$NON-NLS-1$ - return result; - } - return vmArgs; - } - -} Index: src/org/eclipse/pde/ui/launcher/EquinoxLaunchConfiguration.java =================================================================== RCS file: src/org/eclipse/pde/ui/launcher/EquinoxLaunchConfiguration.java diff -N src/org/eclipse/pde/ui/launcher/EquinoxLaunchConfiguration.java --- src/org/eclipse/pde/ui/launcher/EquinoxLaunchConfiguration.java 16 Sep 2009 16:44:44 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * EclipseSource Corporation - ongoing enhancements - *******************************************************************************/ -package org.eclipse.pde.ui.launcher; - -import java.io.File; -import java.net.URL; -import java.util.*; -import org.eclipse.core.runtime.*; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.pde.core.plugin.*; -import org.eclipse.pde.internal.build.IPDEBuildConstants; -import org.eclipse.pde.internal.core.ClasspathHelper; -import org.eclipse.pde.internal.core.P2Utils; -import org.eclipse.pde.internal.core.util.CoreUtility; -import org.eclipse.pde.internal.launching.IPDEConstants; -import org.eclipse.pde.internal.launching.PDEMessages; -import org.eclipse.pde.internal.launching.launcher.*; - -/** - * A launch delegate for launching the Equinox framework - *- * Clients may subclass and instantiate this class. - *
- * @since 3.2 - */ -public class EquinoxLaunchConfiguration extends AbstractPDELaunchConfiguration { - - // used to generate the dev classpath entries - // key is bundle ID, value is a model - protected Map fAllBundles; - - // key is a model, value is startLevel:autoStart - private Map fModels; - - /* - * (non-Javadoc) - * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#getProgramArguments(org.eclipse.debug.core.ILaunchConfiguration) - */ - public String[] getProgramArguments(ILaunchConfiguration configuration) throws CoreException { - ArrayList programArgs = new ArrayList(); - - programArgs.add("-dev"); //$NON-NLS-1$ - programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", fAllBundles)); //$NON-NLS-1$ - - saveConfigurationFile(configuration); - programArgs.add("-configuration"); //$NON-NLS-1$ - programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$ - - String[] args = super.getProgramArguments(configuration); - for (int i = 0; i < args.length; i++) { - programArgs.add(args[i]); - } - return (String[]) programArgs.toArray(new String[programArgs.size()]); - } - - private void saveConfigurationFile(ILaunchConfiguration configuration) throws CoreException { - Properties properties = new Properties(); - properties.setProperty("osgi.install.area", "file:" + TargetPlatform.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$ - properties.setProperty("osgi.configuration.cascaded", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - properties.put("osgi.framework", LaunchConfigurationHelper.getBundleURL(IPDEBuildConstants.BUNDLE_OSGI, fAllBundles, false)); //$NON-NLS-1$ - int start = configuration.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4); - properties.put("osgi.bundles.defaultStartLevel", Integer.toString(start)); //$NON-NLS-1$ - boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, true); - - String bundles = null; - if (fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) { - // If simple configurator is being used, we need to write out the bundles.txt instead of writing out the list in the config.ini - URL bundlesTxt = P2Utils.writeBundlesTxt(fModels, start, autostart, getConfigDir(configuration), null); - if (bundlesTxt != null) { - properties.setProperty("org.eclipse.equinox.simpleconfigurator.configUrl", bundlesTxt.toString()); //$NON-NLS-1$ - if (fAllBundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) { - properties.setProperty("org.eclipse.update.reconcile", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - StringBuffer buffer = new StringBuffer(); - IPluginModelBase model = (IPluginModelBase) fAllBundles.get(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR); - buffer.append(LaunchConfigurationHelper.getBundleURL(model, true)); - appendStartData(buffer, (String) fModels.get(model), autostart); - bundles = buffer.toString(); - } else { - bundles = getBundles(autostart); - } - if (bundles.length() > 0) - properties.put("osgi.bundles", bundles); //$NON-NLS-1$ - - if (!"3.3".equals(configuration.getAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, ""))) { //$NON-NLS-1$ //$NON-NLS-2$ - properties.put("eclipse.ignoreApp", "true"); //$NON-NLS-1$ //$NON-NLS-2$ - properties.put("osgi.noShutdown", "true"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - LaunchConfigurationHelper.save(new File(getConfigDir(configuration), "config.ini"), properties); //$NON-NLS-1$ - } - - private String getBundles(boolean defaultAuto) { - StringBuffer buffer = new StringBuffer(); - Iterator iter = fModels.keySet().iterator(); - while (iter.hasNext()) { - IPluginModelBase model = (IPluginModelBase) iter.next(); - String id = model.getPluginBase().getId(); - if (!IPDEBuildConstants.BUNDLE_OSGI.equals(id)) { - if (buffer.length() > 0) - buffer.append(","); //$NON-NLS-1$ - buffer.append(LaunchConfigurationHelper.getBundleURL(model, true)); - - // fragments must not be started or have a start level - if (model instanceof IFragmentModel) - continue; - - String data = fModels.get(model).toString(); - appendStartData(buffer, data, defaultAuto); - } - } - return buffer.toString(); - } - - /** - * Convenience method to parses the startData ("startLevel:autoStart"), convert it to the - * format expected by the OSGi bundles property, and append to a StringBuffer. - * @param buffer buffer to append the data to - * @param startData data to parse ("startLevel:autoStart") - * @param defaultAuto default auto start setting - */ - private void appendStartData(StringBuffer buffer, String startData, boolean defaultAuto) { - int index = startData.indexOf(':'); - String level = index > 0 ? startData.substring(0, index) : "default"; //$NON-NLS-1$ - String auto = index > 0 && index < startData.length() - 1 ? startData.substring(index + 1) : "default"; //$NON-NLS-1$ - if ("default".equals(auto)) //$NON-NLS-1$ - auto = Boolean.toString(defaultAuto); - if (!level.equals("default") || "true".equals(auto)) //$NON-NLS-1$ //$NON-NLS-2$ - buffer.append("@"); //$NON-NLS-1$ - - if (!level.equals("default")) { //$NON-NLS-1$ - buffer.append(level); - if ("true".equals(auto)) //$NON-NLS-1$ - buffer.append(":"); //$NON-NLS-1$ - } - if ("true".equals(auto)) { //$NON-NLS-1$ - buffer.append("start"); //$NON-NLS-1$ - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException { - fModels = BundleLauncherHelper.getMergedBundleMap(configuration, true); - fAllBundles = new HashMap(fModels.size()); - Iterator iter = fModels.keySet().iterator(); - while (iter.hasNext()) { - IPluginModelBase model = (IPluginModelBase) iter.next(); - fAllBundles.put(model.getPluginBase().getId(), model); - } - - if (!fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_OSGI)) { - // implicitly add it - IPluginModelBase model = PluginRegistry.findModel(IPDEBuildConstants.BUNDLE_OSGI); - if (model != null) { - fModels.put(model, "default:default"); //$NON-NLS-1$ - fAllBundles.put(IPDEBuildConstants.BUNDLE_OSGI, model); - } else { - String message = PDEMessages.EquinoxLaunchConfiguration_oldTarget; - throw new CoreException(LauncherUtils.createErrorStatus(message)); - } - } - super.preLaunchCheck(configuration, launch, monitor); - } - - /* - * (non-Javadoc) - * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#validatePluginDependencies(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor) - */ - protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { - OSGiValidationOperation op = new OSGiValidationOperation(configuration); - LaunchPluginValidator.runValidationOperation(op, monitor); - } - - /** - * Clears the configuration area if the area exists and that option is selected. - * - * @param configuration - * the launch configuration - * @param monitor - * the progress monitor - * @throws CoreException - * if unable to retrieve launch attribute values - * @since 3.3 - */ - protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { - // clear config area, if necessary - if (configuration.getAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false)) - CoreUtility.deleteContent(getConfigDir(configuration)); - } - -} Index: src/org/eclipse/pde/ui/launcher/JUnitLaunchConfigurationDelegate.java =================================================================== RCS file: src/org/eclipse/pde/ui/launcher/JUnitLaunchConfigurationDelegate.java diff -N src/org/eclipse/pde/ui/launcher/JUnitLaunchConfigurationDelegate.java --- src/org/eclipse/pde/ui/launcher/JUnitLaunchConfigurationDelegate.java 16 Sep 2009 16:44:44 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,493 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * EclipseSource Corporation - ongoing enhancements - * David Saff- * Clients may subclass this class. - *
- * @since 3.3 - */ -public class PDESourcePathProvider extends StandardSourcePathProvider { - - public static final String ID = "org.eclipse.pde.ui.workbenchClasspathProvider"; //$NON-NLS-1$ - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.launching.StandardSourcePathProvider#computeUnresolvedClasspath(org.eclipse.debug.core.ILaunchConfiguration) - */ - public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException { - List sourcePath = new ArrayList(); - sourcePath.add(getJREEntry(configuration)); - IProject[] projects = getJavaProjects(configuration); - for (int i = 0; i < projects.length; i++) { - sourcePath.add(JavaRuntime.newProjectRuntimeClasspathEntry(JavaCore.create(projects[i]))); - } - return (IRuntimeClasspathEntry[]) sourcePath.toArray(new IRuntimeClasspathEntry[sourcePath.size()]); - } - - /** - * Returns a JRE runtime classpath entry - * - * @param configuration - * the launch configuration - * @return a JRE runtime classpath entry - * @throws CoreException - * if the JRE associated with the launch configuration cannot be found - * or if unable to retrieve the launch configuration attributes - */ - private IRuntimeClasspathEntry getJREEntry(ILaunchConfiguration configuration) throws CoreException { - IVMInstall jre = VMHelper.createLauncher(configuration); - IPath containerPath = new Path(JavaRuntime.JRE_CONTAINER); - containerPath = containerPath.append(jre.getVMInstallType().getId()); - containerPath = containerPath.append(jre.getName()); - return JavaRuntime.newRuntimeContainerClasspathEntry(containerPath, IRuntimeClasspathEntry.BOOTSTRAP_CLASSES); - } - - /** - * Returns an array of sorted plug-in projects that represent plug-ins participating - * in the launch - * - * @param configuration - * the launch configuration - * @return an array of ordered projects - * @throws CoreException - * if unable to retrieve attributes from the launch configuration or if - * an error occurs when checking the nature of the project - * - */ - private IProject[] getJavaProjects(ILaunchConfiguration configuration) throws CoreException { - IProject[] projects = LaunchPluginValidator.getAffectedProjects(configuration); - return PDELaunchingPlugin.getWorkspace().computeProjectOrder(projects).projects; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jdt.launching.StandardSourcePathProvider#resolveClasspath(org.eclipse.jdt.launching.IRuntimeClasspathEntry[], org.eclipse.debug.core.ILaunchConfiguration) - */ - public IRuntimeClasspathEntry[] resolveClasspath(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration) throws CoreException { - List all = new ArrayList(entries.length); - for (int i = 0; i < entries.length; i++) { - if (entries[i].getType() == IRuntimeClasspathEntry.PROJECT) { - // a project resolves to itself for source lookup (rather than - // the class file output locations) - all.add(entries[i]); - // also add non-JRE libraries - IResource resource = entries[i].getResource(); - if (resource instanceof IProject) { - addBinaryPackageFragmentRoots(JavaCore.create((IProject) resource), all); - } - } else { - IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveRuntimeClasspathEntry(entries[i], configuration); - for (int j = 0; j < resolved.length; j++) { - all.add(resolved[j]); - } - } - } - return (IRuntimeClasspathEntry[]) all.toArray(new IRuntimeClasspathEntry[all.size()]); - } - - /** - * Adds runtime classpath entries for binary package fragment roots contained within - * the project - * - * @param jProject - * the Java project whose roots are to be enumerated - * @param all - * a list of accumulated runtime classpath entries - * @throws CoreException - * if unable to evaluate the package fragment roots - */ - private void addBinaryPackageFragmentRoots(IJavaProject jProject, List all) throws CoreException { - IPackageFragmentRoot[] roots = jProject.getPackageFragmentRoots(); - for (int j = 0; j < roots.length; j++) { - if (roots[j].getKind() == IPackageFragmentRoot.K_BINARY && !PDEJavaHelper.isJRELibrary(roots[j])) { - IRuntimeClasspathEntry rte = JavaRuntime.newArchiveRuntimeClasspathEntry(roots[j].getPath()); - IPath path = roots[j].getSourceAttachmentPath(); - if (path != null) { - rte.setSourceAttachmentPath(path); - rte.setSourceAttachmentRootPath(roots[j].getSourceAttachmentRootPath()); - } - if (!all.contains(rte)) - all.add(rte); - } - } - - } -} \ No newline at end of file Index: src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfiguration.java =================================================================== RCS file: src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfiguration.java diff -N src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfiguration.java --- src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfiguration.java 16 Sep 2009 16:44:44 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,418 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.ui.launcher; - -import java.io.File; -import java.util.ArrayList; -import java.util.Map; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.*; -import org.eclipse.debug.core.*; -import org.eclipse.debug.core.model.LaunchConfigurationDelegate; -import org.eclipse.jdt.core.IJavaModelMarker; -import org.eclipse.jdt.launching.*; -import org.eclipse.pde.core.plugin.TargetPlatform; -import org.eclipse.pde.internal.core.TargetPlatformHelper; -import org.eclipse.pde.internal.core.builders.PDEMarkerFactory; -import org.eclipse.pde.internal.launching.*; -import org.eclipse.pde.internal.launching.launcher.*; - -/** - * An abstract launch delegate for PDE-based launch configurations - *- * Clients may subclass this class. - *
- * @since 3.2 - */ -public abstract class AbstractPDELaunchConfiguration extends LaunchConfigurationDelegate { - - protected File fConfigDir = null; - - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#isLaunchProblem(org.eclipse.core.resources.IMarker) - */ - protected boolean isLaunchProblem(IMarker problemMarker) throws CoreException { - return super.isLaunchProblem(problemMarker) && (problemMarker.getType().equals(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER) || problemMarker.getType().equals(PDEMarkerFactory.MARKER_ID)); - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) - */ - public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { - try { - fConfigDir = null; - monitor.beginTask("", 4); //$NON-NLS-1$ - try { - preLaunchCheck(configuration, launch, new SubProgressMonitor(monitor, 2)); - } catch (CoreException e) { - if (e.getStatus().getSeverity() == IStatus.CANCEL) { - monitor.setCanceled(true); - return; - } - throw e; - } - // if restarting, remove the restart flag from the launch config - if (configuration.getAttribute(IPDEConstants.RESTART, false) && configuration instanceof ILaunchConfigurationWorkingCopy) { - ((ILaunchConfigurationWorkingCopy) configuration).setAttribute(IPDEConstants.RESTART, false); - ((ILaunchConfigurationWorkingCopy) configuration).doSave(); - } - VMRunnerConfiguration runnerConfig = new VMRunnerConfiguration(getMainClass(), getClasspath(configuration)); - runnerConfig.setVMArguments(getVMArguments(configuration)); - runnerConfig.setProgramArguments(getProgramArguments(configuration)); - runnerConfig.setWorkingDirectory(getWorkingDirectory(configuration).getAbsolutePath()); - runnerConfig.setEnvironment(getEnvironment(configuration)); - runnerConfig.setVMSpecificAttributesMap(getVMSpecificAttributesMap(configuration)); - - monitor.worked(1); - - setDefaultSourceLocator(configuration); - manageLaunch(launch); - IVMRunner runner = getVMRunner(configuration, mode); - if (runner != null) - runner.run(runnerConfig, launch, monitor); - else - monitor.setCanceled(true); - monitor.done(); - } catch (final CoreException e) { - monitor.setCanceled(true); - throw e; - } - } - - /** - * Returns the VM runner for the given launch mode to use when launching the - * given configuration. - * - * @param configuration launch configuration - * @param mode launch node - * @return VM runner to use when launching the given configuration in the given mode - * @throws CoreException if a VM runner cannot be determined - */ - public IVMRunner getVMRunner(ILaunchConfiguration configuration, String mode) throws CoreException { - IVMInstall launcher = VMHelper.createLauncher(configuration); - return launcher.getVMRunner(mode); - } - - /** - * Assigns a default source locator to the given launch if a source locator - * has not yet been assigned to it, and the associated launch configuration - * does not specify a source locator. - * - * @param configuration - * configuration being launched - * @exception CoreException - * if unable to set the source locator - */ - protected void setDefaultSourceLocator(ILaunchConfiguration configuration) throws CoreException { - ILaunchConfigurationWorkingCopy wc = null; - if (configuration.isWorkingCopy()) { - wc = (ILaunchConfigurationWorkingCopy) configuration; - } else { - wc = configuration.getWorkingCopy(); - } - String id = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, (String) null); - if (!PDESourcePathProvider.ID.equals(id)) { - wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, PDESourcePathProvider.ID); - wc.doSave(); - } - } - - /** - * Returns the entries that should appear on boot classpath. - * - * @param configuration - * launch configuration - * @return the location of startup.jar and - * the bootstrap classpath specified by the given launch configuration - * - * @exception CoreException - * if unable to find startup.jar - */ - public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException { - String[] classpath = LaunchArgumentsHelper.constructClasspath(configuration); - if (classpath == null) { - String message = PDEMessages.WorkbenchLauncherConfigurationDelegate_noStartup; - throw new CoreException(LauncherUtils.createErrorStatus(message)); - } - return classpath; - } - - /** - * Returns an array of environment variables to be used when - * launching the given configuration ornull
if unspecified.
- *
- * @param configuration launch configuration
- * @throws CoreException if unable to access associated attribute or if
- * unable to resolve a variable in an environment variable's value
- */
- public String[] getEnvironment(ILaunchConfiguration configuration) throws CoreException {
- return DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
- }
-
- /**
- * Returns the working directory path specified by the given launch
- * configuration, or null
if none.
- *
- * @param configuration
- * launch configuration
- * @return the working directory path specified by the given launch
- * configuration, or null
if none
- * @exception CoreException
- * if unable to retrieve the attribute
- */
- public File getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
- return LaunchArgumentsHelper.getWorkingDirectory(configuration);
- }
-
- /**
- * Returns the Map of VM-specific attributes specified by the given launch
- * configuration, or null
if none.
- *
- * @param configuration
- * launch configuration
- * @return the Map
of VM-specific attributes
- * @exception CoreException
- * if unable to retrieve the attribute
- */
- public Map getVMSpecificAttributesMap(ILaunchConfiguration configuration) throws CoreException {
- return LaunchArgumentsHelper.getVMSpecificAttributesMap(configuration);
- }
-
- /**
- * Returns the VM arguments specified by the given launch configuration, as
- * an array of strings.
- *
- * @param configuration
- * launch configuration
- * @return the VM arguments specified by the given launch configuration,
- * possibly an empty array
- * @exception CoreException
- * if unable to retrieve the attribute
- */
- public String[] getVMArguments(ILaunchConfiguration configuration) throws CoreException {
- String[] vmArgs = new ExecutionArguments(LaunchArgumentsHelper.getUserVMArguments(configuration), "").getVMArgumentsArray(); //$NON-NLS-1$
- // For p2 target, add "-Declipse.p2.data.area=@config.dir/p2" unless already specified by user
- Map bundleMap = BundleLauncherHelper.getMergedBundleMap(configuration, false);
- if (bundleMap.containsKey("org.eclipse.equinox.p2.core")) { //$NON-NLS-1$
- for (int i = 0; i < vmArgs.length; i++) {
- String arg = vmArgs[i];
- if (arg.startsWith("-Declipse.p2.data.area=")) { //$NON-NLS-1$
- return vmArgs;
- }
- }
- String[] temp = new String[vmArgs.length + 1];
- System.arraycopy(vmArgs, 0, temp, 0, vmArgs.length);
- temp[vmArgs.length] = "-Declipse.p2.data.area=@config.dir" + File.separator + "p2"; //$NON-NLS-1$ //$NON-NLS-2$
- return temp;
- }
- return vmArgs;
- }
-
- /**
- * Returns the program arguments to launch with.
- * This list is a combination of arguments computed by PDE based on attributes
- * specified in the given launch configuration, followed by the program arguments
- * that the entered directly into the launch configuration.
- *
- * @param configuration
- * launch configuration
- * @return the program arguments necessary for launching
- *
- * @exception CoreException
- * if unable to retrieve the attribute or create the
- * necessary configuration files
- */
- public String[] getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
- ArrayList programArgs = new ArrayList();
-
- // add tracing, if turned on
- if (configuration.getAttribute(IPDELauncherConstants.TRACING, false) && !IPDELauncherConstants.TRACING_NONE.equals(configuration.getAttribute(IPDELauncherConstants.TRACING_CHECKED, (String) null))) {
- programArgs.add("-debug"); //$NON-NLS-1$
- programArgs.add(LaunchArgumentsHelper.getTracingFileArgument(configuration, getConfigDir(configuration).toString() + IPath.SEPARATOR + ".options")); //$NON-NLS-1$
- }
-
- // add the program args specified by the user
- String[] userArgs = LaunchArgumentsHelper.getUserProgramArgumentArray(configuration);
- ArrayList userDefined = new ArrayList();
- for (int i = 0; i < userArgs.length; i++) {
- // be forgiving if people have tracing turned on and forgot
- // to remove the -debug from the program args field.
- if (userArgs[i].equals("-debug") && programArgs.contains("-debug")) //$NON-NLS-1$ //$NON-NLS-2$
- continue;
- userDefined.add(userArgs[i]);
- }
-
- if (!configuration.getAttribute(IPDEConstants.APPEND_ARGS_EXPLICITLY, false)) {
-
- if (!userDefined.contains("-os")) { //$NON-NLS-1$
- programArgs.add("-os"); //$NON-NLS-1$
- programArgs.add(TargetPlatform.getOS());
- }
- if (!userDefined.contains("-ws")) { //$NON-NLS-1$
- programArgs.add("-ws"); //$NON-NLS-1$
- programArgs.add(TargetPlatform.getWS());
- }
- if (!userDefined.contains("-arch")) { //$NON-NLS-1$
- programArgs.add("-arch"); //$NON-NLS-1$
- programArgs.add(TargetPlatform.getOSArch());
- }
- }
-
- if (userDefined.size() > 0) {
- programArgs.addAll(userDefined);
- }
-
- return (String[]) programArgs.toArray(new String[programArgs.size()]);
- }
-
- /**
- * Does sanity checking before launching. The criteria whether the launch should
- * proceed or not is specific to the launch configuration type.
- *
- * @param configuration launch configuration
- * @param launch the launch object to contribute processes and debug targets to
- * @param monitor a progress monitor
- *
- * @throws CoreException exception thrown if launch fails or canceled or if unable to retrieve attributes
- * from the launch configuration
- *
- */
- protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
- boolean autoValidate = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, false);
- monitor.beginTask("", autoValidate ? 3 : 4); //$NON-NLS-1$
- if (autoValidate)
- validatePluginDependencies(configuration, new SubProgressMonitor(monitor, 1));
- validateProjectDependencies(configuration, new SubProgressMonitor(monitor, 1));
- clear(configuration, new SubProgressMonitor(monitor, 1));
- launch.setAttribute(IPDELauncherConstants.CONFIG_LOCATION, getConfigDir(configuration).toString());
- synchronizeManifests(configuration, new SubProgressMonitor(monitor, 1));
- }
-
- /**
- * Returns the configuration area specified by the given launch
- * configuration.
- *
- * @param configuration
- * launch configuration
- * @return the directory path specified by the given launch
- * configuration
- */
- protected File getConfigDir(ILaunchConfiguration configuration) {
- if (fConfigDir == null)
- fConfigDir = LaunchConfigurationHelper.getConfigurationArea(configuration);
- return fConfigDir;
- }
-
- /*
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
- */
- protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
- return computeBuildOrder(LaunchPluginValidator.getAffectedProjects(configuration));
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getProjectsForProblemSearch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
- */
- protected IProject[] getProjectsForProblemSearch(ILaunchConfiguration configuration, String mode) throws CoreException {
- return LaunchPluginValidator.getAffectedProjects(configuration);
- }
-
- /**
- * Returns the fully-qualified name of the class to launch.
- *
- * @return the fully-qualified name of the class to launch. Must not return null
.
- * @since 3.3
- */
- public String getMainClass() {
- if (TargetPlatformHelper.getTargetVersion() >= 3.3)
- return "org.eclipse.equinox.launcher.Main"; //$NON-NLS-1$
- return "org.eclipse.core.launcher.Main"; //$NON-NLS-1$
- }
-
- /**
- * Adds a listener to the launch to be notified at interesting launch lifecycle
- * events such as when the launch terminates.
- *
- * @param launch
- * the launch
- *
- * @since 3.3
- */
- protected void manageLaunch(ILaunch launch) {
- PDELaunchingPlugin.getDefault().getLaunchListener().manage(launch);
- }
-
- /**
- * Checks for old-style plugin.xml files that have become stale since the last launch.
- * For any stale plugin.xml files found, the corresponding MANIFEST.MF is deleted
- * from the runtime configuration area so that it gets regenerated upon startup.
- *
- * @param configuration
- * the launch configuration
- * @param monitor
- * a progress monitor
- *
- * @since 3.3
- */
- protected void synchronizeManifests(ILaunchConfiguration configuration, IProgressMonitor monitor) {
- LaunchConfigurationHelper.synchronizeManifests(configuration, getConfigDir(configuration));
- monitor.done();
- }
-
- /**
- * Checks if the Automated Management of Dependencies option is turned on.
- * If so, it makes aure all manifests are updated with the correct dependencies.
- *
- * @param configuration
- * the launch configuration
- * @param monitor
- * a progress monitor
- *
- * @since 3.3
- */
- protected void validateProjectDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) {
- LauncherUtils.validateProjectDependencies(configuration, monitor);
- }
-
- /**
- * By default, this method does nothing. Clients should override, if appropriate.
- *
- * @param configuration
- * the launch configuration
- * @param monitor
- * the progress monitor
- * @throws CoreException
- * if unable to retrieve launch attribute values
- * @since 3.3
- */
- protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
- }
-
- /**
- * Validates inter-bundle dependencies automatically prior to launching
- * if that option is turned on.
- *
- * @param configuration
- * the launch configuration
- * @param monitor
- * a progress monitor
- * @since 3.3
- */
- protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
- EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration);
- LaunchPluginValidator.runValidationOperation(op, monitor);
- }
-
-}
Index: src/org/eclipse/pde/ui/launcher/IPDELauncherConstants.java
===================================================================
RCS file: src/org/eclipse/pde/ui/launcher/IPDELauncherConstants.java
diff -N src/org/eclipse/pde/ui/launcher/IPDELauncherConstants.java
--- src/org/eclipse/pde/ui/launcher/IPDELauncherConstants.java 16 Sep 2009 16:44:44 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,406 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.ui.launcher;
-
-/**
- * Constant definitions for PDE launch configurations.
- * - * Constant definitions only; not to be implemented. - *
- * @since 3.2 - * - * @noimplement This interface is not intended to be implemented by clients. - * @noextend This interface is not intended to be extended by clients. - */ -public interface IPDELauncherConstants { - - /** - * Launch configuration attribute key. The value is a string specifying - * workspace data location for an Eclipse application. - */ - String LOCATION = "location"; //$NON-NLS-1$ - - /** - * Launch configuration attribute key. The value is a boolean specifying - * workspace data location for an Eclipse application should be cleared - * prior to launching. - */ - String DOCLEAR = "clearws"; //$NON-NLS-1$ - - /** - * Launch configuration attribute key. The value is a boolean specifying - * whether the user should be prompted prior to clearing the workspace. - * - * @see IPDELauncherConstants#DOCLEAR - */ - String ASKCLEAR = "askclear"; //$NON-NLS-1$ - - /** - * Launch configuration attribute key. The value is a string specifying - * the application to run. If the value isnull
, the default
- * application as specified in the target platform will be used.
- */
- String APPLICATION = "application"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * the product to run.
- *
- * @see IPDELauncherConstants#APPLICATION
- */
- String PRODUCT = "product"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * if the launch should appear in product-mode. If the value is false
,
- * the launch takes place in application-mode.
- *
- * @see IPDELauncherConstants#PRODUCT
- * @see IPDELauncherConstants#APPLICATION
- */
- String USE_PRODUCT = "useProduct"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key used in Plug-in JUnit launch configurations only.
- * The value is a string specifying the application to be tested.
- * If the value is null
, the default UI workbench application is tested.
- */
- String APP_TO_TEST = "testApplication"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * the name of the VM to launch with. If the value is null
,
- * the default workspace VM is used.
- *
- * @deprecated use IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH
- */
- String VMINSTALL = "vminstall"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * the user-entered bootstrap classpath entries.
- */
- String BOOTSTRAP_ENTRIES = "bootstrap"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * if the default self-hosting mode should be used when launching.
- * The default being to launch with all workspace plug-ins and all the
- * plug-ins that are explicitly checked on the Target Platform preference page.
- */
- String USE_DEFAULT = "default"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * if the feature-based self-hosting mode should be used.
- * The workspace must be set up properly for the feature-based self-hosting
- * to succeed.
- * Check the PDE Tips and Tricks section for how to set up feature-based self-hosting.
- */
- String USEFEATURES = "usefeatures"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * a comma-separated list of IDs of workspace plug-ins to launch with.
- * This value is only used when the Automatic Add option is off.
- *
- * @see IPDELauncherConstants#AUTOMATIC_ADD
- */
- String SELECTED_WORKSPACE_PLUGINS = "selected_workspace_plugins"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * a comma-separated list of IDs of workspace plug-ins that are to be excluded from
- * the launch.
- * This value is only used when the Automatic Add option is on.
- *
- * @see IPDELauncherConstants#AUTOMATIC_ADD
- */
- String DESELECTED_WORKSPACE_PLUGINS = "deselected_workspace_plugins"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * whether workspace plug-in created after the creation of a launch configuration
- * should be added to the list of plug-ins to launch with.
- *
- * If the value is true
, then DESELECTED_WORKSPACE_PLUGINS should be used.
- * Otherwise, SELECTED_WORKSPACE_PLUGINS should be used.
- *
- * @see IPDELauncherConstants#DESELECTED_WORKSPACE_PLUGINS
- * @see IPDELauncherConstants#SELECTED_WORKSPACE_PLUGINS
- */
- String AUTOMATIC_ADD = "automaticAdd"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * whether the list of plug-ins to run should be validate prior to launching.
- * If problems are found, they will be reported and the user will be able to cancel or
- * continue.
- * If no problems are found, the launch continues as normal.
- */
- String AUTOMATIC_VALIDATE = "automaticValidate"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * a comma-separated list of IDs of target platform plug-ins to launch with.
- * This value is only used when the Automatic Add option is off.
- */
- String SELECTED_TARGET_PLUGINS = "selected_target_plugins"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean indicating
- * whether the computation of required plug-ins on the Plug-ins tab should include
- * the traversal of optional dependencies.
- */
- String INCLUDE_OPTIONAL = "includeOptional"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean indicating
- * whether tracing is enabled or disabled.
- */
- String TRACING = "tracing"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a map containing the list
- * of options to debug with.
- */
- String TRACING_OPTIONS = "tracingOptions"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is the id of the last plug-in
- * that was selected on the Tracing tab.
- */
- String TRACING_SELECTED_PLUGIN = "selectedPlugin"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is the IDs of all plug-ins
- * checked on the Tracing tab. The value may also be "[NONE]"
- *
- * @see IPDELauncherConstants#TRACING_NONE
- */
- String TRACING_CHECKED = "checked"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute value indicating that, although tracing is enabled,
- * no plug-ins have been selected to be traced.
- */
- String TRACING_NONE = "[NONE]"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * if PDE should generate a default configuration area for the launch.
- *
- * If true
, a configuration location in the PDE metadata area
- * is created. Otherwise, the user is expected to specify a location.
- *
- * @see IPDELauncherConstants#CONFIG_LOCATION
- */
- String CONFIG_USE_DEFAULT_AREA = "useDefaultConfigArea"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * the configuration area location for an Eclipse application launch.
- *
- * This key is only used when CONFIG_USE_DEFAULT_AREA is false
.
- *
- * @see IPDELauncherConstants#CONFIG_USE_DEFAULT_AREA
- */
- String CONFIG_LOCATION = "configLocation"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * if the configuration area location should be cleared prior to launching
- */
- String CONFIG_CLEAR_AREA = "clearConfig"; //$NON-NLS-1$
-
- /**
- * Launch configuration atribute key. The value is a boolean specifying
- * if PDE should generate a default config.ini file for the launch.
- *
- * If true
, a configuration file is created.
- * Otherwise, the user is expected to specify a config.ini to be used as a template.
- *
- * @see IPDELauncherConstants#CONFIG_TEMPLATE_LOCATION
- */
- String CONFIG_GENERATE_DEFAULT = "useDefaultConfig"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * the location of the config.ini file to be used as a template for an
- * Eclipse application launch.
- *
- * This key is only used when CONFIG_GENERATE_DEFAULT is false
.
- *
- * @see IPDELauncherConstants#CONFIG_GENERATE_DEFAULT
- */
- String CONFIG_TEMPLATE_LOCATION = "templateConfig"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a string specifying
- * the location of the .product file with which this launch configuration
- * is associated.
- */
- String PRODUCT_FILE = "productFile"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is the ID of an OSGi framework
- * declared in an org.eclipse.pde.ui.osgiLaunchers
extension point.
- *
- * @since 3.3
- */
- String OSGI_FRAMEWORK_ID = "osgi_framework_id"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a boolean specifying
- * if the default Auto-Start for an OSGi Framework launch configuration
- * is true
or false
- *
- * @see IPDELauncherConstants#DEFAULT_START_LEVEL
- */
- String DEFAULT_AUTO_START = "default_auto_start"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is an integer specifying
- * the default start level for bundles in an OSGi Framework launch configuration.
- *
- * @see IPDELauncherConstants#DEFAULT_AUTO_START
- */
- String DEFAULT_START_LEVEL = "default_start_level"; //$NON-NLS-1$
-
- /**
- * Launch configuration attribute key. The value is a comma-separated list
- * of workspace bundles to launch with the OSGi framework.
- *
- * Each token in the list is of the format:
- * true
- *
- * @since 3.5
- */
- String RUN_IN_UI_THREAD = "run_in_ui_thread"; //$NON-NLS-1$
-
- /**
- * The launch configuration type for Eclipse application launches.
- *
- * @since 3.6
- * @see EclipseLaunchShortcut
- */
- String ECLIPSE_APPLICATION_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.pde.ui.RuntimeWorkbench"; //$NON-NLS-1$
-}
Index: src/org/eclipse/pde/ui/launcher/OSGiLaunchConfigurationDelegate.java
===================================================================
RCS file: src/org/eclipse/pde/ui/launcher/OSGiLaunchConfigurationDelegate.java
diff -N src/org/eclipse/pde/ui/launcher/OSGiLaunchConfigurationDelegate.java
--- src/org/eclipse/pde/ui/launcher/OSGiLaunchConfigurationDelegate.java 16 Sep 2009 16:44:44 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.ui.launcher;
-
-import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
-
-
-import org.eclipse.pde.internal.launching.IPDEConstants;
-import org.eclipse.pde.internal.launching.PDEMessages;
-import org.eclipse.pde.internal.launching.launcher.LaunchPluginValidator;
-import org.eclipse.pde.internal.launching.launcher.OSGiFrameworkManager;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.*;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * A launch delegate for launching OSGi frameworks
- * - * Clients may subclass and instantiate this class. - *
- * @since 3.3 - */ -public class OSGiLaunchConfigurationDelegate extends LaunchConfigurationDelegate { - - /** - * Delegates to the launcher delegate associated with the OSGi framework - * selected in the launch configuration. - * - * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) - */ - public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { - OSGiFrameworkManager manager = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager(); - String id = configuration.getAttribute(IPDELauncherConstants.OSGI_FRAMEWORK_ID, manager.getDefaultFramework()); - LaunchConfigurationDelegate launcher = manager.getFrameworkLauncher(id); - if (launcher != null) { - launcher.launch(configuration, mode, launch, monitor); - } else { - String name = manager.getFrameworkName(id); - if (name == null) - name = PDEMessages.OSGiLaunchConfiguration_selected; - String message = NLS.bind(PDEMessages.OSGiLaunchConfiguration_cannotFindLaunchConfiguration, name); - IStatus status = new Status(IStatus.ERROR, IPDEConstants.PLUGIN_ID, IStatus.OK, message, null); - throw new CoreException(status); - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String) - */ - protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException { - return computeBuildOrder(LaunchPluginValidator.getAffectedProjects(configuration)); - } - -} Index: plugin.xml =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.launching/plugin.xml,v retrieving revision 1.1 diff -u -r1.1 plugin.xml --- plugin.xml 16 Sep 2009 16:44:45 -0000 1.1 +++ plugin.xml 21 Sep 2009 18:33:55 -0000 @@ -13,7 +13,7 @@+ * Clients may subclass and instantiate this class. + *
+ * @since 3.2 + */ +public class EquinoxLaunchConfiguration extends AbstractPDELaunchConfiguration { + + // used to generate the dev classpath entries + // key is bundle ID, value is a model + protected Map fAllBundles; + + // key is a model, value is startLevel:autoStart + private Map fModels; + + /* + * (non-Javadoc) + * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#getProgramArguments(org.eclipse.debug.core.ILaunchConfiguration) + */ + public String[] getProgramArguments(ILaunchConfiguration configuration) throws CoreException { + ArrayList programArgs = new ArrayList(); + + programArgs.add("-dev"); //$NON-NLS-1$ + programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", fAllBundles)); //$NON-NLS-1$ + + saveConfigurationFile(configuration); + programArgs.add("-configuration"); //$NON-NLS-1$ + programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$ + + String[] args = super.getProgramArguments(configuration); + for (int i = 0; i < args.length; i++) { + programArgs.add(args[i]); + } + return (String[]) programArgs.toArray(new String[programArgs.size()]); + } + + private void saveConfigurationFile(ILaunchConfiguration configuration) throws CoreException { + Properties properties = new Properties(); + properties.setProperty("osgi.install.area", "file:" + TargetPlatform.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$ + properties.setProperty("osgi.configuration.cascaded", "false"); //$NON-NLS-1$ //$NON-NLS-2$ + properties.put("osgi.framework", LaunchConfigurationHelper.getBundleURL(IPDEBuildConstants.BUNDLE_OSGI, fAllBundles, false)); //$NON-NLS-1$ + int start = configuration.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4); + properties.put("osgi.bundles.defaultStartLevel", Integer.toString(start)); //$NON-NLS-1$ + boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, true); + + String bundles = null; + if (fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) { + // If simple configurator is being used, we need to write out the bundles.txt instead of writing out the list in the config.ini + URL bundlesTxt = P2Utils.writeBundlesTxt(fModels, start, autostart, getConfigDir(configuration), null); + if (bundlesTxt != null) { + properties.setProperty("org.eclipse.equinox.simpleconfigurator.configUrl", bundlesTxt.toString()); //$NON-NLS-1$ + if (fAllBundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) { + properties.setProperty("org.eclipse.update.reconcile", "false"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + StringBuffer buffer = new StringBuffer(); + IPluginModelBase model = (IPluginModelBase) fAllBundles.get(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR); + buffer.append(LaunchConfigurationHelper.getBundleURL(model, true)); + appendStartData(buffer, (String) fModels.get(model), autostart); + bundles = buffer.toString(); + } else { + bundles = getBundles(autostart); + } + if (bundles.length() > 0) + properties.put("osgi.bundles", bundles); //$NON-NLS-1$ + + if (!"3.3".equals(configuration.getAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, ""))) { //$NON-NLS-1$ //$NON-NLS-2$ + properties.put("eclipse.ignoreApp", "true"); //$NON-NLS-1$ //$NON-NLS-2$ + properties.put("osgi.noShutdown", "true"); //$NON-NLS-1$ //$NON-NLS-2$ + } + + LaunchConfigurationHelper.save(new File(getConfigDir(configuration), "config.ini"), properties); //$NON-NLS-1$ + } + + private String getBundles(boolean defaultAuto) { + StringBuffer buffer = new StringBuffer(); + Iterator iter = fModels.keySet().iterator(); + while (iter.hasNext()) { + IPluginModelBase model = (IPluginModelBase) iter.next(); + String id = model.getPluginBase().getId(); + if (!IPDEBuildConstants.BUNDLE_OSGI.equals(id)) { + if (buffer.length() > 0) + buffer.append(","); //$NON-NLS-1$ + buffer.append(LaunchConfigurationHelper.getBundleURL(model, true)); + + // fragments must not be started or have a start level + if (model instanceof IFragmentModel) + continue; + + String data = fModels.get(model).toString(); + appendStartData(buffer, data, defaultAuto); + } + } + return buffer.toString(); + } + + /** + * Convenience method to parses the startData ("startLevel:autoStart"), convert it to the + * format expected by the OSGi bundles property, and append to a StringBuffer. + * @param buffer buffer to append the data to + * @param startData data to parse ("startLevel:autoStart") + * @param defaultAuto default auto start setting + */ + private void appendStartData(StringBuffer buffer, String startData, boolean defaultAuto) { + int index = startData.indexOf(':'); + String level = index > 0 ? startData.substring(0, index) : "default"; //$NON-NLS-1$ + String auto = index > 0 && index < startData.length() - 1 ? startData.substring(index + 1) : "default"; //$NON-NLS-1$ + if ("default".equals(auto)) //$NON-NLS-1$ + auto = Boolean.toString(defaultAuto); + if (!level.equals("default") || "true".equals(auto)) //$NON-NLS-1$ //$NON-NLS-2$ + buffer.append("@"); //$NON-NLS-1$ + + if (!level.equals("default")) { //$NON-NLS-1$ + buffer.append(level); + if ("true".equals(auto)) //$NON-NLS-1$ + buffer.append(":"); //$NON-NLS-1$ + } + if ("true".equals(auto)) { //$NON-NLS-1$ + buffer.append("start"); //$NON-NLS-1$ + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) + */ + protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException { + fModels = BundleLauncherHelper.getMergedBundleMap(configuration, true); + fAllBundles = new HashMap(fModels.size()); + Iterator iter = fModels.keySet().iterator(); + while (iter.hasNext()) { + IPluginModelBase model = (IPluginModelBase) iter.next(); + fAllBundles.put(model.getPluginBase().getId(), model); + } + + if (!fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_OSGI)) { + // implicitly add it + IPluginModelBase model = PluginRegistry.findModel(IPDEBuildConstants.BUNDLE_OSGI); + if (model != null) { + fModels.put(model, "default:default"); //$NON-NLS-1$ + fAllBundles.put(IPDEBuildConstants.BUNDLE_OSGI, model); + } else { + String message = PDEMessages.EquinoxLaunchConfiguration_oldTarget; + throw new CoreException(LauncherUtils.createErrorStatus(message)); + } + } + super.preLaunchCheck(configuration, launch, monitor); + } + + /* + * (non-Javadoc) + * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#validatePluginDependencies(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor) + */ + protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { + OSGiValidationOperation op = new OSGiValidationOperation(configuration); + LaunchPluginValidator.runValidationOperation(op, monitor); + } + + /** + * Clears the configuration area if the area exists and that option is selected. + * + * @param configuration + * the launch configuration + * @param monitor + * the progress monitor + * @throws CoreException + * if unable to retrieve launch attribute values + * @since 3.3 + */ + protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { + // clear config area, if necessary + if (configuration.getAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false)) + CoreUtility.deleteContent(getConfigDir(configuration)); + } + +} Index: src/org/eclipse/pde/launching/OSGiLaunchConfigurationDelegate.java =================================================================== RCS file: src/org/eclipse/pde/launching/OSGiLaunchConfigurationDelegate.java diff -N src/org/eclipse/pde/launching/OSGiLaunchConfigurationDelegate.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/launching/OSGiLaunchConfigurationDelegate.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2006, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.launching; + +import org.eclipse.pde.internal.launching.PDELaunchingPlugin; + + +import org.eclipse.pde.internal.launching.IPDEConstants; +import org.eclipse.pde.internal.launching.PDEMessages; +import org.eclipse.pde.internal.launching.launcher.LaunchPluginValidator; +import org.eclipse.pde.internal.launching.launcher.OSGiFrameworkManager; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.*; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.model.LaunchConfigurationDelegate; +import org.eclipse.osgi.util.NLS; + +/** + * A launch delegate for launching OSGi frameworks + *+ * Clients may subclass and instantiate this class. + *
+ * @since 3.3 + */ +public class OSGiLaunchConfigurationDelegate extends LaunchConfigurationDelegate { + + /** + * Delegates to the launcher delegate associated with the OSGi framework + * selected in the launch configuration. + * + * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) + */ + public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { + OSGiFrameworkManager manager = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager(); + String id = configuration.getAttribute(IPDELauncherConstants.OSGI_FRAMEWORK_ID, manager.getDefaultFramework()); + LaunchConfigurationDelegate launcher = manager.getFrameworkLauncher(id); + if (launcher != null) { + launcher.launch(configuration, mode, launch, monitor); + } else { + String name = manager.getFrameworkName(id); + if (name == null) + name = PDEMessages.OSGiLaunchConfiguration_selected; + String message = NLS.bind(PDEMessages.OSGiLaunchConfiguration_cannotFindLaunchConfiguration, name); + IStatus status = new Status(IStatus.ERROR, IPDEConstants.PLUGIN_ID, IStatus.OK, message, null); + throw new CoreException(status); + } + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String) + */ + protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException { + return computeBuildOrder(LaunchPluginValidator.getAffectedProjects(configuration)); + } + +} Index: src/org/eclipse/pde/launching/AbstractPDELaunchConfiguration.java =================================================================== RCS file: src/org/eclipse/pde/launching/AbstractPDELaunchConfiguration.java diff -N src/org/eclipse/pde/launching/AbstractPDELaunchConfiguration.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/launching/AbstractPDELaunchConfiguration.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,418 @@ +/******************************************************************************* + * Copyright (c) 2005, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.launching; + +import java.io.File; +import java.util.ArrayList; +import java.util.Map; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.*; +import org.eclipse.debug.core.*; +import org.eclipse.debug.core.model.LaunchConfigurationDelegate; +import org.eclipse.jdt.core.IJavaModelMarker; +import org.eclipse.jdt.launching.*; +import org.eclipse.pde.core.plugin.TargetPlatform; +import org.eclipse.pde.internal.core.TargetPlatformHelper; +import org.eclipse.pde.internal.core.builders.PDEMarkerFactory; +import org.eclipse.pde.internal.launching.*; +import org.eclipse.pde.internal.launching.launcher.*; + +/** + * An abstract launch delegate for PDE-based launch configurations + *+ * Clients may subclass this class. + *
+ * @since 3.2 + */ +public abstract class AbstractPDELaunchConfiguration extends LaunchConfigurationDelegate { + + protected File fConfigDir = null; + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#isLaunchProblem(org.eclipse.core.resources.IMarker) + */ + protected boolean isLaunchProblem(IMarker problemMarker) throws CoreException { + return super.isLaunchProblem(problemMarker) && (problemMarker.getType().equals(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER) || problemMarker.getType().equals(PDEMarkerFactory.MARKER_ID)); + } + + /* + * (non-Javadoc) + * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) + */ + public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { + try { + fConfigDir = null; + monitor.beginTask("", 4); //$NON-NLS-1$ + try { + preLaunchCheck(configuration, launch, new SubProgressMonitor(monitor, 2)); + } catch (CoreException e) { + if (e.getStatus().getSeverity() == IStatus.CANCEL) { + monitor.setCanceled(true); + return; + } + throw e; + } + // if restarting, remove the restart flag from the launch config + if (configuration.getAttribute(IPDEConstants.RESTART, false) && configuration instanceof ILaunchConfigurationWorkingCopy) { + ((ILaunchConfigurationWorkingCopy) configuration).setAttribute(IPDEConstants.RESTART, false); + ((ILaunchConfigurationWorkingCopy) configuration).doSave(); + } + VMRunnerConfiguration runnerConfig = new VMRunnerConfiguration(getMainClass(), getClasspath(configuration)); + runnerConfig.setVMArguments(getVMArguments(configuration)); + runnerConfig.setProgramArguments(getProgramArguments(configuration)); + runnerConfig.setWorkingDirectory(getWorkingDirectory(configuration).getAbsolutePath()); + runnerConfig.setEnvironment(getEnvironment(configuration)); + runnerConfig.setVMSpecificAttributesMap(getVMSpecificAttributesMap(configuration)); + + monitor.worked(1); + + setDefaultSourceLocator(configuration); + manageLaunch(launch); + IVMRunner runner = getVMRunner(configuration, mode); + if (runner != null) + runner.run(runnerConfig, launch, monitor); + else + monitor.setCanceled(true); + monitor.done(); + } catch (final CoreException e) { + monitor.setCanceled(true); + throw e; + } + } + + /** + * Returns the VM runner for the given launch mode to use when launching the + * given configuration. + * + * @param configuration launch configuration + * @param mode launch node + * @return VM runner to use when launching the given configuration in the given mode + * @throws CoreException if a VM runner cannot be determined + */ + public IVMRunner getVMRunner(ILaunchConfiguration configuration, String mode) throws CoreException { + IVMInstall launcher = VMHelper.createLauncher(configuration); + return launcher.getVMRunner(mode); + } + + /** + * Assigns a default source locator to the given launch if a source locator + * has not yet been assigned to it, and the associated launch configuration + * does not specify a source locator. + * + * @param configuration + * configuration being launched + * @exception CoreException + * if unable to set the source locator + */ + protected void setDefaultSourceLocator(ILaunchConfiguration configuration) throws CoreException { + ILaunchConfigurationWorkingCopy wc = null; + if (configuration.isWorkingCopy()) { + wc = (ILaunchConfigurationWorkingCopy) configuration; + } else { + wc = configuration.getWorkingCopy(); + } + String id = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, (String) null); + if (!PDESourcePathProvider.ID.equals(id)) { + wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, PDESourcePathProvider.ID); + wc.doSave(); + } + } + + /** + * Returns the entries that should appear on boot classpath. + * + * @param configuration + * launch configuration + * @return the location of startup.jar and + * the bootstrap classpath specified by the given launch configuration + * + * @exception CoreException + * if unable to find startup.jar + */ + public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException { + String[] classpath = LaunchArgumentsHelper.constructClasspath(configuration); + if (classpath == null) { + String message = PDEMessages.WorkbenchLauncherConfigurationDelegate_noStartup; + throw new CoreException(LauncherUtils.createErrorStatus(message)); + } + return classpath; + } + + /** + * Returns an array of environment variables to be used when + * launching the given configuration ornull
if unspecified.
+ *
+ * @param configuration launch configuration
+ * @throws CoreException if unable to access associated attribute or if
+ * unable to resolve a variable in an environment variable's value
+ */
+ public String[] getEnvironment(ILaunchConfiguration configuration) throws CoreException {
+ return DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
+ }
+
+ /**
+ * Returns the working directory path specified by the given launch
+ * configuration, or null
if none.
+ *
+ * @param configuration
+ * launch configuration
+ * @return the working directory path specified by the given launch
+ * configuration, or null
if none
+ * @exception CoreException
+ * if unable to retrieve the attribute
+ */
+ public File getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
+ return LaunchArgumentsHelper.getWorkingDirectory(configuration);
+ }
+
+ /**
+ * Returns the Map of VM-specific attributes specified by the given launch
+ * configuration, or null
if none.
+ *
+ * @param configuration
+ * launch configuration
+ * @return the Map
of VM-specific attributes
+ * @exception CoreException
+ * if unable to retrieve the attribute
+ */
+ public Map getVMSpecificAttributesMap(ILaunchConfiguration configuration) throws CoreException {
+ return LaunchArgumentsHelper.getVMSpecificAttributesMap(configuration);
+ }
+
+ /**
+ * Returns the VM arguments specified by the given launch configuration, as
+ * an array of strings.
+ *
+ * @param configuration
+ * launch configuration
+ * @return the VM arguments specified by the given launch configuration,
+ * possibly an empty array
+ * @exception CoreException
+ * if unable to retrieve the attribute
+ */
+ public String[] getVMArguments(ILaunchConfiguration configuration) throws CoreException {
+ String[] vmArgs = new ExecutionArguments(LaunchArgumentsHelper.getUserVMArguments(configuration), "").getVMArgumentsArray(); //$NON-NLS-1$
+ // For p2 target, add "-Declipse.p2.data.area=@config.dir/p2" unless already specified by user
+ Map bundleMap = BundleLauncherHelper.getMergedBundleMap(configuration, false);
+ if (bundleMap.containsKey("org.eclipse.equinox.p2.core")) { //$NON-NLS-1$
+ for (int i = 0; i < vmArgs.length; i++) {
+ String arg = vmArgs[i];
+ if (arg.startsWith("-Declipse.p2.data.area=")) { //$NON-NLS-1$
+ return vmArgs;
+ }
+ }
+ String[] temp = new String[vmArgs.length + 1];
+ System.arraycopy(vmArgs, 0, temp, 0, vmArgs.length);
+ temp[vmArgs.length] = "-Declipse.p2.data.area=@config.dir" + File.separator + "p2"; //$NON-NLS-1$ //$NON-NLS-2$
+ return temp;
+ }
+ return vmArgs;
+ }
+
+ /**
+ * Returns the program arguments to launch with.
+ * This list is a combination of arguments computed by PDE based on attributes
+ * specified in the given launch configuration, followed by the program arguments
+ * that the entered directly into the launch configuration.
+ *
+ * @param configuration
+ * launch configuration
+ * @return the program arguments necessary for launching
+ *
+ * @exception CoreException
+ * if unable to retrieve the attribute or create the
+ * necessary configuration files
+ */
+ public String[] getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
+ ArrayList programArgs = new ArrayList();
+
+ // add tracing, if turned on
+ if (configuration.getAttribute(IPDELauncherConstants.TRACING, false) && !IPDELauncherConstants.TRACING_NONE.equals(configuration.getAttribute(IPDELauncherConstants.TRACING_CHECKED, (String) null))) {
+ programArgs.add("-debug"); //$NON-NLS-1$
+ programArgs.add(LaunchArgumentsHelper.getTracingFileArgument(configuration, getConfigDir(configuration).toString() + IPath.SEPARATOR + ".options")); //$NON-NLS-1$
+ }
+
+ // add the program args specified by the user
+ String[] userArgs = LaunchArgumentsHelper.getUserProgramArgumentArray(configuration);
+ ArrayList userDefined = new ArrayList();
+ for (int i = 0; i < userArgs.length; i++) {
+ // be forgiving if people have tracing turned on and forgot
+ // to remove the -debug from the program args field.
+ if (userArgs[i].equals("-debug") && programArgs.contains("-debug")) //$NON-NLS-1$ //$NON-NLS-2$
+ continue;
+ userDefined.add(userArgs[i]);
+ }
+
+ if (!configuration.getAttribute(IPDEConstants.APPEND_ARGS_EXPLICITLY, false)) {
+
+ if (!userDefined.contains("-os")) { //$NON-NLS-1$
+ programArgs.add("-os"); //$NON-NLS-1$
+ programArgs.add(TargetPlatform.getOS());
+ }
+ if (!userDefined.contains("-ws")) { //$NON-NLS-1$
+ programArgs.add("-ws"); //$NON-NLS-1$
+ programArgs.add(TargetPlatform.getWS());
+ }
+ if (!userDefined.contains("-arch")) { //$NON-NLS-1$
+ programArgs.add("-arch"); //$NON-NLS-1$
+ programArgs.add(TargetPlatform.getOSArch());
+ }
+ }
+
+ if (userDefined.size() > 0) {
+ programArgs.addAll(userDefined);
+ }
+
+ return (String[]) programArgs.toArray(new String[programArgs.size()]);
+ }
+
+ /**
+ * Does sanity checking before launching. The criteria whether the launch should
+ * proceed or not is specific to the launch configuration type.
+ *
+ * @param configuration launch configuration
+ * @param launch the launch object to contribute processes and debug targets to
+ * @param monitor a progress monitor
+ *
+ * @throws CoreException exception thrown if launch fails or canceled or if unable to retrieve attributes
+ * from the launch configuration
+ *
+ */
+ protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ boolean autoValidate = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, false);
+ monitor.beginTask("", autoValidate ? 3 : 4); //$NON-NLS-1$
+ if (autoValidate)
+ validatePluginDependencies(configuration, new SubProgressMonitor(monitor, 1));
+ validateProjectDependencies(configuration, new SubProgressMonitor(monitor, 1));
+ clear(configuration, new SubProgressMonitor(monitor, 1));
+ launch.setAttribute(IPDELauncherConstants.CONFIG_LOCATION, getConfigDir(configuration).toString());
+ synchronizeManifests(configuration, new SubProgressMonitor(monitor, 1));
+ }
+
+ /**
+ * Returns the configuration area specified by the given launch
+ * configuration.
+ *
+ * @param configuration
+ * launch configuration
+ * @return the directory path specified by the given launch
+ * configuration
+ */
+ protected File getConfigDir(ILaunchConfiguration configuration) {
+ if (fConfigDir == null)
+ fConfigDir = LaunchConfigurationHelper.getConfigurationArea(configuration);
+ return fConfigDir;
+ }
+
+ /*
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
+ */
+ protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
+ return computeBuildOrder(LaunchPluginValidator.getAffectedProjects(configuration));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getProjectsForProblemSearch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
+ */
+ protected IProject[] getProjectsForProblemSearch(ILaunchConfiguration configuration, String mode) throws CoreException {
+ return LaunchPluginValidator.getAffectedProjects(configuration);
+ }
+
+ /**
+ * Returns the fully-qualified name of the class to launch.
+ *
+ * @return the fully-qualified name of the class to launch. Must not return null
.
+ * @since 3.3
+ */
+ public String getMainClass() {
+ if (TargetPlatformHelper.getTargetVersion() >= 3.3)
+ return "org.eclipse.equinox.launcher.Main"; //$NON-NLS-1$
+ return "org.eclipse.core.launcher.Main"; //$NON-NLS-1$
+ }
+
+ /**
+ * Adds a listener to the launch to be notified at interesting launch lifecycle
+ * events such as when the launch terminates.
+ *
+ * @param launch
+ * the launch
+ *
+ * @since 3.3
+ */
+ protected void manageLaunch(ILaunch launch) {
+ PDELaunchingPlugin.getDefault().getLaunchListener().manage(launch);
+ }
+
+ /**
+ * Checks for old-style plugin.xml files that have become stale since the last launch.
+ * For any stale plugin.xml files found, the corresponding MANIFEST.MF is deleted
+ * from the runtime configuration area so that it gets regenerated upon startup.
+ *
+ * @param configuration
+ * the launch configuration
+ * @param monitor
+ * a progress monitor
+ *
+ * @since 3.3
+ */
+ protected void synchronizeManifests(ILaunchConfiguration configuration, IProgressMonitor monitor) {
+ LaunchConfigurationHelper.synchronizeManifests(configuration, getConfigDir(configuration));
+ monitor.done();
+ }
+
+ /**
+ * Checks if the Automated Management of Dependencies option is turned on.
+ * If so, it makes aure all manifests are updated with the correct dependencies.
+ *
+ * @param configuration
+ * the launch configuration
+ * @param monitor
+ * a progress monitor
+ *
+ * @since 3.3
+ */
+ protected void validateProjectDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) {
+ LauncherUtils.validateProjectDependencies(configuration, monitor);
+ }
+
+ /**
+ * By default, this method does nothing. Clients should override, if appropriate.
+ *
+ * @param configuration
+ * the launch configuration
+ * @param monitor
+ * the progress monitor
+ * @throws CoreException
+ * if unable to retrieve launch attribute values
+ * @since 3.3
+ */
+ protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
+ }
+
+ /**
+ * Validates inter-bundle dependencies automatically prior to launching
+ * if that option is turned on.
+ *
+ * @param configuration
+ * the launch configuration
+ * @param monitor
+ * a progress monitor
+ * @since 3.3
+ */
+ protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
+ EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration);
+ LaunchPluginValidator.runValidationOperation(op, monitor);
+ }
+
+}
Index: src/org/eclipse/pde/launching/IPDELauncherConstants.java
===================================================================
RCS file: src/org/eclipse/pde/launching/IPDELauncherConstants.java
diff -N src/org/eclipse/pde/launching/IPDELauncherConstants.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/pde/launching/IPDELauncherConstants.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,406 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.launching;
+
+/**
+ * Constant definitions for PDE launch configurations.
+ * + * Constant definitions only; not to be implemented. + *
+ * @since 3.2 + * + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + */ +public interface IPDELauncherConstants { + + /** + * Launch configuration attribute key. The value is a string specifying + * workspace data location for an Eclipse application. + */ + String LOCATION = "location"; //$NON-NLS-1$ + + /** + * Launch configuration attribute key. The value is a boolean specifying + * workspace data location for an Eclipse application should be cleared + * prior to launching. + */ + String DOCLEAR = "clearws"; //$NON-NLS-1$ + + /** + * Launch configuration attribute key. The value is a boolean specifying + * whether the user should be prompted prior to clearing the workspace. + * + * @see IPDELauncherConstants#DOCLEAR + */ + String ASKCLEAR = "askclear"; //$NON-NLS-1$ + + /** + * Launch configuration attribute key. The value is a string specifying + * the application to run. If the value isnull
, the default
+ * application as specified in the target platform will be used.
+ */
+ String APPLICATION = "application"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a string specifying
+ * the product to run.
+ *
+ * @see IPDELauncherConstants#APPLICATION
+ */
+ String PRODUCT = "product"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a boolean specifying
+ * if the launch should appear in product-mode. If the value is false
,
+ * the launch takes place in application-mode.
+ *
+ * @see IPDELauncherConstants#PRODUCT
+ * @see IPDELauncherConstants#APPLICATION
+ */
+ String USE_PRODUCT = "useProduct"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key used in Plug-in JUnit launch configurations only.
+ * The value is a string specifying the application to be tested.
+ * If the value is null
, the default UI workbench application is tested.
+ */
+ String APP_TO_TEST = "testApplication"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a string specifying
+ * the name of the VM to launch with. If the value is null
,
+ * the default workspace VM is used.
+ *
+ * @deprecated use IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH
+ */
+ String VMINSTALL = "vminstall"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a string specifying
+ * the user-entered bootstrap classpath entries.
+ */
+ String BOOTSTRAP_ENTRIES = "bootstrap"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a boolean specifying
+ * if the default self-hosting mode should be used when launching.
+ * The default being to launch with all workspace plug-ins and all the
+ * plug-ins that are explicitly checked on the Target Platform preference page.
+ */
+ String USE_DEFAULT = "default"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a boolean specifying
+ * if the feature-based self-hosting mode should be used.
+ * The workspace must be set up properly for the feature-based self-hosting
+ * to succeed.
+ * Check the PDE Tips and Tricks section for how to set up feature-based self-hosting.
+ */
+ String USEFEATURES = "usefeatures"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a string specifying
+ * a comma-separated list of IDs of workspace plug-ins to launch with.
+ * This value is only used when the Automatic Add option is off.
+ *
+ * @see IPDELauncherConstants#AUTOMATIC_ADD
+ */
+ String SELECTED_WORKSPACE_PLUGINS = "selected_workspace_plugins"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a string specifying
+ * a comma-separated list of IDs of workspace plug-ins that are to be excluded from
+ * the launch.
+ * This value is only used when the Automatic Add option is on.
+ *
+ * @see IPDELauncherConstants#AUTOMATIC_ADD
+ */
+ String DESELECTED_WORKSPACE_PLUGINS = "deselected_workspace_plugins"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a boolean specifying
+ * whether workspace plug-in created after the creation of a launch configuration
+ * should be added to the list of plug-ins to launch with.
+ *
+ * If the value is true
, then DESELECTED_WORKSPACE_PLUGINS should be used.
+ * Otherwise, SELECTED_WORKSPACE_PLUGINS should be used.
+ *
+ * @see IPDELauncherConstants#DESELECTED_WORKSPACE_PLUGINS
+ * @see IPDELauncherConstants#SELECTED_WORKSPACE_PLUGINS
+ */
+ String AUTOMATIC_ADD = "automaticAdd"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a boolean specifying
+ * whether the list of plug-ins to run should be validate prior to launching.
+ * If problems are found, they will be reported and the user will be able to cancel or
+ * continue.
+ * If no problems are found, the launch continues as normal.
+ */
+ String AUTOMATIC_VALIDATE = "automaticValidate"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a string specifying
+ * a comma-separated list of IDs of target platform plug-ins to launch with.
+ * This value is only used when the Automatic Add option is off.
+ */
+ String SELECTED_TARGET_PLUGINS = "selected_target_plugins"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a boolean indicating
+ * whether the computation of required plug-ins on the Plug-ins tab should include
+ * the traversal of optional dependencies.
+ */
+ String INCLUDE_OPTIONAL = "includeOptional"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a boolean indicating
+ * whether tracing is enabled or disabled.
+ */
+ String TRACING = "tracing"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a map containing the list
+ * of options to debug with.
+ */
+ String TRACING_OPTIONS = "tracingOptions"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is the id of the last plug-in
+ * that was selected on the Tracing tab.
+ */
+ String TRACING_SELECTED_PLUGIN = "selectedPlugin"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is the IDs of all plug-ins
+ * checked on the Tracing tab. The value may also be "[NONE]"
+ *
+ * @see IPDELauncherConstants#TRACING_NONE
+ */
+ String TRACING_CHECKED = "checked"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute value indicating that, although tracing is enabled,
+ * no plug-ins have been selected to be traced.
+ */
+ String TRACING_NONE = "[NONE]"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a boolean specifying
+ * if PDE should generate a default configuration area for the launch.
+ *
+ * If true
, a configuration location in the PDE metadata area
+ * is created. Otherwise, the user is expected to specify a location.
+ *
+ * @see IPDELauncherConstants#CONFIG_LOCATION
+ */
+ String CONFIG_USE_DEFAULT_AREA = "useDefaultConfigArea"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a string specifying
+ * the configuration area location for an Eclipse application launch.
+ *
+ * This key is only used when CONFIG_USE_DEFAULT_AREA is false
.
+ *
+ * @see IPDELauncherConstants#CONFIG_USE_DEFAULT_AREA
+ */
+ String CONFIG_LOCATION = "configLocation"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a boolean specifying
+ * if the configuration area location should be cleared prior to launching
+ */
+ String CONFIG_CLEAR_AREA = "clearConfig"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration atribute key. The value is a boolean specifying
+ * if PDE should generate a default config.ini file for the launch.
+ *
+ * If true
, a configuration file is created.
+ * Otherwise, the user is expected to specify a config.ini to be used as a template.
+ *
+ * @see IPDELauncherConstants#CONFIG_TEMPLATE_LOCATION
+ */
+ String CONFIG_GENERATE_DEFAULT = "useDefaultConfig"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a string specifying
+ * the location of the config.ini file to be used as a template for an
+ * Eclipse application launch.
+ *
+ * This key is only used when CONFIG_GENERATE_DEFAULT is false
.
+ *
+ * @see IPDELauncherConstants#CONFIG_GENERATE_DEFAULT
+ */
+ String CONFIG_TEMPLATE_LOCATION = "templateConfig"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a string specifying
+ * the location of the .product file with which this launch configuration
+ * is associated.
+ */
+ String PRODUCT_FILE = "productFile"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is the ID of an OSGi framework
+ * declared in an org.eclipse.pde.ui.osgiLaunchers
extension point.
+ *
+ * @since 3.3
+ */
+ String OSGI_FRAMEWORK_ID = "osgi_framework_id"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a boolean specifying
+ * if the default Auto-Start for an OSGi Framework launch configuration
+ * is true
or false
+ *
+ * @see IPDELauncherConstants#DEFAULT_START_LEVEL
+ */
+ String DEFAULT_AUTO_START = "default_auto_start"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is an integer specifying
+ * the default start level for bundles in an OSGi Framework launch configuration.
+ *
+ * @see IPDELauncherConstants#DEFAULT_AUTO_START
+ */
+ String DEFAULT_START_LEVEL = "default_start_level"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a comma-separated list
+ * of workspace bundles to launch with the OSGi framework.
+ *
+ * Each token in the list is of the format:
+ * true
+ *
+ * @since 3.5
+ */
+ String RUN_IN_UI_THREAD = "run_in_ui_thread"; //$NON-NLS-1$
+
+ /**
+ * The launch configuration type for Eclipse application launches.
+ *
+ * @since 3.6
+ * @see EclipseLaunchShortcut
+ */
+ String ECLIPSE_APPLICATION_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.pde.ui.RuntimeWorkbench"; //$NON-NLS-1$
+}
Index: src/org/eclipse/pde/launching/EclipseApplicationLaunchConfiguration.java
===================================================================
RCS file: src/org/eclipse/pde/launching/EclipseApplicationLaunchConfiguration.java
diff -N src/org/eclipse/pde/launching/EclipseApplicationLaunchConfiguration.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/pde/launching/EclipseApplicationLaunchConfiguration.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * EclipseSource Corporation - ongoing enhancements
+ *******************************************************************************/
+package org.eclipse.pde.launching;
+
+import java.io.File;
+import java.util.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.core.plugin.TargetPlatform;
+import org.eclipse.pde.internal.core.*;
+import org.eclipse.pde.internal.core.util.CoreUtility;
+import org.eclipse.pde.internal.core.util.VersionUtil;
+import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
+import org.eclipse.pde.internal.launching.PDEMessages;
+import org.eclipse.pde.internal.launching.launcher.*;
+import org.osgi.framework.Version;
+
+/**
+ * A launch delegate for launching Eclipse applications
+ * + * Clients may subclass and instantiate this class. + *
+ * @since 3.2 + */ +public class EclipseApplicationLaunchConfiguration extends AbstractPDELaunchConfiguration { + + // used to generate the dev classpath entries + // key is bundle ID, value is a model + private Map fAllBundles; + + // key is a model, value is startLevel:autoStart + private Map fModels; + + /** + * To avoid duplicating variable substitution (and duplicate prompts) + * this variable will store the substituted workspace location. + */ + private String fWorkspaceLocation; + + /* + * (non-Javadoc) + * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#getProgramArguments(org.eclipse.debug.core.ILaunchConfiguration) + */ + public String[] getProgramArguments(ILaunchConfiguration configuration) throws CoreException { + ArrayList programArgs = new ArrayList(); + + // If a product is specified, then add it to the program args + if (configuration.getAttribute(IPDELauncherConstants.USE_PRODUCT, false)) { + String product = configuration.getAttribute(IPDELauncherConstants.PRODUCT, ""); //$NON-NLS-1$ + if (product.length() > 0) { + programArgs.add("-product"); //$NON-NLS-1$ + programArgs.add(product); + } else { // TODO product w/o an application and product... how to handle gracefully? + programArgs.add("-application"); //$NON-NLS-1$ + programArgs.add(configuration.getAttribute(IPDELauncherConstants.APPLICATION, "")); //$NON-NLS-1$ + } + } else { + // specify the application to launch + programArgs.add("-application"); //$NON-NLS-1$ + programArgs.add(configuration.getAttribute(IPDELauncherConstants.APPLICATION, TargetPlatform.getDefaultApplication())); + } + + // specify the workspace location for the runtime workbench + if (fWorkspaceLocation == null) { + fWorkspaceLocation = LaunchArgumentsHelper.getWorkspaceLocation(configuration); + } + if (fWorkspaceLocation.length() > 0) { + programArgs.add("-data"); //$NON-NLS-1$ + programArgs.add(fWorkspaceLocation); + } + + boolean showSplash = true; + if (configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false)) { + validateFeatures(); + IPath installPath = PDELaunchingPlugin.getWorkspace().getRoot().getLocation(); + programArgs.add("-install"); //$NON-NLS-1$ + programArgs.add("file:" + installPath.removeLastSegments(1).addTrailingSeparator().toString()); //$NON-NLS-1$ + if (!configuration.getAttribute(IPDELauncherConstants.CONFIG_USE_DEFAULT_AREA, true)) { + programArgs.add("-configuration"); //$NON-NLS-1$ + programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$ + } + programArgs.add("-update"); //$NON-NLS-1$ + // add the output folder names + programArgs.add("-dev"); //$NON-NLS-1$ + programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", true)); //$NON-NLS-1$ + } else { + String productID = LaunchConfigurationHelper.getProductID(configuration); + Properties prop = LaunchConfigurationHelper.createConfigIniFile(configuration, productID, fAllBundles, fModels, getConfigDir(configuration)); + showSplash = prop.containsKey("osgi.splashPath") || prop.containsKey("splashLocation"); //$NON-NLS-1$ //$NON-NLS-2$ + String brandingId = LaunchConfigurationHelper.getContributingPlugin(productID); + TargetPlatform.createPlatformConfiguration(getConfigDir(configuration), (IPluginModelBase[]) fAllBundles.values().toArray(new IPluginModelBase[fAllBundles.size()]), brandingId != null ? (IPluginModelBase) fAllBundles.get(brandingId) : null); + TargetPlatformHelper.checkPluginPropertiesConsistency(fAllBundles, getConfigDir(configuration)); + programArgs.add("-configuration"); //$NON-NLS-1$ + programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$ + + // add the output folder names + programArgs.add("-dev"); //$NON-NLS-1$ + programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", fAllBundles)); //$NON-NLS-1$ + } + // necessary for PDE to know how to load plugins when target platform = host platform + // see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode() + IPluginModelBase base = (IPluginModelBase) fAllBundles.get(PDECore.PLUGIN_ID); + if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) < 0) //$NON-NLS-1$ + programArgs.add("-pdelaunch"); //$NON-NLS-1$ + + String[] args = super.getProgramArguments(configuration); + for (int i = 0; i < args.length; i++) { + programArgs.add(args[i]); + } + + if (!programArgs.contains("-nosplash") && showSplash) { //$NON-NLS-1$ + if (TargetPlatformHelper.getTargetVersion() >= 3.1) { + programArgs.add(0, "-launcher"); //$NON-NLS-1$ + + IPath path = null; + if (TargetPlatform.getOS().equals("macosx")) { //$NON-NLS-1$ + path = new Path(TargetPlatform.getLocation()).append("Eclipse.app/Contents/MacOS/eclipse"); //$NON-NLS-1$ + } else { + path = new Path(TargetPlatform.getLocation()).append("eclipse"); //$NON-NLS-1$ + if (TargetPlatform.getOS().equals("win32")) { //$NON-NLS-1$ + path = path.addFileExtension("exe"); //$NON-NLS-1$ + } + } + + programArgs.add(1, path.toOSString()); //This could be the branded launcher if we want (also this does not bring much) + programArgs.add(2, "-name"); //$NON-NLS-1$ + programArgs.add(3, "Eclipse"); //This should be the name of the product //$NON-NLS-1$ + programArgs.add(4, "-showsplash"); //$NON-NLS-1$ + programArgs.add(5, "600"); //$NON-NLS-1$ + } else { + programArgs.add(0, "-showsplash"); //$NON-NLS-1$ + programArgs.add(1, computeShowsplashArgument()); + } + } + return (String[]) programArgs.toArray(new String[programArgs.size()]); + } + + private void validateFeatures() throws CoreException { + IPath installPath = PDELaunchingPlugin.getWorkspace().getRoot().getLocation(); + String lastSegment = installPath.lastSegment(); + boolean badStructure = lastSegment == null; + if (!badStructure) { + IPath featuresPath = installPath.removeLastSegments(1).append("features"); //$NON-NLS-1$ + badStructure = !lastSegment.equalsIgnoreCase("plugins") //$NON-NLS-1$ + || !featuresPath.toFile().exists(); + } + if (badStructure) { + throw new CoreException(LauncherUtils.createErrorStatus(PDEMessages.WorkbenchLauncherConfigurationDelegate_badFeatureSetup)); + } + // Ensure important files are present + ensureProductFilesExist(getProductPath()); + } + + private IPath getProductPath() { + return PDELaunchingPlugin.getWorkspace().getRoot().getLocation().removeLastSegments(1); + } + + private String computeShowsplashArgument() { + IPath eclipseHome = new Path(TargetPlatform.getLocation()); + IPath fullPath = eclipseHome.append("eclipse"); //$NON-NLS-1$ + return fullPath.toOSString() + " -showsplash 600"; //$NON-NLS-1$ + } + + private void ensureProductFilesExist(IPath productArea) { + File productDir = productArea.toFile(); + File marker = new File(productDir, ".eclipseproduct"); //$NON-NLS-1$ + IPath eclipsePath = new Path(TargetPlatform.getLocation()); + if (!marker.exists()) + CoreUtility.copyFile(eclipsePath, ".eclipseproduct", marker); //$NON-NLS-1$ + + File configDir = new File(productDir, "configuration"); //$NON-NLS-1$ + if (!configDir.exists()) + configDir.mkdirs(); + File ini = new File(configDir, "config.ini"); //$NON-NLS-1$ + if (!ini.exists()) + CoreUtility.copyFile(eclipsePath.append("configuration"), "config.ini", ini); //$NON-NLS-1$ //$NON-NLS-2$ + } + + /* + * (non-Javadoc) + * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#getConfigDir(org.eclipse.debug.core.ILaunchConfiguration) + */ + protected File getConfigDir(ILaunchConfiguration config) { + if (fConfigDir == null) { + try { + if (config.getAttribute(IPDELauncherConstants.USEFEATURES, false) && config.getAttribute(IPDELauncherConstants.CONFIG_USE_DEFAULT_AREA, true)) { + String root = getProductPath().toString(); + root += "/configuration"; //$NON-NLS-1$ + fConfigDir = new File(root); + if (!fConfigDir.exists()) + fConfigDir.mkdirs(); + } else { + fConfigDir = LaunchConfigurationHelper.getConfigurationArea(config); + } + } catch (CoreException e) { + fConfigDir = LaunchConfigurationHelper.getConfigurationArea(config); + } + } + return fConfigDir; + } + + /** + * Clears the workspace prior to launching if the workspace exists and the option to + * clear it is turned on. Also clears the configuration area if that option is chosen. + * + * @param configuration + * the launch configuration + * @param monitor + * the progress monitor + * @throws CoreException + * if unable to retrieve launch attribute values + * @since 3.3 + */ + protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { + if (fWorkspaceLocation == null) { + fWorkspaceLocation = LaunchArgumentsHelper.getWorkspaceLocation(configuration); + } + // Clear workspace and prompt, if necessary + if (!LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, monitor)) + throw new CoreException(Status.CANCEL_STATUS); + + // clear config area, if necessary + if (configuration.getAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false)) + CoreUtility.deleteContent(getConfigDir(configuration)); + } + + /* (non-Javadoc) + * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) + */ + protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException { + fWorkspaceLocation = null; + + fModels = BundleLauncherHelper.getMergedBundleMap(configuration, false); + fAllBundles = new HashMap(fModels.size()); + Iterator iter = fModels.keySet().iterator(); + while (iter.hasNext()) { + IPluginModelBase model = (IPluginModelBase) iter.next(); + fAllBundles.put(model.getPluginBase().getId(), model); + } + validateConfigIni(configuration); + super.preLaunchCheck(configuration, launch, monitor); + } + + private void validateConfigIni(ILaunchConfiguration configuration) throws CoreException { + if (!configuration.getAttribute(IPDELauncherConstants.CONFIG_GENERATE_DEFAULT, true)) { + String templateLoc = configuration.getAttribute(IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, ""); //$NON-NLS-1$ + IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager(); + templateLoc = mgr.performStringSubstitution(templateLoc); + + File templateFile = new File(templateLoc); + if (!templateFile.exists()) { + if (!LauncherUtils.generateConfigIni()) + throw new CoreException(Status.CANCEL_STATUS); + // with the way the launcher works, if a config.ini file is not found one will be generated automatically. + // This check was to warn the user a config.ini needs to be generated. - bug 161265, comment #7 + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#getVMArguments(org.eclipse.debug.core.ILaunchConfiguration) + */ + public String[] getVMArguments(ILaunchConfiguration configuration) throws CoreException { + String[] vmArgs = super.getVMArguments(configuration); + IPluginModelBase base = (IPluginModelBase) fAllBundles.get(PDECore.PLUGIN_ID); + if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) >= 0) { //$NON-NLS-1$ + // necessary for PDE to know how to load plugins when target platform = host platform + // see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode() + String[] result = new String[vmArgs.length + 1]; + System.arraycopy(vmArgs, 0, result, 0, vmArgs.length); + result[vmArgs.length] = "-Declipse.pde.launch=true"; //$NON-NLS-1$ + return result; + } + return vmArgs; + } + +} Index: src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java =================================================================== RCS file: src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java diff -N src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,493 @@ +/******************************************************************************* + * Copyright (c) 2006, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * EclipseSource Corporation - ongoing enhancements + * David Saff+ * Clients may instantiate or subclass this class + *
+ * + * @since 3.3 + */ +public class OSGiLaunchConfigurationInitializer { + + protected static final String DEFAULT = "default"; //$NON-NLS-1$ + + /** + * Initializes some attributes on a newly-created launch configuration + * + * @param configuration + * the launch configuration + */ + public void initialize(ILaunchConfigurationWorkingCopy configuration) { + initializeFrameworkDefaults(configuration); + initializeBundleState(configuration); + initializeSourcePathProvider(configuration); + } + + /** + * Sets the source provider ID + * + * @param configuration + * the launch configuration + */ + protected void initializeSourcePathProvider(ILaunchConfigurationWorkingCopy configuration) { + configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, PDESourcePathProvider.ID); + } + + /** + * Initializes the start level and auto-start attributes + * + * @param configuration + * the launch configuration + */ + protected void initializeFrameworkDefaults(ILaunchConfigurationWorkingCopy configuration) { + configuration.setAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, true); + configuration.setAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4); + } + + /** + * Initializes the checked/unchecked state of bundles + * + * @param configuration + * the launch configuration + */ + protected void initializeBundleState(ILaunchConfigurationWorkingCopy configuration) { + StringBuffer explugins = new StringBuffer(); + StringBuffer wsplugins = new StringBuffer(); + IPluginModelBase[] models = PluginRegistry.getActiveModels(); + for (int i = 0; i < models.length; i++) { + boolean inWorkspace = models[i].getUnderlyingResource() != null; + appendBundle(inWorkspace ? wsplugins : explugins, models[i]); + } + configuration.setAttribute(IPDELauncherConstants.WORKSPACE_BUNDLES, wsplugins.toString()); + configuration.setAttribute(IPDELauncherConstants.TARGET_BUNDLES, explugins.toString()); + configuration.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); + } + + private void appendBundle(StringBuffer buffer, IPluginModelBase model) { + if (buffer.length() > 0) + buffer.append(","); //$NON-NLS-1$ + String id = model.getPluginBase().getId(); + String value = BundleLauncherHelper.writeBundleEntry(model, getStartLevel(id), getAutoStart(id)); + buffer.append(value); + } + + /** + * Returns the bundle's start level + * + * @param bundleID + * the bundle ID + * @return the start level for the given bundle or the stringdefault
+ */
+ protected String getStartLevel(String bundleID) {
+ return DEFAULT;
+ }
+
+ /**
+ * Returns whether the bundle should be started automatically
+ * @param bundleID
+ * the bundle ID
+ * @return true
, false
, or default
+ */
+ protected String getAutoStart(String bundleID) {
+ return DEFAULT;
+ }
+
+}
Index: src/org/eclipse/pde/launching/PDESourcePathProvider.java
===================================================================
RCS file: src/org/eclipse/pde/launching/PDESourcePathProvider.java
diff -N src/org/eclipse/pde/launching/PDESourcePathProvider.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/pde/launching/PDESourcePathProvider.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.launching;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.*;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.launching.*;
+import org.eclipse.pde.internal.core.util.PDEJavaHelper;
+import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
+import org.eclipse.pde.internal.launching.launcher.LaunchPluginValidator;
+import org.eclipse.pde.internal.launching.launcher.VMHelper;
+
+/**
+ * Generates a source lookup path for all PDE-based launch configurations
+ * + * Clients may subclass this class. + *
+ * @since 3.3 + */ +public class PDESourcePathProvider extends StandardSourcePathProvider { + + public static final String ID = "org.eclipse.pde.ui.workbenchClasspathProvider"; //$NON-NLS-1$ + + /* + * (non-Javadoc) + * @see org.eclipse.jdt.launching.StandardSourcePathProvider#computeUnresolvedClasspath(org.eclipse.debug.core.ILaunchConfiguration) + */ + public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException { + List sourcePath = new ArrayList(); + sourcePath.add(getJREEntry(configuration)); + IProject[] projects = getJavaProjects(configuration); + for (int i = 0; i < projects.length; i++) { + sourcePath.add(JavaRuntime.newProjectRuntimeClasspathEntry(JavaCore.create(projects[i]))); + } + return (IRuntimeClasspathEntry[]) sourcePath.toArray(new IRuntimeClasspathEntry[sourcePath.size()]); + } + + /** + * Returns a JRE runtime classpath entry + * + * @param configuration + * the launch configuration + * @return a JRE runtime classpath entry + * @throws CoreException + * if the JRE associated with the launch configuration cannot be found + * or if unable to retrieve the launch configuration attributes + */ + private IRuntimeClasspathEntry getJREEntry(ILaunchConfiguration configuration) throws CoreException { + IVMInstall jre = VMHelper.createLauncher(configuration); + IPath containerPath = new Path(JavaRuntime.JRE_CONTAINER); + containerPath = containerPath.append(jre.getVMInstallType().getId()); + containerPath = containerPath.append(jre.getName()); + return JavaRuntime.newRuntimeContainerClasspathEntry(containerPath, IRuntimeClasspathEntry.BOOTSTRAP_CLASSES); + } + + /** + * Returns an array of sorted plug-in projects that represent plug-ins participating + * in the launch + * + * @param configuration + * the launch configuration + * @return an array of ordered projects + * @throws CoreException + * if unable to retrieve attributes from the launch configuration or if + * an error occurs when checking the nature of the project + * + */ + private IProject[] getJavaProjects(ILaunchConfiguration configuration) throws CoreException { + IProject[] projects = LaunchPluginValidator.getAffectedProjects(configuration); + return PDELaunchingPlugin.getWorkspace().computeProjectOrder(projects).projects; + } + + /* + * (non-Javadoc) + * @see org.eclipse.jdt.launching.StandardSourcePathProvider#resolveClasspath(org.eclipse.jdt.launching.IRuntimeClasspathEntry[], org.eclipse.debug.core.ILaunchConfiguration) + */ + public IRuntimeClasspathEntry[] resolveClasspath(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration) throws CoreException { + List all = new ArrayList(entries.length); + for (int i = 0; i < entries.length; i++) { + if (entries[i].getType() == IRuntimeClasspathEntry.PROJECT) { + // a project resolves to itself for source lookup (rather than + // the class file output locations) + all.add(entries[i]); + // also add non-JRE libraries + IResource resource = entries[i].getResource(); + if (resource instanceof IProject) { + addBinaryPackageFragmentRoots(JavaCore.create((IProject) resource), all); + } + } else { + IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveRuntimeClasspathEntry(entries[i], configuration); + for (int j = 0; j < resolved.length; j++) { + all.add(resolved[j]); + } + } + } + return (IRuntimeClasspathEntry[]) all.toArray(new IRuntimeClasspathEntry[all.size()]); + } + + /** + * Adds runtime classpath entries for binary package fragment roots contained within + * the project + * + * @param jProject + * the Java project whose roots are to be enumerated + * @param all + * a list of accumulated runtime classpath entries + * @throws CoreException + * if unable to evaluate the package fragment roots + */ + private void addBinaryPackageFragmentRoots(IJavaProject jProject, List all) throws CoreException { + IPackageFragmentRoot[] roots = jProject.getPackageFragmentRoots(); + for (int j = 0; j < roots.length; j++) { + if (roots[j].getKind() == IPackageFragmentRoot.K_BINARY && !PDEJavaHelper.isJRELibrary(roots[j])) { + IRuntimeClasspathEntry rte = JavaRuntime.newArchiveRuntimeClasspathEntry(roots[j].getPath()); + IPath path = roots[j].getSourceAttachmentPath(); + if (path != null) { + rte.setSourceAttachmentPath(path); + rte.setSourceAttachmentRootPath(roots[j].getSourceAttachmentRootPath()); + } + if (!all.contains(rte)) + all.add(rte); + } + } + + } +} \ No newline at end of file