### 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:54:10 -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:54:10 -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:54:10 -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:54:10 -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:54:10 -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:54:10 -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/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:54:10 -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/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:54:10 -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/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:54:10 -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:54:10 -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 string default - */ - 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:54:10 -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:54:10 -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:54:10 -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:54:10 -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 or null 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:54:10 -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:54:10 -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: - * @: - * - * @see IPDELauncherConstants#DEFAULT_AUTO_START - * @see IPDELauncherConstants#DEFAULT_START_LEVEL - */ - String WORKSPACE_BUNDLES = "workspace_bundles"; //$NON-NLS-1$ - - /** - * Launch configuration attribute key. The value is a comma-separated list - * of non-workspace bundles to launch with the OSGi framework. - * - * Each token in the list is of the format: - * @: - * - * @see IPDELauncherConstants#DEFAULT_AUTO_START - * @see IPDELauncherConstants#DEFAULT_START_LEVEL - */ - String TARGET_BUNDLES = "target_bundles"; //$NON-NLS-1$ - - /** - * Launch configuration attribute key. The value can be either the full path - * to the workspace location of a Target Definition (ie. .target file), or - * the ID of a target defined in an org.eclipse.pde.core.targets extension. - */ - String DEFINED_TARGET = "defined_target"; //$NON-NLS-1$ - - /** - * Launch configuration attribute key. The value is a boolean indicating - * whether or not to display only selected plug-ins. - * - * @since 3.4 - */ - String SHOW_SELECTED_ONLY = "show_selected_only"; //$NON-NLS-1$ - - /** - * The unique tab identifier for the bundles tab - * - * @since 3.5 - * @see BundlesTab - */ - String TAB_BUNDLES_ID = "org.eclipse.pde.ui.launch.tab.osgi.bundles"; //$NON-NLS-1$ - - /** - * The unique tab identifier for the configuration tab - * - * @since 3.5 - * @see ConfigurationTab - */ - String TAB_CONFIGURATION_ID = "org.eclipse.pde.ui.launch.tab.configuration"; //$NON-NLS-1$ - - /** - * The unique tab identifier for the main tab - * - * @since 3.5 - * @see MainTab - */ - String TAB_MAIN_ID = "org.eclipse.pde.ui.launch.tab.main"; //$NON-NLS-1$ - - /** - * The unique tab identifier for the osgi settings tab - * - * @since 3.5 - * @see OSGiSettingsTab - */ - String TAB_OSGI_SETTINGS_ID = "org.eclipse.pde.ui.launch.tab.osgi.settings"; //$NON-NLS-1$ - - /** - * The unique tab identifier for the plug-in junit tab - * - * @since 3.5 - * @see PluginJUnitMainTab - */ - String TAB_PLUGIN_JUNIT_MAIN_ID = "org.eclipse.pde.ui.launch.tab.junit.main"; //$NON-NLS-1$ - - /** - * The unique tab identifier for the plug-ins tab - * - * @since 3.5 - * @see PluginsTab - */ - String TAB_PLUGINS_ID = "org.eclipse.pde.ui.launch.tab.plugins"; //$NON-NLS-1$ - - /** - * The unique tab identifier for the tracing tab - * - * @since 3.5 - * @see TracingTab - */ - String TAB_TRACING_ID = "org.eclipse.pde.ui.launch.tab.tracing"; //$NON-NLS-1$ - - /** - * The unique tab identifier for the tracing tab - * - * @since 3.5 - * @see TestTab - */ - String TAB_TEST_ID = "org.eclipse.pde.ui.launch.tab.test"; //$NON-NLS-1$ - - /** - * The launch configuration type id for OSGi launches. - * - * @since 3.5 - * @see OSGiLaunchShortcut - */ - String OSGI_CONFIGURATION_TYPE = "org.eclipse.pde.ui.EquinoxLauncher"; //$NON-NLS-1$ - - /** - * Launch configuration attribute key. The value is a boolean specifying - * whether the tests should run on the UI thread. - * - * The default value is 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:54:10 -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:54:10 -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:54:10 -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:54:10 -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:54:10 -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:54:10 -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:54:10 -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:54:10 -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:54:10 -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:54:10 -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:54:09 -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 - * or null 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:54:09 -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:54:09 -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:54:09 -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:54:09 -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:54:09 -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:54:10 -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:54:10 -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:54:09 -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:54:09 -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 - Bug 195433 - *******************************************************************************/ -package org.eclipse.pde.internal.ui.launcher; - -import org.eclipse.core.runtime.*; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.launching.*; -import org.eclipse.osgi.util.NLS; -import org.eclipse.pde.internal.core.util.VMUtil; -import org.eclipse.pde.internal.ui.PDEUIMessages; -import org.eclipse.pde.ui.launcher.IPDELauncherConstants; - -public class VMHelper { - - /** - * Get the default VMInstall name using the available info in the config, - * using the JavaProject if available. - * - * @param configuration - * Launch configuration to check - * @return name of the VMInstall - * @throws CoreException - * thrown if there's a problem getting the VM name - */ - public static String getDefaultVMInstallName(ILaunchConfiguration configuration) throws CoreException { - IJavaProject javaProject = JavaRuntime.getJavaProject(configuration); - IVMInstall vmInstall = null; - if (javaProject != null) { - vmInstall = JavaRuntime.getVMInstall(javaProject); - } - - if (vmInstall != null) { - return vmInstall.getName(); - } - - return VMUtil.getDefaultVMInstallName(); - } - - public static IVMInstall getVMInstall(ILaunchConfiguration configuration) throws CoreException { - String jre = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String) null); - IVMInstall vm = null; - if (jre == null) { - String name = configuration.getAttribute(IPDELauncherConstants.VMINSTALL, (String) null); - if (name == null) { - name = getDefaultVMInstallName(configuration); - } - vm = getVMInstall(name); - if (vm == null) { - throw new CoreException(LauncherUtils.createErrorStatus(NLS.bind(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_noJRE, name))); - } - } else { - IPath jrePath = Path.fromPortableString(jre); - vm = JavaRuntime.getVMInstall(jrePath); - if (vm == null) { - String id = JavaRuntime.getExecutionEnvironmentId(jrePath); - if (id == null) { - String name = JavaRuntime.getVMInstallName(jrePath); - throw new CoreException(LauncherUtils.createErrorStatus(NLS.bind(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_noJRE, name))); - } - throw new CoreException(LauncherUtils.createErrorStatus(NLS.bind(PDEUIMessages.VMHelper_cannotFindExecEnv, id))); - } - } - return vm; - } - - public static IVMInstall getVMInstall(String name) { - if (name != null) { - IVMInstall[] installs = VMUtil.getAllVMInstances(); - for (int i = 0; i < installs.length; i++) { - if (installs[i].getName().equals(name)) - return installs[i]; - } - } - return JavaRuntime.getDefaultVMInstall(); - } - - public static IVMInstall createLauncher(ILaunchConfiguration configuration) throws CoreException { - IVMInstall launcher = getVMInstall(configuration); - if (!launcher.getInstallLocation().exists()) - throw new CoreException(LauncherUtils.createErrorStatus(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_jrePathNotFound)); - return launcher; - } - -} Index: src/org/eclipse/pde/internal/ui/launcher/LaunchValidationOperation.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/launcher/LaunchValidationOperation.java diff -N src/org/eclipse/pde/internal/ui/launcher/LaunchValidationOperation.java --- src/org/eclipse/pde/internal/ui/launcher/LaunchValidationOperation.java 27 May 2009 20:38:24 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,161 +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 - *******************************************************************************/ -package org.eclipse.pde.internal.ui.launcher; - -import java.io.*; -import java.util.*; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.debug.core.ILaunchConfiguration; -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.osgi.service.resolver.State; -import org.eclipse.pde.core.plugin.IPluginModelBase; -import org.eclipse.pde.core.plugin.PluginRegistry; -import org.eclipse.pde.internal.core.BundleValidationOperation; -import org.eclipse.pde.internal.core.TargetPlatformHelper; -import org.osgi.framework.Constants; - -public abstract class LaunchValidationOperation implements IWorkspaceRunnable { - - private BundleValidationOperation fOperation; - protected ILaunchConfiguration fLaunchConfiguration; - - public LaunchValidationOperation(ILaunchConfiguration configuration) { - fLaunchConfiguration = configuration; - } - - public void run(IProgressMonitor monitor) throws CoreException { - fOperation = new BundleValidationOperation(getModels(), getPlatformProperties()); - fOperation.run(monitor); - } - - protected abstract IPluginModelBase[] getModels() throws CoreException; - - protected Dictionary[] getPlatformProperties() throws CoreException { - IExecutionEnvironment[] envs = getMatchingEnvironments(); - if (envs.length == 0) - return new Dictionary[] {TargetPlatformHelper.getTargetEnvironment()}; - - // add java profiles for those EE's that have a .profile file in the current system bundle - ArrayList result = new ArrayList(envs.length); - for (int i = 0; i < envs.length; i++) { - Properties profileProps = getJavaProfileProperties(envs[i].getId()); - if (profileProps != null) { - Dictionary props = TargetPlatformHelper.getTargetEnvironment(); - String systemPackages = profileProps.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES); - if (systemPackages != null) - props.put(Constants.FRAMEWORK_SYSTEMPACKAGES, systemPackages); - String ee = profileProps.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT); - if (ee != null) - props.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, ee); - result.add(props); - } - } - if (result.size() > 0) - return (Dictionary[]) result.toArray(new Dictionary[result.size()]); - return new Dictionary[] {TargetPlatformHelper.getTargetEnvironment()}; - - } - - protected IExecutionEnvironment[] getMatchingEnvironments() throws CoreException { - IVMInstall install = VMHelper.getVMInstall(fLaunchConfiguration); - if (install == null) - return new IExecutionEnvironment[0]; - - 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()]); - } - - private Properties getJavaProfileProperties(String ee) { - IPluginModelBase model = PluginRegistry.findModel("system.bundle"); //$NON-NLS-1$ - if (model == null) - return null; - - File location = new File(model.getInstallLocation()); - String filename = ee.replace('/', '_') + ".profile"; //$NON-NLS-1$ - InputStream is = null; - ZipFile zipFile = null; - try { - // find the input stream to the profile properties file - if (location.isDirectory()) { - File file = new File(location, filename); - if (file.exists()) - is = new FileInputStream(file); - } else { - zipFile = null; - try { - zipFile = new ZipFile(location, ZipFile.OPEN_READ); - ZipEntry entry = zipFile.getEntry(filename); - if (entry != null) - is = zipFile.getInputStream(entry); - } catch (IOException e) { - // nothing to do - } - } - if (is != null) { - Properties profile = new Properties(); - profile.load(is); - return profile; - } - } catch (IOException e) { - // nothing to do - } finally { - if (is != null) - try { - is.close(); - } catch (IOException e) { - // nothing to do - } - if (zipFile != null) - try { - zipFile.close(); - } catch (IOException e) { - // nothing to do - } - } - return null; - } - - public boolean hasErrors() { - return fOperation.hasErrors(); - } - - public Map getInput() { - return fOperation.getResolverErrors(); - } - - public boolean isEmpty() { - return fOperation.getState().getHighestBundleId() == -1; - } - - protected State getState() { - return fOperation.getState(); - } - -} Index: src/org/eclipse/pde/internal/ui/launcher/LaunchConfigurationListener.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/launcher/LaunchConfigurationListener.java diff -N src/org/eclipse/pde/internal/ui/launcher/LaunchConfigurationListener.java --- src/org/eclipse/pde/internal/ui/launcher/LaunchConfigurationListener.java 27 May 2009 20:38:24 -0000 1.8 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,48 +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 - *******************************************************************************/ -package org.eclipse.pde.internal.ui.launcher; - -import java.io.File; -import org.eclipse.debug.core.*; -import org.eclipse.pde.internal.core.util.CoreUtility; - -public class LaunchConfigurationListener implements ILaunchConfigurationListener { - - /* (non-Javadoc) - * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationAdded(org.eclipse.debug.core.ILaunchConfiguration) - */ - public void launchConfigurationAdded(ILaunchConfiguration configuration) { - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationChanged(org.eclipse.debug.core.ILaunchConfiguration) - */ - public void launchConfigurationChanged(ILaunchConfiguration configuration) { - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse.debug.core.ILaunchConfiguration) - */ - public void launchConfigurationRemoved(ILaunchConfiguration configuration) { - File configDir = LaunchConfigurationHelper.getConfigurationLocation(configuration); - if (configDir.exists()) { - // rename the config area if it was auto-set by PDE when the launch configuration is renamed - ILaunchConfiguration destination = DebugPlugin.getDefault().getLaunchManager().getMovedTo(configuration); - boolean delete = true; - if (destination != null) { - delete = !configDir.renameTo(LaunchConfigurationHelper.getConfigurationLocation(destination)); - } - if (delete) - CoreUtility.deleteContent(configDir); - } - } - -} Index: src/org/eclipse/pde/internal/ui/launcher/PluginBlock.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/PluginBlock.java,v retrieving revision 1.19 diff -u -r1.19 PluginBlock.java --- src/org/eclipse/pde/internal/ui/launcher/PluginBlock.java 14 Aug 2009 18:48:01 -0000 1.19 +++ src/org/eclipse/pde/internal/ui/launcher/PluginBlock.java 21 Sep 2009 18:54:09 -0000 @@ -12,14 +12,18 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.launcher; +import org.eclipse.pde.launching.*; +import org.eclipse.pde.ui.launcher.AbstractLauncherTab; +import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut; + 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.*; import org.eclipse.pde.internal.core.util.IdUtil; -import org.eclipse.pde.internal.ui.IPDEUIConstants; -import org.eclipse.pde.ui.launcher.*; +import org.eclipse.pde.internal.launching.IPDEConstants; +import org.eclipse.pde.internal.launching.launcher.*; public class PluginBlock extends AbstractPluginBlock { @@ -216,7 +220,7 @@ String configType = fLaunchConfig.getType().getIdentifier(); String attribute = configType.equals(EclipseLaunchShortcut.CONFIGURATION_TYPE) ? IPDELauncherConstants.APPLICATION : IPDELauncherConstants.APP_TO_TEST; String application = fLaunchConfig.getAttribute(attribute, TargetPlatform.getDefaultApplication()); - if (!IPDEUIConstants.CORE_TEST_APPLICATION.equals(application)) + if (!IPDEConstants.CORE_TEST_APPLICATION.equals(application)) validateLaunchId(application); } } catch (CoreException e) { Index: src/org/eclipse/pde/internal/ui/launcher/EclipsePluginValidationOperation.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/launcher/EclipsePluginValidationOperation.java diff -N src/org/eclipse/pde/internal/ui/launcher/EclipsePluginValidationOperation.java --- src/org/eclipse/pde/internal/ui/launcher/EclipsePluginValidationOperation.java 15 Apr 2009 18:00:09 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,122 +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.HashMap; -import java.util.Map; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.debug.core.ILaunchConfiguration; -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.util.IdUtil; -import org.eclipse.pde.internal.ui.*; -import org.eclipse.pde.internal.ui.elements.NamedElement; -import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut; -import org.eclipse.pde.ui.launcher.IPDELauncherConstants; -import org.eclipse.swt.graphics.Image; - -public class EclipsePluginValidationOperation extends LaunchValidationOperation { - - private Map fExtensionErrors = new HashMap(2); - private static Object[] EMPTY = new Object[0]; - - public EclipsePluginValidationOperation(ILaunchConfiguration configuration) { - super(configuration); - } - - protected IPluginModelBase[] getModels() throws CoreException { - return BundleLauncherHelper.getMergedBundles(fLaunchConfiguration, false); - } - - public void run(IProgressMonitor monitor) throws CoreException { - super.run(monitor); - if (fExtensionErrors.size() > 0) - fExtensionErrors.clear(); - validateExtensions(); - } - - private void validateExtensions() { - try { - if (fLaunchConfiguration.getAttribute(IPDELauncherConstants.USE_PRODUCT, false)) { - String product = fLaunchConfiguration.getAttribute(IPDELauncherConstants.PRODUCT, (String) null); - if (product != null) { - validateExtension(product); - String application = getApplication(product); - if (application != null) - validateExtension(application); - } - } else { - String configType = fLaunchConfiguration.getType().getIdentifier(); - String attribute = configType.equals(EclipseLaunchShortcut.CONFIGURATION_TYPE) ? IPDELauncherConstants.APPLICATION : IPDELauncherConstants.APP_TO_TEST; - String application = fLaunchConfiguration.getAttribute(attribute, TargetPlatform.getDefaultApplication()); - if (!IPDEUIConstants.CORE_TEST_APPLICATION.equals(application)) { - validateExtension(application); - } - } - } catch (CoreException e) { - PDEPlugin.log(e); - } - } - - private String getApplication(String product) { - String bundleID = product.substring(0, product.lastIndexOf('.')); - BundleDescription bundle = getState().getBundle(bundleID, null); - if (bundle != null) { - IPluginModelBase model = PluginRegistry.findModel(bundle); - if (model != null) { - IPluginExtension[] extensions = model.getPluginBase().getExtensions(); - for (int i = 0; i < extensions.length; i++) { - IPluginExtension ext = extensions[i]; - String point = ext.getPoint(); - if ("org.eclipse.core.runtime.products".equals(point) //$NON-NLS-1$ - && product.equals(IdUtil.getFullId(ext))) { - if (ext.getChildCount() == 1) { - IPluginElement prod = (IPluginElement) ext.getChildren()[0]; - if (prod.getName().equals("product")) { //$NON-NLS-1$ - IPluginAttribute attr = prod.getAttribute("application"); //$NON-NLS-1$ - return attr != null ? attr.getValue() : null; - } - } - } - } - } - } - return null; - } - - private void validateExtension(String id) { - int index = id.lastIndexOf('.'); - if (index == -1) - return; - String bundleID = id.substring(0, index); - BundleDescription bundle = getState().getBundle(bundleID, null); - if (bundle == null) { - String name = NLS.bind(PDEUIMessages.EclipsePluginValidationOperation_pluginMissing, bundleID); - PDELabelProvider provider = PDEPlugin.getDefault().getLabelProvider(); - Image image = provider.get(PDEPluginImages.DESC_PLUGIN_OBJ); - fExtensionErrors.put(new NamedElement(name, image), EMPTY); - } - } - - public boolean hasErrors() { - return super.hasErrors() || fExtensionErrors.size() >= 1; - } - - public Map getInput() { - Map map = super.getInput(); - map.putAll(fExtensionErrors); - return map; - } - -} Index: src/org/eclipse/pde/internal/ui/launcher/LaunchPluginValidator.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/launcher/LaunchPluginValidator.java diff -N src/org/eclipse/pde/internal/ui/launcher/LaunchPluginValidator.java --- src/org/eclipse/pde/internal/ui/launcher/LaunchPluginValidator.java 13 Apr 2009 14:10:29 -0000 1.34 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,133 +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.util.*; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.*; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.pde.core.plugin.*; -import org.eclipse.pde.internal.core.PDECore; -import org.eclipse.pde.internal.core.SearchablePluginsManager; -import org.eclipse.pde.internal.ui.IPDEUIConstants; -import org.eclipse.pde.ui.launcher.IPDELauncherConstants; -import org.eclipse.swt.widgets.Display; - -public class LaunchPluginValidator { - - private static IPluginModelBase[] getSelectedWorkspacePlugins(ILaunchConfiguration configuration) throws CoreException { - - boolean usedefault = configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true); - boolean useFeatures = configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false); - - IPluginModelBase[] models = PluginRegistry.getWorkspaceModels(); - - if (usedefault || useFeatures || models.length == 0) - return models; - - Collection result = null; - Map bundles = BundleLauncherHelper.getWorkspaceBundleMap(configuration, null, IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS); - result = bundles.keySet(); - return (IPluginModelBase[]) result.toArray(new IPluginModelBase[result.size()]); - } - - /** - * - * @param configuration launchConfiguration to get the attribute value - * @param attribute launch configuration attribute to containing plug-in information - * @return a TreeSet containing IPluginModelBase objects which are represented by the value of the attribute - * @throws CoreException - */ - public static Set parsePlugins(ILaunchConfiguration configuration, String attribute) throws CoreException { - HashSet set = new HashSet(); - String ids = configuration.getAttribute(attribute, (String) null); - if (ids != null) { - String[] entries = ids.split(","); //$NON-NLS-1$ - Map unmatchedEntries = new HashMap(); - for (int i = 0; i < entries.length; i++) { - int index = entries[i].indexOf('@'); - if (index < 0) { // if no start levels, assume default - entries[i] = entries[i].concat("@default:default"); //$NON-NLS-1$ - index = entries[i].indexOf('@'); - } - String idVersion = entries[i].substring(0, index); - int versionIndex = entries[i].indexOf(BundleLauncherHelper.VERSION_SEPARATOR); - String id = (versionIndex > 0) ? idVersion.substring(0, versionIndex) : idVersion; - String version = (versionIndex > 0) ? idVersion.substring(versionIndex + 1) : null; - ModelEntry entry = PluginRegistry.findEntry(id); - if (entry != null) { - IPluginModelBase matchingModels[] = attribute.equals(IPDELauncherConstants.SELECTED_TARGET_PLUGINS) ? entry.getExternalModels() : entry.getWorkspaceModels(); - for (int j = 0; j < matchingModels.length; j++) { - if (matchingModels[j].isEnabled()) { - // TODO Very similar logic to BundleLauncherHelper - // the logic here is this (see bug 225644) - // a) if we come across a bundle that has the right version, immediately add it - // b) if there's no version, add it - // c) if there's only one instance of that bundle in the list of ids... add it - if (version == null || matchingModels[j].getPluginBase().getVersion().equals(version)) { - set.add(matchingModels[j]); - } else if (matchingModels.length == 1) { - if (unmatchedEntries.remove(id) == null) { - unmatchedEntries.put(id, matchingModels[j]); - } - } - } - } - } - } - set.addAll(unmatchedEntries.values()); - } - return set; - } - - public static IProject[] getAffectedProjects(ILaunchConfiguration config) throws CoreException { - // if restarting, no need to check projects for errors - if (config.getAttribute(IPDEUIConstants.RESTART, false)) - return new IProject[0]; - ArrayList projects = new ArrayList(); - IPluginModelBase[] models = getSelectedWorkspacePlugins(config); - for (int i = 0; i < models.length; i++) { - IProject project = models[i].getUnderlyingResource().getProject(); - if (project.hasNature(JavaCore.NATURE_ID)) - projects.add(project); - } - - // add fake "Java Search" project - SearchablePluginsManager manager = PDECore.getDefault().getSearchablePluginsManager(); - IJavaProject proxy = manager.getProxyProject(); - if (proxy != null) { - projects.add(proxy.getProject()); - } - return (IProject[]) projects.toArray(new IProject[projects.size()]); - } - - public static void runValidationOperation(final LaunchValidationOperation op, IProgressMonitor monitor) throws CoreException { - op.run(monitor); - if (op.hasErrors()) { - final int[] result = new int[1]; - final Display display = LauncherUtils.getDisplay(); - display.syncExec(new Runnable() { - public void run() { - PluginStatusDialog dialog = new PluginStatusDialog(display.getActiveShell()); - dialog.showCancelButton(true); - dialog.setInput(op.getInput()); - result[0] = dialog.open(); - } - }); - if (result[0] == IDialogConstants.CANCEL_ID) - throw new CoreException(Status.CANCEL_STATUS); - } - } - -} Index: src/org/eclipse/pde/internal/ui/launcher/ProgramBlock.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/ProgramBlock.java,v retrieving revision 1.14 diff -u -r1.14 ProgramBlock.java --- src/org/eclipse/pde/internal/ui/launcher/ProgramBlock.java 27 May 2009 20:38:24 -0000 1.14 +++ src/org/eclipse/pde/internal/ui/launcher/ProgramBlock.java 21 Sep 2009 18:54:09 -0000 @@ -11,6 +11,8 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.launcher; +import org.eclipse.pde.launching.IPDELauncherConstants; + import java.util.StringTokenizer; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; @@ -21,7 +23,6 @@ import org.eclipse.pde.internal.ui.PDEUIMessages; import org.eclipse.pde.internal.ui.SWTFactory; 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; Index: src/org/eclipse/pde/internal/ui/launcher/LauncherUtils.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/launcher/LauncherUtils.java diff -N src/org/eclipse/pde/internal/ui/launcher/LauncherUtils.java --- src/org/eclipse/pde/internal/ui/launcher/LauncherUtils.java 19 Jan 2009 20:53:09 -0000 1.114 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,413 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.io.*; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.jdt.core.*; -import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.osgi.service.datalocation.Location; -import org.eclipse.osgi.util.NLS; -import org.eclipse.pde.core.plugin.IPluginModelBase; -import org.eclipse.pde.core.plugin.PluginRegistry; -import org.eclipse.pde.internal.core.*; -import org.eclipse.pde.internal.core.util.CoreUtility; -import org.eclipse.pde.internal.ui.*; -import org.eclipse.pde.internal.ui.wizards.tools.OrganizeManifestsProcessor; -import org.eclipse.pde.ui.launcher.IPDELauncherConstants; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; -import org.osgi.framework.*; - -public class LauncherUtils { - - private static final String TIMESTAMP = "timestamp"; //$NON-NLS-1$ - private static final String FILE_NAME = "dep-timestamp.properties"; //$NON-NLS-1$ - private static Properties fLastRun; - - public static Display getDisplay() { - Display display = Display.getCurrent(); - if (display == null) { - display = Display.getDefault(); - } - return display; - } - - public final static Shell getActiveShell() { - IWorkbenchWindow window = PDEPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); - if (window == null) { - IWorkbenchWindow[] windows = PDEPlugin.getDefault().getWorkbench().getWorkbenchWindows(); - if (windows.length > 0) - return windows[0].getShell(); - } else - return window.getShell(); - return getDisplay().getActiveShell(); - } - - public static boolean clearWorkspace(ILaunchConfiguration configuration, String workspace, IProgressMonitor monitor) throws CoreException { - - // If the workspace is not defined, there is no workspace to clear - // What will happen is that the workspace chooser dialog will be - // brought up because no -data parameter will be specified on the - // launch - if (workspace.length() == 0) { - monitor.done(); - return true; - } - - // Check if the workspace is already in use, if so, open a message and stop the launch before clearing - boolean isLocked = false; - try { - BundleContext context = PDECore.getDefault().getBundleContext(); - ServiceReference[] references = context.getServiceReferences(Location.class.getName(), "(type=osgi.configuration.area)"); //$NON-NLS-1$ - if (references.length > 0) { - Object service = context.getService(references[0]); - if (service instanceof Location) { - URL workspaceURL = new Path(workspace).toFile().toURI().toURL(); - Location targetLocation = ((Location) service).createLocation(null, workspaceURL, false); - targetLocation.set(targetLocation.getDefault(), false); - isLocked = targetLocation.isLocked(); - } - } - } catch (InvalidSyntaxException e) { - PDECore.log(e); - isLocked = false; - } catch (MalformedURLException e) { - PDECore.log(e); - isLocked = false; - } catch (IOException e) { - PDECore.log(e); - isLocked = false; - } - - if (isLocked) { - generateErrorDialog(PDEUIMessages.LauncherUtils_workspaceLocked, NLS.bind(PDEUIMessages.LauncherUtils_cannotLaunchApplication, workspace)); - monitor.done(); - return false; - } - - File workspaceFile = new Path(workspace).toFile().getAbsoluteFile(); - if (configuration.getAttribute(IPDELauncherConstants.DOCLEAR, false) && workspaceFile.exists()) { - if (configuration.getAttribute(IPDELauncherConstants.ASKCLEAR, true)) { - int result; - if (configuration.getAttribute(IPDEUIConstants.DOCLEARLOG, false)) { - result = generateDialog(PDEUIMessages.LauncherUtils_clearLogFile); - } else { - result = generateDialog(NLS.bind(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_confirmDeleteWorkspace, workspaceFile.getPath())); - } - - if (result == 2 /*Cancel Button*/|| result == -1 /*Dialog close button*/) { - monitor.done(); - return false; - } else if (result == 0) { - if (configuration.getAttribute(IPDEUIConstants.DOCLEARLOG, false)) { - LauncherUtils.clearWorkspaceLog(workspace); - } else { - CoreUtility.deleteContent(workspaceFile); - } - } - } else if (configuration.getAttribute(IPDEUIConstants.DOCLEARLOG, false)) { - LauncherUtils.clearWorkspaceLog(workspace); - } else { - CoreUtility.deleteContent(workspaceFile); - } - } - - monitor.done(); - return true; - } - - public static boolean generateConfigIni() { - String message = PDEUIMessages.LauncherUtils_generateConfigIni; - return generateDialog(message) == 0; - } - - /** - * Creates a message dialog using a syncExec in case we are launching in the background. - * Dialog will be a question dialog with Yes, No and Cancel buttons. - * @param message Message to use in the dialog - * @return int representing the button clicked (-1 or 2 for cancel, 0 for yes, 1 for no). - */ - private static int generateDialog(final String message) { - final int[] result = new int[1]; - getDisplay().syncExec(new Runnable() { - public void run() { - String title = PDEUIMessages.LauncherUtils_title; - MessageDialog dialog = new MessageDialog(getActiveShell(), title, null, message, MessageDialog.QUESTION, new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL}, 0); - result[0] = dialog.open(); - } - }); - return result[0]; - } - - private static void generateErrorDialog(final String title, final String message) { - getDisplay().syncExec(new Runnable() { - public void run() { - MessageDialog dialog = new MessageDialog(getActiveShell(), title, null, message, MessageDialog.ERROR, new String[] {IDialogConstants.OK_LABEL}, 0); - dialog.open(); - } - }); - } - - public static void validateProjectDependencies(ILaunchConfiguration launch, final IProgressMonitor monitor) { - IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore(); - if (!store.getBoolean(IPreferenceConstants.PROP_AUTO_MANAGE)) - return; - - String timeStamp; - boolean useDefault, autoAdd; - try { - timeStamp = launch.getAttribute(TIMESTAMP, "0"); //$NON-NLS-1$ - autoAdd = launch.getAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); - useDefault = launch.getAttribute(IPDELauncherConstants.USE_DEFAULT, true); - useDefault |= launch.getAttribute(IPDELauncherConstants.USEFEATURES, false); - final ArrayList projects = new ArrayList(); - if (useDefault) - handleUseDefault(timeStamp, projects); - else if (autoAdd) - handleDeselectedPlugins(launch, timeStamp, projects); - else - handleSelectedPlugins(launch, timeStamp, projects); - - if (!projects.isEmpty()) - Display.getDefault().syncExec(new Runnable() { - public void run() { - OrganizeManifestsProcessor processor = new OrganizeManifestsProcessor(projects); - initializeProcessor(processor); - try { - Change change = processor.createChange(monitor); - change.perform(monitor); - // update table for each project with current time stamp - Properties table = getLastRun(); - String ts = Long.toString(System.currentTimeMillis()); - Iterator it = projects.iterator(); - while (it.hasNext()) - table.put(((IProject) it.next()).getName(), ts); - } catch (OperationCanceledException e) { - } catch (CoreException e) { - } - } - }); - - ILaunchConfigurationWorkingCopy wc = null; - if (launch.isWorkingCopy()) - wc = (ILaunchConfigurationWorkingCopy) launch; - else - wc = launch.getWorkingCopy(); - wc.setAttribute(TIMESTAMP, Long.toString(System.currentTimeMillis())); - wc.doSave(); - } catch (CoreException e) { - } - } - - private static void initializeProcessor(OrganizeManifestsProcessor processor) { - processor.setAddMissing(false); - processor.setRemoveUnresolved(false); - processor.setModifyDep(false); - processor.setRemoveLazy(false); - processor.setRemoveUselessFiles(false); - processor.setAddDependencies(true); - processor.setCalculateUses(false); - processor.setMarkInternal(false); - processor.setPrefixIconNL(false); - processor.setUnusedDependencies(false); - processor.setUnusedKeys(false); - } - - private static String getTimeStamp(IProject project) { - IJavaProject jp = JavaCore.create(project); - try { - long timeStamp = 0; - IClasspathEntry[] entries = jp.getResolvedClasspath(true); - for (int i = 0; i < entries.length; i++) { - if (entries[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { - File file; - IPath location = entries[i].getOutputLocation(); - if (location == null) - location = jp.getOutputLocation(); - IResource res = project.getWorkspace().getRoot().findMember(location); - IPath path = res == null ? null : res.getLocation(); - if (path == null) - continue; - file = path.toFile(); - Stack files = new Stack(); - files.push(file); - while (!files.isEmpty()) { - file = (File) files.pop(); - if (file.isDirectory()) { - File[] children = file.listFiles(); - if (children != null) { - for (int j = 0; j < children.length; j++) - files.push(children[j]); - } - } else if (file.getName().endsWith(".class") && timeStamp < file.lastModified()) //$NON-NLS-1$ - timeStamp = file.lastModified(); - } - } - } - String[] otherFiles = {ICoreConstants.BUNDLE_FILENAME_DESCRIPTOR, ICoreConstants.BUILD_FILENAME_DESCRIPTOR}; - for (int i = 0; i < otherFiles.length; i++) { - IResource file = project.getFile(otherFiles[i]); - if (file != null) { - long fileTimeStamp = file.getRawLocation().toFile().lastModified(); - if (timeStamp < fileTimeStamp) - timeStamp = fileTimeStamp; - } - } - return Long.toString(timeStamp); - } catch (JavaModelException e) { - } - return "0"; //$NON-NLS-1$ - } - - private static void handleUseDefault(String launcherTimeStamp, ArrayList projects) { - IProject[] projs = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - for (int i = 0; i < projs.length; i++) { - if (!WorkspaceModelManager.isPluginProject(projs[i])) - continue; - String timestamp = getTimeStamp(projs[i]); - if (timestamp.compareTo(launcherTimeStamp) > 0 && shouldAdd(projs[i], launcherTimeStamp, timestamp)) - projects.add(projs[i]); - } - } - - private static void handleSelectedPlugins(ILaunchConfiguration config, String timeStamp, ArrayList projects) throws CoreException { - Map selectedPlugins = BundleLauncherHelper.getWorkspaceBundleMap(config, null, IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS); - Iterator it = selectedPlugins.keySet().iterator(); - while (it.hasNext()) { - IPluginModelBase model = (IPluginModelBase) it.next(); - IResource res = model.getUnderlyingResource(); - if (res != null) { - IProject project = res.getProject(); - String projTimeStamp = getTimeStamp(project); - if (projTimeStamp.compareTo(timeStamp) > 0 && shouldAdd(project, timeStamp, projTimeStamp)) - projects.add(project); - } - } - } - - private static void handleDeselectedPlugins(ILaunchConfiguration config, String launcherTimeStamp, ArrayList projects) throws CoreException { - Map deSelectedPlugins = BundleLauncherHelper.getWorkspaceBundleMap(config, null, IPDELauncherConstants.DESELECTED_WORKSPACE_PLUGINS); - IProject[] projs = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - for (int i = 0; i < projs.length; i++) { - if (!WorkspaceModelManager.isPluginProject(projs[i])) - continue; - IPluginModelBase base = PluginRegistry.findModel(projs[i]); - if (base == null || base != null && deSelectedPlugins.containsKey(base)) - continue; - String timestamp = getTimeStamp(projs[i]); - if (timestamp.compareTo(launcherTimeStamp) > 0 && shouldAdd(projs[i], launcherTimeStamp, timestamp)) - projects.add(projs[i]); - } - } - - public static final void shutdown() { - if (fLastRun == null) - return; - FileOutputStream stream = null; - try { - stream = new FileOutputStream(new File(getDirectory(), FILE_NAME)); - fLastRun.store(stream, "Cached timestamps"); //$NON-NLS-1$ - stream.flush(); - stream.close(); - } catch (IOException e) { - PDECore.logException(e); - } finally { - try { - if (stream != null) - stream.close(); - } catch (IOException e1) { - } - } - } - - private static File getDirectory() { - IPath path = PDECore.getDefault().getStateLocation().append(".cache"); //$NON-NLS-1$ - File directory = new File(path.toOSString()); - if (!directory.exists() || !directory.isDirectory()) - directory.mkdirs(); - return directory; - } - - private static Properties getLastRun() { - if (fLastRun == null) { - fLastRun = new Properties(); - FileInputStream fis = null; - try { - File file = new File(getDirectory(), FILE_NAME); - if (file.exists()) { - fis = new FileInputStream(file); - fLastRun.load(fis); - fis.close(); - } - } catch (IOException e) { - PDECore.logException(e); - } finally { - try { - if (fis != null) - fis.close(); - } catch (IOException e1) { - } - } - } - return fLastRun; - } - - private static boolean shouldAdd(IProject proj, String launcherTS, String fileSystemTS) { - String projTS = (String) getLastRun().get(proj.getName()); - if (projTS == null) - return true; - return ((projTS.compareTo(launcherTS) < 0) || (projTS.compareTo(fileSystemTS) < 0)); - } - - public static boolean requiresUI(ILaunchConfiguration configuration) { - try { - String projectID = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$ - if (projectID.length() > 0) { - IResource project = PDEPlugin.getWorkspace().getRoot().findMember(projectID); - if (project instanceof IProject) { - IPluginModelBase model = PluginRegistry.findModel((IProject) project); - if (model != null) { - Set plugins = DependencyManager.getSelfAndDependencies(model); - return plugins.contains("org.eclipse.swt"); //$NON-NLS-1$ - } - } - } - } catch (CoreException e) { - } - return true; - } - - public static boolean clearWorkspaceLog(String workspace) { - File logFile = new File(workspace, ".metadata" + File.separator + ".log"); //$NON-NLS-1$ //$NON-NLS-2$ - if (logFile != null && logFile.exists()) { - return logFile.delete(); - } - return true; - } - - public static IStatus createErrorStatus(String message) { - return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), IStatus.OK, message, null); - } - -} Index: src/org/eclipse/pde/internal/ui/launcher/JREBlock.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/JREBlock.java,v retrieving revision 1.18 diff -u -r1.18 JREBlock.java --- src/org/eclipse/pde/internal/ui/launcher/JREBlock.java 28 Apr 2009 21:47:12 -0000 1.18 +++ src/org/eclipse/pde/internal/ui/launcher/JREBlock.java 21 Sep 2009 18:54:09 -0000 @@ -11,6 +11,10 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.launcher; +import org.eclipse.pde.launching.IPDELauncherConstants; + +import org.eclipse.pde.internal.launching.launcher.VMHelper; + import java.util.Arrays; import java.util.Comparator; import org.eclipse.core.runtime.*; @@ -25,7 +29,6 @@ import org.eclipse.pde.internal.ui.SWTFactory; import org.eclipse.pde.internal.ui.util.SWTUtil; 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; Index: src/org/eclipse/pde/internal/ui/launcher/ConfigurationAreaBlock.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/ConfigurationAreaBlock.java,v retrieving revision 1.13 diff -u -r1.13 ConfigurationAreaBlock.java --- src/org/eclipse/pde/internal/ui/launcher/ConfigurationAreaBlock.java 11 Feb 2008 15:54:05 -0000 1.13 +++ src/org/eclipse/pde/internal/ui/launcher/ConfigurationAreaBlock.java 21 Sep 2009 18:54:09 -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,12 +10,13 @@ *******************************************************************************/ 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.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; Index: src/org/eclipse/pde/internal/ui/wizards/exports/BaseExportWizard.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/BaseExportWizard.java,v retrieving revision 1.46 diff -u -r1.46 BaseExportWizard.java --- src/org/eclipse/pde/internal/ui/wizards/exports/BaseExportWizard.java 27 May 2009 20:38:23 -0000 1.46 +++ src/org/eclipse/pde/internal/ui/wizards/exports/BaseExportWizard.java 21 Sep 2009 18:54:10 -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 @@ -14,10 +14,12 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.Wizard; -import org.eclipse.pde.internal.ui.*; +import org.eclipse.pde.internal.launching.ILaunchingPreferenceConstants; +import org.eclipse.pde.internal.ui.PDEPlugin; +import org.eclipse.pde.internal.ui.PDEUIMessages; import org.eclipse.ui.*; -public abstract class BaseExportWizard extends Wizard implements IExportWizard, IPreferenceConstants { +public abstract class BaseExportWizard extends Wizard implements IExportWizard, ILaunchingPreferenceConstants { protected IStructuredSelection fSelection; Index: src/org/eclipse/pde/internal/ui/wizards/feature/PluginListPage.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/feature/PluginListPage.java,v retrieving revision 1.19 diff -u -r1.19 PluginListPage.java --- src/org/eclipse/pde/internal/ui/wizards/feature/PluginListPage.java 30 Jul 2008 21:25:34 -0000 1.19 +++ src/org/eclipse/pde/internal/ui/wizards/feature/PluginListPage.java 21 Sep 2009 18:54:10 -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 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.wizards.feature; +import org.eclipse.pde.launching.IPDELauncherConstants; + import com.ibm.icu.text.Collator; import java.util.TreeSet; import org.eclipse.core.runtime.CoreException; @@ -25,7 +27,6 @@ import org.eclipse.pde.internal.ui.elements.DefaultContentProvider; import org.eclipse.pde.internal.ui.wizards.ListUtil; import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut; -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/wizards/feature/CreateFeatureProjectFromLaunchOperation.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/feature/CreateFeatureProjectFromLaunchOperation.java,v retrieving revision 1.5 diff -u -r1.5 CreateFeatureProjectFromLaunchOperation.java --- src/org/eclipse/pde/internal/ui/wizards/feature/CreateFeatureProjectFromLaunchOperation.java 13 Apr 2009 14:10:29 -0000 1.5 +++ src/org/eclipse/pde/internal/ui/wizards/feature/CreateFeatureProjectFromLaunchOperation.java 21 Sep 2009 18:54:10 -0000 @@ -12,6 +12,10 @@ package org.eclipse.pde.internal.ui.wizards.feature; +import org.eclipse.pde.launching.IPDELauncherConstants; + +import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper; + import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -21,9 +25,7 @@ import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel; import org.eclipse.pde.internal.core.ifeature.IFeature; -import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper; import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut; -import org.eclipse.pde.ui.launcher.IPDELauncherConstants; import org.eclipse.swt.widgets.Shell; public class CreateFeatureProjectFromLaunchOperation extends CreateFeatureProjectOperation { Index: plugin.xml =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/plugin.xml,v retrieving revision 1.471 diff -u -r1.471 plugin.xml --- plugin.xml 22 Jun 2009 16:20:00 -0000 1.471 +++ plugin.xml 21 Sep 2009 18:54:08 -0000 @@ -18,7 +18,6 @@ - @@ -895,42 +894,6 @@ - - - - - - - - - - - - - - - - - - - - - - @@ -2026,5 +1961,68 @@ tooltip="%showErrorInStackTraceConsoleAction.label"> - > + + + + + + + + + + + + + + + + + + + + + + + Index: plugin.properties =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/plugin.properties,v retrieving revision 1.230 diff -u -r1.230 plugin.properties --- plugin.properties 22 Apr 2009 14:36:45 -0000 1.230 +++ plugin.properties 21 Sep 2009 18:54:07 -0000 @@ -20,13 +20,6 @@ expoint.samples.name = Code Samples expoint.osgiLauncher.name = OSGi Launcher -PDELaunchDelegate.name=Eclipse Application Launcher -PDELaunchDelegate.description=The Eclipse Application launcher is used to run or debug a separate instance of an Eclipse application -OSGiLaunchDelegate.name=OSGi Framework Launcher -OSGiLaunchDelegate.description=The OSGi Framework launcher is used to launch an OSGi framework and run or debug OSGi bundles -JUnitPluginLaunchDelegate.name= JUnit Plugin Test Launcher -JUnitPluginLaunchDelegate.description=The JUnit Plugin Test launcher is used to run and debug test suites for plug-in projects - RunPDELaunchShortcut.description=Runs a separate Eclipse application DebugPDELaunchShortcut.description=Debugs a separate Eclipse application RunOSGiLaunchShortcut.description=Runs an OSGi framework @@ -132,16 +125,12 @@ launcher.shortcut.label= Eclipse Application EclipseApplicationShortcut.description.debug = Debug Eclipse Application EclipseApplicationShortcut.description.run = Run Eclipse Application -Equinox.shortcut.label = Equinox OSGiShortcut.description.debug = Debug OSGi Framework OSGiShortcut.description.run = Run OSGi Framework launcher.junit.name = JUnit Plug-in Test JUnitApplicationShortcut.description.debug = Debug JUnit Plug-in Test JUnitApplicationShortcut.description.run = Run JUnit Plug-in Test -launchConfigurationType.name = Eclipse Application -launcher.framework.name = OSGi Framework - osgiLauncherTabGroup.description.debug=Create a configuration to launch the OSGi framework in debug mode. osgiLauncherTabGroup.description.run=Create a configuration to launch the OSGi framework. workbenchLauncherTabGroup.description.debug=Create a configuration to launch an Eclipse application in debug mode. @@ -182,7 +171,6 @@ editor.target.name = Target Editor fontDefinition.label.0 = Manifest compare text font fontDefinition.description.0 = The MANIFEST.MF compare text font is used by Bundle manifest compare/merge tools. -pde.sourcelocator = PDE Source Lookup Director category.source.name = Manifest Editor Source category.source.description = PDE Source Page actions Index: src/org/eclipse/pde/internal/ui/IPDEUIConstants.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/IPDEUIConstants.java,v retrieving revision 1.35 diff -u -r1.35 IPDEUIConstants.java --- src/org/eclipse/pde/internal/ui/IPDEUIConstants.java 13 Apr 2009 19:11:10 -0000 1.35 +++ src/org/eclipse/pde/internal/ui/IPDEUIConstants.java 21 Sep 2009 18:54:08 -0000 @@ -12,8 +12,9 @@ package org.eclipse.pde.internal.ui; import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.pde.internal.launching.IPDEConstants; -public interface IPDEUIConstants { +public interface IPDEUIConstants extends IPDEConstants { String PLUGIN_ID = "org.eclipse.pde.ui"; //$NON-NLS-1$ String MANIFEST_EDITOR_ID = PLUGIN_ID + ".manifestEditor"; //$NON-NLS-1$ @@ -40,19 +41,6 @@ String PLUGIN_DOC_ROOT = "/org.eclipse.pde.doc.user/"; //$NON-NLS-1$ - // JUnit application identifiers - String LEGACY_UI_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.legacytestapplication"; //$NON-NLS-1$ - String NON_UI_THREAD_APPLICATION = "org.eclipse.pde.junit.runtime.nonuithreadtestapplication"; //$NON-NLS-1$ - String UI_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.uitestapplication"; //$NON-NLS-1$ - String CORE_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.coretestapplication"; //$NON-NLS-1$ - - /** - * Launch configuration attribute key. The value is a boolean specifies - * whether the launch configuration is being restarted. This does not need to - * be promoted to IPDELauncherConstants since clients should not need to know - * about restarts. - */ - String RESTART = "restart"; //$NON-NLS-1$ /** * Launch configuration attribute key. The value is a boolean specifying * whether the workspace log for an Eclipse application should be cleared @@ -60,9 +48,6 @@ * * TODO, move to IPDELauncherConstants in 3.4 */ - String DOCLEARLOG = "clearwslog"; //$NON-NLS-1$ - String LAUNCHER_PDE_VERSION = "pde.version"; //$NON-NLS-1$ - String APPEND_ARGS_EXPLICITLY = "append.args"; //$NON-NLS-1$ String GENERATED_CONFIG = "pde.generated.config"; //$NON-NLS-1$ } Index: src/org/eclipse/pde/internal/ui/pderesources.properties =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties,v retrieving revision 1.1097 diff -u -r1.1097 pderesources.properties --- src/org/eclipse/pde/internal/ui/pderesources.properties 2 Sep 2009 21:22:55 -0000 1.1097 +++ src/org/eclipse/pde/internal/ui/pderesources.properties 21 Sep 2009 18:54:09 -0000 @@ -548,19 +548,12 @@ ConfigurationTab_fileDialogMessage=Select a config.ini file: -WorkbenchLauncherConfigurationDelegate_noJRE = Cannot locate JRE definition: "{0}". Launch aborted. -WorkbenchLauncherConfigurationDelegate_jrePathNotFound = The installation path to the specified JRE could not be found. Launch aborted. -WorkbenchLauncherConfigurationDelegate_badFeatureSetup = When in feature mode, plug-ins must be in the 'plugins' directory and features in 'features' directory in the workspace. -WorkbenchLauncherConfigurationDelegate_noStartup = Launching failed. Bootstrap code cannot be found. WorkbenchLauncherConfigurationDelegate_confirmDeleteWorkspace = Do you really want to clear the run-time workspace data in {0}? -JUnitLaunchConfiguration_error_notaplugin = Could not launch the JUnit plug-in tests because project ''{0}'' is not a plug-in project. -JUnitLaunchConfiguration_error_missingPlugin = Required plug-in ''{0}'' could not be found. Launcher_error_title=Launch Error LauncherSection_desc=Customize the executable that is used to launch the product. LauncherSection_ico=Use a single ICO file containing the 6 images: LauncherUtils_workspaceLocked=Workspace Cannot Be Locked -LauncherUtils_cannotLaunchApplication=Could not launch the application because the associated workspace is currently in use by another Eclipse application.\n\n{0} LauncherUtils_clearLogFile=Do you really want to clear the log file? LauncherUtils_title=Launcher LauncherPage_title=Launching @@ -568,7 +561,6 @@ LauncherSection_icon=Icon: LauncherSection_tiny=Tiny: Launcher_error_code13=The application could not start. Would you like to view the log? -Launcher_error_code15=Could not launch the configuration because the associated workspace is currently in use. Launcher_error_displayInLogView=Yes, in the Error Log view LauncherUtils_generateConfigIni=The config.ini template file you specified does not exist. Continue launching with a generated config.ini file? Launcher_error_displayInSystemEditor=Yes, in an editor @@ -2008,7 +2000,6 @@ InternationalizeWizard_NLSFragmentGenerator_errorMessage = An error occured while generating an NL Fragment. MainTab_jreSection = Java Runtime Environment -EquinoxLaunchConfiguration_oldTarget=The org.eclipse.osgi plug-in is missing from this configuration. EquinoxPluginBlock_levelColumn=Start Level EquinoxPluginsTab_defaultStart=Default S&tart level: EquinoxPluginBlock_autoColumn=Auto-Start @@ -2185,8 +2176,6 @@ EditorSourcePage_name=Source EditTargetNode_0=New Target Definition OSGiBundlesTab_frameworkLabel=&Framework: -OSGiLaunchConfiguration_cannotFindLaunchConfiguration=Cannot find the {0} OSGi framework. -OSGiLaunchConfiguration_selected=selected OSGiFrameworkPreferencePage_default=(default) OSGiFrameworkPreferencePage_installed=Installed OSGi frameworks: OSGiFrameworkPreferencePage_installed_nolink=Installed OSGi frameworks: @@ -2218,7 +2207,6 @@ UpdateSplashHandlerInModelAction_nameEnterprise=Enterprise UpdateSplashProgressAction_msgErrorTextFileBuffer=Text file buffer is NULL UpdateSplashHandlerInModelAction_nameLanguages=Languages -EclipsePluginValidationOperation_pluginMissing={0} is missing SplashProgressSection_progressName=Customization SplashProgressSection_progressSectionDesc=Create a custom splash screen using one of the provided templates or by adding a progress bar and message. UpdateSplashHandlerInModelAction_templateTypeInteractive=Interactive - A simulated log-in session @@ -2274,8 +2262,6 @@ PDECompilersConfigurationBlock_warning = Warning PDECompilersConfigurationBlock_ignore = Ignore -VMHelper_cannotFindExecEnv=Cannot locate Execution Environment definition: "{0}". Launch aborted. - LicensingPage_title=Licensing LicenseSection_title=License LicenseSection_description=Specify the license text and URL for the product. Index: src/org/eclipse/pde/internal/ui/PDEPlugin.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPlugin.java,v retrieving revision 1.60 diff -u -r1.60 PDEPlugin.java --- src/org/eclipse/pde/internal/ui/PDEPlugin.java 13 Apr 2009 14:52:48 -0000 1.60 +++ src/org/eclipse/pde/internal/ui/PDEPlugin.java 21 Sep 2009 18:54:08 -0000 @@ -16,12 +16,10 @@ import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.*; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.ILaunchConfigurationListener; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.pde.internal.core.PDEPreferencesManager; -import org.eclipse.pde.internal.ui.launcher.*; +import org.eclipse.pde.internal.ui.launcher.PDELogFileProvider; import org.eclipse.pde.internal.ui.util.SWTUtil; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; @@ -33,18 +31,13 @@ import org.eclipse.ui.internal.views.log.LogFilesManager; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.texteditor.IDocumentProvider; -import org.osgi.framework.*; +import org.osgi.framework.BundleContext; public class PDEPlugin extends AbstractUIPlugin implements IPDEUIConstants { // Shared instance private static PDEPlugin fInstance; - // Launches listener - private LaunchListener fLaunchListener; - - private BundleContext fBundleContext; - private Hashtable fCounters; // Provides Launch Configurations log files to Log View @@ -55,19 +48,11 @@ private PDELabelProvider fLabelProvider; /** - * Utility class to help setup the launch configuration listener - * without loading the debug plugin - */ - private DebugPluginUtil fDebugPluginUtil; - - /** * The shared text file document provider. * @since 3.2 */ private IDocumentProvider fTextFileDocumentProvider; - private OSGiFrameworkManager fOSGiFrameworkManager; - private PDEPreferencesManager fPreferenceManager; public PDEPlugin() { @@ -183,49 +168,14 @@ */ public void start(BundleContext context) throws Exception { super.start(context); - fBundleContext = context; - setupLaunchConfigurationListener(); fLogFileProvider = new PDELogFileProvider(); LogFilesManager.addLogFileProvider(fLogFileProvider); } - /** - * Add the launch configuration listener if the debug plugin - * is started. Otherwise, setup a bundle listener to install - * the listener when the debug plugin loads. - * @param context bundle context needed to get current bundles - */ - private void setupLaunchConfigurationListener() { - boolean listenerStarted = false; - Bundle bundle = Platform.getBundle("org.eclipse.debug.core"); //$NON-NLS-1$ - if (bundle != null && bundle.getState() == Bundle.ACTIVE) { - fDebugPluginUtil = new DebugPluginUtil(); - fDebugPluginUtil.addListener(); - listenerStarted = true; - } - if (!listenerStarted) { - fBundleContext.addBundleListener(new BundleListener() { - public void bundleChanged(BundleEvent event) { - if (event.getType() == BundleEvent.STARTED && "org.eclipse.debug.core".equals(event.getBundle().getSymbolicName())) { //$NON-NLS-1$ - fDebugPluginUtil = new DebugPluginUtil(); - fDebugPluginUtil.addListener(); - fBundleContext.removeBundleListener(this); - } - } - }); - } - } - - public BundleContext getBundleContext() { - return fBundleContext; - } - /* (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ public void stop(BundleContext context) throws Exception { - if (fLaunchListener != null) - fLaunchListener.shutdown(); if (fFormColors != null) { fFormColors.dispose(); fFormColors = null; @@ -234,14 +184,10 @@ fLabelProvider.dispose(); fLabelProvider = null; } - if (fDebugPluginUtil != null) { - fDebugPluginUtil.removeListener(); - } if (fLogFileProvider != null) { LogFilesManager.removeLogFileProvider(fLogFileProvider); fLogFileProvider = null; } - LauncherUtils.shutdown(); super.stop(context); } @@ -251,18 +197,6 @@ return fLabelProvider; } - public LaunchListener getLaunchListener() { - if (fLaunchListener == null) - fLaunchListener = new LaunchListener(); - return fLaunchListener; - } - - public OSGiFrameworkManager getOSGiFrameworkManager() { - if (fOSGiFrameworkManager == null) - fOSGiFrameworkManager = new OSGiFrameworkManager(); - return fOSGiFrameworkManager; - } - public static boolean isFullNameModeEnabled() { IPreferenceStore store = getDefault().getPreferenceStore(); return store.getString(IPreferenceConstants.PROP_SHOW_OBJECTS).equals(IPreferenceConstants.VALUE_USE_NAMES); @@ -280,26 +214,4 @@ return fTextFileDocumentProvider; } - /** - * Utility class that creates and controls a the PDE launch configuration listener. - * This is done in a separate class to avoid loading the debug plugin. - * @since 3.4 - */ - private class DebugPluginUtil { - private ILaunchConfigurationListener fLaunchConfigurationListener; - - public void addListener() { - if (fLaunchConfigurationListener == null) { - fLaunchConfigurationListener = new LaunchConfigurationListener(); - } - DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(fLaunchConfigurationListener); - } - - public void removeListener() { - if (fLaunchConfigurationListener != null) { - DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(fLaunchConfigurationListener); - fLaunchConfigurationListener = null; - } - } - } } Index: src/org/eclipse/pde/internal/ui/IPreferenceConstants.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/IPreferenceConstants.java,v retrieving revision 1.29 diff -u -r1.29 IPreferenceConstants.java --- src/org/eclipse/pde/internal/ui/IPreferenceConstants.java 14 Apr 2009 21:36:31 -0000 1.29 +++ src/org/eclipse/pde/internal/ui/IPreferenceConstants.java 21 Sep 2009 18:54:08 -0000 @@ -11,18 +11,19 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui; +import org.eclipse.pde.internal.launching.ILaunchingPreferenceConstants; + /** * Listing of constants used in PDE preferences * * @noimplement This interface is not intended to be implemented by clients. */ -public interface IPreferenceConstants { +public interface IPreferenceConstants extends ILaunchingPreferenceConstants { // Main preference page public static final String PROP_SHOW_OBJECTS = "Preferences.MainPage.showObjects"; //$NON-NLS-1$ public static final String VALUE_USE_IDS = "useIds"; //$NON-NLS-1$ public static final String VALUE_USE_NAMES = "useNames"; //$NON-NLS-1$ - public static final String PROP_AUTO_MANAGE = "Preferences.MainPage.automanageDependencies"; //$NON-NLS-1$ public static final String PROP_SHOW_SOURCE_BUNDLES = "Preferences.MainPage.showSourceBundles"; //$NON-NLS-1$ public static final String OVERWRITE_BUILD_FILES_ON_EXPORT = "Preferences.MainPage.overwriteBuildFilesOnExport"; //$NON-NLS-1$ public static final String PROP_PROMPT_REMOVE_TARGET = "Preferences.MainPage.promptRemoveTarget"; //$NON-NLS-1$ @@ -37,7 +38,4 @@ public static final String DEPS_VIEW_SHOW_CALLERS = "DependenciesView.show.callers"; //$NON-NLS-1$ public static final String DEPS_VIEW_SHOW_LIST = "DependenciesView.show.list"; //$NON-NLS-1$ public static final String DEPS_VIEW_SHOW_STATE = "DependenciesView.show.state"; //$NON-NLS-1$ - - // OSGi Frameworks - public static final String DEFAULT_OSGI_FRAMEOWRK = "Preference.default.osgi.framework"; //$NON-NLS-1$ } Index: src/org/eclipse/pde/internal/ui/PDEUIMessages.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java,v retrieving revision 1.444 diff -u -r1.444 PDEUIMessages.java --- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 2 Sep 2009 21:22:55 -0000 1.444 +++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 21 Sep 2009 18:54:08 -0000 @@ -52,8 +52,6 @@ public static String DependencyPropertiesDialog_exportGroupText; - public static String EclipsePluginValidationOperation_pluginMissing; - public static String ExternalizeStringsOperation_editNames_addComment; public static String ExternalizeStringsOperation_editNames_insertProperty; @@ -179,8 +177,6 @@ public static String LauncherUtils_workspaceLocked; - public static String LauncherUtils_cannotLaunchApplication; - public static String LauncherUtils_clearLogFile; public static String LauncherUtils_generateConfigIni; @@ -895,13 +891,7 @@ public static String ConfigurationSection_selection; public static String ConfigurationTab_fileDialogMessage; - public static String WorkbenchLauncherConfigurationDelegate_noJRE; - public static String WorkbenchLauncherConfigurationDelegate_jrePathNotFound; - public static String WorkbenchLauncherConfigurationDelegate_badFeatureSetup; - public static String WorkbenchLauncherConfigurationDelegate_noStartup; public static String WorkbenchLauncherConfigurationDelegate_confirmDeleteWorkspace; - public static String JUnitLaunchConfiguration_error_notaplugin; - public static String JUnitLaunchConfiguration_error_missingPlugin; public static String Launcher_error_title; public static String LauncherSection_desc; @@ -910,7 +900,6 @@ public static String LauncherSection_icon; public static String LauncherSection_tiny; public static String Launcher_error_code13; - public static String Launcher_error_code15; public static String Launcher_error_displayInLogView; public static String Launcher_error_displayInSystemEditor; public static String LauncherSection_browse; @@ -933,8 +922,6 @@ public static String OpenLogDialog_cannotDisplay; public static String OSGiBundlesTab_frameworkLabel; - public static String OSGiLaunchConfiguration_cannotFindLaunchConfiguration; - public static String OSGiLaunchConfiguration_selected; // Preferences #################################### public static String Preferences_MainPage_Description; @@ -2103,8 +2090,6 @@ public static String EquinoxSettingsTab_name; - public static String EquinoxLaunchConfiguration_oldTarget; - public static String ModelChangeLabelProvider_instance; public static String ModelChangeLabelProvider_instances; @@ -2758,8 +2743,6 @@ public static String HyperlinkActionOpenBundle; public static String HyperlinkActionOpenPackage; - public static String VMHelper_cannotFindExecEnv; - public static String HyperlinkActionOpenResource; public static String HyperlinkActionOpenSchema; public static String HyperlinkActionOpenTranslation; Index: src/org/eclipse/pde/internal/ui/editor/plugin/DependencyManagementSection.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/DependencyManagementSection.java,v retrieving revision 1.25 diff -u -r1.25 DependencyManagementSection.java --- src/org/eclipse/pde/internal/ui/editor/plugin/DependencyManagementSection.java 4 Jul 2009 11:18:04 -0000 1.25 +++ src/org/eclipse/pde/internal/ui/editor/plugin/DependencyManagementSection.java 21 Sep 2009 18:54:09 -0000 @@ -19,7 +19,6 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.action.*; -import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.*; @@ -33,6 +32,8 @@ import org.eclipse.pde.internal.core.plugin.ExternalPluginModel; import org.eclipse.pde.internal.core.plugin.WorkspacePluginModel; import org.eclipse.pde.internal.core.text.build.BuildEntry; +import org.eclipse.pde.internal.launching.ILaunchingPreferenceConstants; +import org.eclipse.pde.internal.launching.PDELaunchingPlugin; import org.eclipse.pde.internal.ui.*; import org.eclipse.pde.internal.ui.dialogs.PluginSelectionDialog; import org.eclipse.pde.internal.ui.editor.*; @@ -393,8 +394,8 @@ entry.addToken(pmodel.getPlugin().getId()); } markDirty(); - IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore(); - store.setDefault(IPreferenceConstants.PROP_AUTO_MANAGE, true); + PDEPreferencesManager store = PDELaunchingPlugin.getDefault().getPreferenceManager(); + store.setDefault(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE, true); } catch (CoreException e) { PDEPlugin.logException(e); } Index: schema/osgiFrameworks.exsd =================================================================== RCS file: schema/osgiFrameworks.exsd diff -N schema/osgiFrameworks.exsd --- schema/osgiFrameworks.exsd 17 Sep 2006 08:48:15 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,159 +0,0 @@ - - - - - - - - - <p> -This extension point is used to register new OSGi frameworks. Each framework is associated with a launcher delegate that is called when the OSGi framework is selected in the <b>OSGi Framework</b> launch configuration. -</p> -<p>Registered OSGi frameworks appear on the <b>Plug-in Development > OSGi frameworks</b> preference page, where a default framework can be set. -</p> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - a unique identifier of the framework - - - - - - - human-readable name of the OSGi framework - - - - - - - - - - a launch configuration delegate to launch the OSGi framework. The value of this attribute is the fully qualified name of the Java class that extends <code>org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration</code>. - - - - - - - - - - initializes new OSGi Framework launch configurations with suitable defaults. The value of this attribute must be a fully-qualified name of a Java class that extends the default implementation <code>org.eclipse.pde.ui.launcher.OSGiLaunchConfigurationInitializer</code>. If not specified, the default initializer <code>org.eclipse.pde.ui.launcher.OSGiLaunchConfigurationInitializer</code> is instantiated. - - - - - - - - - - - - - - - 3.3 - - - - - - - - - <p> -The following is an example of the extension point: -<pre> - <extension - point="org.eclipse.pde.ui.osgiFrameworks"> - <framework - launcherDelegate="org.eclipse.pde.ui.launcher.EquinoxLaunchConfiguration" - id="org.eclipse.pde.ui.EquinoxFramework" - name="%Equinox.shortcut.label" - initializer="org.eclipse.pde.internal.ui.launcher.EquinoxInitializer"/> - </extension> -</pre> - - - - - - - - - <p> -The value of the attribute <code>launcherDelegate</code> must be a fully qualified name of a Java class that extends <code>org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration</code>. If the launcher is to provide its own source lookup order, then the method <code>setDefaultSourceLocator</code> should be overridden. -</p> -<p> -The value of the attribute <code>initializer</code> must be a fully qualified name of a Java class that extends <code>org.eclipse.ui.launcher.OSGiLaunchConfigurationInitializer</code>. -</p> - - - - - - - - - <p> -PDE supplies the Equinox OSGi Framework extension to launch Equinox frameworks. -</p> - - - - - - - - - Copyright (c) 2006 IBM Corporation and others. -<br> -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 -<a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. - - - - Index: src/org/eclipse/pde/internal/ui/wizards/product/ProductFileWizardPage.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/product/ProductFileWizardPage.java,v retrieving revision 1.6 diff -u -r1.6 ProductFileWizardPage.java --- src/org/eclipse/pde/internal/ui/wizards/product/ProductFileWizardPage.java 19 Mar 2009 16:30:39 -0000 1.6 +++ src/org/eclipse/pde/internal/ui/wizards/product/ProductFileWizardPage.java 21 Sep 2009 18:54:10 -0000 @@ -11,6 +11,8 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.wizards.product; +import org.eclipse.pde.launching.IPDELauncherConstants; + import java.util.ArrayList; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -24,7 +26,6 @@ import org.eclipse.pde.internal.ui.*; import org.eclipse.pde.internal.ui.wizards.PDEWizardNewFileCreationPage; import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut; -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/wizards/product/ProductFromConfigOperation.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/product/ProductFromConfigOperation.java,v retrieving revision 1.15 diff -u -r1.15 ProductFromConfigOperation.java --- src/org/eclipse/pde/internal/ui/wizards/product/ProductFromConfigOperation.java 15 Apr 2009 21:23:34 -0000 1.15 +++ src/org/eclipse/pde/internal/ui/wizards/product/ProductFromConfigOperation.java 21 Sep 2009 18:54:10 -0000 @@ -11,6 +11,10 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.wizards.product; +import org.eclipse.pde.launching.IPDELauncherConstants; + +import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper; + import java.util.*; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; @@ -21,8 +25,6 @@ import org.eclipse.pde.internal.core.iproduct.*; import org.eclipse.pde.internal.core.iproduct.IProduct; import org.eclipse.pde.internal.ui.PDEPlugin; -import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper; -import org.eclipse.pde.ui.launcher.IPDELauncherConstants; /** * This operation generates a product configuration filling in fields based on information Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF,v retrieving revision 1.77 diff -u -r1.77 MANIFEST.MF --- META-INF/MANIFEST.MF 22 Jun 2009 15:55:29 -0000 1.77 +++ META-INF/MANIFEST.MF 21 Sep 2009 18:54:08 -0000 @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %name Bundle-SymbolicName: org.eclipse.pde.ui; singleton:=true -Bundle-Version: 3.5.100.qualifier +Bundle-Version: 3.6.0.qualifier Bundle-Activator: org.eclipse.pde.internal.ui.PDEPlugin Bundle-Vendor: %provider-name Bundle-Localization: plugin @@ -103,7 +103,8 @@ org.eclipse.equinox.p2.metadata.repository;bundle-version="[1.0.100,2.0.0)", org.eclipse.equinox.frameworkadmin;bundle-version="[1.0.100,2.0.0)", org.eclipse.equinox.frameworkadmin.equinox;bundle-version="[1.0.100,2.0.0)", - org.eclipse.equinox.p2.repository;bundle-version="[1.0.0,2.0.0)" + org.eclipse.equinox.p2.repository;bundle-version="[1.0.0,2.0.0)", + org.eclipse.pde.launching;bundle-version="[3.6.0,4.0.0)";visibility:=reexport Eclipse-LazyStart: true Import-Package: com.ibm.icu.text, org.eclipse.jdt.debug.core Index: src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizardPage.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizardPage.java,v retrieving revision 1.10 diff -u -r1.10 OrganizeManifestsWizardPage.java --- src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizardPage.java 20 May 2008 13:32:22 -0000 1.10 +++ src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizardPage.java 21 Sep 2009 18:54:10 -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 @@ -14,7 +14,9 @@ import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.ltk.ui.refactoring.UserInputWizardPage; -import org.eclipse.pde.internal.ui.*; +import org.eclipse.pde.internal.launching.ILaunchingPreferenceConstants; +import org.eclipse.pde.internal.ui.IHelpContextIds; +import org.eclipse.pde.internal.ui.PDEUIMessages; import org.eclipse.pde.internal.ui.refactoring.PDERefactor; import org.eclipse.swt.SWT; import org.eclipse.swt.events.*; @@ -23,7 +25,7 @@ import org.eclipse.swt.widgets.*; import org.eclipse.ui.PlatformUI; -public class OrganizeManifestsWizardPage extends UserInputWizardPage implements IPreferenceConstants, IOrganizeManifestsSettings { +public class OrganizeManifestsWizardPage extends UserInputWizardPage implements ILaunchingPreferenceConstants, IOrganizeManifestsSettings { private Button fRemoveUnresolved; private Button fCalculateUses; Index: src/org/eclipse/pde/internal/ui/editor/product/ProductValidateAction.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/product/ProductValidateAction.java,v retrieving revision 1.1 diff -u -r1.1 ProductValidateAction.java --- src/org/eclipse/pde/internal/ui/editor/product/ProductValidateAction.java 13 Apr 2009 16:20:07 -0000 1.1 +++ src/org/eclipse/pde/internal/ui/editor/product/ProductValidateAction.java 21 Sep 2009 18:54:09 -0000 @@ -21,8 +21,8 @@ import org.eclipse.pde.internal.core.*; import org.eclipse.pde.internal.core.ifeature.*; import org.eclipse.pde.internal.core.iproduct.*; +import org.eclipse.pde.internal.launching.launcher.*; import org.eclipse.pde.internal.ui.*; -import org.eclipse.pde.internal.ui.launcher.*; public class ProductValidateAction extends Action { Index: src/org/eclipse/pde/internal/ui/editor/PDEMultiPageContentOutline.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/PDEMultiPageContentOutline.java,v retrieving revision 1.21 diff -u -r1.21 PDEMultiPageContentOutline.java --- src/org/eclipse/pde/internal/ui/editor/PDEMultiPageContentOutline.java 27 May 2009 20:38:16 -0000 1.21 +++ src/org/eclipse/pde/internal/ui/editor/PDEMultiPageContentOutline.java 21 Sep 2009 18:54:09 -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 @@ -13,6 +13,7 @@ import java.util.ArrayList; import org.eclipse.jface.action.*; import org.eclipse.jface.viewers.*; +import org.eclipse.pde.internal.launching.ILaunchingPreferenceConstants; import org.eclipse.pde.internal.ui.*; import org.eclipse.swt.SWT; import org.eclipse.swt.events.FocusListener; @@ -24,7 +25,7 @@ import org.eclipse.ui.part.PageBook; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; -public class PDEMultiPageContentOutline extends Page implements IContentOutlinePage, ISelectionProvider, ISelectionChangedListener, IPreferenceConstants { +public class PDEMultiPageContentOutline extends Page implements IContentOutlinePage, ISelectionProvider, ISelectionChangedListener, ILaunchingPreferenceConstants { private PageBook pagebook; private ISelection selection; private ArrayList listeners; Index: src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java,v retrieving revision 1.56 diff -u -r1.56 PluginImportWizard.java --- src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java 27 May 2009 20:38:22 -0000 1.56 +++ src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java 21 Sep 2009 18:54:10 -0000 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.wizards.imports; +import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper; + import java.util.*; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; @@ -22,7 +24,6 @@ import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.internal.core.SourceLocationManager; import org.eclipse.pde.internal.ui.*; -import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IImportWizard; import org.eclipse.ui.IWorkbench; Index: src/org/eclipse/pde/internal/ui/launcher/PluginValidationStatusHandler.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/launcher/PluginValidationStatusHandler.java diff -N src/org/eclipse/pde/internal/ui/launcher/PluginValidationStatusHandler.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/launcher/PluginValidationStatusHandler.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2009 eXXcellent solutions gmbh, 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: + * Achim Demelt, eXXcellent solutions gmbh - initial API and implementation + * EclipseSource - initial API and implementation, ongoing enhancements + *******************************************************************************/ +package org.eclipse.pde.internal.ui.launcher; + +import org.eclipse.core.runtime.*; +import org.eclipse.debug.core.IStatusHandler; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.osgi.util.NLS; +import org.eclipse.pde.internal.launching.PDEMessages; +import org.eclipse.pde.internal.launching.launcher.*; +import org.eclipse.pde.internal.ui.*; +import org.eclipse.pde.internal.ui.elements.NamedElement; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; + +public class PluginValidationStatusHandler implements IStatusHandler { + public Object handleStatus(IStatus status, Object source) throws CoreException { + if (status.getCode() == EclipsePluginValidationOperation.CREATE_EXTENSION_ERROR_CODE) + return createExtensionError((String) source); + else if (status.getCode() == LaunchPluginValidator.DISPLAY_VALIDATION_ERROR_CODE) + displayValidationError((LaunchValidationOperation) source); + return null; + } + + private Object createExtensionError(String bundleID) { + String name = NLS.bind(PDEMessages.EclipsePluginValidationOperation_pluginMissing, bundleID); + PDELabelProvider provider = PDEPlugin.getDefault().getLabelProvider(); + Image image = provider.get(PDEPluginImages.DESC_PLUGIN_OBJ); + return new NamedElement(name, image); + } + + private void displayValidationError(final LaunchValidationOperation op) throws CoreException { + final int[] result = new int[1]; + final Display display = LauncherUtilsStatusHandler.getDisplay(); + display.syncExec(new Runnable() { + public void run() { + PluginStatusDialog dialog = new PluginStatusDialog(display.getActiveShell()); + dialog.showCancelButton(true); + dialog.setInput(op.getInput()); + result[0] = dialog.open(); + } + }); + if (result[0] == IDialogConstants.CANCEL_ID) + throw new CoreException(Status.CANCEL_STATUS); + } + +} Index: src/org/eclipse/pde/internal/ui/launcher/LauncherUtilsStatusHandler.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/launcher/LauncherUtilsStatusHandler.java diff -N src/org/eclipse/pde/internal/ui/launcher/LauncherUtilsStatusHandler.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/launcher/LauncherUtilsStatusHandler.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,148 @@ +/******************************************************************************* + * Copyright (c) 2009 eXXcellent solutions gmbh, 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: + * Achim Demelt, eXXcellent solutions gmbh - initial API and implementation + * EclipseSource - initial API and implementation, ongoing enhancements + *******************************************************************************/ +package org.eclipse.pde.internal.ui.launcher; + +import java.util.*; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.*; +import org.eclipse.debug.core.IStatusHandler; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.osgi.util.NLS; +import org.eclipse.pde.internal.launching.PDEMessages; +import org.eclipse.pde.internal.launching.launcher.LauncherUtils; +import org.eclipse.pde.internal.ui.PDEPlugin; +import org.eclipse.pde.internal.ui.PDEUIMessages; +import org.eclipse.pde.internal.ui.wizards.tools.OrganizeManifestsProcessor; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; + +public class LauncherUtilsStatusHandler implements IStatusHandler { + + public Object handleStatus(IStatus status, Object source) throws CoreException { + if (status.getCode() == LauncherUtils.WORKSPACE_LOCKED) + handleWorkspaceLocked((String) source); + else if (status.getCode() == LauncherUtils.CLEAR_LOG) + return clearLog(); + else if (status.getCode() == LauncherUtils.DELETE_WORKSPACE) + return deleteWorkspace((String) source); + else if (status.getCode() == LauncherUtils.GENERATE_CONFIG_INI) + return generateConfigIni(); + else if (status.getCode() == LauncherUtils.ORGANIZE_MANIFESTS) { + Object[] args = (Object[]) source; + organizeManifests((ArrayList) args[0], (IProgressMonitor) args[1], (Properties) args[2]); + } + return null; + } + + private Boolean generateConfigIni() { + String message = PDEUIMessages.LauncherUtils_generateConfigIni; + return Boolean.valueOf(generateDialog(message).intValue() == 0); + } + + private Integer deleteWorkspace(String path) { + return generateDialog(NLS.bind(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_confirmDeleteWorkspace, path)); + } + + private Integer clearLog() { + return generateDialog(PDEUIMessages.LauncherUtils_clearLogFile); + } + + private void handleWorkspaceLocked(String workspace) { + generateErrorDialog(PDEUIMessages.LauncherUtils_workspaceLocked, NLS.bind(PDEMessages.LauncherUtils_cannotLaunchApplication, workspace)); + } + + private void organizeManifests(final ArrayList projects, final IProgressMonitor monitor, final Properties lastRun) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + OrganizeManifestsProcessor processor = new OrganizeManifestsProcessor(projects); + initializeProcessor(processor); + try { + Change change = processor.createChange(monitor); + change.perform(monitor); + // update table for each project with current time stamp + Properties table = lastRun; + String ts = Long.toString(System.currentTimeMillis()); + Iterator it = projects.iterator(); + while (it.hasNext()) + table.put(((IProject) it.next()).getName(), ts); + } catch (OperationCanceledException e) { + } catch (CoreException e) { + } + } + }); + } + + public static Display getDisplay() { + Display display = Display.getCurrent(); + if (display == null) { + display = Display.getDefault(); + } + return display; + } + + public final static Shell getActiveShell() { + IWorkbenchWindow window = PDEPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); + if (window == null) { + IWorkbenchWindow[] windows = PDEPlugin.getDefault().getWorkbench().getWorkbenchWindows(); + if (windows.length > 0) + return windows[0].getShell(); + } else + return window.getShell(); + return getDisplay().getActiveShell(); + } + + private static void initializeProcessor(OrganizeManifestsProcessor processor) { + processor.setAddMissing(false); + processor.setRemoveUnresolved(false); + processor.setModifyDep(false); + processor.setRemoveLazy(false); + processor.setRemoveUselessFiles(false); + processor.setAddDependencies(true); + processor.setCalculateUses(false); + processor.setMarkInternal(false); + processor.setPrefixIconNL(false); + processor.setUnusedDependencies(false); + processor.setUnusedKeys(false); + } + + /** + * Creates a message dialog using a syncExec in case we are launching in the background. + * Dialog will be a question dialog with Yes, No and Cancel buttons. + * @param message Message to use in the dialog + * @return int representing the button clicked (-1 or 2 for cancel, 0 for yes, 1 for no). + */ + private static Integer generateDialog(final String message) { + final int[] result = new int[1]; + getDisplay().syncExec(new Runnable() { + public void run() { + String title = PDEUIMessages.LauncherUtils_title; + MessageDialog dialog = new MessageDialog(getActiveShell(), title, null, message, MessageDialog.QUESTION, new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL}, 0); + result[0] = dialog.open(); + } + }); + return Integer.valueOf(result[0]); + } + + private static void generateErrorDialog(final String title, final String message) { + getDisplay().syncExec(new Runnable() { + public void run() { + MessageDialog dialog = new MessageDialog(getActiveShell(), title, null, message, MessageDialog.ERROR, new String[] {IDialogConstants.OK_LABEL}, 0); + dialog.open(); + } + }); + } + +} Index: src/org/eclipse/pde/internal/ui/launcher/LaunchTerminationStatusHandler.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/launcher/LaunchTerminationStatusHandler.java diff -N src/org/eclipse/pde/internal/ui/launcher/LaunchTerminationStatusHandler.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/launcher/LaunchTerminationStatusHandler.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2009 eXXcellent solutions gmbh, 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: + * Achim Demelt, eXXcellent solutions gmbh - initial API and implementation + * EclipseSource - initial API and implementation, ongoing enhancements + *******************************************************************************/ +package org.eclipse.pde.internal.ui.launcher; + +import java.io.File; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.runtime.*; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.IStatusHandler; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.pde.internal.launching.PDEMessages; +import org.eclipse.pde.internal.launching.launcher.LaunchListener; +import org.eclipse.pde.internal.ui.PDEPlugin; +import org.eclipse.pde.internal.ui.PDEUIMessages; +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 LaunchTerminationStatusHandler implements IStatusHandler { + // 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 Object handleStatus(IStatus status, Object source) throws CoreException { + if (status.getCode() == 13) + handleOtherReasonsFoundInLog((ILaunch) source); + else if (status.getCode() == 15) + handleWorkspaceInUse(); + return null; + } + + private void handleWorkspaceInUse() { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + MessageDialog.openError(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.Launcher_error_title, PDEMessages.Launcher_error_code15); + } + }); + } + + private void handleOtherReasonsFoundInLog(final ILaunch launch) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + try { + File log = LaunchListener.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) { + } + } + } +} Index: src/org/eclipse/pde/internal/ui/launcher/GenericExceptionStatusHandler.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/launcher/GenericExceptionStatusHandler.java diff -N src/org/eclipse/pde/internal/ui/launcher/GenericExceptionStatusHandler.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/launcher/GenericExceptionStatusHandler.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2009 eXXcellent solutions gmbh 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: + * Achim Demelt, eXXcellent solutions gmbh - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.internal.ui.launcher; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.debug.core.IStatusHandler; +import org.eclipse.pde.internal.ui.PDEPlugin; + +public class GenericExceptionStatusHandler implements IStatusHandler { + + public Object handleStatus(IStatus status, Object source) throws CoreException { + PDEPlugin.logException(status.getException()); + return null; + } + +} #P org.eclipse.pde.ui.tests Index: src/org/eclipse/pde/ui/tests/launcher/LaunchConfigurationHelperTestCase.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/LaunchConfigurationHelperTestCase.java,v retrieving revision 1.3 diff -u -r1.3 LaunchConfigurationHelperTestCase.java --- src/org/eclipse/pde/ui/tests/launcher/LaunchConfigurationHelperTestCase.java 19 Aug 2009 20:51:11 -0000 1.3 +++ src/org/eclipse/pde/ui/tests/launcher/LaunchConfigurationHelperTestCase.java 21 Sep 2009 18:54:12 -0000 @@ -10,9 +10,8 @@ *******************************************************************************/ package org.eclipse.pde.ui.tests.launcher; -import org.eclipse.pde.internal.ui.launcher.LaunchConfigurationHelper; - import junit.framework.*; +import org.eclipse.pde.internal.launching.launcher.LaunchConfigurationHelper; /** * Tests LaunchConfigurationHelper convenience methods Index: src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java,v retrieving revision 1.10 diff -u -r1.10 LocalTargetDefinitionTests.java --- src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java 4 Sep 2009 17:46:46 -0000 1.10 +++ src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java 21 Sep 2009 18:54:12 -0000 @@ -10,21 +10,20 @@ *******************************************************************************/ package org.eclipse.pde.ui.tests.target; -import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle; - -import org.eclipse.pde.internal.core.target.*; - import java.io.*; import java.net.URL; import java.util.*; -import junit.framework.*; +import junit.framework.Test; +import junit.framework.TestSuite; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; 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.target.TargetDefinition; +import org.eclipse.pde.internal.core.target.TargetDefinitionPersistenceHelper; import org.eclipse.pde.internal.core.target.provisional.*; -import org.eclipse.pde.internal.ui.launcher.LaunchArgumentsHelper; +import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper; import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin; import org.osgi.framework.ServiceReference;