View | Details | Raw Unified | Return to bug 278845 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/ui/tests/launcher/LaunchConfigurationHelperTestCase.java (-2 / +1 lines)
Lines 10-18 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.tests.launcher;
11
package org.eclipse.pde.ui.tests.launcher;
12
12
13
import org.eclipse.pde.internal.ui.launcher.LaunchConfigurationHelper;
14
15
import junit.framework.*;
13
import junit.framework.*;
14
import org.eclipse.pde.internal.launching.launcher.LaunchConfigurationHelper;
16
15
17
/**
16
/**
18
 * Tests LaunchConfigurationHelper convenience methods
17
 * Tests LaunchConfigurationHelper convenience methods
(-)src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java (-6 / +5 lines)
Lines 10-30 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.tests.target;
11
package org.eclipse.pde.ui.tests.target;
12
12
13
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
14
15
import org.eclipse.pde.internal.core.target.*;
16
17
import java.io.*;
13
import java.io.*;
18
import java.net.URL;
14
import java.net.URL;
19
import java.util.*;
15
import java.util.*;
20
import junit.framework.*;
16
import junit.framework.Test;
17
import junit.framework.TestSuite;
21
import org.eclipse.core.runtime.*;
18
import org.eclipse.core.runtime.*;
22
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
19
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
23
import org.eclipse.pde.core.plugin.IPluginModelBase;
20
import org.eclipse.pde.core.plugin.IPluginModelBase;
24
import org.eclipse.pde.core.plugin.TargetPlatform;
21
import org.eclipse.pde.core.plugin.TargetPlatform;
25
import org.eclipse.pde.internal.core.*;
22
import org.eclipse.pde.internal.core.*;
23
import org.eclipse.pde.internal.core.target.TargetDefinition;
24
import org.eclipse.pde.internal.core.target.TargetDefinitionPersistenceHelper;
26
import org.eclipse.pde.internal.core.target.provisional.*;
25
import org.eclipse.pde.internal.core.target.provisional.*;
27
import org.eclipse.pde.internal.ui.launcher.LaunchArgumentsHelper;
26
import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper;
28
import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
27
import org.eclipse.pde.internal.ui.tests.macro.MacroPlugin;
29
import org.osgi.framework.ServiceReference;
28
import org.osgi.framework.ServiceReference;
30
29
(-)src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfigurationTabGroup.java (-6 / +9 lines)
Lines 11-16 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.pde.ui.launcher;
12
package org.eclipse.pde.ui.launcher;
13
13
14
import org.eclipse.pde.launching.IPDELauncherConstants;
15
import org.eclipse.pde.launching.PDESourcePathProvider;
16
14
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.debug.core.ILaunchConfiguration;
18
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
19
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
Lines 18-26 Link Here
18
import org.eclipse.debug.ui.ILaunchConfigurationTab;
21
import org.eclipse.debug.ui.ILaunchConfigurationTab;
19
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
22
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
20
import org.eclipse.pde.internal.core.TargetPlatformHelper;
23
import org.eclipse.pde.internal.core.TargetPlatformHelper;
21
import org.eclipse.pde.internal.ui.IPDEUIConstants;
24
import org.eclipse.pde.internal.launching.IPDEConstants;
22
import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper;
25
import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper;
23
import org.eclipse.pde.internal.ui.launcher.LaunchArgumentsHelper;
26
import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper;
24
import org.eclipse.swt.custom.BusyIndicator;
27
import org.eclipse.swt.custom.BusyIndicator;
25
import org.eclipse.swt.widgets.Display;
28
import org.eclipse.swt.widgets.Display;
26
29
Lines 110-118 Link Here
110
	public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
113
	public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
111
		super.setDefaults(configuration);
114
		super.setDefaults(configuration);
112
		if (TargetPlatformHelper.usesNewApplicationModel())
115
		if (TargetPlatformHelper.usesNewApplicationModel())
113
			configuration.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$ 
116
			configuration.setAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$ 
114
		else if (TargetPlatformHelper.getTargetVersion() >= 3.2)
117
		else if (TargetPlatformHelper.getTargetVersion() >= 3.2)
115
			configuration.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.2a"); //$NON-NLS-1$ 
118
			configuration.setAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, "3.2a"); //$NON-NLS-1$ 
116
119
117
		configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, PDESourcePathProvider.ID);
120
		configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, PDESourcePathProvider.ID);
118
121
Lines 125-131 Link Here
125
		if (vmArgs.length() > 0)
128
		if (vmArgs.length() > 0)
126
			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs);
129
			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs);
127
130
128
		configuration.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true);
131
		configuration.setAttribute(IPDEConstants.APPEND_ARGS_EXPLICITLY, true);
129
	}
132
	}
130
133
131
}
134
}
(-)src/org/eclipse/pde/ui/launcher/PDESourcePathProvider.java (-119 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 *  Copyright (c) 2006, 2008 IBM Corporation and others.
2
 *  Copyright (c) 2006, 2009 IBM Corporation and others.
3
 *  All rights reserved. This program and the accompanying materials
3
 *  All rights reserved. This program and the accompanying materials
4
 *  are made available under the terms of the Eclipse Public License v1.0
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 *  which accompanies this distribution, and is available at
5
 *  which accompanies this distribution, and is available at
Lines 10-139 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
11
package org.eclipse.pde.ui.launcher;
12
12
13
import java.util.ArrayList;
14
import java.util.List;
15
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.runtime.*;
18
import org.eclipse.debug.core.ILaunchConfiguration;
19
import org.eclipse.jdt.core.*;
20
import org.eclipse.jdt.launching.*;
21
import org.eclipse.pde.internal.core.util.PDEJavaHelper;
22
import org.eclipse.pde.internal.ui.PDEPlugin;
23
import org.eclipse.pde.internal.ui.launcher.LaunchPluginValidator;
24
import org.eclipse.pde.internal.ui.launcher.VMHelper;
25
26
/**
13
/**
27
 * Generates a source lookup path for all PDE-based launch configurations
14
 * Generates a source lookup path for all PDE-based launch configurations
28
 * <p>
15
 * <p>
29
 * Clients may subclass this class.
16
 * Clients may subclass this class.
30
 * </p>
17
 * </p>
31
 * @since 3.3
18
 * @since 3.3
19
 * @deprecated use {@link org.eclipse.pde.launching.PDESourcePathProvider} instead.
20
 * @see org.eclipse.pde.launching.PDESourcePathProvider
32
 */
21
 */
33
public class PDESourcePathProvider extends StandardSourcePathProvider {
22
public class PDESourcePathProvider extends org.eclipse.pde.launching.PDESourcePathProvider {
34
35
	public static final String ID = "org.eclipse.pde.ui.workbenchClasspathProvider"; //$NON-NLS-1$
36
37
	/*
38
	 * (non-Javadoc)
39
	 * @see org.eclipse.jdt.launching.StandardSourcePathProvider#computeUnresolvedClasspath(org.eclipse.debug.core.ILaunchConfiguration)
40
	 */
41
	public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException {
42
		List sourcePath = new ArrayList();
43
		sourcePath.add(getJREEntry(configuration));
44
		IProject[] projects = getJavaProjects(configuration);
45
		for (int i = 0; i < projects.length; i++) {
46
			sourcePath.add(JavaRuntime.newProjectRuntimeClasspathEntry(JavaCore.create(projects[i])));
47
		}
48
		return (IRuntimeClasspathEntry[]) sourcePath.toArray(new IRuntimeClasspathEntry[sourcePath.size()]);
49
	}
50
51
	/**
52
	 * Returns a JRE runtime classpath entry
53
	 * 
54
	 * @param configuration
55
	 * 			the launch configuration
56
	 * @return a JRE runtime classpath entry
57
	 * @throws CoreException
58
	 * 			if the JRE associated with the launch configuration cannot be found
59
	 * 			or if unable to retrieve the launch configuration attributes
60
	 */
61
	private IRuntimeClasspathEntry getJREEntry(ILaunchConfiguration configuration) throws CoreException {
62
		IVMInstall jre = VMHelper.createLauncher(configuration);
63
		IPath containerPath = new Path(JavaRuntime.JRE_CONTAINER);
64
		containerPath = containerPath.append(jre.getVMInstallType().getId());
65
		containerPath = containerPath.append(jre.getName());
66
		return JavaRuntime.newRuntimeContainerClasspathEntry(containerPath, IRuntimeClasspathEntry.BOOTSTRAP_CLASSES);
67
	}
68
69
	/**
70
	 * Returns an array of sorted plug-in projects that represent plug-ins participating
71
	 * in the launch
72
	 * 
73
	 * @param configuration
74
	 * 			the launch configuration
75
	 * @return an array of ordered projects
76
	 * @throws CoreException
77
	 * 			if unable to retrieve attributes from the launch configuration or if 
78
	 * 			an error occurs when checking the nature of the project
79
	 * 			
80
	 */
81
	private IProject[] getJavaProjects(ILaunchConfiguration configuration) throws CoreException {
82
		IProject[] projects = LaunchPluginValidator.getAffectedProjects(configuration);
83
		return PDEPlugin.getWorkspace().computeProjectOrder(projects).projects;
84
	}
85
86
	/*
87
	 * (non-Javadoc)
88
	 * @see org.eclipse.jdt.launching.StandardSourcePathProvider#resolveClasspath(org.eclipse.jdt.launching.IRuntimeClasspathEntry[], org.eclipse.debug.core.ILaunchConfiguration)
89
	 */
90
	public IRuntimeClasspathEntry[] resolveClasspath(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration) throws CoreException {
91
		List all = new ArrayList(entries.length);
92
		for (int i = 0; i < entries.length; i++) {
93
			if (entries[i].getType() == IRuntimeClasspathEntry.PROJECT) {
94
				// a project resolves to itself for source lookup (rather than
95
				// the class file output locations)
96
				all.add(entries[i]);
97
				// also add non-JRE libraries
98
				IResource resource = entries[i].getResource();
99
				if (resource instanceof IProject) {
100
					addBinaryPackageFragmentRoots(JavaCore.create((IProject) resource), all);
101
				}
102
			} else {
103
				IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveRuntimeClasspathEntry(entries[i], configuration);
104
				for (int j = 0; j < resolved.length; j++) {
105
					all.add(resolved[j]);
106
				}
107
			}
108
		}
109
		return (IRuntimeClasspathEntry[]) all.toArray(new IRuntimeClasspathEntry[all.size()]);
110
	}
111
112
	/**
113
	 * Adds runtime classpath entries for binary package fragment roots contained within
114
	 * the project
115
	 * 
116
	 * @param jProject
117
	 * 			the Java project whose roots are to be enumerated
118
	 * @param all
119
	 * 			a list of accumulated runtime classpath entries
120
	 * @throws CoreException
121
	 * 			if unable to evaluate the package fragment roots
122
	 */
123
	private void addBinaryPackageFragmentRoots(IJavaProject jProject, List all) throws CoreException {
124
		IPackageFragmentRoot[] roots = jProject.getPackageFragmentRoots();
125
		for (int j = 0; j < roots.length; j++) {
126
			if (roots[j].getKind() == IPackageFragmentRoot.K_BINARY && !PDEJavaHelper.isJRELibrary(roots[j])) {
127
				IRuntimeClasspathEntry rte = JavaRuntime.newArchiveRuntimeClasspathEntry(roots[j].getPath());
128
				IPath path = roots[j].getSourceAttachmentPath();
129
				if (path != null) {
130
					rte.setSourceAttachmentPath(path);
131
					rte.setSourceAttachmentRootPath(roots[j].getSourceAttachmentRootPath());
132
				}
133
				if (!all.contains(rte))
134
					all.add(rte);
135
			}
136
		}
137
23
138
	}
139
}
24
}
(-)src/org/eclipse/pde/ui/launcher/OSGiSettingsTab.java (+2 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
11
package org.eclipse.pde.ui.launcher;
12
12
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
13
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
(-)src/org/eclipse/pde/ui/launcher/OSGiLaunchShortcut.java (-3 / +5 lines)
Lines 10-20 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
11
package org.eclipse.pde.ui.launcher;
12
12
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
13
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.core.ILaunchConfiguration;
14
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
16
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
15
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.jface.viewers.ISelection;
16
import org.eclipse.pde.internal.ui.PDEPlugin;
18
import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
17
import org.eclipse.pde.internal.ui.launcher.OSGiFrameworkManager;
19
import org.eclipse.pde.internal.launching.launcher.OSGiFrameworkManager;
18
import org.eclipse.ui.IEditorPart;
20
import org.eclipse.ui.IEditorPart;
19
21
20
/**
22
/**
Lines 59-65 Link Here
59
	 * @see org.eclipse.pde.ui.launcher.AbstractLaunchShortcut#initializeConfiguration(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
61
	 * @see org.eclipse.pde.ui.launcher.AbstractLaunchShortcut#initializeConfiguration(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
60
	 */
62
	 */
61
	protected void initializeConfiguration(ILaunchConfigurationWorkingCopy configuration) {
63
	protected void initializeConfiguration(ILaunchConfigurationWorkingCopy configuration) {
62
		OSGiFrameworkManager manager = PDEPlugin.getDefault().getOSGiFrameworkManager();
64
		OSGiFrameworkManager manager = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager();
63
		manager.getDefaultInitializer().initialize(configuration);
65
		manager.getDefaultInitializer().initialize(configuration);
64
	}
66
	}
65
67
(-)src/org/eclipse/pde/ui/launcher/EquinoxLaunchConfiguration.java (-8 / +10 lines)
Lines 22-30 Link Here
22
import org.eclipse.pde.internal.core.ClasspathHelper;
22
import org.eclipse.pde.internal.core.ClasspathHelper;
23
import org.eclipse.pde.internal.core.P2Utils;
23
import org.eclipse.pde.internal.core.P2Utils;
24
import org.eclipse.pde.internal.core.util.CoreUtility;
24
import org.eclipse.pde.internal.core.util.CoreUtility;
25
import org.eclipse.pde.internal.ui.IPDEUIConstants;
25
import org.eclipse.pde.internal.launching.IPDEConstants;
26
import org.eclipse.pde.internal.ui.PDEUIMessages;
26
import org.eclipse.pde.internal.launching.PDEMessages;
27
import org.eclipse.pde.internal.ui.launcher.*;
27
import org.eclipse.pde.internal.launching.launcher.*;
28
28
29
/**
29
/**
30
 * A launch delegate for launching the Equinox framework
30
 * A launch delegate for launching the Equinox framework
Lines 32-37 Link Here
32
 * Clients may subclass and instantiate this class.
32
 * Clients may subclass and instantiate this class.
33
 * </p>
33
 * </p>
34
 * @since 3.2
34
 * @since 3.2
35
 * @deprecated use {@link org.eclipse.pde.launching.EquinoxLaunchConfiguration} instead.
36
 * @see org.eclipse.pde.launching.EquinoxLaunchConfiguration
35
 */
37
 */
36
public class EquinoxLaunchConfiguration extends AbstractPDELaunchConfiguration {
38
public class EquinoxLaunchConfiguration extends AbstractPDELaunchConfiguration {
37
39
Lines 68-76 Link Here
68
		properties.setProperty("osgi.install.area", "file:" + TargetPlatform.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$
70
		properties.setProperty("osgi.install.area", "file:" + TargetPlatform.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$
69
		properties.setProperty("osgi.configuration.cascaded", "false"); //$NON-NLS-1$ //$NON-NLS-2$
71
		properties.setProperty("osgi.configuration.cascaded", "false"); //$NON-NLS-1$ //$NON-NLS-2$
70
		properties.put("osgi.framework", LaunchConfigurationHelper.getBundleURL(IPDEBuildConstants.BUNDLE_OSGI, fAllBundles, false)); //$NON-NLS-1$
72
		properties.put("osgi.framework", LaunchConfigurationHelper.getBundleURL(IPDEBuildConstants.BUNDLE_OSGI, fAllBundles, false)); //$NON-NLS-1$
71
		int start = configuration.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4);
73
		int start = configuration.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.DEFAULT_START_LEVEL, 4);
72
		properties.put("osgi.bundles.defaultStartLevel", Integer.toString(start)); //$NON-NLS-1$
74
		properties.put("osgi.bundles.defaultStartLevel", Integer.toString(start)); //$NON-NLS-1$
73
		boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, true);
75
		boolean autostart = configuration.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.DEFAULT_AUTO_START, true);
74
76
75
		String bundles = null;
77
		String bundles = null;
76
		if (fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) {
78
		if (fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) {
Lines 93-99 Link Here
93
		if (bundles.length() > 0)
95
		if (bundles.length() > 0)
94
			properties.put("osgi.bundles", bundles); //$NON-NLS-1$
96
			properties.put("osgi.bundles", bundles); //$NON-NLS-1$
95
97
96
		if (!"3.3".equals(configuration.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, ""))) { //$NON-NLS-1$ //$NON-NLS-2$
98
		if (!"3.3".equals(configuration.getAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, ""))) { //$NON-NLS-1$ //$NON-NLS-2$
97
			properties.put("eclipse.ignoreApp", "true"); //$NON-NLS-1$ //$NON-NLS-2$
99
			properties.put("eclipse.ignoreApp", "true"); //$NON-NLS-1$ //$NON-NLS-2$
98
			properties.put("osgi.noShutdown", "true"); //$NON-NLS-1$ //$NON-NLS-2$
100
			properties.put("osgi.noShutdown", "true"); //$NON-NLS-1$ //$NON-NLS-2$
99
		}
101
		}
Lines 169-175 Link Here
169
				fModels.put(model, "default:default"); //$NON-NLS-1$
171
				fModels.put(model, "default:default"); //$NON-NLS-1$
170
				fAllBundles.put(IPDEBuildConstants.BUNDLE_OSGI, model);
172
				fAllBundles.put(IPDEBuildConstants.BUNDLE_OSGI, model);
171
			} else {
173
			} else {
172
				String message = PDEUIMessages.EquinoxLaunchConfiguration_oldTarget;
174
				String message = PDEMessages.EquinoxLaunchConfiguration_oldTarget;
173
				throw new CoreException(LauncherUtils.createErrorStatus(message));
175
				throw new CoreException(LauncherUtils.createErrorStatus(message));
174
			}
176
			}
175
		}
177
		}
Lines 198-204 Link Here
198
	 */
200
	 */
199
	protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
201
	protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
200
		// clear config area, if necessary
202
		// clear config area, if necessary
201
		if (configuration.getAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false))
203
		if (configuration.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.CONFIG_CLEAR_AREA, false))
202
			CoreUtility.deleteContent(getConfigDir(configuration));
204
			CoreUtility.deleteContent(getConfigDir(configuration));
203
	}
205
	}
204
206
(-)src/org/eclipse/pde/ui/launcher/OSGiLauncherTabGroup.java (-3 / +3 lines)
Lines 13-20 Link Here
13
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
13
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
14
import org.eclipse.debug.ui.*;
14
import org.eclipse.debug.ui.*;
15
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab;
15
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab;
16
import org.eclipse.pde.internal.ui.PDEPlugin;
16
import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
17
import org.eclipse.pde.internal.ui.launcher.OSGiFrameworkManager;
17
import org.eclipse.pde.internal.launching.launcher.OSGiFrameworkManager;
18
18
19
/**
19
/**
20
 * Creates and initializes the tabs on the OSGi Framework launch configuration.
20
 * Creates and initializes the tabs on the OSGi Framework launch configuration.
Lines 49-55 Link Here
49
	 */
49
	 */
50
	public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
50
	public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
51
		super.setDefaults(configuration);
51
		super.setDefaults(configuration);
52
		OSGiFrameworkManager manager = PDEPlugin.getDefault().getOSGiFrameworkManager();
52
		OSGiFrameworkManager manager = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager();
53
		manager.getDefaultInitializer().initialize(configuration);
53
		manager.getDefaultInitializer().initialize(configuration);
54
	}
54
	}
55
55
(-)src/org/eclipse/pde/ui/launcher/JUnitLaunchConfigurationDelegate.java (-470 / +3 lines)
Lines 13-492 Link Here
13
 *******************************************************************************/
13
 *******************************************************************************/
14
package org.eclipse.pde.ui.launcher;
14
package org.eclipse.pde.ui.launcher;
15
15
16
import java.io.File;
17
import java.util.*;
18
import org.eclipse.core.resources.IProject;
19
import org.eclipse.core.runtime.*;
20
import org.eclipse.debug.core.*;
21
import org.eclipse.jdt.core.IJavaProject;
22
import org.eclipse.jdt.internal.junit.launcher.*;
23
import org.eclipse.jdt.launching.*;
24
import org.eclipse.osgi.service.resolver.BundleDescription;
25
import org.eclipse.osgi.util.NLS;
26
import org.eclipse.pde.core.plugin.*;
27
import org.eclipse.pde.internal.core.*;
28
import org.eclipse.pde.internal.core.util.CoreUtility;
29
import org.eclipse.pde.internal.core.util.VersionUtil;
30
import org.eclipse.pde.internal.ui.*;
31
import org.eclipse.pde.internal.ui.launcher.*;
32
import org.osgi.framework.Version;
33
34
/**
16
/**
35
 * A launch delegate for launching JUnit Plug-in tests.
17
 * A launch delegate for launching JUnit Plug-in tests.
36
 *
18
 *
37
 * @since 3.3
19
 * @since 3.3
20
 * @deprecated use {@link org.eclipse.pde.launching.JUnitLaunchConfigurationDelegate} instead.
21
 * @see org.eclipse.pde.launching.JUnitLaunchConfigurationDelegate
38
 */
22
 */
39
public class JUnitLaunchConfigurationDelegate extends org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate {
23
public class JUnitLaunchConfigurationDelegate extends org.eclipse.pde.launching.JUnitLaunchConfigurationDelegate {
40
41
	/**
42
	 * To avoid duplicating variable substitution (and duplicate prompts)
43
	 * this variable will store the substituted workspace location.
44
	 */
45
	private String fWorkspaceLocation;
46
47
	protected File fConfigDir = null;
48
49
	// used to generate the dev classpath entries
50
	// key is bundle ID, value is a model
51
	private Map fAllBundles;
52
53
	// key is a model, value is startLevel:autoStart
54
	private Map fModels;
55
56
	/*
57
	 * (non-Javadoc)
58
	 * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getVMRunner(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
59
	 */
60
	public IVMRunner getVMRunner(ILaunchConfiguration configuration, String mode) throws CoreException {
61
		IVMInstall launcher = VMHelper.createLauncher(configuration);
62
		return launcher.getVMRunner(mode);
63
	}
64
65
	/* (non-Javadoc)
66
	 * @see org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate#verifyMainTypeName(org.eclipse.debug.core.ILaunchConfiguration)
67
	 */
68
	public String verifyMainTypeName(ILaunchConfiguration configuration) throws CoreException {
69
		if (TargetPlatformHelper.getTargetVersion() >= 3.3)
70
			return "org.eclipse.equinox.launcher.Main"; //$NON-NLS-1$
71
		return "org.eclipse.core.launcher.Main"; //$NON-NLS-1$
72
	}
73
74
	private String getTestPluginId(ILaunchConfiguration configuration) throws CoreException {
75
		IJavaProject javaProject = getJavaProject(configuration);
76
		IPluginModelBase model = PluginRegistry.findModel(javaProject.getProject());
77
		if (model == null)
78
			abort(NLS.bind(PDEUIMessages.JUnitLaunchConfiguration_error_notaplugin, javaProject.getProject().getName()), null, IStatus.OK);
79
		if (model instanceof IFragmentModel)
80
			return ((IFragmentModel) model).getFragment().getPluginId();
81
82
		return model.getPluginBase().getId();
83
	}
84
85
	/*
86
	 * (non-Javadoc)
87
	 * @see org.eclipse.jdt.internal.junit.launcher.JUnitBaseLaunchConfiguration#abort(java.lang.String, java.lang.Throwable, int)
88
	 */
89
	protected void abort(String message, Throwable exception, int code) throws CoreException {
90
		throw new CoreException(new Status(IStatus.ERROR, IPDEUIConstants.PLUGIN_ID, code, message, exception));
91
	}
92
93
	/* (non-Javadoc)
94
	 * @see org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate#collectExecutionArguments(org.eclipse.debug.core.ILaunchConfiguration, java.util.List, java.util.List)
95
	 */
96
	protected void collectExecutionArguments(ILaunchConfiguration configuration, List/*String*/vmArguments, List/*String*/programArgs) throws CoreException {
97
		super.collectExecutionArguments(configuration, vmArguments, programArgs);
98
99
		// Specify the JUnit Plug-in test application to launch
100
		programArgs.add("-application"); //$NON-NLS-1$
101
		String application = getApplication(configuration);
102
103
		programArgs.add(application);
104
105
		// If a product is specified, then add it to the program args
106
		if (configuration.getAttribute(IPDELauncherConstants.USE_PRODUCT, false)) {
107
			programArgs.add("-product"); //$NON-NLS-1$
108
			programArgs.add(configuration.getAttribute(IPDELauncherConstants.PRODUCT, "")); //$NON-NLS-1$
109
		} else {
110
			// Specify the application to test
111
			String defaultApplication = IPDEUIConstants.CORE_TEST_APPLICATION.equals(application) ? null : TargetPlatform.getDefaultApplication();
112
			String testApplication = configuration.getAttribute(IPDELauncherConstants.APP_TO_TEST, defaultApplication);
113
			if (testApplication != null) {
114
				programArgs.add("-testApplication"); //$NON-NLS-1$
115
				programArgs.add(testApplication);
116
			}
117
		}
118
119
		// Specify the location of the runtime workbench
120
		if (fWorkspaceLocation == null) {
121
			fWorkspaceLocation = LaunchArgumentsHelper.getWorkspaceLocation(configuration);
122
		}
123
		if (fWorkspaceLocation.length() > 0) {
124
			programArgs.add("-data"); //$NON-NLS-1$
125
			programArgs.add(fWorkspaceLocation);
126
		}
127
128
		// Create the platform configuration for the runtime workbench
129
		String productID = LaunchConfigurationHelper.getProductID(configuration);
130
		LaunchConfigurationHelper.createConfigIniFile(configuration, productID, fAllBundles, fModels, getConfigurationDirectory(configuration));
131
		String brandingId = LaunchConfigurationHelper.getContributingPlugin(productID);
132
		TargetPlatform.createPlatformConfiguration(getConfigurationDirectory(configuration), (IPluginModelBase[]) fAllBundles.values().toArray(new IPluginModelBase[fAllBundles.size()]), brandingId != null ? (IPluginModelBase) fAllBundles.get(brandingId) : null);
133
		TargetPlatformHelper.checkPluginPropertiesConsistency(fAllBundles, getConfigurationDirectory(configuration));
134
135
		programArgs.add("-configuration"); //$NON-NLS-1$
136
		programArgs.add("file:" + new Path(getConfigurationDirectory(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
137
138
		// Specify the output folder names
139
		programArgs.add("-dev"); //$NON-NLS-1$
140
		programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigurationDirectory(configuration).toString() + "/dev.properties", fAllBundles)); //$NON-NLS-1$
141
142
		// necessary for PDE to know how to load plugins when target platform = host platform
143
		// see PluginPathFinder.getPluginPaths()
144
		IPluginModelBase base = findPlugin(PDECore.PLUGIN_ID);
145
		if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) < 0) //$NON-NLS-1$
146
			programArgs.add("-pdelaunch"); //$NON-NLS-1$				
147
148
		// Create the .options file if tracing is turned on
149
		if (configuration.getAttribute(IPDELauncherConstants.TRACING, false) && !IPDELauncherConstants.TRACING_NONE.equals(configuration.getAttribute(IPDELauncherConstants.TRACING_CHECKED, (String) null))) {
150
			programArgs.add("-debug"); //$NON-NLS-1$
151
			String path = getConfigurationDirectory(configuration).getPath() + IPath.SEPARATOR + ".options"; //$NON-NLS-1$
152
			programArgs.add(LaunchArgumentsHelper.getTracingFileArgument(configuration, path));
153
		}
154
155
		// add the program args specified by the user
156
		String[] userArgs = LaunchArgumentsHelper.getUserProgramArgumentArray(configuration);
157
		for (int i = 0; i < userArgs.length; i++) {
158
			// be forgiving if people have tracing turned on and forgot
159
			// to remove the -debug from the program args field.
160
			if (userArgs[i].equals("-debug") && programArgs.contains("-debug")) //$NON-NLS-1$ //$NON-NLS-2$
161
				continue;
162
			programArgs.add(userArgs[i]);
163
		}
164
165
		if (!configuration.getAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, false)) {
166
			if (!programArgs.contains("-os")) { //$NON-NLS-1$
167
				programArgs.add("-os"); //$NON-NLS-1$
168
				programArgs.add(TargetPlatform.getOS());
169
			}
170
			if (!programArgs.contains("-ws")) { //$NON-NLS-1$
171
				programArgs.add("-ws"); //$NON-NLS-1$
172
				programArgs.add(TargetPlatform.getWS());
173
			}
174
			if (!programArgs.contains("-arch")) { //$NON-NLS-1$
175
				programArgs.add("-arch"); //$NON-NLS-1$
176
				programArgs.add(TargetPlatform.getOSArch());
177
			}
178
		}
179
180
		programArgs.add("-testpluginname"); //$NON-NLS-1$
181
		programArgs.add(getTestPluginId(configuration));
182
	}
183
184
	/**
185
	 * Returns the application to launch plug-in tests with
186
	 * 
187
	 * @since 3.5
188
	 * 
189
	 * @param configuration
190
	 * @return the application
191
	 */
192
	protected String getApplication(ILaunchConfiguration configuration) {
193
		String application = null;
194
195
		boolean shouldRunInUIThread = true;
196
		try {
197
			shouldRunInUIThread = configuration.getAttribute(IPDELauncherConstants.RUN_IN_UI_THREAD, true);
198
		} catch (CoreException e) {
199
		}
200
201
		if (!shouldRunInUIThread) {
202
			return IPDEUIConstants.NON_UI_THREAD_APPLICATION;
203
		}
204
205
		try {
206
			// if application is set, it must be a headless app.
207
			application = configuration.getAttribute(IPDELauncherConstants.APPLICATION, (String) null);
208
		} catch (CoreException e) {
209
		}
210
211
		// if application is not set, we should launch the default UI test app
212
		// Check to see if we should launch the legacy UI app
213
		if (application == null) {
214
			IPluginModelBase model = (IPluginModelBase) fAllBundles.get("org.eclipse.pde.junit.runtime"); //$NON-NLS-1$
215
			BundleDescription desc = model != null ? model.getBundleDescription() : null;
216
			if (desc != null) {
217
				Version version = desc.getVersion();
218
				int major = version.getMajor();
219
				// launch legacy UI app only if we are launching a target that does 
220
				// not use the new application model and we are launching with a 
221
				// org.eclipse.pde.junit.runtime whose version is >= 3.3
222
				if (major >= 3 && version.getMinor() >= 3 && !TargetPlatformHelper.usesNewApplicationModel()) {
223
					application = IPDEUIConstants.LEGACY_UI_TEST_APPLICATION;
224
				}
225
			}
226
		}
227
228
		// launch the UI test application
229
		if (application == null)
230
			application = IPDEUIConstants.UI_TEST_APPLICATION;
231
		return application;
232
	}
233
234
	private IPluginModelBase findPlugin(String id) throws CoreException {
235
		IPluginModelBase model = PluginRegistry.findModel(id);
236
		if (model == null)
237
			model = PDECore.getDefault().findPluginInHost(id);
238
		if (model == null)
239
			abort(NLS.bind(PDEUIMessages.JUnitLaunchConfiguration_error_missingPlugin, id), null, IStatus.OK);
240
		return model;
241
	}
242
243
	/*
244
	 * (non-Javadoc)
245
	 * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getProgramArguments(org.eclipse.debug.core.ILaunchConfiguration)
246
	 */
247
	public String getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
248
		return LaunchArgumentsHelper.getUserProgramArguments(configuration);
249
	}
250
251
	/*
252
	 * (non-Javadoc)
253
	 * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getVMArguments(org.eclipse.debug.core.ILaunchConfiguration)
254
	 */
255
	public String getVMArguments(ILaunchConfiguration configuration) throws CoreException {
256
		String vmArgs = LaunchArgumentsHelper.getUserVMArguments(configuration);
257
258
		// necessary for PDE to know how to load plugins when target platform = host platform
259
		IPluginModelBase base = (IPluginModelBase) fAllBundles.get(PDECore.PLUGIN_ID);
260
		if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) >= 0) { //$NON-NLS-1$
261
			vmArgs = concatArg(vmArgs, "-Declipse.pde.launch=true"); //$NON-NLS-1$
262
		}
263
		// For p2 target, add "-Declipse.p2.data.area=@config.dir/p2" unless already specified by user
264
		if (fAllBundles.containsKey("org.eclipse.equinox.p2.core")) { //$NON-NLS-1$
265
			if (vmArgs.indexOf("-Declipse.p2.data.area=") < 0) { //$NON-NLS-1$
266
				vmArgs = concatArg(vmArgs, "-Declipse.p2.data.area=@config.dir" + File.separator + "p2"); //$NON-NLS-1$ //$NON-NLS-2$
267
			}
268
		}
269
		return vmArgs;
270
	}
271
272
	/**
273
	 * Returns the result of concatenating the given argument to the
274
	 * specified vmArgs.
275
	 * 
276
	 * @param vmArgs existing VM arguments
277
	 * @param arg argument to concatenate
278
	 * @return result of concatenation
279
	 */
280
	private String concatArg(String vmArgs, String arg) {
281
		if (vmArgs.length() > 0 && !vmArgs.endsWith(" ")) //$NON-NLS-1$
282
			vmArgs = vmArgs.concat(" "); //$NON-NLS-1$
283
		return vmArgs.concat(arg);
284
	}
285
286
	/*
287
	 * (non-Javadoc)
288
	 * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getEnvironment(org.eclipse.debug.core.ILaunchConfiguration)
289
	 */
290
	public String[] getEnvironment(ILaunchConfiguration configuration) throws CoreException {
291
		return DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
292
	}
293
294
	/*
295
	 * (non-Javadoc)
296
	 * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getClasspath(org.eclipse.debug.core.ILaunchConfiguration)
297
	 */
298
	public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
299
		String[] classpath = LaunchArgumentsHelper.constructClasspath(configuration);
300
		if (classpath == null) {
301
			abort(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_noStartup, null, IStatus.OK);
302
		}
303
		return classpath;
304
	}
305
306
	/*
307
	 * (non-Javadoc)
308
	 * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getWorkingDirectory(org.eclipse.debug.core.ILaunchConfiguration)
309
	 */
310
	public File getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
311
		return LaunchArgumentsHelper.getWorkingDirectory(configuration);
312
	}
313
314
	/*
315
	 * (non-Javadoc)
316
	 * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getVMSpecificAttributesMap(org.eclipse.debug.core.ILaunchConfiguration)
317
	 */
318
	public Map getVMSpecificAttributesMap(ILaunchConfiguration configuration) throws CoreException {
319
		return LaunchArgumentsHelper.getVMSpecificAttributesMap(configuration);
320
	}
321
322
	/*
323
	 * (non-Javadoc)
324
	 * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#setDefaultSourceLocator(org.eclipse.debug.core.ILaunch, org.eclipse.debug.core.ILaunchConfiguration)
325
	 */
326
	protected void setDefaultSourceLocator(ILaunch launch, ILaunchConfiguration configuration) throws CoreException {
327
		ILaunchConfigurationWorkingCopy wc = null;
328
		if (configuration.isWorkingCopy()) {
329
			wc = (ILaunchConfigurationWorkingCopy) configuration;
330
		} else {
331
			wc = configuration.getWorkingCopy();
332
		}
333
		String id = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, (String) null);
334
		if (!PDESourcePathProvider.ID.equals(id)) {
335
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, PDESourcePathProvider.ID);
336
			wc.doSave();
337
		}
338
339
		manageLaunch(launch);
340
	}
341
342
	/**
343
	 * Returns the location of the configuration area
344
	 * 
345
	 * @param configuration
346
	 * 				the launch configuration
347
	 * @return a directory where the configuration area is located
348
	 */
349
	protected File getConfigurationDirectory(ILaunchConfiguration configuration) {
350
		if (fConfigDir == null)
351
			fConfigDir = LaunchConfigurationHelper.getConfigurationArea(configuration);
352
		return fConfigDir;
353
	}
354
355
	/*
356
	 * (non-Javadoc)
357
	 * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
358
	 */
359
	protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
360
		return computeBuildOrder(LaunchPluginValidator.getAffectedProjects(configuration));
361
	}
362
363
	/*
364
	 * (non-Javadoc)
365
	 * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getProjectsForProblemSearch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
366
	 */
367
	protected IProject[] getProjectsForProblemSearch(ILaunchConfiguration configuration, String mode) throws CoreException {
368
		return LaunchPluginValidator.getAffectedProjects(configuration);
369
	}
370
371
	/**
372
	 * Adds a listener to the launch to be notified at interesting launch lifecycle
373
	 * events such as when the launch terminates.
374
	 * 
375
	 * @param launch
376
	 * 			the launch 			
377
	 */
378
	protected void manageLaunch(ILaunch launch) {
379
		PDEPlugin.getDefault().getLaunchListener().manage(launch);
380
	}
381
382
	/* (non-Javadoc)
383
	 * @see org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
384
	 */
385
	protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
386
		fWorkspaceLocation = null;
387
		fModels = BundleLauncherHelper.getMergedBundleMap(configuration, false);
388
		fAllBundles = new HashMap(fModels.size());
389
		Iterator iter = fModels.keySet().iterator();
390
		while (iter.hasNext()) {
391
			IPluginModelBase model = (IPluginModelBase) iter.next();
392
			fAllBundles.put(model.getPluginBase().getId(), model);
393
		}
394
395
		// implicitly add the plug-ins required for JUnit testing if necessary
396
		String[] requiredPlugins = getRequiredPlugins(configuration);
397
		for (int i = 0; i < requiredPlugins.length; i++) {
398
			String id = requiredPlugins[i];
399
			if (!fAllBundles.containsKey(id)) {
400
				IPluginModelBase model = findPlugin(id);
401
				fAllBundles.put(id, model);
402
				fModels.put(model, "default:default"); //$NON-NLS-1$
403
			}
404
		}
405
406
		boolean autoValidate = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, false);
407
		monitor.beginTask("", autoValidate ? 3 : 4); //$NON-NLS-1$
408
		if (autoValidate)
409
			validatePluginDependencies(configuration, new SubProgressMonitor(monitor, 1));
410
		validateProjectDependencies(configuration, new SubProgressMonitor(monitor, 1));
411
		clear(configuration, new SubProgressMonitor(monitor, 1));
412
		launch.setAttribute(IPDELauncherConstants.CONFIG_LOCATION, getConfigurationDirectory(configuration).toString());
413
		synchronizeManifests(configuration, new SubProgressMonitor(monitor, 1));
414
	}
415
416
	private String[] getRequiredPlugins(ILaunchConfiguration configuration) {
417
		// if we are using JUnit4, we need to include the junit4 specific bundles
418
		ITestKind testKind = JUnitLaunchConfigurationConstants.getTestRunnerKind(configuration);
419
		if (TestKindRegistry.JUNIT4_TEST_KIND_ID.equals(testKind.getId()))
420
			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$
421
		return new String[] {"org.junit", "org.eclipse.jdt.junit.runtime", "org.eclipse.pde.junit.runtime"}; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
422
	}
423
424
	/**
425
	 * Checks for old-style plugin.xml files that have become stale since the last launch.
426
	 * For any stale plugin.xml files found, the corresponding MANIFEST.MF is deleted 
427
	 * from the runtime configuration area so that it gets regenerated upon startup.
428
	 * 
429
	 * @param configuration
430
	 * 			the launch configuration
431
	 * @param monitor
432
	 * 			the progress monitor
433
	 */
434
	protected void synchronizeManifests(ILaunchConfiguration configuration, IProgressMonitor monitor) {
435
		LaunchConfigurationHelper.synchronizeManifests(configuration, getConfigurationDirectory(configuration));
436
		monitor.done();
437
	}
438
439
	/**
440
	 * Clears the workspace prior to launching if the workspace exists and the option to 
441
	 * clear it is turned on.  Also clears the configuration area if that option is chosen.
442
	 * 
443
	 * @param configuration
444
	 * 			the launch configuration
445
	 * @param monitor
446
	 * 			the progress monitor
447
	 * @throws CoreException
448
	 * 			if unable to retrieve launch attribute values
449
	 * @since 3.3
450
	 */
451
	protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
452
		if (fWorkspaceLocation == null) {
453
			fWorkspaceLocation = LaunchArgumentsHelper.getWorkspaceLocation(configuration);
454
		}
455
		// Clear workspace and prompt, if necessary
456
		if (!LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, new SubProgressMonitor(monitor, 1))) {
457
			monitor.setCanceled(true);
458
			return;
459
		}
460
461
		// clear config area, if necessary
462
		if (configuration.getAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false))
463
			CoreUtility.deleteContent(getConfigurationDirectory(configuration));
464
	}
465
466
	/**
467
	 * Checks if the Automated Management of Dependencies option is turned on.
468
	 * If so, it makes aure all manifests are updated with the correct dependencies.
469
	 * 
470
	 * @param configuration
471
	 * 			the launch configuration
472
	 * @param monitor
473
	 * 			a progress monitor
474
	 */
475
	protected void validateProjectDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) {
476
		LauncherUtils.validateProjectDependencies(configuration, monitor);
477
	}
478
24
479
	/**
480
	 * Validates inter-bundle dependencies automatically prior to launching
481
	 * if that option is turned on.
482
	 * 
483
	 * @param configuration
484
	 * 			the launch configuration
485
	 * @param monitor
486
	 * 			a progress monitor
487
	 */
488
	protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
489
		EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration);
490
		LaunchPluginValidator.runValidationOperation(op, monitor);
491
	}
492
}
25
}
(-)src/org/eclipse/pde/ui/launcher/OSGiLaunchConfigurationInitializer.java (-90 / +3 lines)
Lines 10-21 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
11
package org.eclipse.pde.ui.launcher;
12
12
13
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
14
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
15
import org.eclipse.pde.core.plugin.IPluginModelBase;
16
import org.eclipse.pde.core.plugin.PluginRegistry;
17
import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper;
18
19
/**
13
/**
20
 * Initializes launch configuration attributes for newly-created OSGi Framework 
14
 * Initializes launch configuration attributes for newly-created OSGi Framework 
21
 * launch configurations
15
 * launch configurations
Lines 25-114 Link Here
25
 * </p>
19
 * </p>
26
 * 
20
 * 
27
 * @since 3.3
21
 * @since 3.3
22
 * @deprecated use {@link org.eclipse.pde.launching.OSGiLaunchConfigurationInitializer} instead.
23
 * @see org.eclipse.pde.launching.OSGiLaunchConfigurationInitializer
28
 */
24
 */
29
public class OSGiLaunchConfigurationInitializer {
25
public class OSGiLaunchConfigurationInitializer extends org.eclipse.pde.launching.OSGiLaunchConfigurationInitializer {
30
31
	protected static final String DEFAULT = "default"; //$NON-NLS-1$
32
33
	/**
34
	 * Initializes some attributes on a newly-created launch configuration
35
	 * 
36
	 * @param configuration
37
	 * 			the launch configuration
38
	 */
39
	public void initialize(ILaunchConfigurationWorkingCopy configuration) {
40
		initializeFrameworkDefaults(configuration);
41
		initializeBundleState(configuration);
42
		initializeSourcePathProvider(configuration);
43
	}
44
45
	/**
46
	 * Sets the source provider ID
47
	 * 
48
	 * @param configuration
49
	 * 			the launch configuration
50
	 */
51
	protected void initializeSourcePathProvider(ILaunchConfigurationWorkingCopy configuration) {
52
		configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, PDESourcePathProvider.ID);
53
	}
54
55
	/**
56
	 * Initializes the start level and auto-start attributes
57
	 * 
58
	 * @param configuration
59
	 * 			the launch configuration
60
	 */
61
	protected void initializeFrameworkDefaults(ILaunchConfigurationWorkingCopy configuration) {
62
		configuration.setAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, true);
63
		configuration.setAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4);
64
	}
65
66
	/**
67
	 * Initializes the checked/unchecked state of bundles
68
	 * 
69
	 * @param configuration
70
	 * 			the launch configuration
71
	 */
72
	protected void initializeBundleState(ILaunchConfigurationWorkingCopy configuration) {
73
		StringBuffer explugins = new StringBuffer();
74
		StringBuffer wsplugins = new StringBuffer();
75
		IPluginModelBase[] models = PluginRegistry.getActiveModels();
76
		for (int i = 0; i < models.length; i++) {
77
			boolean inWorkspace = models[i].getUnderlyingResource() != null;
78
			appendBundle(inWorkspace ? wsplugins : explugins, models[i]);
79
		}
80
		configuration.setAttribute(IPDELauncherConstants.WORKSPACE_BUNDLES, wsplugins.toString());
81
		configuration.setAttribute(IPDELauncherConstants.TARGET_BUNDLES, explugins.toString());
82
		configuration.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
83
	}
84
85
	private void appendBundle(StringBuffer buffer, IPluginModelBase model) {
86
		if (buffer.length() > 0)
87
			buffer.append(","); //$NON-NLS-1$
88
		String id = model.getPluginBase().getId();
89
		String value = BundleLauncherHelper.writeBundleEntry(model, getStartLevel(id), getAutoStart(id));
90
		buffer.append(value);
91
	}
92
93
	/**
94
	 * Returns the bundle's start level
95
	 * 
96
	 * @param bundleID
97
	 * 			the bundle ID
98
	 * @return the start level for the given bundle or the string <code>default</code>
99
	 */
100
	protected String getStartLevel(String bundleID) {
101
		return DEFAULT;
102
	}
103
104
	/**
105
	 * Returns whether the bundle should be started automatically
106
	 * @param bundleID
107
	 * 			the bundle ID
108
	 * @return <code>true</code>, <code>false</code>, or <code>default</code>
109
	 */
110
	protected String getAutoStart(String bundleID) {
111
		return DEFAULT;
112
	}
113
26
114
}
27
}
(-)src/org/eclipse/pde/ui/launcher/TestTab.java (+2 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
11
package org.eclipse.pde.ui.launcher;
12
12
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
13
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
(-)src/org/eclipse/pde/ui/launcher/EclipseApplicationLaunchConfiguration.java (-13 / +15 lines)
Lines 23-31 Link Here
23
import org.eclipse.pde.internal.core.*;
23
import org.eclipse.pde.internal.core.*;
24
import org.eclipse.pde.internal.core.util.CoreUtility;
24
import org.eclipse.pde.internal.core.util.CoreUtility;
25
import org.eclipse.pde.internal.core.util.VersionUtil;
25
import org.eclipse.pde.internal.core.util.VersionUtil;
26
import org.eclipse.pde.internal.launching.PDEMessages;
27
import org.eclipse.pde.internal.launching.launcher.*;
26
import org.eclipse.pde.internal.ui.PDEPlugin;
28
import org.eclipse.pde.internal.ui.PDEPlugin;
27
import org.eclipse.pde.internal.ui.PDEUIMessages;
28
import org.eclipse.pde.internal.ui.launcher.*;
29
import org.osgi.framework.Version;
29
import org.osgi.framework.Version;
30
30
31
/**
31
/**
Lines 34-39 Link Here
34
 * Clients may subclass and instantiate this class.
34
 * Clients may subclass and instantiate this class.
35
 * </p>
35
 * </p>
36
 * @since 3.2
36
 * @since 3.2
37
 * @deprecated use {@link org.eclipse.pde.launching.EclipseApplicationLaunchConfiguration}
38
 * @see org.eclipse.pde.launching.AbstractPDELaunchConfiguration
37
 */
39
 */
38
public class EclipseApplicationLaunchConfiguration extends AbstractPDELaunchConfiguration {
40
public class EclipseApplicationLaunchConfiguration extends AbstractPDELaunchConfiguration {
39
41
Lines 58-76 Link Here
58
		ArrayList programArgs = new ArrayList();
60
		ArrayList programArgs = new ArrayList();
59
61
60
		// If a product is specified, then add it to the program args
62
		// If a product is specified, then add it to the program args
61
		if (configuration.getAttribute(IPDELauncherConstants.USE_PRODUCT, false)) {
63
		if (configuration.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.USE_PRODUCT, false)) {
62
			String product = configuration.getAttribute(IPDELauncherConstants.PRODUCT, ""); //$NON-NLS-1$
64
			String product = configuration.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.PRODUCT, ""); //$NON-NLS-1$
63
			if (product.length() > 0) {
65
			if (product.length() > 0) {
64
				programArgs.add("-product"); //$NON-NLS-1$
66
				programArgs.add("-product"); //$NON-NLS-1$
65
				programArgs.add(product);
67
				programArgs.add(product);
66
			} else { // TODO product w/o an application and product... how to handle gracefully?
68
			} else { // TODO product w/o an application and product... how to handle gracefully?
67
				programArgs.add("-application"); //$NON-NLS-1$
69
				programArgs.add("-application"); //$NON-NLS-1$
68
				programArgs.add(configuration.getAttribute(IPDELauncherConstants.APPLICATION, "")); //$NON-NLS-1$
70
				programArgs.add(configuration.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.APPLICATION, "")); //$NON-NLS-1$
69
			}
71
			}
70
		} else {
72
		} else {
71
			// specify the application to launch
73
			// specify the application to launch
72
			programArgs.add("-application"); //$NON-NLS-1$
74
			programArgs.add("-application"); //$NON-NLS-1$
73
			programArgs.add(configuration.getAttribute(IPDELauncherConstants.APPLICATION, TargetPlatform.getDefaultApplication()));
75
			programArgs.add(configuration.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.APPLICATION, TargetPlatform.getDefaultApplication()));
74
		}
76
		}
75
77
76
		// specify the workspace location for the runtime workbench
78
		// specify the workspace location for the runtime workbench
Lines 83-94 Link Here
83
		}
85
		}
84
86
85
		boolean showSplash = true;
87
		boolean showSplash = true;
86
		if (configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false)) {
88
		if (configuration.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.USEFEATURES, false)) {
87
			validateFeatures();
89
			validateFeatures();
88
			IPath installPath = PDEPlugin.getWorkspace().getRoot().getLocation();
90
			IPath installPath = PDEPlugin.getWorkspace().getRoot().getLocation();
89
			programArgs.add("-install"); //$NON-NLS-1$
91
			programArgs.add("-install"); //$NON-NLS-1$
90
			programArgs.add("file:" + installPath.removeLastSegments(1).addTrailingSeparator().toString()); //$NON-NLS-1$
92
			programArgs.add("file:" + installPath.removeLastSegments(1).addTrailingSeparator().toString()); //$NON-NLS-1$
91
			if (!configuration.getAttribute(IPDELauncherConstants.CONFIG_USE_DEFAULT_AREA, true)) {
93
			if (!configuration.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.CONFIG_USE_DEFAULT_AREA, true)) {
92
				programArgs.add("-configuration"); //$NON-NLS-1$
94
				programArgs.add("-configuration"); //$NON-NLS-1$
93
				programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
95
				programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
94
			}
96
			}
Lines 158-164 Link Here
158
					|| !featuresPath.toFile().exists();
160
					|| !featuresPath.toFile().exists();
159
		}
161
		}
160
		if (badStructure) {
162
		if (badStructure) {
161
			throw new CoreException(LauncherUtils.createErrorStatus(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_badFeatureSetup));
163
			throw new CoreException(LauncherUtils.createErrorStatus(PDEMessages.WorkbenchLauncherConfigurationDelegate_badFeatureSetup));
162
		}
164
		}
163
		// Ensure important files are present
165
		// Ensure important files are present
164
		ensureProductFilesExist(getProductPath());
166
		ensureProductFilesExist(getProductPath());
Lines 196-202 Link Here
196
	protected File getConfigDir(ILaunchConfiguration config) {
198
	protected File getConfigDir(ILaunchConfiguration config) {
197
		if (fConfigDir == null) {
199
		if (fConfigDir == null) {
198
			try {
200
			try {
199
				if (config.getAttribute(IPDELauncherConstants.USEFEATURES, false) && config.getAttribute(IPDELauncherConstants.CONFIG_USE_DEFAULT_AREA, true)) {
201
				if (config.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.USEFEATURES, false) && config.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.CONFIG_USE_DEFAULT_AREA, true)) {
200
					String root = getProductPath().toString();
202
					String root = getProductPath().toString();
201
					root += "/configuration"; //$NON-NLS-1$
203
					root += "/configuration"; //$NON-NLS-1$
202
					fConfigDir = new File(root);
204
					fConfigDir = new File(root);
Lines 233-239 Link Here
233
			throw new CoreException(Status.CANCEL_STATUS);
235
			throw new CoreException(Status.CANCEL_STATUS);
234
236
235
		// clear config area, if necessary
237
		// clear config area, if necessary
236
		if (configuration.getAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false))
238
		if (configuration.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.CONFIG_CLEAR_AREA, false))
237
			CoreUtility.deleteContent(getConfigDir(configuration));
239
			CoreUtility.deleteContent(getConfigDir(configuration));
238
	}
240
	}
239
241
Lines 255-262 Link Here
255
	}
257
	}
256
258
257
	private void validateConfigIni(ILaunchConfiguration configuration) throws CoreException {
259
	private void validateConfigIni(ILaunchConfiguration configuration) throws CoreException {
258
		if (!configuration.getAttribute(IPDELauncherConstants.CONFIG_GENERATE_DEFAULT, true)) {
260
		if (!configuration.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.CONFIG_GENERATE_DEFAULT, true)) {
259
			String templateLoc = configuration.getAttribute(IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, ""); //$NON-NLS-1$
261
			String templateLoc = configuration.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, ""); //$NON-NLS-1$
260
			IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
262
			IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
261
			templateLoc = mgr.performStringSubstitution(templateLoc);
263
			templateLoc = mgr.performStringSubstitution(templateLoc);
262
264
(-)src/org/eclipse/pde/ui/launcher/EclipseLauncherTabGroup.java (-3 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-20 Link Here
15
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
15
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
16
import org.eclipse.debug.ui.*;
16
import org.eclipse.debug.ui.*;
17
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab;
17
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab;
18
import org.eclipse.pde.internal.launching.IPDEConstants;
18
import org.eclipse.pde.internal.ui.IPDEUIConstants;
19
import org.eclipse.pde.internal.ui.IPDEUIConstants;
19
20
20
/**
21
/**
Lines 51-58 Link Here
51
			// is present in the original copy.  We do this by querying the config twice, with different default values.  If the values == eachother, we 
52
			// is present in the original copy.  We do this by querying the config twice, with different default values.  If the values == eachother, we 
52
			// we know the value is present.  Since generated configs don't contain DOCLEARLOG, we know if DOCLEARLOG is present in the original copy the 
53
			// we know the value is present.  Since generated configs don't contain DOCLEARLOG, we know if DOCLEARLOG is present in the original copy the 
53
			// perform apply so save the initialization values has already been run and this is a user modification.
54
			// perform apply so save the initialization values has already been run and this is a user modification.
54
			boolean firstQuery = original.getAttribute(IPDEUIConstants.DOCLEARLOG, false);
55
			boolean firstQuery = original.getAttribute(IPDEConstants.DOCLEARLOG, false);
55
			boolean secondQuery = original.getAttribute(IPDEUIConstants.DOCLEARLOG, true);
56
			boolean secondQuery = original.getAttribute(IPDEConstants.DOCLEARLOG, true);
56
			if (original != null && firstQuery == secondQuery)
57
			if (original != null && firstQuery == secondQuery)
57
				configuration.setAttribute(IPDEUIConstants.GENERATED_CONFIG, false);
58
				configuration.setAttribute(IPDEUIConstants.GENERATED_CONFIG, false);
58
		} catch (CoreException e) {
59
		} catch (CoreException e) {
(-)src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfiguration.java (-402 / +3 lines)
Lines 10-423 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
11
package org.eclipse.pde.ui.launcher;
12
12
13
import java.io.File;
14
import java.util.ArrayList;
15
import java.util.Map;
16
import org.eclipse.core.resources.IMarker;
17
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.runtime.*;
19
import org.eclipse.debug.core.*;
20
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
21
import org.eclipse.jdt.core.IJavaModelMarker;
22
import org.eclipse.jdt.launching.*;
23
import org.eclipse.jface.dialogs.MessageDialog;
24
import org.eclipse.pde.core.plugin.TargetPlatform;
25
import org.eclipse.pde.internal.core.TargetPlatformHelper;
26
import org.eclipse.pde.internal.core.builders.PDEMarkerFactory;
27
import org.eclipse.pde.internal.ui.*;
28
import org.eclipse.pde.internal.ui.launcher.*;
29
30
/**
13
/**
31
 * An abstract launch delegate for PDE-based launch configurations
14
 * An abstract launch delegate for PDE-based launch configurations
32
 * <p>
15
 * <p>
33
 * Clients may subclass this class.
16
 * Clients may subclass this class.
34
 * </p>
17
 * </p>
35
 * @since 3.2
18
 * @since 3.2
19
 * @deprecated use {@link org.eclipse.pde.launching.AbstractPDELaunchConfiguration}
20
 * @see org.eclipse.pde.launching.AbstractPDELaunchConfiguration
36
 */
21
 */
37
public abstract class AbstractPDELaunchConfiguration extends LaunchConfigurationDelegate {
22
public abstract class AbstractPDELaunchConfiguration extends org.eclipse.pde.launching.AbstractPDELaunchConfiguration {
38
39
	protected File fConfigDir = null;
40
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#isLaunchProblem(org.eclipse.core.resources.IMarker)
43
	 */
44
	protected boolean isLaunchProblem(IMarker problemMarker) throws CoreException {
45
		return super.isLaunchProblem(problemMarker) && (problemMarker.getType().equals(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER) || problemMarker.getType().equals(PDEMarkerFactory.MARKER_ID));
46
	}
47
48
	/*
49
	 * (non-Javadoc)
50
	 * @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)
51
	 */
52
	public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
53
		try {
54
			fConfigDir = null;
55
			monitor.beginTask("", 4); //$NON-NLS-1$
56
			try {
57
				preLaunchCheck(configuration, launch, new SubProgressMonitor(monitor, 2));
58
			} catch (CoreException e) {
59
				if (e.getStatus().getSeverity() == IStatus.CANCEL) {
60
					monitor.setCanceled(true);
61
					return;
62
				}
63
				throw e;
64
			}
65
			// if restarting, remove the restart flag from the launch config
66
			if (configuration.getAttribute(IPDEUIConstants.RESTART, false) && configuration instanceof ILaunchConfigurationWorkingCopy) {
67
				((ILaunchConfigurationWorkingCopy) configuration).setAttribute(IPDEUIConstants.RESTART, false);
68
				((ILaunchConfigurationWorkingCopy) configuration).doSave();
69
			}
70
			VMRunnerConfiguration runnerConfig = new VMRunnerConfiguration(getMainClass(), getClasspath(configuration));
71
			runnerConfig.setVMArguments(getVMArguments(configuration));
72
			runnerConfig.setProgramArguments(getProgramArguments(configuration));
73
			runnerConfig.setWorkingDirectory(getWorkingDirectory(configuration).getAbsolutePath());
74
			runnerConfig.setEnvironment(getEnvironment(configuration));
75
			runnerConfig.setVMSpecificAttributesMap(getVMSpecificAttributesMap(configuration));
76
77
			monitor.worked(1);
78
79
			setDefaultSourceLocator(configuration);
80
			manageLaunch(launch);
81
			IVMRunner runner = getVMRunner(configuration, mode);
82
			if (runner != null)
83
				runner.run(runnerConfig, launch, monitor);
84
			else
85
				monitor.setCanceled(true);
86
			monitor.done();
87
		} catch (final CoreException e) {
88
			monitor.setCanceled(true);
89
			LauncherUtils.getDisplay().syncExec(new Runnable() {
90
				public void run() {
91
					MessageDialog.openError(LauncherUtils.getActiveShell(), PDEUIMessages.Launcher_error_title, e.getMessage());
92
				}
93
			});
94
		}
95
	}
96
97
	/**
98
	 * Returns the VM runner for the given launch mode to use when launching the
99
	 * given configuration.
100
	 *  
101
	 * @param configuration launch configuration
102
	 * @param mode launch node
103
	 * @return VM runner to use when launching the given configuration in the given mode
104
	 * @throws CoreException if a VM runner cannot be determined
105
	 */
106
	public IVMRunner getVMRunner(ILaunchConfiguration configuration, String mode) throws CoreException {
107
		IVMInstall launcher = VMHelper.createLauncher(configuration);
108
		return launcher.getVMRunner(mode);
109
	}
110
111
	/**
112
	 * Assigns a default source locator to the given launch if a source locator
113
	 * has not yet been assigned to it, and the associated launch configuration
114
	 * does not specify a source locator.
115
	 * 
116
	 * @param configuration
117
	 *            configuration being launched
118
	 * @exception CoreException
119
	 *                if unable to set the source locator
120
	 */
121
	protected void setDefaultSourceLocator(ILaunchConfiguration configuration) throws CoreException {
122
		ILaunchConfigurationWorkingCopy wc = null;
123
		if (configuration.isWorkingCopy()) {
124
			wc = (ILaunchConfigurationWorkingCopy) configuration;
125
		} else {
126
			wc = configuration.getWorkingCopy();
127
		}
128
		String id = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, (String) null);
129
		if (!PDESourcePathProvider.ID.equals(id)) {
130
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, PDESourcePathProvider.ID);
131
			wc.doSave();
132
		}
133
	}
134
135
	/**
136
	 * Returns the entries that should appear on boot classpath.
137
	 * 
138
	 * @param configuration
139
	 *            launch configuration
140
	 * @return the location of startup.jar and 
141
	 * 		the bootstrap classpath specified by the given launch configuration
142
	 *        
143
	 * @exception CoreException
144
	 *                if unable to find startup.jar
145
	 */
146
	public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
147
		String[] classpath = LaunchArgumentsHelper.constructClasspath(configuration);
148
		if (classpath == null) {
149
			String message = PDEUIMessages.WorkbenchLauncherConfigurationDelegate_noStartup;
150
			throw new CoreException(LauncherUtils.createErrorStatus(message));
151
		}
152
		return classpath;
153
	}
154
155
	/** 
156
	 * Returns an array of environment variables to be used when
157
	 * launching the given configuration or <code>null</code> if unspecified.
158
	 * 
159
	 * @param configuration launch configuration
160
	 * @throws CoreException if unable to access associated attribute or if
161
	 * unable to resolve a variable in an environment variable's value
162
	 */
163
	public String[] getEnvironment(ILaunchConfiguration configuration) throws CoreException {
164
		return DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
165
	}
166
167
	/**
168
	 * Returns the working directory path specified by the given launch
169
	 * configuration, or <code>null</code> if none.
170
	 * 
171
	 * @param configuration
172
	 *            launch configuration
173
	 * @return the working directory path specified by the given launch
174
	 *         configuration, or <code>null</code> if none
175
	 * @exception CoreException
176
	 *                if unable to retrieve the attribute
177
	 */
178
	public File getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
179
		return LaunchArgumentsHelper.getWorkingDirectory(configuration);
180
	}
181
182
	/**
183
	 * Returns the Map of VM-specific attributes specified by the given launch
184
	 * configuration, or <code>null</code> if none.
185
	 * 
186
	 * @param configuration
187
	 *            launch configuration
188
	 * @return the <code>Map</code> of VM-specific attributes
189
	 * @exception CoreException
190
	 *                if unable to retrieve the attribute
191
	 */
192
	public Map getVMSpecificAttributesMap(ILaunchConfiguration configuration) throws CoreException {
193
		return LaunchArgumentsHelper.getVMSpecificAttributesMap(configuration);
194
	}
195
196
	/**
197
	 * Returns the VM arguments specified by the given launch configuration, as
198
	 * an array of strings. 
199
	 * 
200
	 * @param configuration
201
	 *            launch configuration
202
	 * @return the VM arguments specified by the given launch configuration,
203
	 *         possibly an empty array
204
	 * @exception CoreException
205
	 *                if unable to retrieve the attribute
206
	 */
207
	public String[] getVMArguments(ILaunchConfiguration configuration) throws CoreException {
208
		String[] vmArgs = new ExecutionArguments(LaunchArgumentsHelper.getUserVMArguments(configuration), "").getVMArgumentsArray(); //$NON-NLS-1$
209
		// For p2 target, add "-Declipse.p2.data.area=@config.dir/p2" unless already specified by user
210
		Map bundleMap = BundleLauncherHelper.getMergedBundleMap(configuration, false);
211
		if (bundleMap.containsKey("org.eclipse.equinox.p2.core")) { //$NON-NLS-1$
212
			for (int i = 0; i < vmArgs.length; i++) {
213
				String arg = vmArgs[i];
214
				if (arg.startsWith("-Declipse.p2.data.area=")) { //$NON-NLS-1$
215
					return vmArgs;
216
				}
217
			}
218
			String[] temp = new String[vmArgs.length + 1];
219
			System.arraycopy(vmArgs, 0, temp, 0, vmArgs.length);
220
			temp[vmArgs.length] = "-Declipse.p2.data.area=@config.dir" + File.separator + "p2"; //$NON-NLS-1$ //$NON-NLS-2$
221
			return temp;
222
		}
223
		return vmArgs;
224
	}
225
226
	/**
227
	 * Returns the program arguments to launch with.
228
	 * This list is a combination of arguments computed by PDE based on attributes
229
	 * specified in the given launch configuration, followed by the program arguments
230
	 * that the entered directly into the launch configuration.
231
	 * 
232
	 * @param configuration
233
	 *            launch configuration
234
	 * @return the program arguments necessary for launching
235
	 * 
236
	 * @exception CoreException
237
	 *                if unable to retrieve the attribute or create the
238
	 *                necessary configuration files      
239
	 */
240
	public String[] getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
241
		ArrayList programArgs = new ArrayList();
242
243
		// add tracing, if turned on	
244
		if (configuration.getAttribute(IPDELauncherConstants.TRACING, false) && !IPDELauncherConstants.TRACING_NONE.equals(configuration.getAttribute(IPDELauncherConstants.TRACING_CHECKED, (String) null))) {
245
			programArgs.add("-debug"); //$NON-NLS-1$
246
			programArgs.add(LaunchArgumentsHelper.getTracingFileArgument(configuration, getConfigDir(configuration).toString() + IPath.SEPARATOR + ".options")); //$NON-NLS-1$
247
		}
248
249
		// add the program args specified by the user
250
		String[] userArgs = LaunchArgumentsHelper.getUserProgramArgumentArray(configuration);
251
		ArrayList userDefined = new ArrayList();
252
		for (int i = 0; i < userArgs.length; i++) {
253
			// be forgiving if people have tracing turned on and forgot
254
			// to remove the -debug from the program args field.
255
			if (userArgs[i].equals("-debug") && programArgs.contains("-debug")) //$NON-NLS-1$ //$NON-NLS-2$
256
				continue;
257
			userDefined.add(userArgs[i]);
258
		}
259
260
		if (!configuration.getAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, false)) {
261
262
			if (!userDefined.contains("-os")) { //$NON-NLS-1$
263
				programArgs.add("-os"); //$NON-NLS-1$
264
				programArgs.add(TargetPlatform.getOS());
265
			}
266
			if (!userDefined.contains("-ws")) { //$NON-NLS-1$
267
				programArgs.add("-ws"); //$NON-NLS-1$
268
				programArgs.add(TargetPlatform.getWS());
269
			}
270
			if (!userDefined.contains("-arch")) { //$NON-NLS-1$
271
				programArgs.add("-arch"); //$NON-NLS-1$
272
				programArgs.add(TargetPlatform.getOSArch());
273
			}
274
		}
275
276
		if (userDefined.size() > 0) {
277
			programArgs.addAll(userDefined);
278
		}
279
280
		return (String[]) programArgs.toArray(new String[programArgs.size()]);
281
	}
282
283
	/**
284
	 * Does sanity checking before launching.  The criteria whether the launch should 
285
	 * proceed or not is specific to the launch configuration type.
286
	 * 
287
	 * @param configuration launch configuration
288
	 * @param launch the launch object to contribute processes and debug targets to
289
	 * @param monitor a progress monitor
290
	 * 
291
	 * @throws CoreException exception thrown if launch fails or canceled or if unable to retrieve attributes
292
	 * from the launch configuration
293
	 * 				
294
	 */
295
	protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
296
		boolean autoValidate = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, false);
297
		monitor.beginTask("", autoValidate ? 3 : 4); //$NON-NLS-1$
298
		if (autoValidate)
299
			validatePluginDependencies(configuration, new SubProgressMonitor(monitor, 1));
300
		validateProjectDependencies(configuration, new SubProgressMonitor(monitor, 1));
301
		clear(configuration, new SubProgressMonitor(monitor, 1));
302
		launch.setAttribute(IPDELauncherConstants.CONFIG_LOCATION, getConfigDir(configuration).toString());
303
		synchronizeManifests(configuration, new SubProgressMonitor(monitor, 1));
304
	}
305
306
	/**
307
	 * Returns the configuration area specified by the given launch
308
	 * configuration.
309
	 * 
310
	 * @param configuration
311
	 *            launch configuration
312
	 * @return the directory path specified by the given launch
313
	 *         configuration
314
	 */
315
	protected File getConfigDir(ILaunchConfiguration configuration) {
316
		if (fConfigDir == null)
317
			fConfigDir = LaunchConfigurationHelper.getConfigurationArea(configuration);
318
		return fConfigDir;
319
	}
320
321
	/*
322
	/* (non-Javadoc)
323
	 * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
324
	 */
325
	protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
326
		return computeBuildOrder(LaunchPluginValidator.getAffectedProjects(configuration));
327
	}
328
329
	/*
330
	 * (non-Javadoc)
331
	 * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getProjectsForProblemSearch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
332
	 */
333
	protected IProject[] getProjectsForProblemSearch(ILaunchConfiguration configuration, String mode) throws CoreException {
334
		return LaunchPluginValidator.getAffectedProjects(configuration);
335
	}
336
337
	/**
338
	 * Returns the fully-qualified name of the class to launch. 
339
	 * 
340
	 * @return the fully-qualified name of the class to launch.  Must not return <code>null</code>. 
341
	 * @since 3.3
342
	 */
343
	public String getMainClass() {
344
		if (TargetPlatformHelper.getTargetVersion() >= 3.3)
345
			return "org.eclipse.equinox.launcher.Main"; //$NON-NLS-1$
346
		return "org.eclipse.core.launcher.Main"; //$NON-NLS-1$
347
	}
348
349
	/**
350
	 * Adds a listener to the launch to be notified at interesting launch lifecycle
351
	 * events such as when the launch terminates.
352
	 * 
353
	 * @param launch
354
	 * 			the launch 		
355
	 * 
356
	 * @since 3.3	
357
	 */
358
	protected void manageLaunch(ILaunch launch) {
359
		PDEPlugin.getDefault().getLaunchListener().manage(launch);
360
	}
361
362
	/**
363
	 * Checks for old-style plugin.xml files that have become stale since the last launch.
364
	 * For any stale plugin.xml files found, the corresponding MANIFEST.MF is deleted 
365
	 * from the runtime configuration area so that it gets regenerated upon startup.
366
	 * 
367
	 * @param configuration
368
	 * 			the launch configuration
369
	 * @param monitor
370
	 * 			a progress monitor
371
	 * 
372
	 * @since 3.3
373
	 */
374
	protected void synchronizeManifests(ILaunchConfiguration configuration, IProgressMonitor monitor) {
375
		LaunchConfigurationHelper.synchronizeManifests(configuration, getConfigDir(configuration));
376
		monitor.done();
377
	}
378
379
	/**
380
	 * Checks if the Automated Management of Dependencies option is turned on.
381
	 * If so, it makes aure all manifests are updated with the correct dependencies.
382
	 * 
383
	 * @param configuration
384
	 * 			the launch configuration
385
	 * @param monitor
386
	 * 			a progress monitor
387
	 * 
388
	 * @since 3.3
389
	 */
390
	protected void validateProjectDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) {
391
		LauncherUtils.validateProjectDependencies(configuration, monitor);
392
	}
393
394
	/**
395
	 * By default, this method does nothing.  Clients should override, if appropriate.
396
	 * 
397
	 * @param configuration
398
	 * 			the launch configuration
399
	 * @param monitor
400
	 * 			the progress monitor
401
	 * @throws CoreException
402
	 * 			if unable to retrieve launch attribute values
403
	 * @since 3.3
404
	 */
405
	protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
406
	}
407
408
	/**
409
	 * Validates inter-bundle dependencies automatically prior to launching
410
	 * if that option is turned on.
411
	 * 
412
	 * @param configuration
413
	 * 			the launch configuration
414
	 * @param monitor
415
	 * 			a progress monitor
416
	 * @since 3.3
417
	 */
418
	protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
419
		EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration);
420
		LaunchPluginValidator.runValidationOperation(op, monitor);
421
	}
422
23
423
}
24
}
(-)src/org/eclipse/pde/ui/launcher/JUnitWorkbenchLaunchShortcut.java (-7 / +10 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
11
package org.eclipse.pde.ui.launcher;
12
12
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
import org.eclipse.pde.launching.PDESourcePathProvider;
15
13
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
15
import org.eclipse.jdt.core.IJavaElement;
18
import org.eclipse.jdt.core.IJavaElement;
Lines 17-25 Link Here
17
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
20
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
18
import org.eclipse.pde.core.plugin.TargetPlatform;
21
import org.eclipse.pde.core.plugin.TargetPlatform;
19
import org.eclipse.pde.internal.core.TargetPlatformHelper;
22
import org.eclipse.pde.internal.core.TargetPlatformHelper;
20
import org.eclipse.pde.internal.ui.IPDEUIConstants;
23
import org.eclipse.pde.internal.launching.IPDEConstants;
21
import org.eclipse.pde.internal.ui.launcher.LaunchArgumentsHelper;
24
import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper;
22
import org.eclipse.pde.internal.ui.launcher.LauncherUtils;
25
import org.eclipse.pde.internal.launching.launcher.LauncherUtils;
23
26
24
/**
27
/**
25
 * A launch shortcut capable of launching a Plug-in JUnit test.
28
 * A launch shortcut capable of launching a Plug-in JUnit test.
Lines 43-55 Link Here
43
	protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(IJavaElement element) throws CoreException {
46
	protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(IJavaElement element) throws CoreException {
44
		ILaunchConfigurationWorkingCopy configuration = super.createLaunchConfiguration(element);
47
		ILaunchConfigurationWorkingCopy configuration = super.createLaunchConfiguration(element);
45
		if (TargetPlatformHelper.usesNewApplicationModel())
48
		if (TargetPlatformHelper.usesNewApplicationModel())
46
			configuration.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$ 
49
			configuration.setAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$ 
47
		else if (TargetPlatformHelper.getTargetVersion() >= 3.2)
50
		else if (TargetPlatformHelper.getTargetVersion() >= 3.2)
48
			configuration.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.2a"); //$NON-NLS-1$
51
			configuration.setAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, "3.2a"); //$NON-NLS-1$
49
		configuration.setAttribute(IPDELauncherConstants.LOCATION, LaunchArgumentsHelper.getDefaultJUnitWorkspaceLocation());
52
		configuration.setAttribute(IPDELauncherConstants.LOCATION, LaunchArgumentsHelper.getDefaultJUnitWorkspaceLocation());
50
		configuration.setAttribute(IPDELauncherConstants.DOCLEAR, true);
53
		configuration.setAttribute(IPDELauncherConstants.DOCLEAR, true);
51
		configuration.setAttribute(IPDELauncherConstants.ASKCLEAR, false);
54
		configuration.setAttribute(IPDELauncherConstants.ASKCLEAR, false);
52
		configuration.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true);
55
		configuration.setAttribute(IPDEConstants.APPEND_ARGS_EXPLICITLY, true);
53
56
54
		// Program to launch
57
		// Program to launch
55
		if (LauncherUtils.requiresUI(configuration)) {
58
		if (LauncherUtils.requiresUI(configuration)) {
Lines 59-65 Link Here
59
				configuration.setAttribute(IPDELauncherConstants.PRODUCT, product);
62
				configuration.setAttribute(IPDELauncherConstants.PRODUCT, product);
60
			}
63
			}
61
		} else {
64
		} else {
62
			configuration.setAttribute(IPDELauncherConstants.APPLICATION, IPDEUIConstants.CORE_TEST_APPLICATION);
65
			configuration.setAttribute(IPDELauncherConstants.APPLICATION, IPDEConstants.CORE_TEST_APPLICATION);
63
		}
66
		}
64
67
65
		// Plug-ins to launch
68
		// Plug-ins to launch
(-)src/org/eclipse/pde/ui/launcher/IPDELauncherConstants.java (-374 / +3 lines)
Lines 19-398 Link Here
19
 * 
19
 * 
20
 * @noimplement This interface is not intended to be implemented by clients.
20
 * @noimplement This interface is not intended to be implemented by clients.
21
 * @noextend This interface is not intended to be extended by clients.
21
 * @noextend This interface is not intended to be extended by clients.
22
 * @deprecated use {@link org.eclipse.pde.launching.IPDELauncherConstants} instead.
23
 * @see org.eclipse.pde.launching.IPDELauncherConstants
22
 */
24
 */
23
public interface IPDELauncherConstants {
25
public interface IPDELauncherConstants extends org.eclipse.pde.launching.IPDELauncherConstants {
24
26
25
	/**
26
	 * Launch configuration attribute key. The value is a string specifying
27
	 * workspace data location for an Eclipse application.
28
	 */
29
	String LOCATION = "location"; //$NON-NLS-1$
30
31
	/**
32
	 * Launch configuration attribute key. The value is a boolean specifying
33
	 * workspace data location for an Eclipse application should be cleared
34
	 * prior to launching.
35
	 */
36
	String DOCLEAR = "clearws"; //$NON-NLS-1$
37
38
	/**
39
	 * Launch configuration attribute key. The value is a boolean specifying
40
	 * whether the user should be prompted prior to clearing the workspace.
41
	 * 
42
	 * @see IPDELauncherConstants#DOCLEAR
43
	 */
44
	String ASKCLEAR = "askclear"; //$NON-NLS-1$
45
46
	/**
47
	 * Launch configuration attribute key. The value is a string specifying
48
	 * the application to run.  If the value is <code>null</code>, the default 
49
	 * application as specified in the target platform will be used.
50
	 */
51
	String APPLICATION = "application"; //$NON-NLS-1$
52
53
	/**
54
	 * Launch configuration attribute key. The value is a string specifying
55
	 * the product to run.
56
	 * 
57
	 * @see IPDELauncherConstants#APPLICATION
58
	 */
59
	String PRODUCT = "product"; //$NON-NLS-1$
60
61
	/**
62
	 * Launch configuration attribute key. The value is a boolean specifying
63
	 * if the launch should appear in product-mode.  If the value is <code>false</code>,
64
	 * the launch takes place in application-mode.
65
	 * 
66
	 * @see IPDELauncherConstants#PRODUCT
67
	 * @see IPDELauncherConstants#APPLICATION
68
	 */
69
	String USE_PRODUCT = "useProduct"; //$NON-NLS-1$
70
71
	/**
72
	 * Launch configuration attribute key used in Plug-in JUnit launch configurations only. 
73
	 * The value is a string specifying the application to be tested.  
74
	 * If the value is <code>null</code>, the default UI workbench application is tested.
75
	 */
76
	String APP_TO_TEST = "testApplication"; //$NON-NLS-1$
77
78
	/**
79
	 * Launch configuration attribute key. The value is a string specifying
80
	 * the name of the VM to launch with.  If the value is <code>null</code>,
81
	 * the default workspace VM is used.
82
	 * 
83
	 * @deprecated use IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH
84
	 */
85
	String VMINSTALL = "vminstall"; //$NON-NLS-1$
86
87
	/**
88
	 * Launch configuration attribute key. The value is a string specifying
89
	 * the user-entered bootstrap classpath entries. 
90
	 */
91
	String BOOTSTRAP_ENTRIES = "bootstrap"; //$NON-NLS-1$
92
93
	/**
94
	 * Launch configuration attribute key. The value is a boolean specifying
95
	 * if the default self-hosting mode should be used when launching.
96
	 * The default being to launch with all workspace plug-ins and all the 
97
	 * plug-ins that are explicitly checked on the Target Platform preference page.
98
	 */
99
	String USE_DEFAULT = "default"; //$NON-NLS-1$
100
101
	/**
102
	 * Launch configuration attribute key. The value is a boolean specifying
103
	 * if the feature-based self-hosting mode should be used.
104
	 * The workspace must be set up properly for the feature-based self-hosting
105
	 * to succeed.
106
	 * Check the PDE Tips and Tricks section for how to set up feature-based self-hosting.
107
	 */
108
	String USEFEATURES = "usefeatures"; //$NON-NLS-1$
109
110
	/**
111
	 * Launch configuration attribute key. The value is a string specifying
112
	 * a comma-separated list of IDs of workspace plug-ins to launch with.
113
	 * This value is only used when the Automatic Add option is off.
114
	 * 
115
	 * @see IPDELauncherConstants#AUTOMATIC_ADD
116
	 */
117
	String SELECTED_WORKSPACE_PLUGINS = "selected_workspace_plugins"; //$NON-NLS-1$
118
119
	/**
120
	 * Launch configuration attribute key. The value is a string specifying
121
	 * a comma-separated list of IDs of workspace plug-ins that are to be excluded from
122
	 * the launch.
123
	 * This value is only used when the Automatic Add option is on.
124
	 * 
125
	 * @see IPDELauncherConstants#AUTOMATIC_ADD
126
	 */
127
	String DESELECTED_WORKSPACE_PLUGINS = "deselected_workspace_plugins"; //$NON-NLS-1$
128
129
	/**
130
	 * Launch configuration attribute key. The value is a boolean specifying
131
	 * whether workspace plug-in created after the creation of a launch configuration
132
	 * should be added to the list of plug-ins to launch with.
133
	 * 
134
	 * If the value is <code>true</code>, then DESELECTED_WORKSPACE_PLUGINS should be used.
135
	 * Otherwise, SELECTED_WORKSPACE_PLUGINS should be used.
136
	 * 
137
	 * @see IPDELauncherConstants#DESELECTED_WORKSPACE_PLUGINS
138
	 * @see IPDELauncherConstants#SELECTED_WORKSPACE_PLUGINS
139
	 */
140
	String AUTOMATIC_ADD = "automaticAdd"; //$NON-NLS-1$
141
142
	/**
143
	 * Launch configuration attribute key. The value is a boolean specifying
144
	 * whether the list of plug-ins to run should be validate prior to launching.
145
	 * If problems are found, they will be reported and the user will be able to cancel or
146
	 * continue.
147
	 * If no problems are found, the launch continues as normal.
148
	 */
149
	String AUTOMATIC_VALIDATE = "automaticValidate"; //$NON-NLS-1$
150
151
	/**
152
	 * Launch configuration attribute key. The value is a string specifying
153
	 * a comma-separated list of IDs of target platform plug-ins to launch with.
154
	 * This value is only used when the Automatic Add option is off.
155
	 */
156
	String SELECTED_TARGET_PLUGINS = "selected_target_plugins"; //$NON-NLS-1$
157
158
	/**
159
	 * Launch configuration attribute key. The value is a boolean indicating
160
	 * whether the computation of required plug-ins on the Plug-ins tab should include
161
	 * the traversal of optional dependencies.
162
	 */
163
	String INCLUDE_OPTIONAL = "includeOptional"; //$NON-NLS-1$
164
165
	/**
166
	 * Launch configuration attribute key. The value is a boolean indicating
167
	 * whether tracing is enabled or disabled.
168
	 */
169
	String TRACING = "tracing"; //$NON-NLS-1$
170
171
	/**
172
	 * Launch configuration attribute key. The value is a map containing the list
173
	 * of options to debug with.
174
	 */
175
	String TRACING_OPTIONS = "tracingOptions"; //$NON-NLS-1$
176
177
	/**
178
	 * Launch configuration attribute key. The value is the id of the last plug-in 
179
	 * that was selected on the Tracing tab.
180
	 */
181
	String TRACING_SELECTED_PLUGIN = "selectedPlugin"; //$NON-NLS-1$
182
183
	/**
184
	 * Launch configuration attribute key. The value is the IDs of all plug-ins
185
	 * checked on the Tracing tab.  The value may also be "[NONE]"
186
	 * 
187
	 * @see IPDELauncherConstants#TRACING_NONE
188
	 */
189
	String TRACING_CHECKED = "checked"; //$NON-NLS-1$
190
191
	/**
192
	 * Launch configuration attribute value indicating that, although tracing is enabled,
193
	 * no plug-ins have been selected to be traced.
194
	 */
195
	String TRACING_NONE = "[NONE]"; //$NON-NLS-1$
196
197
	/**
198
	 * Launch configuration attribute key. The value is a boolean specifying 
199
	 * if PDE should generate a default configuration area for the launch.
200
	 * 
201
	 * If <code>true</code>, a configuration location in the PDE metadata area 
202
	 * is created.  Otherwise, the user is expected to specify a location.
203
	 * 
204
	 * @see IPDELauncherConstants#CONFIG_LOCATION
205
	 */
206
	String CONFIG_USE_DEFAULT_AREA = "useDefaultConfigArea"; //$NON-NLS-1$
207
208
	/**
209
	 * Launch configuration attribute key. The value is a string specifying 
210
	 * the configuration area location for an Eclipse application launch.
211
	 * 
212
	 * This key is only used when CONFIG_USE_DEFAULT_AREA is <code>false</code>.
213
	 * 
214
	 * @see IPDELauncherConstants#CONFIG_USE_DEFAULT_AREA
215
	 */
216
	String CONFIG_LOCATION = "configLocation"; //$NON-NLS-1$
217
218
	/**
219
	 * Launch configuration attribute key. The value is a boolean specifying 
220
	 * if the configuration area location should be cleared prior to launching
221
	*/
222
	String CONFIG_CLEAR_AREA = "clearConfig"; //$NON-NLS-1$
223
224
	/**
225
	 * Launch configuration atribute key.  The value is a boolean specifying
226
	 * if PDE should generate a default config.ini file for the launch.
227
	 * 
228
	 * If <code>true</code>, a configuration file is created.  
229
	 * Otherwise, the user is expected to specify a config.ini to be used as a template.
230
	 * 
231
	 * @see IPDELauncherConstants#CONFIG_TEMPLATE_LOCATION
232
	 */
233
	String CONFIG_GENERATE_DEFAULT = "useDefaultConfig"; //$NON-NLS-1$
234
235
	/**
236
	 * Launch configuration attribute key. The value is a string specifying 
237
	 * the location of the config.ini file to be used as a template for an 
238
	 * Eclipse application launch.
239
	 * 
240
	 * This key is only used when CONFIG_GENERATE_DEFAULT is <code>false</code>.
241
	 * 
242
	 * @see IPDELauncherConstants#CONFIG_GENERATE_DEFAULT
243
	 */
244
	String CONFIG_TEMPLATE_LOCATION = "templateConfig"; //$NON-NLS-1$
245
246
	/**
247
	 * Launch configuration attribute key. The value is a string specifying 
248
	 * the location of the .product file with which this launch configuration 
249
	 * is associated.
250
	 */
251
	String PRODUCT_FILE = "productFile"; //$NON-NLS-1$
252
253
	/**
254
	 * Launch configuration attribute key.  The value is the ID of an OSGi framework
255
	 * declared in an <code>org.eclipse.pde.ui.osgiLaunchers</code> extension point.
256
	 * 
257
	 * @since 3.3
258
	 */
259
	String OSGI_FRAMEWORK_ID = "osgi_framework_id"; //$NON-NLS-1$
260
261
	/**
262
	 * Launch configuration attribute key.  The value is a boolean specifying
263
	 * if the default Auto-Start for an OSGi Framework launch configuration 
264
	 * is <code>true</code> or <code>false</code>
265
	 * 
266
	 * @see IPDELauncherConstants#DEFAULT_START_LEVEL
267
	 */
268
	String DEFAULT_AUTO_START = "default_auto_start"; //$NON-NLS-1$
269
270
	/**
271
	 * Launch configuration attribute key.  The value is an integer specifying
272
	 * the default start level for bundles in an OSGi Framework launch configuration.
273
	 * 
274
	 * @see IPDELauncherConstants#DEFAULT_AUTO_START
275
	 */
276
	String DEFAULT_START_LEVEL = "default_start_level"; //$NON-NLS-1$
277
278
	/**
279
	 * Launch configuration attribute key.  The value is a comma-separated list
280
	 * of workspace bundles to launch with the OSGi framework.
281
	 * 
282
	 * Each token in the list is of the format:
283
	 * <plugin-id>@<start-level>:<auto-start>
284
	 * 
285
	 * @see IPDELauncherConstants#DEFAULT_AUTO_START
286
	 * @see IPDELauncherConstants#DEFAULT_START_LEVEL
287
	 */
288
	String WORKSPACE_BUNDLES = "workspace_bundles"; //$NON-NLS-1$
289
290
	/**
291
	 * Launch configuration attribute key.  The value is a comma-separated list
292
	 * of non-workspace bundles to launch with the OSGi framework.
293
	 * 
294
	 * Each token in the list is of the format:
295
	 * <plugin-id>@<start-level>:<auto-start>
296
	 * 
297
	 * @see IPDELauncherConstants#DEFAULT_AUTO_START
298
	 * @see IPDELauncherConstants#DEFAULT_START_LEVEL
299
	 */
300
	String TARGET_BUNDLES = "target_bundles"; //$NON-NLS-1$
301
302
	/**
303
	 * Launch configuration attribute key.  The value can be either the full path
304
	 * to the workspace location of a Target Definition (ie. .target file), or
305
	 * the ID of a target defined in an org.eclipse.pde.core.targets extension.
306
	 */
307
	String DEFINED_TARGET = "defined_target"; //$NON-NLS-1$
308
309
	/**
310
	 * Launch configuration attribute key. The value is a boolean indicating
311
	 * whether or not to display only selected plug-ins. 
312
	 * 
313
	 * @since 3.4
314
	 */
315
	String SHOW_SELECTED_ONLY = "show_selected_only"; //$NON-NLS-1$
316
317
	/**
318
	 * The unique tab identifier for the bundles tab
319
	 * 
320
	 * @since 3.5
321
	 * @see BundlesTab
322
	 */
323
	String TAB_BUNDLES_ID = "org.eclipse.pde.ui.launch.tab.osgi.bundles"; //$NON-NLS-1$
324
325
	/**
326
	 * The unique tab identifier for the configuration tab
327
	 * 
328
	 * @since 3.5
329
	 * @see ConfigurationTab
330
	 */
331
	String TAB_CONFIGURATION_ID = "org.eclipse.pde.ui.launch.tab.configuration"; //$NON-NLS-1$
332
333
	/**
334
	 * The unique tab identifier for the main tab
335
	 * 
336
	 * @since 3.5
337
	 * @see MainTab
338
	 */
339
	String TAB_MAIN_ID = "org.eclipse.pde.ui.launch.tab.main"; //$NON-NLS-1$
340
341
	/**
342
	 * The unique tab identifier for the osgi settings tab
343
	 * 
344
	 * @since 3.5
345
	 * @see OSGiSettingsTab
346
	 */
347
	String TAB_OSGI_SETTINGS_ID = "org.eclipse.pde.ui.launch.tab.osgi.settings"; //$NON-NLS-1$
348
349
	/**
350
	 * The unique tab identifier for the plug-in junit tab
351
	 * 
352
	 * @since 3.5
353
	 * @see PluginJUnitMainTab
354
	 */
355
	String TAB_PLUGIN_JUNIT_MAIN_ID = "org.eclipse.pde.ui.launch.tab.junit.main"; //$NON-NLS-1$
356
357
	/**
358
	 * The unique tab identifier for the plug-ins tab
359
	 * 
360
	 * @since 3.5
361
	 * @see PluginsTab
362
	 */
363
	String TAB_PLUGINS_ID = "org.eclipse.pde.ui.launch.tab.plugins"; //$NON-NLS-1$
364
365
	/**
366
	 * The unique tab identifier for the tracing tab
367
	 * 
368
	 * @since 3.5
369
	 * @see TracingTab
370
	 */
371
	String TAB_TRACING_ID = "org.eclipse.pde.ui.launch.tab.tracing"; //$NON-NLS-1$
372
373
	/**
374
	 * The unique tab identifier for the tracing tab
375
	 * 
376
	 * @since 3.5
377
	 * @see TestTab
378
	 */
379
	String TAB_TEST_ID = "org.eclipse.pde.ui.launch.tab.test"; //$NON-NLS-1$
380
381
	/**
382
	 * The launch configuration type id for OSGi launches.
383
	 * 
384
	 * @since 3.5
385
	 * @see OSGiLaunchShortcut
386
	 */
387
	String OSGI_CONFIGURATION_TYPE = "org.eclipse.pde.ui.EquinoxLauncher"; //$NON-NLS-1$
388
389
	/**
390
	 * Launch configuration attribute key. The value is a boolean specifying 
391
	 * whether the tests should run on the UI thread.
392
	 * 
393
	 * The default value is <code>true</code>
394
	 * 
395
	 * @since 3.5
396
	 */
397
	String RUN_IN_UI_THREAD = "run_in_ui_thread"; //$NON-NLS-1$
398
}
27
}
(-)src/org/eclipse/pde/ui/launcher/OSGiLaunchConfigurationDelegate.java (-40 / +3 lines)
Lines 10-61 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
11
package org.eclipse.pde.ui.launcher;
12
12
13
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.runtime.*;
15
import org.eclipse.debug.core.ILaunch;
16
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
18
import org.eclipse.osgi.util.NLS;
19
import org.eclipse.pde.internal.ui.*;
20
import org.eclipse.pde.internal.ui.launcher.LaunchPluginValidator;
21
import org.eclipse.pde.internal.ui.launcher.OSGiFrameworkManager;
22
23
/**
13
/**
24
 * A launch delegate for launching OSGi frameworks
14
 * A launch delegate for launching OSGi frameworks
25
 * <p>
15
 * <p>
26
 * Clients may subclass and instantiate this class.
16
 * Clients may subclass and instantiate this class.
27
 * </p>
17
 * </p>
28
 * @since 3.3
18
 * @since 3.3
19
 * @deprecated use {@link org.eclipse.pde.launching.OSGiLaunchConfigurationDelegate} instead.
20
 * @see org.eclipse.pde.launching.OSGiLaunchConfigurationDelegat
29
 */
21
 */
30
public class OSGiLaunchConfigurationDelegate extends LaunchConfigurationDelegate {
22
public class OSGiLaunchConfigurationDelegate extends org.eclipse.pde.launching.OSGiLaunchConfigurationDelegate {
31
32
	/**
33
	 * Delegates to the launcher delegate associated with the OSGi framework
34
	 * selected in the launch configuration.
35
	 * 
36
	 * @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)
37
	 */
38
	public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
39
		OSGiFrameworkManager manager = PDEPlugin.getDefault().getOSGiFrameworkManager();
40
		String id = configuration.getAttribute(IPDELauncherConstants.OSGI_FRAMEWORK_ID, manager.getDefaultFramework());
41
		LaunchConfigurationDelegate launcher = manager.getFrameworkLauncher(id);
42
		if (launcher != null) {
43
			launcher.launch(configuration, mode, launch, monitor);
44
		} else {
45
			String name = manager.getFrameworkName(id);
46
			if (name == null)
47
				name = PDEUIMessages.OSGiLaunchConfiguration_selected;
48
			String message = NLS.bind(PDEUIMessages.OSGiLaunchConfiguration_cannotFindLaunchConfiguration, name);
49
			IStatus status = new Status(IStatus.ERROR, IPDEUIConstants.PLUGIN_ID, IStatus.OK, message, null);
50
			throw new CoreException(status);
51
		}
52
	}
53
54
	/* (non-Javadoc)
55
	 * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
56
	 */
57
	protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
58
		return computeBuildOrder(LaunchPluginValidator.getAffectedProjects(configuration));
59
	}
60
23
61
}
24
}
(-)src/org/eclipse/pde/ui/launcher/BundlesTab.java (+2 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
11
package org.eclipse.pde.ui.launcher;
12
12
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
13
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
(-)src/org/eclipse/pde/ui/launcher/PluginsTab.java (+2 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
11
package org.eclipse.pde.ui.launcher;
12
12
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
13
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.IPath;
15
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.debug.core.ILaunchConfiguration;
(-)src/org/eclipse/pde/ui/launcher/EclipseLaunchShortcut.java (-5 / +12 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
11
package org.eclipse.pde.ui.launcher;
12
12
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
import org.eclipse.pde.launching.PDESourcePathProvider;
15
13
import java.util.*;
16
import java.util.*;
14
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.resources.IProject;
Lines 25-33 Link Here
25
import org.eclipse.pde.internal.core.TargetPlatformHelper;
28
import org.eclipse.pde.internal.core.TargetPlatformHelper;
26
import org.eclipse.pde.internal.core.product.WorkspaceProductModel;
29
import org.eclipse.pde.internal.core.product.WorkspaceProductModel;
27
import org.eclipse.pde.internal.core.util.IdUtil;
30
import org.eclipse.pde.internal.core.util.IdUtil;
31
import org.eclipse.pde.internal.launching.IPDEConstants;
32
import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper;
33
import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper;
28
import org.eclipse.pde.internal.ui.IPDEUIConstants;
34
import org.eclipse.pde.internal.ui.IPDEUIConstants;
29
import org.eclipse.pde.internal.ui.PDEPlugin;
35
import org.eclipse.pde.internal.ui.PDEPlugin;
30
import org.eclipse.pde.internal.ui.launcher.*;
36
import org.eclipse.pde.internal.ui.launcher.ApplicationSelectionDialog;
37
import org.eclipse.pde.internal.ui.launcher.LaunchAction;
31
import org.eclipse.ui.IEditorPart;
38
import org.eclipse.ui.IEditorPart;
32
39
33
/**
40
/**
Lines 41-47 Link Here
41
 */
48
 */
42
public class EclipseLaunchShortcut extends AbstractLaunchShortcut {
49
public class EclipseLaunchShortcut extends AbstractLaunchShortcut {
43
50
44
	public static final String CONFIGURATION_TYPE = "org.eclipse.pde.ui.RuntimeWorkbench"; //$NON-NLS-1$
51
	public static final String CONFIGURATION_TYPE = IPDELauncherConstants.ECLIPSE_APPLICATION_LAUNCH_CONFIGURATION_TYPE;
45
52
46
	private IPluginModelBase fModel = null;
53
	private IPluginModelBase fModel = null;
47
54
Lines 214-229 Link Here
214
	 */
221
	 */
215
	protected void initializeConfiguration(ILaunchConfigurationWorkingCopy wc) {
222
	protected void initializeConfiguration(ILaunchConfigurationWorkingCopy wc) {
216
		if (TargetPlatformHelper.usesNewApplicationModel())
223
		if (TargetPlatformHelper.usesNewApplicationModel())
217
			wc.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$
224
			wc.setAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$
218
		else if (TargetPlatformHelper.getTargetVersion() >= 3.2)
225
		else if (TargetPlatformHelper.getTargetVersion() >= 3.2)
219
			wc.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.2a"); //$NON-NLS-1$
226
			wc.setAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, "3.2a"); //$NON-NLS-1$
220
		wc.setAttribute(IPDELauncherConstants.LOCATION, LaunchArgumentsHelper.getDefaultWorkspaceLocation(wc.getName()));
227
		wc.setAttribute(IPDELauncherConstants.LOCATION, LaunchArgumentsHelper.getDefaultWorkspaceLocation(wc.getName()));
221
		initializeProgramArguments(wc);
228
		initializeProgramArguments(wc);
222
		initializeVMArguments(wc);
229
		initializeVMArguments(wc);
223
		wc.setAttribute(IPDELauncherConstants.USEFEATURES, false);
230
		wc.setAttribute(IPDELauncherConstants.USEFEATURES, false);
224
		wc.setAttribute(IPDELauncherConstants.DOCLEAR, false);
231
		wc.setAttribute(IPDELauncherConstants.DOCLEAR, false);
225
		wc.setAttribute(IPDELauncherConstants.ASKCLEAR, true);
232
		wc.setAttribute(IPDELauncherConstants.ASKCLEAR, true);
226
		wc.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true);
233
		wc.setAttribute(IPDEConstants.APPEND_ARGS_EXPLICITLY, true);
227
		wc.setAttribute(IPDELauncherConstants.TRACING_CHECKED, IPDELauncherConstants.TRACING_NONE);
234
		wc.setAttribute(IPDELauncherConstants.TRACING_CHECKED, IPDELauncherConstants.TRACING_NONE);
228
		wc.setAttribute(IPDELauncherConstants.USE_DEFAULT, fApplicationName == null);
235
		wc.setAttribute(IPDELauncherConstants.USE_DEFAULT, fApplicationName == null);
229
		if (fApplicationName != null) {
236
		if (fApplicationName != null) {
(-)src/org/eclipse/pde/ui/launcher/TracingTab.java (+2 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
11
package org.eclipse.pde.ui.launcher;
12
12
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
13
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.core.ILaunchConfiguration;
14
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
16
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
15
import org.eclipse.jface.dialogs.Dialog;
17
import org.eclipse.jface.dialogs.Dialog;
(-)src/org/eclipse/pde/ui/launcher/AbstractLaunchShortcut.java (+2 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
11
package org.eclipse.pde.ui.launcher;
12
12
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
13
import java.util.ArrayList;
15
import java.util.ArrayList;
14
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.debug.core.*;
17
import org.eclipse.debug.core.*;
(-)src/org/eclipse/pde/internal/ui/preferences/PreferenceInitializer.java (-3 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-21 Link Here
15
import org.eclipse.pde.internal.ui.IPreferenceConstants;
15
import org.eclipse.pde.internal.ui.IPreferenceConstants;
16
import org.eclipse.pde.internal.ui.PDEPlugin;
16
import org.eclipse.pde.internal.ui.PDEPlugin;
17
import org.eclipse.pde.internal.ui.editor.text.ColorManager;
17
import org.eclipse.pde.internal.ui.editor.text.ColorManager;
18
import org.eclipse.pde.internal.ui.launcher.OSGiFrameworkManager;
19
18
20
public class PreferenceInitializer extends AbstractPreferenceInitializer {
19
public class PreferenceInitializer extends AbstractPreferenceInitializer {
21
20
Lines 27-33 Link Here
27
		ColorManager.initializeDefaults(store);
26
		ColorManager.initializeDefaults(store);
28
		store.setDefault(IPreferenceConstants.PROP_SHOW_OBJECTS, IPreferenceConstants.VALUE_USE_IDS);
27
		store.setDefault(IPreferenceConstants.PROP_SHOW_OBJECTS, IPreferenceConstants.VALUE_USE_IDS);
29
		store.setDefault(IPreferenceConstants.EDITOR_FOLDING_ENABLED, false);
28
		store.setDefault(IPreferenceConstants.EDITOR_FOLDING_ENABLED, false);
30
		store.setDefault(IPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK, OSGiFrameworkManager.DEFAULT_FRAMEWORK);
31
	}
29
	}
32
30
33
}
31
}
(-)src/org/eclipse/pde/internal/ui/preferences/OSGiFrameworkPreferencePage.java (-9 / +22 lines)
Lines 13-28 Link Here
13
package org.eclipse.pde.internal.ui.preferences;
13
package org.eclipse.pde.internal.ui.preferences;
14
14
15
import org.eclipse.core.runtime.IConfigurationElement;
15
import org.eclipse.core.runtime.IConfigurationElement;
16
import org.eclipse.core.runtime.preferences.*;
16
import org.eclipse.jface.dialogs.Dialog;
17
import org.eclipse.jface.dialogs.Dialog;
17
import org.eclipse.jface.preference.IPreferenceStore;
18
import org.eclipse.jface.preference.PreferencePage;
18
import org.eclipse.jface.preference.PreferencePage;
19
import org.eclipse.jface.resource.JFaceResources;
19
import org.eclipse.jface.resource.JFaceResources;
20
import org.eclipse.jface.viewers.*;
20
import org.eclipse.jface.viewers.*;
21
import org.eclipse.pde.core.plugin.IPluginExtensionPoint;
21
import org.eclipse.pde.core.plugin.IPluginExtensionPoint;
22
import org.eclipse.pde.internal.core.PDECore;
22
import org.eclipse.pde.internal.core.PDECore;
23
import org.eclipse.pde.internal.core.PDEPreferencesManager;
23
import org.eclipse.pde.internal.core.schema.SchemaRegistry;
24
import org.eclipse.pde.internal.core.schema.SchemaRegistry;
25
import org.eclipse.pde.internal.launching.*;
26
import org.eclipse.pde.internal.launching.launcher.OSGiFrameworkManager;
24
import org.eclipse.pde.internal.ui.*;
27
import org.eclipse.pde.internal.ui.*;
25
import org.eclipse.pde.internal.ui.launcher.OSGiFrameworkManager;
26
import org.eclipse.pde.internal.ui.search.ShowDescriptionAction;
28
import org.eclipse.pde.internal.ui.search.ShowDescriptionAction;
27
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.SWT;
28
import org.eclipse.swt.events.SelectionAdapter;
30
import org.eclipse.swt.events.SelectionAdapter;
Lines 31-36 Link Here
31
import org.eclipse.swt.layout.GridData;
33
import org.eclipse.swt.layout.GridData;
32
import org.eclipse.swt.widgets.*;
34
import org.eclipse.swt.widgets.*;
33
import org.eclipse.ui.*;
35
import org.eclipse.ui.*;
36
import org.osgi.service.prefs.BackingStoreException;
34
37
35
/**
38
/**
36
 * Provides the preference page for managing the default OSGi framework to use.
39
 * Provides the preference page for managing the default OSGi framework to use.
Lines 106-113 Link Here
106
	 * Restores the default framework setting from the PDE preferences
109
	 * Restores the default framework setting from the PDE preferences
107
	 */
110
	 */
108
	private void setDefaultFramework() {
111
	private void setDefaultFramework() {
109
		IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore();
112
		PDEPreferencesManager preferenceManager = PDELaunchingPlugin.getDefault().getPreferenceManager();
110
		fDefaultFramework = store.getString(IPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK);
113
		fDefaultFramework = preferenceManager.getString(ILaunchingPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK);
111
	}
114
	}
112
115
113
	/* (non-Javadoc)
116
	/* (non-Javadoc)
Lines 132-138 Link Here
132
		fTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
135
		fTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
133
		fTableViewer.setContentProvider(ArrayContentProvider.getInstance());
136
		fTableViewer.setContentProvider(ArrayContentProvider.getInstance());
134
		fTableViewer.setLabelProvider(new FrameworkLabelProvider());
137
		fTableViewer.setLabelProvider(new FrameworkLabelProvider());
135
		fTableViewer.setInput(PDEPlugin.getDefault().getOSGiFrameworkManager().getSortedFrameworks());
138
		fTableViewer.setInput(PDELaunchingPlugin.getDefault().getOSGiFrameworkManager().getSortedFrameworks());
136
		fTableViewer.addCheckStateListener(new ICheckStateListener() {
139
		fTableViewer.addCheckStateListener(new ICheckStateListener() {
137
			public void checkStateChanged(CheckStateChangedEvent event) {
140
			public void checkStateChanged(CheckStateChangedEvent event) {
138
				IConfigurationElement element = (IConfigurationElement) event.getElement();
141
				IConfigurationElement element = (IConfigurationElement) event.getElement();
Lines 142-148 Link Here
142
			}
145
			}
143
		});
146
		});
144
		if (fDefaultFramework != null) {
147
		if (fDefaultFramework != null) {
145
			IConfigurationElement element = PDEPlugin.getDefault().getOSGiFrameworkManager().getFramework(fDefaultFramework);
148
			IConfigurationElement element = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager().getFramework(fDefaultFramework);
146
			if (element != null) {
149
			if (element != null) {
147
				fTableViewer.setCheckedElements(new Object[] {element});
150
				fTableViewer.setCheckedElements(new Object[] {element});
148
			}
151
			}
Lines 156-164 Link Here
156
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
159
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
157
	 */
160
	 */
158
	public boolean performOk() {
161
	public boolean performOk() {
159
		IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore();
162
		IEclipsePreferences instancePrefs = new InstanceScope().getNode(IPDEConstants.PLUGIN_ID);
160
		store.setValue(IPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK, fDefaultFramework);
163
		IEclipsePreferences defaultPrefs = new DefaultScope().getNode(IPDEConstants.PLUGIN_ID);
161
		PDEPlugin.getDefault().getPreferenceManager().savePluginPreferences();
164
		if (defaultPrefs.get(ILaunchingPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK, "").equals(fDefaultFramework)) { //$NON-NLS-1$
165
			instancePrefs.remove(ILaunchingPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK);
166
		} else {
167
			instancePrefs.put(ILaunchingPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK, fDefaultFramework);
168
		}
169
		try {
170
			instancePrefs.flush();
171
		} catch (BackingStoreException e) {
172
			PDEPlugin.log(e);
173
		}
174
162
		return super.performOk();
175
		return super.performOk();
163
	}
176
	}
164
177
(-)src/org/eclipse/pde/internal/ui/preferences/MainPreferencePage.java (-2 / +21 lines)
Lines 11-20 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.preferences;
12
package org.eclipse.pde.internal.ui.preferences;
13
13
14
import org.eclipse.core.runtime.preferences.*;
14
import org.eclipse.jface.dialogs.Dialog;
15
import org.eclipse.jface.dialogs.Dialog;
15
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
16
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
16
import org.eclipse.jface.preference.IPreferenceStore;
17
import org.eclipse.jface.preference.IPreferenceStore;
17
import org.eclipse.jface.preference.PreferencePage;
18
import org.eclipse.jface.preference.PreferencePage;
19
import org.eclipse.pde.internal.core.PDEPreferencesManager;
20
import org.eclipse.pde.internal.launching.*;
18
import org.eclipse.pde.internal.ui.*;
21
import org.eclipse.pde.internal.ui.*;
19
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.events.SelectionAdapter;
23
import org.eclipse.swt.events.SelectionAdapter;
Lines 23-28 Link Here
23
import org.eclipse.swt.layout.GridLayout;
26
import org.eclipse.swt.layout.GridLayout;
24
import org.eclipse.swt.widgets.*;
27
import org.eclipse.swt.widgets.*;
25
import org.eclipse.ui.*;
28
import org.eclipse.ui.*;
29
import org.osgi.service.prefs.BackingStoreException;
26
30
27
public class MainPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
31
public class MainPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
28
	private Button fUseID;
32
	private Button fUseID;
Lines 39-44 Link Here
39
43
40
	protected Control createContents(Composite parent) {
44
	protected Control createContents(Composite parent) {
41
		IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore();
45
		IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore();
46
		PDEPreferencesManager launchingStore = PDELaunchingPlugin.getDefault().getPreferenceManager();
42
47
43
		Composite composite = new Composite(parent, SWT.NONE);
48
		Composite composite = new Composite(parent, SWT.NONE);
44
		GridLayout layout = new GridLayout();
49
		GridLayout layout = new GridLayout();
Lines 63-69 Link Here
63
68
64
		fAutoManage = new Button(group, SWT.CHECK);
69
		fAutoManage = new Button(group, SWT.CHECK);
65
		fAutoManage.setText(PDEUIMessages.MainPreferencePage_updateStale);
70
		fAutoManage.setText(PDEUIMessages.MainPreferencePage_updateStale);
66
		fAutoManage.setSelection(store.getBoolean(IPreferenceConstants.PROP_AUTO_MANAGE));
71
		fAutoManage.setSelection(launchingStore.getBoolean(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE));
67
72
68
		group = SWTFactory.createGroup(composite, PDEUIMessages.MainPreferencePage_exportingGroup, 1, 1, GridData.FILL_HORIZONTAL);
73
		group = SWTFactory.createGroup(composite, PDEUIMessages.MainPreferencePage_exportingGroup, 1, 1, GridData.FILL_HORIZONTAL);
69
74
Lines 107-116 Link Here
107
		} else {
112
		} else {
108
			store.setValue(IPreferenceConstants.PROP_SHOW_OBJECTS, IPreferenceConstants.VALUE_USE_NAMES);
113
			store.setValue(IPreferenceConstants.PROP_SHOW_OBJECTS, IPreferenceConstants.VALUE_USE_NAMES);
109
		}
114
		}
110
		store.setValue(IPreferenceConstants.PROP_AUTO_MANAGE, fAutoManage.getSelection());
111
		store.setValue(IPreferenceConstants.OVERWRITE_BUILD_FILES_ON_EXPORT, fOverwriteBuildFiles.getSelection() ? MessageDialogWithToggle.PROMPT : MessageDialogWithToggle.ALWAYS);
115
		store.setValue(IPreferenceConstants.OVERWRITE_BUILD_FILES_ON_EXPORT, fOverwriteBuildFiles.getSelection() ? MessageDialogWithToggle.PROMPT : MessageDialogWithToggle.ALWAYS);
112
		store.setValue(IPreferenceConstants.PROP_SHOW_SOURCE_BUNDLES, fShowSourceBundles.getSelection());
116
		store.setValue(IPreferenceConstants.PROP_SHOW_SOURCE_BUNDLES, fShowSourceBundles.getSelection());
113
		PDEPlugin.getDefault().getPreferenceManager().savePluginPreferences();
117
		PDEPlugin.getDefault().getPreferenceManager().savePluginPreferences();
118
119
		// write AUTO_MANAGE setting to pde.launching instance scope 
120
		IEclipsePreferences instancePrefs = new InstanceScope().getNode(IPDEConstants.PLUGIN_ID);
121
		IEclipsePreferences defaultPrefs = new DefaultScope().getNode(IPDEConstants.PLUGIN_ID);
122
		if (defaultPrefs.getBoolean(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE, false) == fAutoManage.getSelection()) {
123
			instancePrefs.remove(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE);
124
		} else {
125
			instancePrefs.putBoolean(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE, fAutoManage.getSelection());
126
		}
127
		try {
128
			instancePrefs.flush();
129
		} catch (BackingStoreException e) {
130
			PDEPlugin.log(e);
131
		}
132
114
		return super.performOk();
133
		return super.performOk();
115
	}
134
	}
116
135
(-)src/org/eclipse/pde/internal/ui/launcher/PDEMigrationDelegate.java (-56 lines)
Removed Link Here
1
/*******************************************************************************
2
 *  Copyright (c) 2007, 2008 IBM Corporation and others.
3
 *  All rights reserved. This program and the accompanying materials
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 *  which accompanies this distribution, and is available at
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IPath;
15
import org.eclipse.debug.core.*;
16
import org.eclipse.jdt.launching.*;
17
import org.eclipse.pde.internal.ui.IPDEUIConstants;
18
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
19
20
public class PDEMigrationDelegate implements ILaunchConfigurationMigrationDelegate {
21
22
	public boolean isCandidate(ILaunchConfiguration candidate) throws CoreException {
23
		return !candidate.getAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, false) || candidate.hasAttribute(IPDELauncherConstants.VMINSTALL);
24
	}
25
26
	public void migrate(ILaunchConfiguration candidate) throws CoreException {
27
		ILaunchConfigurationWorkingCopy wc = candidate.getWorkingCopy();
28
		migrate(wc);
29
		wc.doSave();
30
	}
31
32
	public void migrate(ILaunchConfigurationWorkingCopy candidate) throws CoreException {
33
		if (!candidate.getAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, false)) {
34
			candidate.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true);
35
			String args = candidate.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$
36
			StringBuffer buffer = new StringBuffer(LaunchArgumentsHelper.getInitialProgramArguments());
37
			if (args.length() > 0) {
38
				buffer.append(" "); //$NON-NLS-1$
39
				buffer.append(args);
40
			}
41
			candidate.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, buffer.toString());
42
		}
43
		if (candidate.hasAttribute(IPDELauncherConstants.VMINSTALL)) {
44
			String name = candidate.getAttribute(IPDELauncherConstants.VMINSTALL, (String) null);
45
			if (name != null) {
46
				IVMInstall vm = VMHelper.getVMInstall(name);
47
				if (vm != null) {
48
					IPath path = JavaRuntime.newJREContainerPath(vm);
49
					candidate.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, path.toPortableString());
50
				}
51
			}
52
			candidate.removeAttribute(IPDELauncherConstants.VMINSTALL);
53
		}
54
	}
55
56
}
(-)src/org/eclipse/pde/internal/ui/launcher/OpenLogDialog.java (-2 / +4 lines)
Lines 27-32 Link Here
27
 * Displays the error log in non-Win32 platforms - see bug 55314.
27
 * Displays the error log in non-Win32 platforms - see bug 55314.
28
 */
28
 */
29
public final class OpenLogDialog extends TrayDialog {
29
public final class OpenLogDialog extends TrayDialog {
30
	// maximum log file size
31
	public static final long MAX_FILE_LENGTH = 1024 * 1024;
30
	// input log file
32
	// input log file
31
	private File logFile;
33
	private File logFile;
32
	// location/size configuration
34
	// location/size configuration
Lines 90-96 Link Here
90
	private String getLogSummary() {
92
	private String getLogSummary() {
91
		StringWriter out = new StringWriter();
93
		StringWriter out = new StringWriter();
92
		PrintWriter writer = new PrintWriter(out);
94
		PrintWriter writer = new PrintWriter(out);
93
		if (logFile.length() > LaunchListener.MAX_FILE_LENGTH) {
95
		if (logFile.length() > MAX_FILE_LENGTH) {
94
			readLargeFileWithMonitor(writer);
96
			readLargeFileWithMonitor(writer);
95
		} else {
97
		} else {
96
			readFileWithMonitor(writer);
98
			readFileWithMonitor(writer);
Lines 112-118 Link Here
112
		boolean hasStarted = false;
114
		boolean hasStarted = false;
113
		try {
115
		try {
114
			random = new RandomAccessFile(logFile, "r"); //$NON-NLS-1$
116
			random = new RandomAccessFile(logFile, "r"); //$NON-NLS-1$
115
			random.seek(logFile.length() - LaunchListener.MAX_FILE_LENGTH);
117
			random.seek(logFile.length() - MAX_FILE_LENGTH);
116
			for (;;) {
118
			for (;;) {
117
				String line = random.readLine();
119
				String line = random.readLine();
118
				if (line == null)
120
				if (line == null)
(-)src/org/eclipse/pde/internal/ui/launcher/LaunchConfigurationHelper.java (-453 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
13
import java.io.*;
14
import java.net.URL;
15
import java.util.*;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.variables.IStringVariableManager;
18
import org.eclipse.core.variables.VariablesPlugin;
19
import org.eclipse.debug.core.ILaunchConfiguration;
20
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
21
import org.eclipse.osgi.service.resolver.BundleDescription;
22
import org.eclipse.pde.core.plugin.IPluginModelBase;
23
import org.eclipse.pde.core.plugin.TargetPlatform;
24
import org.eclipse.pde.internal.build.IPDEBuildConstants;
25
import org.eclipse.pde.internal.core.*;
26
import org.eclipse.pde.internal.ui.PDEPlugin;
27
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
28
29
/**
30
 * Contains helper methods for launching an Eclipse Runtime Workbench
31
 */
32
public class LaunchConfigurationHelper {
33
34
	private static final String PROP_OSGI_FRAMEWORK = "osgi.framework"; //$NON-NLS-1$
35
	private static final String PROP_OSGI_BUNDLES = "osgi.bundles"; //$NON-NLS-1$
36
	private static final String PROP_P2_DATA_AREA = "eclipse.p2.data.area"; //$NON-NLS-1$
37
38
	public static void synchronizeManifests(ILaunchConfiguration config, File configDir) {
39
		try {
40
			String programArgs = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$
41
			if (programArgs.indexOf("-clean") != -1) //$NON-NLS-1$
42
				return;
43
		} catch (CoreException e) {
44
		}
45
		File dir = new File(configDir, "org.eclipse.osgi/manifests"); //$NON-NLS-1$
46
		if (dir.exists() && dir.isDirectory()) {
47
			PDECore.getDefault().getJavaElementChangeListener().synchronizeManifests(dir);
48
		}
49
	}
50
51
	public static File getConfigurationArea(ILaunchConfiguration config) {
52
		File dir = getConfigurationLocation(config);
53
		if (!dir.exists())
54
			dir.mkdirs();
55
		return dir;
56
	}
57
58
	public static File getConfigurationLocation(ILaunchConfiguration config) {
59
		//bug 170213 change config location if config name contains #
60
		String configName = config.getName();
61
		configName = configName.replace('#', 'h');
62
		File dir = new File(PDECore.getDefault().getStateLocation().toOSString(), configName);
63
		try {
64
			if (!config.getAttribute(IPDELauncherConstants.CONFIG_USE_DEFAULT_AREA, true)) {
65
				String userPath = config.getAttribute(IPDELauncherConstants.CONFIG_LOCATION, (String) null);
66
				if (userPath != null) {
67
					userPath = getSubstitutedString(userPath);
68
					dir = new File(userPath).getAbsoluteFile();
69
				}
70
			}
71
		} catch (CoreException e) {
72
		}
73
		return dir;
74
	}
75
76
	private static String getSubstitutedString(String text) throws CoreException {
77
		if (text == null)
78
			return ""; //$NON-NLS-1$
79
		IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
80
		return mgr.performStringSubstitution(text);
81
	}
82
83
	public static Properties createConfigIniFile(ILaunchConfiguration configuration, String productID, Map bundles, Map bundlesWithStartLevels, File directory) throws CoreException {
84
		Properties properties = null;
85
		// if we are to generate a config.ini, start with the values in the target platform's config.ini - bug 141918
86
		if (configuration.getAttribute(IPDELauncherConstants.CONFIG_GENERATE_DEFAULT, true)) {
87
			properties = TargetPlatformHelper.getConfigIniProperties();
88
			// if target's config.ini does not exist, lets try to fill in default values
89
			if (properties == null)
90
				properties = new Properties();
91
			// keep properties only if we are launching the default product (bug 175437)
92
			else if (productID == null || !productID.equals(properties.get("eclipse.product"))) //$NON-NLS-1$
93
				properties.clear();
94
			// if target's config.ini has the osgi.bundles header, then parse and compute the proper osgi.bundles value
95
			String bundleList = properties.getProperty(PROP_OSGI_BUNDLES);
96
			if (bundleList != null)
97
				properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatformHelper.stripPathInformation(bundleList), bundles, bundlesWithStartLevels));
98
			String dataArea = properties.getProperty(PROP_P2_DATA_AREA);
99
			if (dataArea != null) {
100
				// Make the p2 data area in the configuration area itself, rather than a sibling of the configuration
101
				// area (which is a the root pde.core shared metadata area) @see bug 272810
102
				properties.setProperty(PROP_P2_DATA_AREA, "@config.dir/.p2"); //$NON-NLS-1$
103
			}
104
		} else {
105
			String templateLoc = configuration.getAttribute(IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, (String) null);
106
			if (templateLoc != null) {
107
				properties = loadFromTemplate(getSubstitutedString(templateLoc));
108
				// if template contains osgi.bundles, then only strip the path, do not compute the value
109
				String osgiBundles = properties.getProperty(PROP_OSGI_BUNDLES);
110
				if (osgiBundles != null)
111
					properties.setProperty(PROP_OSGI_BUNDLES, TargetPlatformHelper.stripPathInformation(osgiBundles));
112
			}
113
		}
114
		// whether we create a new config.ini or read from one as a template, we should add the required properties - bug 161265
115
		if (properties != null) {
116
			addRequiredProperties(properties, productID, bundles, bundlesWithStartLevels);
117
		} else {
118
			properties = new Properties();
119
		}
120
		if (!directory.exists()) {
121
			directory.mkdirs();
122
		}
123
		String osgiBundles = properties.getProperty(PROP_OSGI_BUNDLES);
124
		int start = configuration.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4);
125
		properties.put("osgi.bundles.defaultStartLevel", Integer.toString(start)); //$NON-NLS-1$
126
		boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, false);
127
128
		// if we are launching using P2, write out P2 files (bundles.txt) and add P2 property to config.ini
129
		if (osgiBundles != null && osgiBundles.indexOf(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR) != -1 && bundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) {
130
			URL bundlesTxt = null;
131
			boolean usedefault = configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true);
132
			boolean useFeatures = configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false);
133
			if (usedefault || useFeatures) {
134
				bundlesTxt = P2Utils.writeBundlesTxt(bundlesWithStartLevels, 4, false, directory, osgiBundles);
135
			} else {
136
				bundlesTxt = P2Utils.writeBundlesTxt(bundlesWithStartLevels, start, autostart, directory, null);
137
			}
138
139
			if (bundlesTxt != null) {
140
				properties.setProperty("org.eclipse.equinox.simpleconfigurator.configUrl", bundlesTxt.toString()); //$NON-NLS-1$
141
				// if we have simple configurator and update configurator together, ensure update doesn't reconcile
142
				if (bundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) {
143
					properties.setProperty("org.eclipse.update.reconcile", "false"); //$NON-NLS-1$ //$NON-NLS-2$
144
				}
145
			}
146
		}
147
148
		setBundleLocations(bundles, properties, autostart);
149
150
		save(new File(directory, "config.ini"), properties); //$NON-NLS-1$
151
		return properties;
152
	}
153
154
	private static void addRequiredProperties(Properties properties, String productID, Map bundles, Map bundlesWithStartLevels) {
155
		if (!properties.containsKey("osgi.install.area")) //$NON-NLS-1$
156
			properties.setProperty("osgi.install.area", "file:" + TargetPlatform.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$
157
		if (!properties.containsKey("osgi.configuration.cascaded")) //$NON-NLS-1$
158
			properties.setProperty("osgi.configuration.cascaded", "false"); //$NON-NLS-1$ //$NON-NLS-2$
159
		if (!properties.containsKey(PROP_OSGI_FRAMEWORK))
160
			properties.setProperty(PROP_OSGI_FRAMEWORK, IPDEBuildConstants.BUNDLE_OSGI);
161
		if (!properties.containsKey("osgi.splashPath") && productID != null) //$NON-NLS-1$
162
			addSplashLocation(properties, productID, bundles);
163
		// if osgi.splashPath is set, try to resolve relative paths to absolute paths
164
		if (properties.containsKey("osgi.splashPath")) //$NON-NLS-1$
165
			resolveLocationPath(properties.getProperty("osgi.splashPath"), properties, bundles); //$NON-NLS-1$
166
		if (!properties.containsKey(PROP_OSGI_BUNDLES))
167
			properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatform.getBundleList(), bundles, bundlesWithStartLevels));
168
		if (!properties.containsKey("osgi.bundles.defaultStartLevel")) //$NON-NLS-1$
169
			properties.setProperty("osgi.bundles.defaultStartLevel", "4"); //$NON-NLS-1$ //$NON-NLS-2$
170
	}
171
172
	/**
173
	 * Computes a list of osgi bundles to be put into the osgi.bundles property based
174
	 * on the bundles from the target platform config.ini and a map of bundles we are
175
	 * launching with.  The list of bundles must have already had it's path information
176
	 * removed.
177
	 * @param bundleList list of bundles without path information
178
	 * @param bundles map of bundle id to bundle model, contains all bundles being launched with
179
	 * @param bundlesWithStartLevels map of bundles of start level
180
	 * @return string list of osgi bundles
181
	 */
182
	private static String computeOSGiBundles(String bundleList, Map bundles, Map bundlesWithStartLevels) {
183
184
		// if p2 and only simple configurator and 
185
		// if simple configurator isn't selected & isn't in bundle list... hack it
186
187
		// if using p2's simple configurator, a bundles.txt will be written, so we only need simple configurator in the config.ini
188
		if (bundles.get(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR) != null)
189
			return "org.eclipse.equinox.simpleconfigurator@1:start"; //$NON-NLS-1$
190
191
		StringBuffer buffer = new StringBuffer();
192
		Set initialBundleSet = new HashSet();
193
		StringTokenizer tokenizer = new StringTokenizer(bundleList, ","); //$NON-NLS-1$
194
		while (tokenizer.hasMoreTokens()) {
195
			String token = tokenizer.nextToken();
196
			int index = token.indexOf('@');
197
			String id = index != -1 ? token.substring(0, index) : token;
198
			if (bundles.containsKey(id)) {
199
				if (buffer.length() > 0)
200
					buffer.append(',');
201
				buffer.append(id);
202
				if (index != -1 && index < token.length() - 1)
203
					buffer.append(token.substring(index));
204
				initialBundleSet.add(id);
205
			}
206
		}
207
208
		// if org.eclipse.update.configurator is not included (LIKE IN BASIC RCP APPLICATION), then write out all bundles in osgi.bundles - bug 170772
209
		if (!initialBundleSet.contains(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR)) {
210
			initialBundleSet.add(IPDEBuildConstants.BUNDLE_OSGI);
211
			Iterator iter = bundlesWithStartLevels.keySet().iterator();
212
			while (iter.hasNext()) {
213
				IPluginModelBase model = (IPluginModelBase) iter.next();
214
				String id = model.getPluginBase().getId();
215
				if (!initialBundleSet.contains(id)) {
216
					if (buffer.length() > 0)
217
						buffer.append(',');
218
219
					String slinfo = (String) bundlesWithStartLevels.get(model);
220
					buffer.append(id);
221
					buffer.append('@');
222
					buffer.append(slinfo);
223
				}
224
			}
225
		}
226
		return buffer.toString();
227
	}
228
229
	private static Properties loadFromTemplate(String templateLoc) throws CoreException {
230
		Properties properties = new Properties();
231
		File templateFile = new File(templateLoc);
232
		if (templateFile.exists() && templateFile.isFile()) {
233
			FileInputStream stream = null;
234
			try {
235
				stream = new FileInputStream(templateFile);
236
				properties.load(stream);
237
			} catch (Exception e) {
238
				String message = e.getMessage();
239
				if (message != null)
240
					throw new CoreException(new Status(IStatus.ERROR, PDEPlugin.getPluginId(), IStatus.ERROR, message, e));
241
			} finally {
242
				if (stream != null) {
243
					try {
244
						stream.close();
245
					} catch (IOException e) {
246
					}
247
				}
248
			}
249
		}
250
		return properties;
251
	}
252
253
	private static void addSplashLocation(Properties properties, String productID, Map map) {
254
		Properties targetConfig = TargetPlatformHelper.getConfigIniProperties();
255
		String targetProduct = targetConfig == null ? null : targetConfig.getProperty("eclipse.product"); //$NON-NLS-1$
256
		String targetSplash = targetConfig == null ? null : targetConfig.getProperty("osgi.splashPath"); //$NON-NLS-1$
257
		if (!productID.equals(targetProduct) || targetSplash == null) {
258
			ArrayList locations = new ArrayList();
259
			String plugin = getContributingPlugin(productID);
260
			locations.add(plugin);
261
			IPluginModelBase model = (IPluginModelBase) map.get(plugin);
262
			if (model != null) {
263
				BundleDescription desc = model.getBundleDescription();
264
				if (desc != null) {
265
					BundleDescription[] fragments = desc.getFragments();
266
					for (int i = 0; i < fragments.length; i++)
267
						locations.add(fragments[i].getSymbolicName());
268
				}
269
			}
270
			resolveLocationPath(locations, properties, map);
271
		} else
272
			resolveLocationPath(targetSplash, properties, map);
273
	}
274
275
	private static void resolveLocationPath(String splashPath, Properties properties, Map map) {
276
		ArrayList locations = new ArrayList();
277
		StringTokenizer tok = new StringTokenizer(splashPath, ","); //$NON-NLS-1$
278
		while (tok.hasMoreTokens())
279
			locations.add(tok.nextToken());
280
		resolveLocationPath(locations, properties, map);
281
	}
282
283
	private static void resolveLocationPath(ArrayList locations, Properties properties, Map map) {
284
		StringBuffer buffer = new StringBuffer();
285
		for (int i = 0; i < locations.size(); i++) {
286
			String location = (String) locations.get(i);
287
			if (location.startsWith("platform:/base/plugins/")) { //$NON-NLS-1$
288
				location = location.replaceFirst("platform:/base/plugins/", ""); //$NON-NLS-1$ //$NON-NLS-2$
289
			}
290
			String url = getBundleURL(location, map, false);
291
			if (url == null)
292
				continue;
293
			if (buffer.length() > 0)
294
				buffer.append(","); //$NON-NLS-1$
295
			buffer.append(url);
296
		}
297
		if (buffer.length() > 0)
298
			properties.setProperty("osgi.splashPath", buffer.toString()); //$NON-NLS-1$
299
	}
300
301
	/**
302
	 * Returns a string url representing the install location of the bundle model with the
303
	 * specified id.  The model is obtained using the provided map.
304
	 * @param id the id of the bundle
305
	 * @param pluginMap mapping of bundle ids to bundle models
306
	 * @param includeReference whether to prefix the url with 'reference:'
307
	 * @return string url for the bundle location
308
	 */
309
	public static String getBundleURL(String id, Map pluginMap, boolean includeReference) {
310
		IPluginModelBase model = (IPluginModelBase) pluginMap.get(id.trim());
311
		return getBundleURL(model, includeReference);
312
	}
313
314
	/**
315
	 * Returns a string url representing the install location of the given bundle model
316
	 * @param model the model to create the url for
317
	 * @param includeReference whether to prefix the url with 'reference:'
318
	 * @return string url for bundle location
319
	 */
320
	public static String getBundleURL(IPluginModelBase model, boolean includeReference) {
321
		if (model == null || model.getInstallLocation() == null)
322
			return null;
323
		StringBuffer buf = new StringBuffer();
324
		if (includeReference) {
325
			buf.append(TargetPlatformHelper.REFERENCE_PREFIX);
326
		}
327
		buf.append(TargetPlatformHelper.FILE_URL_PREFIX);
328
		buf.append(new Path(model.getInstallLocation()).removeTrailingSeparator().toString());
329
		return buf.toString();
330
	}
331
332
	/**
333
	 * Use the map of bundles we are launching with to update the osgi.framework
334
	 * and osgi.bundles properties with the correct info.
335
	 * @param map map of bundles being launched (id mapped to model)
336
	 * @param properties properties for config.ini
337
	 */
338
	private static void setBundleLocations(Map map, Properties properties, boolean defaultAuto) {
339
		String framework = properties.getProperty(PROP_OSGI_FRAMEWORK);
340
		if (framework != null) {
341
			framework = TargetPlatformHelper.stripPathInformation(framework);
342
			String url = getBundleURL(framework, map, false);
343
			if (url != null)
344
				properties.setProperty(PROP_OSGI_FRAMEWORK, url);
345
		}
346
347
		String bundles = properties.getProperty(PROP_OSGI_BUNDLES);
348
		if (bundles != null) {
349
			StringBuffer buffer = new StringBuffer();
350
			StringTokenizer tokenizer = new StringTokenizer(bundles, ","); //$NON-NLS-1$
351
			while (tokenizer.hasMoreTokens()) {
352
				String token = tokenizer.nextToken().trim();
353
				String url = getBundleURL(token, map, false);
354
				int i = -1;
355
				if (url == null) {
356
					i = token.indexOf('@');
357
					if (i != -1) {
358
						url = getBundleURL(token.substring(0, i), map, false);
359
					}
360
					if (url == null) {
361
						i = token.indexOf(':');
362
						if (i != -1)
363
							url = getBundleURL(token.substring(0, i), map, false);
364
					}
365
				}
366
				if (url != null) {
367
					if (buffer.length() > 0) {
368
						buffer.append(","); //$NON-NLS-1$
369
					}
370
					buffer.append("reference:" + url); //$NON-NLS-1$
371
					if (i != -1) {
372
						String slinfo = token.substring(i + 1);
373
						buffer.append(getStartData(slinfo, defaultAuto));
374
					}
375
				}
376
			}
377
			properties.setProperty(PROP_OSGI_BUNDLES, buffer.toString());
378
		}
379
	}
380
381
	/**
382
	 * Convenience method to parses the startData ("startLevel:autoStart"), convert it to the
383
	 * format expected by the OSGi bundles property, and append to a StringBuffer.
384
	 * @param startData data to parse ("startLevel:autoStart")
385
	 * @param defaultAuto default auto start setting
386
	 */
387
	public static String getStartData(String startData, boolean defaultAuto) {
388
		StringBuffer buffer = new StringBuffer();
389
		int index = startData.indexOf(':');
390
		String level = index > 0 ? startData.substring(0, index) : "default"; //$NON-NLS-1$
391
		String auto = startData;
392
		if (!startData.equals("start")) //$NON-NLS-1$
393
			auto = index >= 0 && index < startData.length() - 1 ? startData.substring(index + 1) : "default"; //$NON-NLS-1$
394
		if ("default".equals(auto)) //$NON-NLS-1$
395
			auto = Boolean.toString(defaultAuto);
396
		if (!level.equals("default") || "true".equals(auto) || "start".equals(auto)) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
397
			buffer.append("@"); //$NON-NLS-1$
398
399
		if (!level.equals("default")) { //$NON-NLS-1$
400
			buffer.append(level);
401
			if ("start".equals(auto) || "true".equals(auto)) //$NON-NLS-1$ //$NON-NLS-2$
402
				buffer.append(":"); //$NON-NLS-1$
403
		}
404
		if ("start".equals(auto) || "true".equals(auto)) { //$NON-NLS-1$ //$NON-NLS-2$
405
			buffer.append("start"); //$NON-NLS-1$
406
		}
407
		return buffer.toString();
408
	}
409
410
	public static void save(File file, Properties properties) {
411
		try {
412
			FileOutputStream stream = new FileOutputStream(file);
413
			properties.store(stream, "Configuration File"); //$NON-NLS-1$
414
			stream.flush();
415
			stream.close();
416
		} catch (IOException e) {
417
			PDECore.logException(e);
418
		}
419
	}
420
421
	public static String getContributingPlugin(String productID) {
422
		if (productID == null)
423
			return null;
424
		int index = productID.lastIndexOf('.');
425
		return index == -1 ? productID : productID.substring(0, index);
426
	}
427
428
	public static String getProductID(ILaunchConfiguration configuration) throws CoreException {
429
		if (configuration.getAttribute(IPDELauncherConstants.USE_PRODUCT, false)) {
430
			return configuration.getAttribute(IPDELauncherConstants.PRODUCT, (String) null);
431
		}
432
433
		// find the product associated with the application, and return its
434
		// contributing plug-in
435
		String appID = configuration.getAttribute(IPDELauncherConstants.APPLICATION, TargetPlatform.getDefaultApplication());
436
		IExtension[] extensions = PDECore.getDefault().getExtensionsRegistry().findExtensions("org.eclipse.core.runtime.products", true); //$NON-NLS-1$
437
		for (int i = 0; i < extensions.length; i++) {
438
			String id = extensions[i].getUniqueIdentifier();
439
			if (id == null)
440
				continue;
441
			IConfigurationElement[] children = extensions[i].getConfigurationElements();
442
			if (children.length != 1)
443
				continue;
444
			if (!"product".equals(children[0].getName())) //$NON-NLS-1$
445
				continue;
446
			if (appID.equals(children[0].getAttribute("application"))) //$NON-NLS-1$
447
				return id;
448
		}
449
		return null;
450
451
	}
452
453
}
(-)src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkManager.java (-141 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
13
import java.util.*;
14
import org.eclipse.core.runtime.*;
15
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
16
import org.eclipse.jface.preference.IPreferenceStore;
17
import org.eclipse.pde.internal.ui.IPreferenceConstants;
18
import org.eclipse.pde.internal.ui.PDEPlugin;
19
import org.eclipse.pde.ui.launcher.OSGiLaunchConfigurationInitializer;
20
21
public class OSGiFrameworkManager implements IRegistryChangeListener {
22
23
	public static final String POINT_ID = "org.eclipse.pde.ui.osgiFrameworks"; //$NON-NLS-1$
24
	public static final String DEFAULT_FRAMEWORK = "org.eclipse.pde.ui.EquinoxFramework"; //$NON-NLS-1$
25
26
	public static final String ATT_ID = "id"; //$NON-NLS-1$
27
	public static final String ATT_NAME = "name"; //$NON-NLS-1$
28
	public static final String ATT_DELEGATE = "launcherDelegate"; //$NON-NLS-1$
29
	public static final String ATT_INITIALIZER = "initializer"; //$NON-NLS-1$
30
31
	public static final String ELEMENT_FRAMEWORK = "framework"; //$NON-NLS-1$
32
33
	private Map fFrameworks;
34
35
	public IConfigurationElement[] getFrameworks() {
36
		if (fFrameworks == null)
37
			loadElements();
38
		return (IConfigurationElement[]) fFrameworks.values().toArray(new IConfigurationElement[fFrameworks.size()]);
39
	}
40
41
	public IConfigurationElement[] getSortedFrameworks() {
42
		IConfigurationElement[] elements = getFrameworks();
43
		return orderElements(elements);
44
	}
45
46
	private void loadElements() {
47
		fFrameworks = new HashMap();
48
		IExtensionRegistry registry = Platform.getExtensionRegistry();
49
		IConfigurationElement[] elements = registry.getConfigurationElementsFor(POINT_ID);
50
		for (int i = 0; i < elements.length; i++) {
51
			String id = elements[i].getAttribute(ATT_ID);
52
			if (id == null || elements[i].getAttribute(ATT_NAME) == null || elements[i].getAttribute(ATT_DELEGATE) == null)
53
				continue;
54
			fFrameworks.put(id, elements[i]);
55
		}
56
	}
57
58
	private IConfigurationElement[] orderElements(IConfigurationElement[] elems) {
59
		Arrays.sort(elems, new Comparator() {
60
			public int compare(Object o1, Object o2) {
61
				String name1 = ((IConfigurationElement) o1).getAttribute(ATT_NAME);
62
				String name2 = ((IConfigurationElement) o2).getAttribute(ATT_NAME);
63
				if (name1 != null)
64
					return name1.compareToIgnoreCase(name2);
65
				return 1;
66
			}
67
		});
68
		return elems;
69
	}
70
71
	public void registryChanged(IRegistryChangeEvent event) {
72
		//TODO implement 
73
	}
74
75
	public String getDefaultFramework() {
76
		IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore();
77
		return store.getString(IPreferenceConstants.DEFAULT_OSGI_FRAMEOWRK);
78
	}
79
80
	public OSGiLaunchConfigurationInitializer getDefaultInitializer() {
81
		return getInitializer(getDefaultFramework());
82
	}
83
84
	public OSGiLaunchConfigurationInitializer getInitializer(String frameworkID) {
85
		if (fFrameworks == null)
86
			loadElements();
87
		if (fFrameworks.containsKey(frameworkID)) {
88
			try {
89
				IConfigurationElement element = (IConfigurationElement) fFrameworks.get(frameworkID);
90
				if (element.getAttribute(ATT_INITIALIZER) != null) {
91
					Object result = element.createExecutableExtension(ATT_INITIALIZER);
92
					if (result instanceof OSGiLaunchConfigurationInitializer)
93
						return (OSGiLaunchConfigurationInitializer) result;
94
				}
95
			} catch (CoreException e) {
96
			}
97
		}
98
		return new OSGiLaunchConfigurationInitializer();
99
	}
100
101
	public LaunchConfigurationDelegate getFrameworkLauncher(String frameworkID) {
102
		if (fFrameworks == null)
103
			loadElements();
104
		if (fFrameworks.containsKey(frameworkID)) {
105
			try {
106
				IConfigurationElement element = (IConfigurationElement) fFrameworks.get(frameworkID);
107
				Object result = element.createExecutableExtension(ATT_DELEGATE);
108
				if (result instanceof LaunchConfigurationDelegate)
109
					return (LaunchConfigurationDelegate) result;
110
			} catch (CoreException e) {
111
			}
112
		}
113
		return null;
114
	}
115
116
	public String getFrameworkName(String frameworkID) {
117
		if (fFrameworks == null)
118
			loadElements();
119
		if (fFrameworks.containsKey(frameworkID)) {
120
			IConfigurationElement element = (IConfigurationElement) fFrameworks.get(frameworkID);
121
			return element.getAttribute(ATT_NAME);
122
		}
123
		return null;
124
	}
125
126
	/**
127
	 * Returns the {@link IConfigurationElement} for the framework with the given ID
128
	 * or <code>null</code> if no element exists with that ID.
129
	 * @param frameworkId
130
	 * @return the {@link IConfigurationElement} for the framework with the given ID or <code>null</code>
131
	 * 
132
	 * @since 3.5
133
	 */
134
	public IConfigurationElement getFramework(String frameworkId) {
135
		if (fFrameworks == null) {
136
			loadElements();
137
		}
138
		return (IConfigurationElement) fFrameworks.get(frameworkId);
139
	}
140
141
}
(-)src/org/eclipse/pde/internal/ui/launcher/LaunchListener.java (-208 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
13
import java.io.File;
14
import java.util.ArrayList;
15
import org.eclipse.core.filesystem.EFS;
16
import org.eclipse.core.filesystem.IFileStore;
17
import org.eclipse.core.runtime.*;
18
import org.eclipse.debug.core.*;
19
import org.eclipse.debug.core.model.IProcess;
20
import org.eclipse.jface.dialogs.IDialogConstants;
21
import org.eclipse.jface.dialogs.MessageDialog;
22
import org.eclipse.pde.internal.ui.*;
23
import org.eclipse.swt.widgets.Display;
24
import org.eclipse.ui.*;
25
import org.eclipse.ui.ide.IDE;
26
import org.eclipse.ui.internal.views.log.LogView;
27
28
public class LaunchListener implements ILaunchListener, IDebugEventSetListener {
29
	private ArrayList managedLaunches;
30
	// maximum log file size
31
	public static final long MAX_FILE_LENGTH = 1024 * 1024;
32
	// different ways to open the error log
33
	public static final int OPEN_IN_ERROR_LOG_VIEW = 0;
34
	public static final int OPEN_IN_SYSTEM_EDITOR = 1;
35
36
	public LaunchListener() {
37
		managedLaunches = new ArrayList();
38
	}
39
40
	public void manage(ILaunch launch) {
41
		if (managedLaunches.size() == 0)
42
			hookListener(true);
43
		if (!managedLaunches.contains(launch))
44
			managedLaunches.add(launch);
45
	}
46
47
	/**
48
	 * @see org.eclipse.debug.core.ILaunchesListener#launchesRemoved(org.eclipse.debug.core.ILaunch)
49
	 */
50
	public void launchRemoved(ILaunch launch) {
51
		update(launch, true);
52
	}
53
54
	/**
55
	 * @see org.eclipse.debug.core.ILaunchesListener#launchesAdded(org.eclipse.debug.core.ILaunch)
56
	 */
57
	public void launchAdded(ILaunch launch) {
58
	}
59
60
	/**
61
	 * @see org.eclipse.debug.core.ILaunchesListener#launchesChanged(org.eclipse.debug.core.ILaunch)
62
	 */
63
	public void launchChanged(ILaunch launch) {
64
	}
65
66
	private void update(ILaunch launch, boolean remove) {
67
		if (managedLaunches.contains(launch)) {
68
			if (remove || launch.isTerminated()) {
69
				managedLaunches.remove(launch);
70
				if (managedLaunches.size() == 0) {
71
					hookListener(false);
72
				}
73
			}
74
		}
75
	}
76
77
	private void hookListener(boolean add) {
78
		DebugPlugin debugPlugin = DebugPlugin.getDefault();
79
		ILaunchManager launchManager = debugPlugin.getLaunchManager();
80
		if (add) {
81
			launchManager.addLaunchListener(this);
82
			debugPlugin.addDebugEventListener(this);
83
		} else {
84
			launchManager.removeLaunchListener(this);
85
			debugPlugin.removeDebugEventListener(this);
86
		}
87
	}
88
89
	private void doRestart(ILaunch launch) {
90
		ILaunchConfiguration config = launch.getLaunchConfiguration();
91
		try {
92
			ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy();
93
			copy.setAttribute(IPDEUIConstants.RESTART, true);
94
			copy.launch(launch.getLaunchMode(), new NullProgressMonitor());
95
		} catch (CoreException e) {
96
			PDEPlugin.logException(e);
97
		}
98
	}
99
100
	public void shutdown() {
101
		hookListener(false);
102
	}
103
104
	/**
105
	 * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent)
106
	 */
107
	public void handleDebugEvents(DebugEvent[] events) {
108
		for (int i = 0; i < events.length; i++) {
109
			DebugEvent event = events[i];
110
			Object source = event.getSource();
111
			if (source instanceof IProcess && event.getKind() == DebugEvent.TERMINATE) {
112
				IProcess process = (IProcess) source;
113
				ILaunch launch = process.getLaunch();
114
				if (launch != null) {
115
					try {
116
						launchTerminated(launch, process.getExitValue());
117
					} catch (DebugException e) {
118
					}
119
				}
120
			}
121
		}
122
	}
123
124
	private void launchTerminated(final ILaunch launch, int returnValue) {
125
		if (managedLaunches.contains(launch)) {
126
			update(launch, true);
127
			if (returnValue == 23) {
128
				doRestart(launch);
129
				return;
130
			}
131
			// launch failed because the associated workspace is in use
132
			if (returnValue == 15) {
133
				Display.getDefault().asyncExec(new Runnable() {
134
					public void run() {
135
						MessageDialog.openError(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.Launcher_error_title, PDEUIMessages.Launcher_error_code15);
136
					}
137
				});
138
				return;
139
			}
140
			// launch failed for reasons printed to the log.
141
			if (returnValue == 13) {
142
				Display.getDefault().asyncExec(new Runnable() {
143
					public void run() {
144
						try {
145
							File log = getMostRecentLogFile(launch.getLaunchConfiguration());
146
							if (log != null && log.exists()) {
147
								MessageDialog dialog = new MessageDialog(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.Launcher_error_title, null, // accept the default window icon
148
										PDEUIMessages.Launcher_error_code13, MessageDialog.ERROR, new String[] {PDEUIMessages.Launcher_error_displayInLogView, PDEUIMessages.Launcher_error_displayInSystemEditor, IDialogConstants.NO_LABEL}, OPEN_IN_ERROR_LOG_VIEW);
149
								int dialog_value = dialog.open();
150
								if (dialog_value == OPEN_IN_ERROR_LOG_VIEW) {
151
									LogView errlog = (LogView) PDEPlugin.getActivePage().showView("org.eclipse.pde.runtime.LogView"); //$NON-NLS-1$
152
									errlog.handleImportPath(log.getAbsolutePath());
153
									errlog.sortByDateDescending();
154
								} else if (dialog_value == OPEN_IN_SYSTEM_EDITOR) {
155
									openInEditor(log);
156
								}
157
							}
158
						} catch (CoreException e) {
159
						}
160
					}
161
				});
162
			}
163
		}
164
	}
165
166
	private void openInEditor(File log) {
167
		IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(log.getAbsolutePath()));
168
		if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) {
169
			IWorkbenchWindow ww = PDEPlugin.getActiveWorkbenchWindow();
170
			IWorkbenchPage page = ww.getActivePage();
171
			try {
172
				IDE.openEditorOnFileStore(page, fileStore);
173
			} catch (PartInitException e) {
174
			}
175
		}
176
	}
177
178
	/**
179
	 * Returns latest log file for Launch Configuration.
180
	 * It's ".metadala/.log", file with most recent timestamp ending with ".log"
181
	 * in configuration location or null if none found.
182
	 *
183
	 * @returns log file or null
184
	 * @throws CoreException
185
	 * @since 3.4
186
	 */
187
	static File getMostRecentLogFile(ILaunchConfiguration configuration) throws CoreException {
188
		File latest = null;
189
		String workspace = LaunchArgumentsHelper.getWorkspaceLocation(configuration);
190
		if (workspace.length() > 0) {
191
			latest = new File(workspace, ".metadata/.log"); //$NON-NLS-1$
192
			if (!latest.exists())
193
				latest = null;
194
		}
195
		File configDir = LaunchConfigurationHelper.getConfigurationLocation(configuration);
196
		File[] children = configDir.listFiles();
197
		if (children != null) {
198
			for (int i = 0; i < children.length; i++) {
199
				if (!children[i].isDirectory() && children[i].getName().endsWith(".log")) { //$NON-NLS-1$
200
					if (latest == null || latest.lastModified() < children[i].lastModified())
201
						latest = children[i];
202
				}
203
			}
204
		}
205
		return latest;
206
	}
207
208
}
(-)src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkBlock.java (-129 / +131 lines)
Lines 8-139 Link Here
8
 *  Contributors:
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
11
package org.eclipse.pde.internal.ui.launcher;
12
12
13
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
import org.eclipse.core.runtime.IConfigurationElement;
14
15
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
16
import org.eclipse.core.runtime.IConfigurationElement;
17
import org.eclipse.pde.internal.ui.PDEPlugin;
17
import org.eclipse.debug.core.ILaunchConfiguration;
18
import org.eclipse.pde.internal.ui.PDEUIMessages;
18
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
19
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
19
import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
20
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
20
import org.eclipse.pde.internal.launching.launcher.OSGiFrameworkManager;
21
import org.eclipse.swt.SWT;
21
import org.eclipse.pde.internal.ui.PDEUIMessages;
22
import org.eclipse.swt.events.*;
22
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
23
import org.eclipse.swt.layout.GridData;
23
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.layout.GridLayout;
24
import org.eclipse.swt.events.*;
25
import org.eclipse.swt.widgets.*;
25
import org.eclipse.swt.layout.GridData;
26
26
import org.eclipse.swt.layout.GridLayout;
27
public class OSGiFrameworkBlock {
27
import org.eclipse.swt.widgets.*;
28
28
29
	private Combo fDefaultAutoStart;
29
public class OSGiFrameworkBlock {
30
	private Spinner fDefaultStartLevel;
30
31
	private IConfigurationElement[] fConfigElements;
31
	private Combo fDefaultAutoStart;
32
	private Combo fLauncherCombo;
32
	private Spinner fDefaultStartLevel;
33
	private Listener fListener;
33
	private IConfigurationElement[] fConfigElements;
34
	private AbstractLauncherTab fTab;
34
	private Combo fLauncherCombo;
35
35
	private Listener fListener;
36
	class Listener extends SelectionAdapter implements ModifyListener {
36
	private AbstractLauncherTab fTab;
37
37
38
		public void widgetSelected(SelectionEvent e) {
38
	class Listener extends SelectionAdapter implements ModifyListener {
39
			fTab.updateLaunchConfigurationDialog();
39
40
		}
40
		public void widgetSelected(SelectionEvent e) {
41
41
			fTab.updateLaunchConfigurationDialog();
42
		public void modifyText(ModifyEvent e) {
42
		}
43
			fTab.updateLaunchConfigurationDialog();
43
44
		}
44
		public void modifyText(ModifyEvent e) {
45
	}
45
			fTab.updateLaunchConfigurationDialog();
46
46
		}
47
	public OSGiFrameworkBlock(AbstractLauncherTab tab) {
47
	}
48
		fTab = tab;
48
49
		fConfigElements = PDEPlugin.getDefault().getOSGiFrameworkManager().getSortedFrameworks();
49
	public OSGiFrameworkBlock(AbstractLauncherTab tab) {
50
		fListener = new Listener();
50
		fTab = tab;
51
	}
51
		fConfigElements = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager().getSortedFrameworks();
52
52
		fListener = new Listener();
53
	public void createControl(Composite parent) {
53
	}
54
		Composite composite = new Composite(parent, SWT.NONE);
54
55
		GridLayout layout = new GridLayout(6, false);
55
	public void createControl(Composite parent) {
56
		layout.marginHeight = layout.marginWidth = 0;
56
		Composite composite = new Composite(parent, SWT.NONE);
57
		composite.setLayout(layout);
57
		GridLayout layout = new GridLayout(6, false);
58
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
58
		layout.marginHeight = layout.marginWidth = 0;
59
		gd.horizontalSpan = 2;
59
		composite.setLayout(layout);
60
		composite.setLayoutData(gd);
60
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
61
61
		gd.horizontalSpan = 2;
62
		Label label = new Label(composite, SWT.NONE);
62
		composite.setLayoutData(gd);
63
		label.setText(PDEUIMessages.OSGiBundlesTab_frameworkLabel);
63
64
		gd = new GridData();
64
		Label label = new Label(composite, SWT.NONE);
65
		gd.horizontalIndent = 5;
65
		label.setText(PDEUIMessages.OSGiBundlesTab_frameworkLabel);
66
		label.setLayoutData(gd);
66
		gd = new GridData();
67
67
		gd.horizontalIndent = 5;
68
		fLauncherCombo = new Combo(composite, SWT.READ_ONLY);
68
		label.setLayoutData(gd);
69
		for (int i = 0; i < fConfigElements.length; i++)
69
70
			fLauncherCombo.add(fConfigElements[i].getAttribute("name")); //$NON-NLS-1$
70
		fLauncherCombo = new Combo(composite, SWT.READ_ONLY);
71
		fLauncherCombo.addSelectionListener(fListener);
71
		for (int i = 0; i < fConfigElements.length; i++)
72
72
			fLauncherCombo.add(fConfigElements[i].getAttribute("name")); //$NON-NLS-1$
73
		label = new Label(composite, SWT.NONE);
73
		fLauncherCombo.addSelectionListener(fListener);
74
		gd = new GridData();
74
75
		gd.horizontalIndent = 20;
75
		label = new Label(composite, SWT.NONE);
76
		label.setLayoutData(gd);
76
		gd = new GridData();
77
		label.setText(PDEUIMessages.EquinoxPluginsTab_defaultStart);
77
		gd.horizontalIndent = 20;
78
78
		label.setLayoutData(gd);
79
		fDefaultStartLevel = new Spinner(composite, SWT.BORDER);
79
		label.setText(PDEUIMessages.EquinoxPluginsTab_defaultStart);
80
		fDefaultStartLevel.setMinimum(1);
80
81
		fDefaultStartLevel.addModifyListener(fListener);
81
		fDefaultStartLevel = new Spinner(composite, SWT.BORDER);
82
82
		fDefaultStartLevel.setMinimum(1);
83
		label = new Label(composite, SWT.NONE);
83
		fDefaultStartLevel.addModifyListener(fListener);
84
		gd = new GridData();
84
85
		gd.horizontalIndent = 20;
85
		label = new Label(composite, SWT.NONE);
86
		label.setLayoutData(gd);
86
		gd = new GridData();
87
		label.setText(PDEUIMessages.EquinoxPluginsTab_defaultAuto);
87
		gd.horizontalIndent = 20;
88
88
		label.setLayoutData(gd);
89
		fDefaultAutoStart = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
89
		label.setText(PDEUIMessages.EquinoxPluginsTab_defaultAuto);
90
		fDefaultAutoStart.setItems(new String[] {Boolean.toString(true), Boolean.toString(false)});
90
91
		fDefaultAutoStart.select(0);
91
		fDefaultAutoStart = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
92
		fDefaultAutoStart.addSelectionListener(fListener);
92
		fDefaultAutoStart.setItems(new String[] {Boolean.toString(true), Boolean.toString(false)});
93
93
		fDefaultAutoStart.select(0);
94
		label = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
94
		fDefaultAutoStart.addSelectionListener(fListener);
95
		gd = new GridData(GridData.FILL_HORIZONTAL);
95
96
		gd.horizontalSpan = 6;
96
		label = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
97
		label.setLayoutData(gd);
97
		gd = new GridData(GridData.FILL_HORIZONTAL);
98
	}
98
		gd.horizontalSpan = 6;
99
99
		label.setLayoutData(gd);
100
	public void initializeFrom(ILaunchConfiguration config) throws CoreException {
100
	}
101
		initializeFramework(config);
101
102
		boolean auto = config.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, true);
102
	public void initializeFrom(ILaunchConfiguration config) throws CoreException {
103
		fDefaultAutoStart.setText(Boolean.toString(auto));
103
		initializeFramework(config);
104
		int level = config.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4);
104
		boolean auto = config.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, true);
105
		fDefaultStartLevel.setSelection(level);
105
		fDefaultAutoStart.setText(Boolean.toString(auto));
106
	}
106
		int level = config.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4);
107
107
		fDefaultStartLevel.setSelection(level);
108
	private void initializeFramework(ILaunchConfiguration config) throws CoreException {
108
	}
109
		OSGiFrameworkManager manager = PDEPlugin.getDefault().getOSGiFrameworkManager();
109
110
		String id = config.getAttribute(IPDELauncherConstants.OSGI_FRAMEWORK_ID, manager.getDefaultFramework());
110
	private void initializeFramework(ILaunchConfiguration config) throws CoreException {
111
111
		OSGiFrameworkManager manager = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager();
112
		for (int i = 0; i < fConfigElements.length; i++) {
112
		String id = config.getAttribute(IPDELauncherConstants.OSGI_FRAMEWORK_ID, manager.getDefaultFramework());
113
			if (id.equals(fConfigElements[i].getAttribute(OSGiFrameworkManager.ATT_ID))) {
113
114
				fLauncherCombo.select(i);
114
		for (int i = 0; i < fConfigElements.length; i++) {
115
				return;
115
			if (id.equals(fConfigElements[i].getAttribute(OSGiFrameworkManager.ATT_ID))) {
116
			}
116
				fLauncherCombo.select(i);
117
		}
117
				return;
118
		if (fLauncherCombo.getItemCount() > 0)
118
			}
119
			fLauncherCombo.select(0);
119
		}
120
	}
120
		if (fLauncherCombo.getItemCount() > 0)
121
121
			fLauncherCombo.select(0);
122
	public void performApply(ILaunchConfigurationWorkingCopy config) {
122
	}
123
		config.setAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, Boolean.toString(true).equals(fDefaultAutoStart.getText()));
123
124
		config.setAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, fDefaultStartLevel.getSelection());
124
	public void performApply(ILaunchConfigurationWorkingCopy config) {
125
125
		config.setAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, Boolean.toString(true).equals(fDefaultAutoStart.getText()));
126
		int index = fLauncherCombo.getSelectionIndex();
126
		config.setAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, fDefaultStartLevel.getSelection());
127
		String id = index > -1 ? fConfigElements[index].getAttribute(OSGiFrameworkManager.ATT_ID) : null;
127
128
		OSGiFrameworkManager manager = PDEPlugin.getDefault().getOSGiFrameworkManager();
128
		int index = fLauncherCombo.getSelectionIndex();
129
129
		String id = index > -1 ? fConfigElements[index].getAttribute(OSGiFrameworkManager.ATT_ID) : null;
130
		// no need to persist the default OSGi framework
130
		OSGiFrameworkManager manager = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager();
131
		if (manager.getDefaultFramework().equals(id))
131
132
			id = null;
132
		// no need to persist the default OSGi framework
133
		config.setAttribute(IPDELauncherConstants.OSGI_FRAMEWORK_ID, id);
133
		if (manager.getDefaultFramework().equals(id))
134
	}
134
			id = null;
135
135
		config.setAttribute(IPDELauncherConstants.OSGI_FRAMEWORK_ID, id);
136
	public int getDefaultStartLevel() {
136
	}
137
		return fDefaultStartLevel.getSelection();
137
138
	}
138
	public int getDefaultStartLevel() {
139
}
139
		return fDefaultStartLevel.getSelection();
140
	}
141
}
(-)src/org/eclipse/pde/internal/ui/launcher/OSGiBundleBlock.java (-1 / +4 lines)
Lines 11-23 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.launcher;
12
package org.eclipse.pde.internal.ui.launcher;
13
13
14
import org.eclipse.pde.launching.IPDELauncherConstants;
15
16
import org.eclipse.pde.internal.launching.launcher.*;
17
14
import java.util.*;
18
import java.util.*;
15
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.debug.core.ILaunchConfiguration;
20
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
21
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
18
import org.eclipse.pde.core.plugin.IPluginModelBase;
22
import org.eclipse.pde.core.plugin.IPluginModelBase;
19
import org.eclipse.pde.ui.launcher.BundlesTab;
23
import org.eclipse.pde.ui.launcher.BundlesTab;
20
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
21
24
22
public class OSGiBundleBlock extends AbstractPluginBlock {
25
public class OSGiBundleBlock extends AbstractPluginBlock {
23
26
(-)src/org/eclipse/pde/internal/ui/launcher/AbstractPluginBlock.java (-1 / +5 lines)
Lines 12-17 Link Here
12
 *******************************************************************************/
12
 *******************************************************************************/
13
package org.eclipse.pde.internal.ui.launcher;
13
package org.eclipse.pde.internal.ui.launcher;
14
14
15
import org.eclipse.pde.launching.IPDELauncherConstants;
16
17
import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper;
18
import org.eclipse.pde.internal.launching.launcher.LaunchValidationOperation;
19
15
import java.util.*;
20
import java.util.*;
16
import org.eclipse.core.resources.IProject;
21
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.resources.IResource;
22
import org.eclipse.core.resources.IResource;
Lines 35-41 Link Here
35
import org.eclipse.pde.internal.ui.util.*;
40
import org.eclipse.pde.internal.ui.util.*;
36
import org.eclipse.pde.internal.ui.wizards.ListUtil;
41
import org.eclipse.pde.internal.ui.wizards.ListUtil;
37
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
42
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
38
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
39
import org.eclipse.swt.SWT;
43
import org.eclipse.swt.SWT;
40
import org.eclipse.swt.SWTException;
44
import org.eclipse.swt.SWTException;
41
import org.eclipse.swt.custom.CCombo;
45
import org.eclipse.swt.custom.CCombo;
(-)src/org/eclipse/pde/internal/ui/launcher/PDESourceLookupDirector.java (-242 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Code 9 Corporation - ongoing enhancements
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.launcher;
13
14
import java.io.File;
15
import java.util.*;
16
import org.eclipse.core.filesystem.URIUtil;
17
import org.eclipse.core.resources.*;
18
import org.eclipse.core.runtime.*;
19
import org.eclipse.debug.core.sourcelookup.*;
20
import org.eclipse.debug.core.sourcelookup.containers.*;
21
import org.eclipse.debug.ui.sourcelookup.WorkingSetSourceContainer;
22
import org.eclipse.jdt.core.*;
23
import org.eclipse.jdt.debug.core.*;
24
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
25
import org.eclipse.jdt.launching.JavaRuntime;
26
import org.eclipse.jdt.launching.sourcelookup.containers.JavaSourceLookupParticipant;
27
import org.eclipse.pde.core.plugin.*;
28
import org.eclipse.pde.internal.core.PDEClasspathContainer;
29
import org.eclipse.pde.internal.core.TargetPlatformHelper;
30
import org.eclipse.pde.internal.ui.PDEPlugin;
31
32
public class PDESourceLookupDirector extends AbstractSourceLookupDirector {
33
34
	/**
35
	 * Cache of source containers by location and id (String & String)
36
	 */
37
	private Map fSourceContainerMap = new HashMap();
38
39
	private static Set fFilteredTypes;
40
41
	static {
42
		fFilteredTypes = new HashSet(3);
43
		fFilteredTypes.add(ProjectSourceContainer.TYPE_ID);
44
		fFilteredTypes.add(WorkspaceSourceContainer.TYPE_ID);
45
		fFilteredTypes.add(WorkingSetSourceContainer.TYPE_ID);
46
	}
47
48
	/**
49
	 * Lazily initialized.
50
	 */
51
	private double fOSGiRuntimeVersion = Double.MIN_VALUE;
52
53
	/* (non-Javadoc)
54
	 * @see org.eclipse.debug.internal.core.sourcelookup.ISourceLookupDirector#initializeParticipants()
55
	 */
56
	public void initializeParticipants() {
57
		addParticipants(new ISourceLookupParticipant[] {new JavaSourceLookupParticipant()});
58
	}
59
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.debug.internal.core.sourcelookup.ISourceLookupDirector#supportsSourceContainerType(org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType)
62
	 */
63
	public boolean supportsSourceContainerType(ISourceContainerType type) {
64
		return !fFilteredTypes.contains(type.getId());
65
	}
66
67
	/* (non-Javadoc)
68
	 * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#getSourceElement(java.lang.Object)
69
	 */
70
	public Object getSourceElement(Object element) {
71
		PDESourceLookupQuery query = new PDESourceLookupQuery(this, element);
72
		SafeRunner.run(query);
73
		Object result = query.getResult();
74
		return result != null ? result : super.getSourceElement(element);
75
	}
76
77
	/* (non-Javadoc)
78
	 * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#findSourceElements(java.lang.Object)
79
	 */
80
	public Object[] findSourceElements(Object object) throws CoreException {
81
		Object[] sourceElements = null;
82
		if (object instanceof IJavaStackFrame || object instanceof IJavaObject || object instanceof IJavaReferenceType) {
83
			sourceElements = new Object[] {getSourceElement(object)};
84
		}
85
		if (sourceElements == null) {
86
			sourceElements = super.findSourceElements(object);
87
		}
88
		return sourceElements;
89
	}
90
91
	ISourceContainer[] getSourceContainers(String location, String id) throws CoreException {
92
93
		ISourceContainer[] containers = (ISourceContainer[]) fSourceContainerMap.get(location);
94
		if (containers != null) {
95
			return containers;
96
		}
97
98
		ArrayList result = new ArrayList();
99
		ModelEntry entry = PluginRegistry.findEntry(id);
100
101
		boolean match = false;
102
103
		IPluginModelBase[] models = entry.getWorkspaceModels();
104
		for (int i = 0; i < models.length; i++) {
105
			if (isPerfectMatch(models[i], new Path(location))) {
106
				IResource resource = models[i].getUnderlyingResource();
107
				// if the plug-in matches a workspace model,
108
				// add the project and any libraries not coming via a container
109
				// to the list of source containers, in that order
110
				if (resource != null) {
111
					addProjectSourceContainers(resource.getProject(), result);
112
				}
113
				match = true;
114
				break;
115
			}
116
		}
117
118
		if (!match) {
119
			File file = new File(location);
120
			if (file.isFile()) {
121
				// in case of linked plug-in projects that map to an external JARd plug-in,
122
				// use source container that maps to the library in the linked project.
123
				ISourceContainer container = getArchiveSourceContainer(location);
124
				if (container != null) {
125
					containers = new ISourceContainer[] {container};
126
					fSourceContainerMap.put(location, containers);
127
					return containers;
128
				}
129
			}
130
131
			models = entry.getExternalModels();
132
			for (int i = 0; i < models.length; i++) {
133
				if (isPerfectMatch(models[i], new Path(location))) {
134
					// try all source zips found in the source code locations
135
					IClasspathEntry[] entries = PDEClasspathContainer.getExternalEntries(models[i]);
136
					for (int j = 0; j < entries.length; j++) {
137
						IRuntimeClasspathEntry rte = convertClasspathEntry(entries[j]);
138
						if (rte != null)
139
							result.add(rte);
140
					}
141
					break;
142
				}
143
			}
144
		}
145
146
		IRuntimeClasspathEntry[] entries = (IRuntimeClasspathEntry[]) result.toArray(new IRuntimeClasspathEntry[result.size()]);
147
		containers = JavaRuntime.getSourceContainers(entries);
148
		fSourceContainerMap.put(location, containers);
149
		return containers;
150
	}
151
152
	private boolean isPerfectMatch(IPluginModelBase model, IPath path) {
153
		return model == null ? false : path.equals(new Path(model.getInstallLocation()));
154
	}
155
156
	private IRuntimeClasspathEntry convertClasspathEntry(IClasspathEntry entry) {
157
		if (entry == null)
158
			return null;
159
160
		IPath srcPath = entry.getSourceAttachmentPath();
161
		if (srcPath != null && srcPath.segmentCount() > 0) {
162
			IRuntimeClasspathEntry rte = JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath());
163
			rte.setSourceAttachmentPath(srcPath);
164
			rte.setSourceAttachmentRootPath(entry.getSourceAttachmentRootPath());
165
			return rte;
166
		}
167
		return null;
168
	}
169
170
	private ISourceContainer getArchiveSourceContainer(String location) throws JavaModelException {
171
		IWorkspaceRoot root = PDEPlugin.getWorkspace().getRoot();
172
		IFile[] containers = root.findFilesForLocationURI(URIUtil.toURI(location));
173
		for (int i = 0; i < containers.length; i++) {
174
			IJavaElement element = JavaCore.create(containers[i]);
175
			if (element instanceof IPackageFragmentRoot) {
176
				IPackageFragmentRoot archive = (IPackageFragmentRoot) element;
177
				IPath path = archive.getSourceAttachmentPath();
178
				if (path == null || path.segmentCount() == 0)
179
					continue;
180
181
				IPath rootPath = archive.getSourceAttachmentRootPath();
182
				boolean detectRootPath = rootPath != null && rootPath.segmentCount() > 0;
183
184
				IFile archiveFile = root.getFile(path);
185
				if (archiveFile.exists())
186
					return new ArchiveSourceContainer(archiveFile, detectRootPath);
187
188
				File file = path.toFile();
189
				if (file.exists())
190
					return new ExternalArchiveSourceContainer(file.getAbsolutePath(), detectRootPath);
191
			}
192
		}
193
		return null;
194
	}
195
196
	private void addProjectSourceContainers(IProject project, ArrayList result) throws CoreException {
197
		if (project == null || !project.hasNature(JavaCore.NATURE_ID))
198
			return;
199
200
		IJavaProject jProject = JavaCore.create(project);
201
		result.add(JavaRuntime.newProjectRuntimeClasspathEntry(jProject));
202
203
		IClasspathEntry[] entries = jProject.getRawClasspath();
204
		for (int i = 0; i < entries.length; i++) {
205
			IClasspathEntry entry = entries[i];
206
			if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
207
				IRuntimeClasspathEntry rte = convertClasspathEntry(entry);
208
				if (rte != null)
209
					result.add(rte);
210
			}
211
		}
212
	}
213
214
	/* (non-Javadoc)
215
	 * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#dispose()
216
	 */
217
	public synchronized void dispose() {
218
		Iterator iterator = fSourceContainerMap.values().iterator();
219
		while (iterator.hasNext()) {
220
			ISourceContainer[] containers = (ISourceContainer[]) iterator.next();
221
			for (int i = 0; i < containers.length; i++) {
222
				containers[i].dispose();
223
			}
224
		}
225
		fSourceContainerMap.clear();
226
		super.dispose();
227
	}
228
229
	/**
230
	 * Returns the version of the OSGi runtime being debugged, based on the target platform.
231
	 * Cached per source lookup director.
232
	 * 
233
	 * @return OSGi runtime version
234
	 */
235
	double getOSGiRuntimeVersion() {
236
		if (fOSGiRuntimeVersion == Double.MIN_VALUE) {
237
			fOSGiRuntimeVersion = TargetPlatformHelper.getTargetVersion();
238
		}
239
		return fOSGiRuntimeVersion;
240
	}
241
242
}
(-)src/org/eclipse/pde/internal/ui/launcher/ConfigurationTemplateBlock.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
11
package org.eclipse.pde.internal.ui.launcher;
12
12
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
13
import java.io.File;
15
import java.io.File;
14
import org.eclipse.core.filesystem.URIUtil;
16
import org.eclipse.core.filesystem.URIUtil;
15
import org.eclipse.core.resources.*;
17
import org.eclipse.core.resources.*;
Lines 23-29 Link Here
23
import org.eclipse.pde.internal.ui.PDEUIMessages;
25
import org.eclipse.pde.internal.ui.PDEUIMessages;
24
import org.eclipse.pde.internal.ui.util.FileNameFilter;
26
import org.eclipse.pde.internal.ui.util.FileNameFilter;
25
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
27
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
26
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
27
import org.eclipse.swt.SWT;
28
import org.eclipse.swt.SWT;
28
import org.eclipse.swt.events.SelectionAdapter;
29
import org.eclipse.swt.events.SelectionAdapter;
29
import org.eclipse.swt.events.SelectionEvent;
30
import org.eclipse.swt.events.SelectionEvent;
(-)src/org/eclipse/pde/internal/ui/launcher/ProductValidationOperation.java (-54 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 EclipseSource Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     EclipseSource Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.jdt.launching.IVMInstall;
17
import org.eclipse.jdt.launching.JavaRuntime;
18
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
19
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
20
import org.eclipse.pde.core.plugin.IPluginModelBase;
21
22
public class ProductValidationOperation extends LaunchValidationOperation {
23
24
	private IPluginModelBase[] fModels;
25
26
	public ProductValidationOperation(IPluginModelBase[] models) {
27
		super(null);
28
		fModels = models;
29
	}
30
31
	protected IPluginModelBase[] getModels() throws CoreException {
32
		return fModels;
33
	}
34
35
	protected IExecutionEnvironment[] getMatchingEnvironments() throws CoreException {
36
		IVMInstall install = JavaRuntime.getDefaultVMInstall();
37
38
		IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
39
		IExecutionEnvironment[] envs = manager.getExecutionEnvironments();
40
		List result = new ArrayList(envs.length);
41
		for (int i = 0; i < envs.length; i++) {
42
			IExecutionEnvironment env = envs[i];
43
			IVMInstall[] compatible = env.getCompatibleVMs();
44
			for (int j = 0; j < compatible.length; j++) {
45
				if (compatible[j].equals(install)) {
46
					result.add(env);
47
					break;
48
				}
49
			}
50
		}
51
		return (IExecutionEnvironment[]) result.toArray(new IExecutionEnvironment[result.size()]);
52
	}
53
54
}
(-)src/org/eclipse/pde/internal/ui/launcher/PDELogFileProvider.java (+1 lines)
Lines 15-20 Link Here
15
import java.util.*;
15
import java.util.*;
16
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.debug.core.*;
17
import org.eclipse.debug.core.*;
18
import org.eclipse.pde.internal.launching.launcher.LaunchListener;
18
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
19
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
19
import org.eclipse.ui.internal.views.log.ILogFileProvider;
20
import org.eclipse.ui.internal.views.log.ILogFileProvider;
20
import org.eclipse.ui.statushandlers.StatusManager;
21
import org.eclipse.ui.statushandlers.StatusManager;
(-)src/org/eclipse/pde/internal/ui/launcher/WorkspaceDataBlock.java (-7 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-22 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
11
package org.eclipse.pde.internal.ui.launcher;
12
12
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
13
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
16
import org.eclipse.pde.internal.ui.IPDEUIConstants;
18
import org.eclipse.pde.internal.launching.IPDEConstants;
19
import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper;
17
import org.eclipse.pde.internal.ui.PDEUIMessages;
20
import org.eclipse.pde.internal.ui.PDEUIMessages;
18
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
21
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
19
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
20
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.events.SelectionAdapter;
23
import org.eclipse.swt.events.SelectionAdapter;
22
import org.eclipse.swt.events.SelectionEvent;
24
import org.eclipse.swt.events.SelectionEvent;
Lines 96-102 Link Here
96
		config.setAttribute(IPDELauncherConstants.LOCATION, getLocation());
98
		config.setAttribute(IPDELauncherConstants.LOCATION, getLocation());
97
		config.setAttribute(IPDELauncherConstants.DOCLEAR, fClearWorkspaceCheck.getSelection());
99
		config.setAttribute(IPDELauncherConstants.DOCLEAR, fClearWorkspaceCheck.getSelection());
98
		config.setAttribute(IPDELauncherConstants.ASKCLEAR, fAskClearCheck.getSelection());
100
		config.setAttribute(IPDELauncherConstants.ASKCLEAR, fAskClearCheck.getSelection());
99
		config.setAttribute(IPDEUIConstants.DOCLEARLOG, fClearWorkspaceLogRadio.getSelection());
101
		config.setAttribute(IPDEConstants.DOCLEARLOG, fClearWorkspaceLogRadio.getSelection());
100
	}
102
	}
101
103
102
	public void initializeFrom(ILaunchConfiguration configuration) throws CoreException {
104
	public void initializeFrom(ILaunchConfiguration configuration) throws CoreException {
Lines 105-113 Link Here
105
		fAskClearCheck.setSelection(configuration.getAttribute(IPDELauncherConstants.ASKCLEAR, true));
107
		fAskClearCheck.setSelection(configuration.getAttribute(IPDELauncherConstants.ASKCLEAR, true));
106
		fAskClearCheck.setEnabled(fClearWorkspaceCheck.getSelection());
108
		fAskClearCheck.setEnabled(fClearWorkspaceCheck.getSelection());
107
		fClearWorkspaceLogRadio.setEnabled(fClearWorkspaceCheck.getSelection());
109
		fClearWorkspaceLogRadio.setEnabled(fClearWorkspaceCheck.getSelection());
108
		fClearWorkspaceLogRadio.setSelection(configuration.getAttribute(IPDEUIConstants.DOCLEARLOG, false));
110
		fClearWorkspaceLogRadio.setSelection(configuration.getAttribute(IPDEConstants.DOCLEARLOG, false));
109
		fClearWorkspaceRadio.setEnabled(fClearWorkspaceCheck.getSelection());
111
		fClearWorkspaceRadio.setEnabled(fClearWorkspaceCheck.getSelection());
110
		fClearWorkspaceRadio.setSelection(!configuration.getAttribute(IPDEUIConstants.DOCLEARLOG, false));
112
		fClearWorkspaceRadio.setSelection(!configuration.getAttribute(IPDEConstants.DOCLEARLOG, false));
111
	}
113
	}
112
114
113
	public void setDefaults(ILaunchConfigurationWorkingCopy configuration, boolean isJUnit) {
115
	public void setDefaults(ILaunchConfigurationWorkingCopy configuration, boolean isJUnit) {
Lines 118-124 Link Here
118
		}
120
		}
119
		configuration.setAttribute(IPDELauncherConstants.DOCLEAR, isJUnit);
121
		configuration.setAttribute(IPDELauncherConstants.DOCLEAR, isJUnit);
120
		configuration.setAttribute(IPDELauncherConstants.ASKCLEAR, !isJUnit);
122
		configuration.setAttribute(IPDELauncherConstants.ASKCLEAR, !isJUnit);
121
		configuration.setAttribute(IPDEUIConstants.DOCLEARLOG, false);
123
		configuration.setAttribute(IPDEConstants.DOCLEARLOG, false);
122
	}
124
	}
123
125
124
	protected String getName() {
126
	protected String getName() {
(-)src/org/eclipse/pde/internal/ui/launcher/LaunchArgumentsHelper.java (-332 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
13
import java.io.File;
14
import java.io.IOException;
15
import java.net.URL;
16
import java.util.*;
17
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.runtime.*;
20
import org.eclipse.core.variables.IStringVariableManager;
21
import org.eclipse.core.variables.VariablesPlugin;
22
import org.eclipse.debug.core.ILaunchConfiguration;
23
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
24
import org.eclipse.jdt.core.*;
25
import org.eclipse.jdt.launching.ExecutionArguments;
26
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
27
import org.eclipse.pde.core.plugin.*;
28
import org.eclipse.pde.internal.build.IPDEBuildConstants;
29
import org.eclipse.pde.internal.core.*;
30
import org.eclipse.pde.internal.core.target.provisional.ITargetHandle;
31
import org.eclipse.pde.internal.core.target.provisional.ITargetPlatformService;
32
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
33
import org.osgi.framework.Bundle;
34
35
public class LaunchArgumentsHelper {
36
37
	/**
38
	 * Returns the location that will be used as the workspace when launching.  Will
39
	 * replace variables, so this method should only be called
40
	 * when variable substitution (may prompt the user) is appropriate.
41
	 * @param configuration the launch configuration to get the workspace value for
42
	 * @return workspace location path as a string
43
	 * @throws CoreException if there is a problem with the configuration
44
	 */
45
	public static String getWorkspaceLocation(ILaunchConfiguration configuration) throws CoreException {
46
		String location = configuration.getAttribute(IPDELauncherConstants.LOCATION, (String) null);
47
		if (location == null) {
48
			// backward compatibility
49
			location = configuration.getAttribute(IPDELauncherConstants.LOCATION + "0", (String) null); //$NON-NLS-1$
50
			if (location != null) {
51
				ILaunchConfigurationWorkingCopy wc = null;
52
				if (configuration.isWorkingCopy()) {
53
					wc = (ILaunchConfigurationWorkingCopy) configuration;
54
				} else {
55
					wc = configuration.getWorkingCopy();
56
				}
57
				wc.setAttribute(IPDELauncherConstants.LOCATION + "0", (String) null); //$NON-NLS-1$
58
				wc.setAttribute(IPDELauncherConstants.LOCATION, location);
59
				wc.doSave();
60
			}
61
		}
62
		return getSubstitutedString(location);
63
	}
64
65
	public static String[] getUserProgramArgumentArray(ILaunchConfiguration configuration) throws CoreException {
66
		String args = getUserProgramArguments(configuration);
67
		return new ExecutionArguments("", args).getProgramArgumentsArray(); //$NON-NLS-1$
68
	}
69
70
	public static String getUserProgramArguments(ILaunchConfiguration configuration) throws CoreException {
71
		String args = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null);
72
		if (args == null) {
73
			// backward compatibility
74
			args = configuration.getAttribute("progargs", (String) null); //$NON-NLS-1$
75
			if (args != null) {
76
				ILaunchConfigurationWorkingCopy wc = null;
77
				if (configuration.isWorkingCopy()) {
78
					wc = (ILaunchConfigurationWorkingCopy) configuration;
79
				} else {
80
					wc = configuration.getWorkingCopy();
81
				}
82
				wc.setAttribute("progargs", (String) null); //$NON-NLS-1$
83
				wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args);
84
				wc.doSave();
85
			}
86
		}
87
		return args == null ? "" : getSubstitutedString(args); //$NON-NLS-1$
88
	}
89
90
	public static String getUserVMArguments(ILaunchConfiguration configuration) throws CoreException {
91
		String args = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String) null);
92
		if (args == null) {
93
			// backward compatibility
94
			args = configuration.getAttribute("vmargs", (String) null); //$NON-NLS-1$
95
			if (args != null) {
96
				ILaunchConfigurationWorkingCopy wc = null;
97
				if (configuration.isWorkingCopy()) {
98
					wc = (ILaunchConfigurationWorkingCopy) configuration;
99
				} else {
100
					wc = configuration.getWorkingCopy();
101
				}
102
				wc.setAttribute("vmargs", (String) null); //$NON-NLS-1$
103
				wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, args);
104
				wc.doSave();
105
			}
106
		}
107
		return args == null ? "" : getSubstitutedString(args); //$NON-NLS-1$
108
	}
109
110
	/**
111
	 * Fetches the VM Arguments from the current Target Platform
112
	 *  
113
	 * @return	VM Arguments from the current Target Platform or empty string if none found
114
	 */
115
	public static String getInitialVMArguments() {
116
117
		try {
118
			ITargetPlatformService service = (ITargetPlatformService) PDECore.getDefault().acquireService(ITargetPlatformService.class.getName());
119
			if (service != null) {
120
				ITargetHandle target = service.getWorkspaceTargetHandle();
121
				if (target != null) {
122
					String result = target.getTargetDefinition().getVMArguments();
123
					result = result != null ? result : ""; //$NON-NLS-1$
124
					return result;
125
				}
126
			}
127
		} catch (CoreException e) {
128
		}
129
130
		// TODO: Generally, once the new preference target platform preference page is in use,
131
		// this code path will not be used. Once we decide to remove support for old targets/preferences
132
		// this code can be removed.
133
		PDEPreferencesManager preferences = PDECore.getDefault().getPreferencesManager();
134
		StringBuffer result = new StringBuffer(preferences.getString(ICoreConstants.VM_ARGS));
135
136
		if (preferences.getBoolean(ICoreConstants.VM_LAUNCHER_INI)) {
137
			// hack on the arguments from eclipse.ini
138
			result.append(TargetPlatformHelper.getIniVMArgs());
139
		}
140
		return result.toString();
141
	}
142
143
	public static String getInitialProgramArguments() {
144
		StringBuffer buffer = new StringBuffer("-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"); //$NON-NLS-1$
145
146
		PDEPreferencesManager preferences = PDECore.getDefault().getPreferencesManager();
147
		String programArgs = preferences.getString(ICoreConstants.PROGRAM_ARGS);
148
		if (programArgs.length() > 0) {
149
			buffer.append(" "); //$NON-NLS-1$
150
			buffer.append(programArgs);
151
		}
152
		return buffer.toString();
153
	}
154
155
	public static File getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
156
		String working;
157
		try {
158
			working = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, new File(".").getCanonicalPath()); //$NON-NLS-1$
159
		} catch (IOException e) {
160
			working = "${workspace_loc}/../"; //$NON-NLS-1$
161
		}
162
		File dir = new File(getSubstitutedString(working));
163
		if (!dir.exists())
164
			dir.mkdirs();
165
		return dir;
166
	}
167
168
	public static Map getVMSpecificAttributesMap(ILaunchConfiguration config) throws CoreException {
169
		Map map = new HashMap(2);
170
		String javaCommand = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_JAVA_COMMAND, (String) null);
171
		map.put(IJavaLaunchConfigurationConstants.ATTR_JAVA_COMMAND, javaCommand);
172
		if (TargetPlatform.getOS().equals("macosx")) { //$NON-NLS-1$
173
			ModelEntry entry = PluginRegistry.findEntry("org.eclipse.jdt.debug"); //$NON-NLS-1$
174
			if (entry != null) {
175
				IPluginModelBase[] models = entry.getExternalModels();
176
				for (int i = 0; i < models.length; i++) {
177
					File file = new File(models[i].getInstallLocation());
178
					if (!file.isFile())
179
						file = new File(file, "jdi.jar"); //$NON-NLS-1$
180
					if (file.exists()) {
181
						map.put(IJavaLaunchConfigurationConstants.ATTR_BOOTPATH_PREPEND, new String[] {file.getAbsolutePath()});
182
						break;
183
					}
184
				}
185
			}
186
		}
187
		return map;
188
	}
189
190
	public static String getTracingFileArgument(ILaunchConfiguration config, String optionsFileName) throws CoreException {
191
		try {
192
			TracingOptionsManager mng = PDECore.getDefault().getTracingOptionsManager();
193
			Map options = config.getAttribute(IPDELauncherConstants.TRACING_OPTIONS, (Map) null);
194
			String selected = config.getAttribute(IPDELauncherConstants.TRACING_CHECKED, (String) null);
195
			if (selected == null) {
196
				mng.save(optionsFileName, options);
197
			} else if (!selected.equals(IPDELauncherConstants.TRACING_NONE)) {
198
				HashSet result = new HashSet();
199
				StringTokenizer tokenizer = new StringTokenizer(selected, ","); //$NON-NLS-1$
200
				while (tokenizer.hasMoreTokens()) {
201
					result.add(tokenizer.nextToken());
202
				}
203
				mng.save(optionsFileName, options, result);
204
			}
205
		} catch (CoreException e) {
206
			return ""; //$NON-NLS-1$
207
		}
208
		return optionsFileName;
209
	}
210
211
	public static String[] constructClasspath(ILaunchConfiguration configuration) throws CoreException {
212
		double targetVersion = TargetPlatformHelper.getTargetVersion();
213
		String jarPath = targetVersion >= 3.3 ? getEquinoxStartupPath(IPDEBuildConstants.BUNDLE_EQUINOX_LAUNCHER) : getStartupJarPath();
214
		if (jarPath == null && targetVersion < 3.3)
215
			jarPath = getEquinoxStartupPath("org.eclipse.core.launcher"); //$NON-NLS-1$
216
217
		if (jarPath == null)
218
			return null;
219
220
		ArrayList entries = new ArrayList();
221
		entries.add(jarPath);
222
223
		String bootstrap = configuration.getAttribute(IPDELauncherConstants.BOOTSTRAP_ENTRIES, ""); //$NON-NLS-1$
224
		StringTokenizer tok = new StringTokenizer(getSubstitutedString(bootstrap), ","); //$NON-NLS-1$
225
		while (tok.hasMoreTokens())
226
			entries.add(tok.nextToken().trim());
227
		return (String[]) entries.toArray(new String[entries.size()]);
228
	}
229
230
	private static String getEquinoxStartupPath(String packageName) throws CoreException {
231
		IPluginModelBase model = PluginRegistry.findModel(IPDEBuildConstants.BUNDLE_EQUINOX_LAUNCHER);
232
		if (model != null) {
233
			IResource resource = model.getUnderlyingResource();
234
			// found in the target
235
			if (resource == null)
236
				return model.getInstallLocation();
237
238
			// find it in the workspace
239
			IProject project = resource.getProject();
240
			if (project.hasNature(JavaCore.NATURE_ID)) {
241
				IJavaProject jProject = JavaCore.create(project);
242
				IClasspathEntry[] entries = jProject.getRawClasspath();
243
				for (int i = 0; i < entries.length; i++) {
244
					int kind = entries[i].getEntryKind();
245
					if (kind == IClasspathEntry.CPE_SOURCE || kind == IClasspathEntry.CPE_LIBRARY) {
246
						IPackageFragmentRoot[] roots = jProject.findPackageFragmentRoots(entries[i]);
247
						for (int j = 0; j < roots.length; j++) {
248
							if (roots[j].getPackageFragment(packageName).exists()) {
249
								// if source folder, find the output folder
250
								if (kind == IClasspathEntry.CPE_SOURCE) {
251
									IPath path = entries[i].getOutputLocation();
252
									if (path == null)
253
										path = jProject.getOutputLocation();
254
									path = path.removeFirstSegments(1);
255
									return project.getLocation().append(path).toOSString();
256
								}
257
								// else if is a library jar, then get the location of the jar itself
258
								IResource jar = roots[j].getResource();
259
								if (jar != null) {
260
									return jar.getLocation().toOSString();
261
								}
262
							}
263
						}
264
					}
265
				}
266
			}
267
		}
268
		Bundle bundle = Platform.getBundle(IPDEBuildConstants.BUNDLE_EQUINOX_LAUNCHER);
269
		if (bundle != null) {
270
			try {
271
				URL url = FileLocator.resolve(bundle.getEntry("/")); //$NON-NLS-1$
272
				url = FileLocator.toFileURL(url);
273
				String path = url.getFile();
274
				if (path.startsWith("file:")) //$NON-NLS-1$
275
					path = path.substring(5);
276
				path = new File(path).getAbsolutePath();
277
				if (path.endsWith("!")) //$NON-NLS-1$
278
					path = path.substring(0, path.length() - 1);
279
				return path;
280
			} catch (IOException e) {
281
			}
282
		}
283
		return null;
284
	}
285
286
	private static String getStartupJarPath() throws CoreException {
287
		IPluginModelBase model = PluginRegistry.findModel("org.eclipse.platform"); //$NON-NLS-1$
288
		if (model != null && model.getUnderlyingResource() != null) {
289
			IProject project = model.getUnderlyingResource().getProject();
290
			if (project.hasNature(JavaCore.NATURE_ID)) {
291
				IJavaProject jProject = JavaCore.create(project);
292
				IPackageFragmentRoot[] roots = jProject.getPackageFragmentRoots();
293
				for (int i = 0; i < roots.length; i++) {
294
					if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE && roots[i].getPackageFragment("org.eclipse.core.launcher").exists()) { //$NON-NLS-1$
295
						IPath path = jProject.getOutputLocation().removeFirstSegments(1);
296
						return project.getLocation().append(path).toOSString();
297
					}
298
				}
299
			}
300
			if (project.getFile("startup.jar").exists()) //$NON-NLS-1$
301
				return project.getFile("startup.jar").getLocation().toOSString(); //$NON-NLS-1$
302
		}
303
		File startupJar = new Path(TargetPlatform.getLocation()).append("startup.jar").toFile(); //$NON-NLS-1$
304
305
		// if something goes wrong with the preferences, fall back on the startup.jar 
306
		// in the running eclipse.  
307
		if (!startupJar.exists())
308
			startupJar = new Path(TargetPlatform.getDefaultLocation()).append("startup.jar").toFile(); //$NON-NLS-1$
309
310
		return startupJar.exists() ? startupJar.getAbsolutePath() : null;
311
	}
312
313
	private static String getSubstitutedString(String text) throws CoreException {
314
		if (text == null)
315
			return ""; //$NON-NLS-1$
316
		IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
317
		return mgr.performStringSubstitution(text);
318
	}
319
320
	public static String getDefaultWorkspaceLocation(String uniqueName) {
321
		return "${workspace_loc}/../runtime-" + uniqueName.replaceAll("\\s", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
322
	}
323
324
	public static String getDefaultJUnitWorkspaceLocation() {
325
		return "${workspace_loc}/../junit-workspace"; //$NON-NLS-1$
326
	}
327
328
	public static String getDefaultJUnitConfigurationLocation() {
329
		return "${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"; //$NON-NLS-1$
330
	}
331
332
}
(-)src/org/eclipse/pde/internal/ui/launcher/TracingBlock.java (-1 / +4 lines)
Lines 12-17 Link Here
12
 *******************************************************************************/
12
 *******************************************************************************/
13
package org.eclipse.pde.internal.ui.launcher;
13
package org.eclipse.pde.internal.ui.launcher;
14
14
15
import org.eclipse.pde.launching.IPDELauncherConstants;
16
15
import java.util.*;
17
import java.util.*;
16
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.debug.core.ILaunchConfiguration;
19
import org.eclipse.debug.core.ILaunchConfiguration;
Lines 25-31 Link Here
25
import org.eclipse.pde.internal.ui.PDEUIMessages;
27
import org.eclipse.pde.internal.ui.PDEUIMessages;
26
import org.eclipse.pde.internal.ui.util.SWTUtil;
28
import org.eclipse.pde.internal.ui.util.SWTUtil;
27
import org.eclipse.pde.internal.ui.wizards.ListUtil;
29
import org.eclipse.pde.internal.ui.wizards.ListUtil;
28
import org.eclipse.pde.ui.launcher.*;
30
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
31
import org.eclipse.pde.ui.launcher.TracingTab;
29
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.custom.SashForm;
33
import org.eclipse.swt.custom.SashForm;
31
import org.eclipse.swt.events.SelectionAdapter;
34
import org.eclipse.swt.events.SelectionAdapter;
(-)src/org/eclipse/pde/internal/ui/launcher/PDESourceLookupQuery.java (-261 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann - Bug 242461 - JSR045 support
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.launcher;
13
14
import java.io.File;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.ISafeRunnable;
17
import org.eclipse.debug.core.DebugException;
18
import org.eclipse.debug.core.model.IValue;
19
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
20
import org.eclipse.jdt.debug.core.*;
21
import org.eclipse.osgi.service.resolver.BundleDescription;
22
import org.eclipse.osgi.service.resolver.State;
23
import org.eclipse.pde.core.plugin.IPluginModelBase;
24
import org.eclipse.pde.internal.core.PDECore;
25
import org.eclipse.pde.internal.core.TargetPlatformHelper;
26
27
public class PDESourceLookupQuery implements ISafeRunnable {
28
29
	protected static String OSGI_CLASSLOADER = "org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader"; //$NON-NLS-1$
30
	private static String LEGACY_ECLIPSE_CLASSLOADER = "org.eclipse.core.runtime.adaptor.EclipseClassLoader"; //$NON-NLS-1$
31
	private static String MAIN_CLASS = "org.eclipse.core.launcher.Main"; //$NON-NLS-1$
32
	private static String MAIN_PLUGIN = "org.eclipse.platform"; //$NON-NLS-1$
33
34
	private Object fElement;
35
	private Object fResult;
36
	private PDESourceLookupDirector fDirector;
37
38
	public PDESourceLookupQuery(PDESourceLookupDirector director, Object object) {
39
		fElement = object;
40
		fDirector = director;
41
	}
42
43
	public void handleException(Throwable exception) {
44
	}
45
46
	public void run() throws Exception {
47
		IJavaReferenceType declaringType = null;
48
		String sourcePath = null;
49
		if (fElement instanceof IJavaStackFrame) {
50
			IJavaStackFrame stackFrame = (IJavaStackFrame) fElement;
51
			declaringType = stackFrame.getReferenceType();
52
			// under JSR 45 source path from the stack frame is more precise than anything derived from the type: 
53
			sourcePath = stackFrame.getSourcePath();
54
		} else if (fElement instanceof IJavaObject) {
55
			IJavaType javaType = ((IJavaObject) fElement).getJavaType();
56
			if (javaType instanceof IJavaReferenceType) {
57
				declaringType = (IJavaReferenceType) javaType;
58
			}
59
		} else if (fElement instanceof IJavaReferenceType) {
60
			declaringType = (IJavaReferenceType) fElement;
61
		}
62
		if (declaringType != null) {
63
			IJavaObject classLoaderObject = declaringType.getClassLoaderObject();
64
			String declaringTypeName = declaringType.getName();
65
			if (sourcePath == null) {
66
				String[] sourcePaths = declaringType.getSourcePaths(null);
67
				if (sourcePaths != null) {
68
					sourcePath = sourcePaths[0];
69
				}
70
				if (sourcePath == null) {
71
					sourcePath = generateSourceName(declaringTypeName);
72
				}
73
			}
74
75
			if (classLoaderObject != null) {
76
				IJavaClassType type = (IJavaClassType) classLoaderObject.getJavaType();
77
				if (OSGI_CLASSLOADER.equals(type.getName())) {
78
					if (fDirector.getOSGiRuntimeVersion() < 3.5) {
79
						fResult = findSourceElement34(classLoaderObject, sourcePath);
80
					} else {
81
						fResult = findSourceElement(classLoaderObject, sourcePath);
82
					}
83
				} else if (LEGACY_ECLIPSE_CLASSLOADER.equals(type.getName())) {
84
					fResult = findSourceElement_legacy(classLoaderObject, sourcePath);
85
				} else if (MAIN_CLASS.equals(declaringTypeName)) {
86
					IPluginModelBase model = PDECore.getDefault().getModelManager().findModel(MAIN_PLUGIN);
87
					if (model != null)
88
						fResult = getSourceElement(model.getInstallLocation(), MAIN_PLUGIN, sourcePath);
89
				}
90
			}
91
		}
92
	}
93
94
	protected Object getResult() {
95
		return fResult;
96
	}
97
98
	private String getValue(IJavaObject object, String variable) throws DebugException {
99
		IJavaFieldVariable var = object.getField(variable, false);
100
		return var == null ? null : var.getValue().getValueString();
101
	}
102
103
	/**
104
	 * Finds a source element in a 3.4 OSGi runtime.
105
	 * 
106
	 * @param object Bundle class loader object
107
	 * @param typeName fully qualified name of the source type being searched for
108
	 * @return source element
109
	 * @throws CoreException
110
	 */
111
	protected Object findSourceElement34(IJavaObject object, String typeName) throws CoreException {
112
		IJavaObject manager = getObject(object, "manager", false); //$NON-NLS-1$
113
		if (manager != null) {
114
			IJavaObject data = getObject(manager, "data", false); //$NON-NLS-1$
115
			if (data != null) {
116
				String location = getValue(data, "fileName"); //$NON-NLS-1$
117
				String id = getValue(data, "symbolicName"); //$NON-NLS-1$
118
				return getSourceElement(location, id, typeName);
119
			}
120
		}
121
		return null;
122
	}
123
124
	/**
125
	 * Finds source in a 3.5 runtime. In 3.5, the OSGi runtime provides hooks to properly
126
	 * lookup source in fragments that replace/prepend jars in their host.
127
	 * 
128
	 * @param object Bundle class loader object
129
	 * @param typeName fully qualified name of the source type being searched for 
130
	 * @return source element
131
	 * @throws CoreException
132
	 */
133
	protected Object findSourceElement(IJavaObject object, String typeName) throws CoreException {
134
		IJavaObject manager = getObject(object, "manager", false); //$NON-NLS-1$
135
		if (manager != null) {
136
			IJavaObject data = getObject(manager, "data", false); //$NON-NLS-1$
137
			if (data != null) {
138
				String id = getValue(data, "symbolicName"); //$NON-NLS-1$
139
				// search manager's class path for location
140
				Object result = searchClasspathEntries(manager, id, typeName);
141
				if (result != null) {
142
					return result;
143
				}
144
				// then check its fragments
145
				IJavaObject frgArray = getObject(manager, "fragments", false); //$NON-NLS-1$
146
				if (frgArray instanceof IJavaArray) {
147
					IJavaArray fragments = (IJavaArray) frgArray;
148
					for (int i = 0; i < fragments.getLength(); i++) {
149
						IJavaObject fragment = (IJavaObject) fragments.getValue(i);
150
						if (!fragment.isNull()) {
151
							// search fragment class path
152
							result = searchClasspathEntries(fragment, id, typeName);
153
							if (result != null) {
154
								return result;
155
							}
156
						}
157
158
					}
159
				}
160
			}
161
		}
162
		return null;
163
	}
164
165
	private Object searchClasspathEntries(IJavaObject entriesOwner, String id, String typeName) throws CoreException {
166
		IJavaObject cpeArray = getObject(entriesOwner, "entries", false); //$NON-NLS-1$
167
		if (cpeArray instanceof IJavaArray) {
168
			IJavaArray entries = (IJavaArray) cpeArray;
169
			for (int i = 0; i < entries.getLength(); i++) {
170
				IJavaObject entry = (IJavaObject) entries.getValue(i);
171
				if (!entry.isNull()) {
172
					IJavaObject baseData = getObject(entry, "data", false); //$NON-NLS-1$
173
					if (baseData != null && !baseData.isNull()) {
174
						IJavaObject fileName = getObject(baseData, "fileName", false); //$NON-NLS-1$
175
						if (fileName != null && !fileName.isNull()) {
176
							String location = fileName.getValueString();
177
							Object el = getSourceElement(location, id, typeName);
178
							if (el != null) {
179
								return el;
180
							}
181
						}
182
					}
183
				}
184
			}
185
		}
186
		return null;
187
	}
188
189
	private IJavaObject getObject(IJavaObject object, String field, boolean superfield) throws DebugException {
190
		IJavaFieldVariable variable = object.getField(field, superfield);
191
		if (variable != null) {
192
			IValue value = variable.getValue();
193
			if (value instanceof IJavaObject)
194
				return (IJavaObject) value;
195
		}
196
		return null;
197
	}
198
199
	private Object findSourceElement_legacy(IJavaObject object, String typeName) throws CoreException {
200
		IJavaObject hostdata = getObject(object, "hostdata", true); //$NON-NLS-1$
201
		if (hostdata != null) {
202
			String location = getValue(hostdata, "fileName"); //$NON-NLS-1$
203
			String id = getValue(hostdata, "symbolicName"); //$NON-NLS-1$
204
			return getSourceElement(location, id, typeName);
205
		}
206
		return null;
207
	}
208
209
	private Object getSourceElement(String location, String id, String typeName) throws CoreException {
210
		if (location != null && id != null) {
211
			Object result = findSourceElement(getSourceContainers(location, id), typeName);
212
			if (result != null)
213
				return result;
214
215
			// don't give up yet, search fragments attached to this host
216
			State state = TargetPlatformHelper.getState();
217
			BundleDescription desc = state.getBundle(id, null);
218
			if (desc != null) {
219
				BundleDescription[] fragments = desc.getFragments();
220
				for (int i = 0; i < fragments.length; i++) {
221
					location = fragments[i].getLocation();
222
					id = fragments[i].getSymbolicName();
223
					result = findSourceElement(getSourceContainers(location, id), typeName);
224
					if (result != null)
225
						return result;
226
				}
227
			}
228
		}
229
		return null;
230
	}
231
232
	private Object findSourceElement(ISourceContainer[] containers, String typeName) throws CoreException {
233
		for (int i = 0; i < containers.length; i++) {
234
			Object[] result = containers[i].findSourceElements(typeName);
235
			if (result.length > 0)
236
				return result[0];
237
		}
238
		return null;
239
	}
240
241
	protected ISourceContainer[] getSourceContainers(String location, String id) throws CoreException {
242
		return fDirector.getSourceContainers(location, id);
243
	}
244
245
	/**
246
	 * Generates and returns a source file path based on a qualified type name.
247
	 * For example, when <code>java.lang.String</code> is provided,
248
	 * the returned source name is <code>java/lang/String.java</code>.
249
	 * 
250
	 * @param qualifiedTypeName fully qualified type name that may contain inner types
251
	 *  denoted with <code>$</code> character
252
	 * @return a source file path corresponding to the type name
253
	 */
254
	private static String generateSourceName(String qualifiedTypeName) {
255
		int index = qualifiedTypeName.indexOf('$');
256
		if (index >= 0)
257
			qualifiedTypeName = qualifiedTypeName.substring(0, index);
258
		return qualifiedTypeName.replace('.', File.separatorChar) + ".java"; //$NON-NLS-1$
259
	}
260
261
}
(-)src/org/eclipse/pde/internal/ui/launcher/JUnitProgramBlock.java (-5 / +7 lines)
Lines 10-23 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
11
package org.eclipse.pde.internal.ui.launcher;
12
12
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
13
import java.util.TreeSet;
15
import java.util.TreeSet;
14
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
18
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17
import org.eclipse.pde.internal.ui.IPDEUIConstants;
19
import org.eclipse.pde.internal.launching.IPDEConstants;
20
import org.eclipse.pde.internal.launching.launcher.LauncherUtils;
18
import org.eclipse.pde.internal.ui.PDEUIMessages;
21
import org.eclipse.pde.internal.ui.PDEUIMessages;
19
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
22
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
20
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
21
23
22
public class JUnitProgramBlock extends ProgramBlock {
24
public class JUnitProgramBlock extends ProgramBlock {
23
25
Lines 31-37 Link Here
31
33
32
	public void setDefaults(ILaunchConfigurationWorkingCopy config) {
34
	public void setDefaults(ILaunchConfigurationWorkingCopy config) {
33
		if (!LauncherUtils.requiresUI(config))
35
		if (!LauncherUtils.requiresUI(config))
34
			config.setAttribute(IPDELauncherConstants.APPLICATION, IPDEUIConstants.CORE_TEST_APPLICATION);
36
			config.setAttribute(IPDELauncherConstants.APPLICATION, IPDEConstants.CORE_TEST_APPLICATION);
35
		else
37
		else
36
			super.setDefaults(config);
38
			super.setDefaults(config);
37
	}
39
	}
Lines 51-57 Link Here
51
	 */
53
	 */
52
	protected void initializeApplicationSection(ILaunchConfiguration config) throws CoreException {
54
	protected void initializeApplicationSection(ILaunchConfiguration config) throws CoreException {
53
		String application = config.getAttribute(IPDELauncherConstants.APPLICATION, (String) null);
55
		String application = config.getAttribute(IPDELauncherConstants.APPLICATION, (String) null);
54
		if (IPDEUIConstants.CORE_TEST_APPLICATION.equals(application))
56
		if (IPDEConstants.CORE_TEST_APPLICATION.equals(application))
55
			fApplicationCombo.setText(PDEUIMessages.JUnitProgramBlock_headless);
57
			fApplicationCombo.setText(PDEUIMessages.JUnitProgramBlock_headless);
56
		else
58
		else
57
			super.initializeApplicationSection(config);
59
			super.initializeApplicationSection(config);
Lines 62-68 Link Here
62
	 */
64
	 */
63
	protected void saveApplicationSection(ILaunchConfigurationWorkingCopy config) {
65
	protected void saveApplicationSection(ILaunchConfigurationWorkingCopy config) {
64
		if (fApplicationCombo.getText().equals(PDEUIMessages.JUnitProgramBlock_headless)) {
66
		if (fApplicationCombo.getText().equals(PDEUIMessages.JUnitProgramBlock_headless)) {
65
			String appName = fApplicationCombo.isEnabled() ? IPDEUIConstants.CORE_TEST_APPLICATION : null;
67
			String appName = fApplicationCombo.isEnabled() ? IPDEConstants.CORE_TEST_APPLICATION : null;
66
			config.setAttribute(IPDELauncherConstants.APPLICATION, appName);
68
			config.setAttribute(IPDELauncherConstants.APPLICATION, appName);
67
			config.setAttribute(IPDELauncherConstants.APP_TO_TEST, (String) null);
69
			config.setAttribute(IPDELauncherConstants.APP_TO_TEST, (String) null);
68
		} else {
70
		} else {
(-)src/org/eclipse/pde/internal/ui/launcher/OSGiValidationOperation.java (-28 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     EclipseSource Corporation - ongoing enhancements
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.launcher;
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.pde.core.plugin.IPluginModelBase;
17
18
public class OSGiValidationOperation extends LaunchValidationOperation {
19
20
	public OSGiValidationOperation(ILaunchConfiguration configuration) {
21
		super(configuration);
22
	}
23
24
	protected IPluginModelBase[] getModels() throws CoreException {
25
		return BundleLauncherHelper.getMergedBundles(fLaunchConfiguration, true);
26
	}
27
28
}
(-)src/org/eclipse/pde/internal/ui/launcher/LaunchAction.java (-4 / +10 lines)
Lines 11-16 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.launcher;
12
package org.eclipse.pde.internal.ui.launcher;
13
13
14
import org.eclipse.pde.launching.*;
15
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
16
14
import java.io.File;
17
import java.io.File;
15
import java.util.*;
18
import java.util.*;
16
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.IResource;
Lines 28-35 Link Here
28
import org.eclipse.pde.internal.core.iproduct.*;
31
import org.eclipse.pde.internal.core.iproduct.*;
29
import org.eclipse.pde.internal.core.iproduct.IProduct;
32
import org.eclipse.pde.internal.core.iproduct.IProduct;
30
import org.eclipse.pde.internal.core.util.CoreUtility;
33
import org.eclipse.pde.internal.core.util.CoreUtility;
31
import org.eclipse.pde.internal.ui.*;
34
import org.eclipse.pde.internal.launching.IPDEConstants;
32
import org.eclipse.pde.ui.launcher.*;
35
import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper;
36
import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper;
37
import org.eclipse.pde.internal.ui.PDEPlugin;
38
import org.eclipse.pde.internal.ui.PDEUIMessages;
33
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
39
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
34
40
35
public class LaunchAction extends Action {
41
public class LaunchAction extends Action {
Lines 263-270 Link Here
263
		wc.setAttribute(IPDELauncherConstants.USEFEATURES, false);
269
		wc.setAttribute(IPDELauncherConstants.USEFEATURES, false);
264
		wc.setAttribute(IPDELauncherConstants.USE_DEFAULT, false);
270
		wc.setAttribute(IPDELauncherConstants.USE_DEFAULT, false);
265
		wc.setAttribute(IPDELauncherConstants.DOCLEAR, false);
271
		wc.setAttribute(IPDELauncherConstants.DOCLEAR, false);
266
		wc.setAttribute(IPDEUIConstants.DOCLEARLOG, false);
272
		wc.setAttribute(IPDEConstants.DOCLEARLOG, false);
267
		wc.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true);
273
		wc.setAttribute(IPDEConstants.APPEND_ARGS_EXPLICITLY, true);
268
		wc.setAttribute(IPDELauncherConstants.ASKCLEAR, true);
274
		wc.setAttribute(IPDELauncherConstants.ASKCLEAR, true);
269
		wc.setAttribute(IPDELauncherConstants.USE_PRODUCT, true);
275
		wc.setAttribute(IPDELauncherConstants.USE_PRODUCT, true);
270
		wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, false);
276
		wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, false);
(-)src/org/eclipse/pde/internal/ui/launcher/EquinoxInitializer.java (-130 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
13
import java.util.*;
14
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
15
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
16
import org.eclipse.pde.internal.core.*;
17
import org.eclipse.pde.internal.ui.IPDEUIConstants;
18
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
19
import org.eclipse.pde.ui.launcher.OSGiLaunchConfigurationInitializer;
20
21
public class EquinoxInitializer extends OSGiLaunchConfigurationInitializer {
22
23
	private Map fStartLevels;
24
25
	public void initialize(ILaunchConfigurationWorkingCopy configuration) {
26
		super.initialize(configuration);
27
		initializeProgramArguments(configuration);
28
		initializeVMArguments(configuration);
29
		initializeTracing(configuration);
30
	}
31
32
	private void initializeProgramArguments(ILaunchConfigurationWorkingCopy configuration) {
33
		StringBuffer buffer = new StringBuffer(LaunchArgumentsHelper.getInitialProgramArguments());
34
		if (buffer.length() > 0) {
35
			if (buffer.indexOf("-console") == -1) { //$NON-NLS-1$
36
				buffer.append(" -console"); //$NON-NLS-1$
37
			}
38
		} else {
39
			buffer.append("-console"); //$NON-NLS-1$
40
		}
41
		configuration.setAttribute(IPDEUIConstants.APPEND_ARGS_EXPLICITLY, true);
42
		configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, buffer.toString());
43
	}
44
45
	private void initializeVMArguments(ILaunchConfigurationWorkingCopy configuration) {
46
		configuration.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$
47
		PDEPreferencesManager preferences = PDECore.getDefault().getPreferencesManager();
48
		StringBuffer vmArgs = new StringBuffer(preferences.getString(ICoreConstants.VM_ARGS));
49
		if (vmArgs.indexOf("-Declipse.ignoreApp") == -1) { //$NON-NLS-1$
50
			if (vmArgs.length() > 0)
51
				vmArgs.append(" "); //$NON-NLS-1$
52
			vmArgs.append("-Declipse.ignoreApp=true"); //$NON-NLS-1$
53
		}
54
		if (vmArgs.indexOf("-Dosgi.noShutdown") == -1) { //$NON-NLS-1$
55
			vmArgs.append(" -Dosgi.noShutdown=true"); //$NON-NLS-1$
56
		}
57
		configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.toString());
58
	}
59
60
	private void initializeTracing(ILaunchConfigurationWorkingCopy configuration) {
61
		configuration.setAttribute(IPDELauncherConstants.TRACING_CHECKED, IPDELauncherConstants.TRACING_NONE);
62
	}
63
64
	protected void initializeBundleState(ILaunchConfigurationWorkingCopy configuration) {
65
		initializeBundleState();
66
		super.initializeBundleState(configuration);
67
	}
68
69
	protected String getAutoStart(String bundleID) {
70
		if (fStartLevels.containsKey(bundleID)) {
71
			String value = fStartLevels.get(bundleID).toString();
72
			return value.substring(value.indexOf(":") + 1); //$NON-NLS-1$
73
		}
74
		return super.getAutoStart(bundleID);
75
	}
76
77
	protected String getStartLevel(String bundleID) {
78
		if (fStartLevels.containsKey(bundleID)) {
79
			String value = fStartLevels.get(bundleID).toString();
80
			return value.substring(0, value.indexOf(":")); //$NON-NLS-1$
81
		}
82
		return super.getStartLevel(bundleID);
83
	}
84
85
	private void initializeBundleState() {
86
		if (fStartLevels == null)
87
			fStartLevels = new HashMap();
88
		Properties props = TargetPlatformHelper.getConfigIniProperties();
89
		if (props != null) {
90
			String value = (String) props.get("osgi.bundles"); //$NON-NLS-1$
91
			if (value != null) {
92
				StringTokenizer tokenizer = new StringTokenizer(value, ","); //$NON-NLS-1$
93
				while (tokenizer.hasMoreTokens()) {
94
					String tokenValue = tokenizer.nextToken();
95
					int index = tokenValue.indexOf("@"); //$NON-NLS-1$
96
					if (index > 0) {
97
						String bundle = tokenValue.substring(0, index).trim();
98
						fStartLevels.put(bundle, getStartValue(tokenValue.substring(index)));
99
					}
100
				}
101
			}
102
		}
103
	}
104
105
	private String getStartValue(String value) {
106
		StringBuffer buffer = new StringBuffer(value);
107
		StringBuffer result = new StringBuffer(":"); //$NON-NLS-1$
108
109
		int index = value.indexOf("start"); //$NON-NLS-1$
110
		result.append(Boolean.toString(index != -1));
111
112
		if (index != -1)
113
			buffer.delete(index, index + 5);
114
115
		int colon = value.indexOf(':');
116
		if (colon != -1)
117
			buffer.deleteCharAt(colon);
118
119
		// delete the first char '@'
120
		buffer.deleteCharAt(0);
121
122
		try {
123
			result.insert(0, Integer.parseInt(buffer.toString().trim()));
124
		} catch (NumberFormatException e) {
125
			result.insert(0, DEFAULT);
126
		}
127
		return result.toString();
128
	}
129
130
}
(-)src/org/eclipse/pde/internal/ui/launcher/BundleLauncherHelper.java (-313 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     EclipseSource Corporation - ongoing enhancements
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.launcher;
13
14
import java.util.*;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
18
import org.eclipse.osgi.service.resolver.BundleDescription;
19
import org.eclipse.pde.core.plugin.*;
20
import org.eclipse.pde.internal.build.IPDEBuildConstants;
21
import org.eclipse.pde.internal.core.TargetPlatformHelper;
22
import org.eclipse.pde.internal.ui.IPDEUIConstants;
23
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
24
25
public class BundleLauncherHelper {
26
27
	public static final char VERSION_SEPARATOR = '*';
28
29
	public static Map getWorkspaceBundleMap(ILaunchConfiguration configuration) throws CoreException {
30
		return getWorkspaceBundleMap(configuration, null, IPDELauncherConstants.WORKSPACE_BUNDLES);
31
	}
32
33
	public static Map getTargetBundleMap(ILaunchConfiguration configuration) throws CoreException {
34
		return getTargetBundleMap(configuration, null, IPDELauncherConstants.TARGET_BUNDLES);
35
	}
36
37
	public static Map getMergedBundleMap(ILaunchConfiguration configuration, boolean osgi) throws CoreException {
38
		Set set = new HashSet();
39
		Map map = new HashMap();
40
41
		// if we are using the eclipse-based launcher, we need special checks
42
		if (!osgi) {
43
44
			checkBackwardCompatibility(configuration, true);
45
46
			if (configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true)) {
47
				IPluginModelBase[] models = PluginRegistry.getActiveModels();
48
				for (int i = 0; i < models.length; i++) {
49
					addBundleToMap(map, models[i], "default:default"); //$NON-NLS-1$
50
				}
51
				return map;
52
			}
53
54
			if (configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false)) {
55
				IPluginModelBase[] models = PluginRegistry.getWorkspaceModels();
56
				for (int i = 0; i < models.length; i++) {
57
					addBundleToMap(map, models[i], "default:default"); //$NON-NLS-1$
58
				}
59
				return map;
60
			}
61
		}
62
63
		String workspace = osgi == false ? IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS : IPDELauncherConstants.WORKSPACE_BUNDLES;
64
		String target = osgi == false ? IPDELauncherConstants.SELECTED_TARGET_PLUGINS : IPDELauncherConstants.TARGET_BUNDLES;
65
		map = getWorkspaceBundleMap(configuration, set, workspace);
66
		map.putAll(getTargetBundleMap(configuration, set, target));
67
		return map;
68
	}
69
70
	public static IPluginModelBase[] getMergedBundles(ILaunchConfiguration configuration, boolean osgi) throws CoreException {
71
		Map map = getMergedBundleMap(configuration, osgi);
72
		return (IPluginModelBase[]) map.keySet().toArray(new IPluginModelBase[map.size()]);
73
	}
74
75
	public static Map getWorkspaceBundleMap(ILaunchConfiguration configuration, Set set, String attribute) throws CoreException {
76
		String selected = configuration.getAttribute(attribute, ""); //$NON-NLS-1$
77
		Map map = new HashMap();
78
		StringTokenizer tok = new StringTokenizer(selected, ","); //$NON-NLS-1$
79
		while (tok.hasMoreTokens()) {
80
			String token = tok.nextToken();
81
			int index = token.indexOf('@');
82
			if (index < 0) { // if no start levels, assume default
83
				token = token.concat("@default:default"); //$NON-NLS-1$
84
				index = token.indexOf('@');
85
			}
86
			String idVersion = token.substring(0, index);
87
			int versionIndex = idVersion.indexOf(VERSION_SEPARATOR);
88
			String id = (versionIndex > 0) ? idVersion.substring(0, versionIndex) : idVersion;
89
			String version = (versionIndex > 0) ? idVersion.substring(versionIndex + 1) : null;
90
			if (set != null)
91
				set.add(id);
92
			ModelEntry entry = PluginRegistry.findEntry(id);
93
			if (entry != null) {
94
				IPluginModelBase[] models = entry.getWorkspaceModels();
95
				for (int i = 0; i < models.length; i++) {
96
					IPluginBase base = models[i].getPluginBase();
97
98
					// match only if...
99
					// a) if we have the same version
100
					// b) no version
101
					// c) all else fails, if there's just one bundle available, use it
102
					if (base.getVersion().equals(version) || version == null || models.length == 1)
103
						addBundleToMap(map, models[i], token.substring(index + 1));
104
				}
105
			}
106
		}
107
108
		if (configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true)) {
109
			Set deselectedPlugins = LaunchPluginValidator.parsePlugins(configuration, IPDELauncherConstants.DESELECTED_WORKSPACE_PLUGINS);
110
			IPluginModelBase[] models = PluginRegistry.getWorkspaceModels();
111
			for (int i = 0; i < models.length; i++) {
112
				String id = models[i].getPluginBase().getId();
113
				if (id == null)
114
					continue;
115
				if (!deselectedPlugins.contains(models[i])) {
116
					if (set != null)
117
						set.add(id);
118
					if (!map.containsKey(models[i]))
119
						addBundleToMap(map, models[i], "default:default"); //$NON-NLS-1$
120
				}
121
			}
122
		}
123
		return map;
124
	}
125
126
	/**
127
	 * Adds the given bundle and start information to the map.  This will override anything set
128
	 * for system bundles, and set their start level to the appropriate level
129
	 * @param map The map to add the bundles too
130
	 * @param bundle The bundle to add
131
	 * @param substring the start information in the form level:autostart
132
	 */
133
	private static void addBundleToMap(Map map, IPluginModelBase bundle, String sl) {
134
		BundleDescription desc = bundle.getBundleDescription();
135
		boolean defaultsl = (sl == null || sl.equals("default:default")); //$NON-NLS-1$
136
		if (desc != null && defaultsl) {
137
			String modelName = desc.getSymbolicName();
138
			if (IPDEBuildConstants.BUNDLE_DS.equals(modelName)) {
139
				map.put(bundle, "1:true"); //$NON-NLS-1$ 
140
			} else if (IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR.equals(modelName)) {
141
				map.put(bundle, "1:true"); //$NON-NLS-1$
142
			} else if (IPDEBuildConstants.BUNDLE_EQUINOX_COMMON.equals(modelName)) {
143
				map.put(bundle, "2:true"); //$NON-NLS-1$
144
			} else if (IPDEBuildConstants.BUNDLE_OSGI.equals(modelName)) {
145
				map.put(bundle, "-1:true"); //$NON-NLS-1$
146
			} else if (IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR.equals(modelName)) {
147
				map.put(bundle, "3:true"); //$NON-NLS-1$
148
			} else if (IPDEBuildConstants.BUNDLE_CORE_RUNTIME.equals(modelName)) {
149
				if (TargetPlatformHelper.getTargetVersion() > 3.1) {
150
					map.put(bundle, "default:true"); //$NON-NLS-1$
151
				} else {
152
					map.put(bundle, "2:true"); //$NON-NLS-1$
153
				}
154
			} else {
155
				map.put(bundle, sl);
156
			}
157
		} else {
158
			map.put(bundle, sl);
159
		}
160
161
	}
162
163
	public static Map getTargetBundleMap(ILaunchConfiguration configuration, Set set, String attribute) throws CoreException {
164
		String selected = configuration.getAttribute(attribute, ""); //$NON-NLS-1$
165
		Map map = new HashMap();
166
		StringTokenizer tok = new StringTokenizer(selected, ","); //$NON-NLS-1$
167
		while (tok.hasMoreTokens()) {
168
			String token = tok.nextToken();
169
			int index = token.indexOf('@');
170
			if (index < 0) { // if no start levels, assume default
171
				token = token.concat("@default:default"); //$NON-NLS-1$
172
				index = token.indexOf('@');
173
			}
174
			String idVersion = token.substring(0, index);
175
			int versionIndex = idVersion.indexOf(VERSION_SEPARATOR);
176
			String id = (versionIndex > 0) ? idVersion.substring(0, versionIndex) : idVersion;
177
			String version = (versionIndex > 0) ? idVersion.substring(versionIndex + 1) : null;
178
			if (set != null && set.contains(id))
179
				continue;
180
			ModelEntry entry = PluginRegistry.findEntry(id);
181
			if (entry != null) {
182
				IPluginModelBase[] models = entry.getExternalModels();
183
				for (int i = 0; i < models.length; i++) {
184
					if (models[i].isEnabled()) {
185
						IPluginBase base = models[i].getPluginBase();
186
						// match only if...
187
						// a) if we have the same version
188
						// b) no version
189
						// c) all else fails, if there's just one bundle available, use it
190
						if (base.getVersion().equals(version) || version == null || models.length == 1)
191
							addBundleToMap(map, models[i], token.substring(index + 1));
192
					}
193
				}
194
			}
195
		}
196
		return map;
197
	}
198
199
	public static String writeBundleEntry(IPluginModelBase model, String startLevel, String autoStart) {
200
		IPluginBase base = model.getPluginBase();
201
		String id = base.getId();
202
		StringBuffer buffer = new StringBuffer(id);
203
204
		ModelEntry entry = PluginRegistry.findEntry(id);
205
		if (entry.getActiveModels().length > 1) {
206
			buffer.append(VERSION_SEPARATOR);
207
			buffer.append(model.getPluginBase().getVersion());
208
		}
209
210
		boolean hasStartLevel = (startLevel != null && startLevel.length() > 0);
211
		boolean hasAutoStart = (autoStart != null && autoStart.length() > 0);
212
213
		if (hasStartLevel || hasAutoStart)
214
			buffer.append('@');
215
		if (hasStartLevel)
216
			buffer.append(startLevel);
217
		if (hasStartLevel || hasAutoStart)
218
			buffer.append(':');
219
		if (hasAutoStart)
220
			buffer.append(autoStart);
221
		return buffer.toString();
222
	}
223
224
	public static void checkBackwardCompatibility(ILaunchConfiguration configuration, boolean save) throws CoreException {
225
		ILaunchConfigurationWorkingCopy wc = null;
226
		if (configuration.isWorkingCopy()) {
227
			wc = (ILaunchConfigurationWorkingCopy) configuration;
228
		} else {
229
			wc = configuration.getWorkingCopy();
230
		}
231
232
		String value = configuration.getAttribute("wsproject", (String) null); //$NON-NLS-1$
233
		if (value != null) {
234
			wc.setAttribute("wsproject", (String) null); //$NON-NLS-1$
235
			if (value.indexOf(';') != -1) {
236
				value = value.replace(';', ',');
237
			} else if (value.indexOf(':') != -1) {
238
				value = value.replace(':', ',');
239
			}
240
			value = (value.length() == 0 || value.equals(",")) //$NON-NLS-1$
241
			? null
242
					: value.substring(0, value.length() - 1);
243
244
			boolean automatic = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
245
			String attr = automatic ? IPDELauncherConstants.DESELECTED_WORKSPACE_PLUGINS : IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS;
246
			wc.setAttribute(attr, value);
247
		}
248
249
		String value2 = configuration.getAttribute("extplugins", (String) null); //$NON-NLS-1$
250
		if (value2 != null) {
251
			wc.setAttribute("extplugins", (String) null); //$NON-NLS-1$
252
			if (value2.indexOf(';') != -1) {
253
				value2 = value2.replace(';', ',');
254
			} else if (value2.indexOf(':') != -1) {
255
				value2 = value2.replace(':', ',');
256
			}
257
			value2 = (value2.length() == 0 || value2.equals(",")) ? null : value2.substring(0, value2.length() - 1); //$NON-NLS-1$
258
			wc.setAttribute(IPDELauncherConstants.SELECTED_TARGET_PLUGINS, value2);
259
		}
260
261
		String version = configuration.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, (String) null);
262
		boolean newApp = TargetPlatformHelper.usesNewApplicationModel();
263
		boolean upgrade = !"3.3".equals(version) && newApp; //$NON-NLS-1$
264
		if (!upgrade)
265
			upgrade = TargetPlatformHelper.getTargetVersion() >= 3.2 && version == null;
266
		if (upgrade) {
267
			wc.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, newApp ? "3.3" : "3.2a"); //$NON-NLS-1$ //$NON-NLS-2$
268
			boolean usedefault = configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true);
269
			boolean useFeatures = configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false);
270
			boolean automaticAdd = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
271
			if (!usedefault && !useFeatures) {
272
				ArrayList list = new ArrayList();
273
				if (version == null) {
274
					list.add("org.eclipse.core.contenttype"); //$NON-NLS-1$
275
					list.add("org.eclipse.core.jobs"); //$NON-NLS-1$
276
					list.add(IPDEBuildConstants.BUNDLE_EQUINOX_COMMON);
277
					list.add("org.eclipse.equinox.preferences"); //$NON-NLS-1$
278
					list.add("org.eclipse.equinox.registry"); //$NON-NLS-1$
279
					list.add("org.eclipse.core.runtime.compatibility.registry"); //$NON-NLS-1$
280
				}
281
				if (!"3.3".equals(version) && newApp) //$NON-NLS-1$
282
					list.add("org.eclipse.equinox.app"); //$NON-NLS-1$
283
				StringBuffer extensions = new StringBuffer(configuration.getAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS, "")); //$NON-NLS-1$
284
				StringBuffer target = new StringBuffer(configuration.getAttribute(IPDELauncherConstants.SELECTED_TARGET_PLUGINS, "")); //$NON-NLS-1$
285
				for (int i = 0; i < list.size(); i++) {
286
					String plugin = list.get(i).toString();
287
					IPluginModelBase model = PluginRegistry.findModel(plugin);
288
					if (model == null)
289
						continue;
290
					if (model.getUnderlyingResource() != null) {
291
						if (automaticAdd)
292
							continue;
293
						if (extensions.length() > 0)
294
							extensions.append(","); //$NON-NLS-1$
295
						extensions.append(plugin);
296
					} else {
297
						if (target.length() > 0)
298
							target.append(","); //$NON-NLS-1$
299
						target.append(plugin);
300
					}
301
				}
302
				if (extensions.length() > 0)
303
					wc.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS, extensions.toString());
304
				if (target.length() > 0)
305
					wc.setAttribute(IPDELauncherConstants.SELECTED_TARGET_PLUGINS, target.toString());
306
			}
307
		}
308
309
		if (save && (value != null || value2 != null || upgrade))
310
			wc.doSave();
311
	}
312
313
}
(-)src/org/eclipse/pde/internal/ui/launcher/OSGiMigrationDelegate.java (-42 lines)
Removed Link Here
1
/*******************************************************************************
2
 *  Copyright (c) 2007, 2008 IBM Corporation and others.
3
 *  All rights reserved. This program and the accompanying materials
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 *  which accompanies this distribution, and is available at
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
16
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
17
import org.eclipse.pde.internal.ui.IPDEUIConstants;
18
19
public class OSGiMigrationDelegate extends PDEMigrationDelegate {
20
21
	public boolean isCandidate(ILaunchConfiguration candidate) throws CoreException {
22
		return super.isCandidate(candidate) || !candidate.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "").equals("3.3"); //$NON-NLS-1$ //$NON-NLS-2$
23
	}
24
25
	public void migrate(ILaunchConfigurationWorkingCopy wc) throws CoreException {
26
		if (!wc.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "").equals("3.3")) { //$NON-NLS-1$ //$NON-NLS-2$
27
			wc.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$
28
			StringBuffer vmArgs = new StringBuffer(wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "")); //$NON-NLS-1$
29
			if (vmArgs.indexOf("-Declipse.ignoreApp") == -1) { //$NON-NLS-1$
30
				if (vmArgs.length() > 0)
31
					vmArgs.append(" "); //$NON-NLS-1$
32
				vmArgs.append("-Declipse.ignoreApp=true"); //$NON-NLS-1$
33
			}
34
			if (vmArgs.indexOf("-Dosgi.noShutdown") == -1) { //$NON-NLS-1$
35
				vmArgs.append(" -Dosgi.noShutdown=true"); //$NON-NLS-1$
36
			}
37
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.toString());
38
		}
39
		super.migrate(wc);
40
	}
41
42
}
(-)src/org/eclipse/pde/internal/ui/launcher/VMHelper.java (-94 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Les Jones <lesojones@gmail.com> - Bug 195433
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.launcher;
13
14
import org.eclipse.core.runtime.*;
15
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.jdt.core.IJavaProject;
17
import org.eclipse.jdt.launching.*;
18
import org.eclipse.osgi.util.NLS;
19
import org.eclipse.pde.internal.core.util.VMUtil;
20
import org.eclipse.pde.internal.ui.PDEUIMessages;
21
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
22
23
public class VMHelper {
24
25
	/**
26
	 * Get the default VMInstall name using the available info in the config,
27
	 * using the JavaProject if available.
28
	 * 
29
	 * @param configuration
30
	 *            Launch configuration to check
31
	 * @return name of the VMInstall
32
	 * @throws CoreException
33
	 *             thrown if there's a problem getting the VM name
34
	 */
35
	public static String getDefaultVMInstallName(ILaunchConfiguration configuration) throws CoreException {
36
		IJavaProject javaProject = JavaRuntime.getJavaProject(configuration);
37
		IVMInstall vmInstall = null;
38
		if (javaProject != null) {
39
			vmInstall = JavaRuntime.getVMInstall(javaProject);
40
		}
41
42
		if (vmInstall != null) {
43
			return vmInstall.getName();
44
		}
45
46
		return VMUtil.getDefaultVMInstallName();
47
	}
48
49
	public static IVMInstall getVMInstall(ILaunchConfiguration configuration) throws CoreException {
50
		String jre = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String) null);
51
		IVMInstall vm = null;
52
		if (jre == null) {
53
			String name = configuration.getAttribute(IPDELauncherConstants.VMINSTALL, (String) null);
54
			if (name == null) {
55
				name = getDefaultVMInstallName(configuration);
56
			}
57
			vm = getVMInstall(name);
58
			if (vm == null) {
59
				throw new CoreException(LauncherUtils.createErrorStatus(NLS.bind(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_noJRE, name)));
60
			}
61
		} else {
62
			IPath jrePath = Path.fromPortableString(jre);
63
			vm = JavaRuntime.getVMInstall(jrePath);
64
			if (vm == null) {
65
				String id = JavaRuntime.getExecutionEnvironmentId(jrePath);
66
				if (id == null) {
67
					String name = JavaRuntime.getVMInstallName(jrePath);
68
					throw new CoreException(LauncherUtils.createErrorStatus(NLS.bind(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_noJRE, name)));
69
				}
70
				throw new CoreException(LauncherUtils.createErrorStatus(NLS.bind(PDEUIMessages.VMHelper_cannotFindExecEnv, id)));
71
			}
72
		}
73
		return vm;
74
	}
75
76
	public static IVMInstall getVMInstall(String name) {
77
		if (name != null) {
78
			IVMInstall[] installs = VMUtil.getAllVMInstances();
79
			for (int i = 0; i < installs.length; i++) {
80
				if (installs[i].getName().equals(name))
81
					return installs[i];
82
			}
83
		}
84
		return JavaRuntime.getDefaultVMInstall();
85
	}
86
87
	public static IVMInstall createLauncher(ILaunchConfiguration configuration) throws CoreException {
88
		IVMInstall launcher = getVMInstall(configuration);
89
		if (!launcher.getInstallLocation().exists())
90
			throw new CoreException(LauncherUtils.createErrorStatus(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_jrePathNotFound));
91
		return launcher;
92
	}
93
94
}
(-)src/org/eclipse/pde/internal/ui/launcher/LaunchValidationOperation.java (-161 lines)
Removed Link Here
1
/*******************************************************************************
2
 *  Copyright (c) 2007, 2009 IBM Corporation and others.
3
 *  All rights reserved. This program and the accompanying materials
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 *  which accompanies this distribution, and is available at
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
13
import java.io.*;
14
import java.util.*;
15
import java.util.zip.ZipEntry;
16
import java.util.zip.ZipFile;
17
import org.eclipse.core.resources.IWorkspaceRunnable;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.debug.core.ILaunchConfiguration;
21
import org.eclipse.jdt.launching.IVMInstall;
22
import org.eclipse.jdt.launching.JavaRuntime;
23
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
24
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
25
import org.eclipse.osgi.service.resolver.State;
26
import org.eclipse.pde.core.plugin.IPluginModelBase;
27
import org.eclipse.pde.core.plugin.PluginRegistry;
28
import org.eclipse.pde.internal.core.BundleValidationOperation;
29
import org.eclipse.pde.internal.core.TargetPlatformHelper;
30
import org.osgi.framework.Constants;
31
32
public abstract class LaunchValidationOperation implements IWorkspaceRunnable {
33
34
	private BundleValidationOperation fOperation;
35
	protected ILaunchConfiguration fLaunchConfiguration;
36
37
	public LaunchValidationOperation(ILaunchConfiguration configuration) {
38
		fLaunchConfiguration = configuration;
39
	}
40
41
	public void run(IProgressMonitor monitor) throws CoreException {
42
		fOperation = new BundleValidationOperation(getModels(), getPlatformProperties());
43
		fOperation.run(monitor);
44
	}
45
46
	protected abstract IPluginModelBase[] getModels() throws CoreException;
47
48
	protected Dictionary[] getPlatformProperties() throws CoreException {
49
		IExecutionEnvironment[] envs = getMatchingEnvironments();
50
		if (envs.length == 0)
51
			return new Dictionary[] {TargetPlatformHelper.getTargetEnvironment()};
52
53
		// add java profiles for those EE's that have a .profile file in the current system bundle
54
		ArrayList result = new ArrayList(envs.length);
55
		for (int i = 0; i < envs.length; i++) {
56
			Properties profileProps = getJavaProfileProperties(envs[i].getId());
57
			if (profileProps != null) {
58
				Dictionary props = TargetPlatformHelper.getTargetEnvironment();
59
				String systemPackages = profileProps.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES);
60
				if (systemPackages != null)
61
					props.put(Constants.FRAMEWORK_SYSTEMPACKAGES, systemPackages);
62
				String ee = profileProps.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
63
				if (ee != null)
64
					props.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, ee);
65
				result.add(props);
66
			}
67
		}
68
		if (result.size() > 0)
69
			return (Dictionary[]) result.toArray(new Dictionary[result.size()]);
70
		return new Dictionary[] {TargetPlatformHelper.getTargetEnvironment()};
71
72
	}
73
74
	protected IExecutionEnvironment[] getMatchingEnvironments() throws CoreException {
75
		IVMInstall install = VMHelper.getVMInstall(fLaunchConfiguration);
76
		if (install == null)
77
			return new IExecutionEnvironment[0];
78
79
		IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
80
		IExecutionEnvironment[] envs = manager.getExecutionEnvironments();
81
		List result = new ArrayList(envs.length);
82
		for (int i = 0; i < envs.length; i++) {
83
			IExecutionEnvironment env = envs[i];
84
			IVMInstall[] compatible = env.getCompatibleVMs();
85
			for (int j = 0; j < compatible.length; j++) {
86
				if (compatible[j].equals(install)) {
87
					result.add(env);
88
					break;
89
				}
90
			}
91
		}
92
		return (IExecutionEnvironment[]) result.toArray(new IExecutionEnvironment[result.size()]);
93
	}
94
95
	private Properties getJavaProfileProperties(String ee) {
96
		IPluginModelBase model = PluginRegistry.findModel("system.bundle"); //$NON-NLS-1$
97
		if (model == null)
98
			return null;
99
100
		File location = new File(model.getInstallLocation());
101
		String filename = ee.replace('/', '_') + ".profile"; //$NON-NLS-1$
102
		InputStream is = null;
103
		ZipFile zipFile = null;
104
		try {
105
			// find the input stream to the profile properties file
106
			if (location.isDirectory()) {
107
				File file = new File(location, filename);
108
				if (file.exists())
109
					is = new FileInputStream(file);
110
			} else {
111
				zipFile = null;
112
				try {
113
					zipFile = new ZipFile(location, ZipFile.OPEN_READ);
114
					ZipEntry entry = zipFile.getEntry(filename);
115
					if (entry != null)
116
						is = zipFile.getInputStream(entry);
117
				} catch (IOException e) {
118
					// nothing to do
119
				}
120
			}
121
			if (is != null) {
122
				Properties profile = new Properties();
123
				profile.load(is);
124
				return profile;
125
			}
126
		} catch (IOException e) {
127
			// nothing to do
128
		} finally {
129
			if (is != null)
130
				try {
131
					is.close();
132
				} catch (IOException e) {
133
					// nothing to do
134
				}
135
			if (zipFile != null)
136
				try {
137
					zipFile.close();
138
				} catch (IOException e) {
139
					// nothing to do
140
				}
141
		}
142
		return null;
143
	}
144
145
	public boolean hasErrors() {
146
		return fOperation.hasErrors();
147
	}
148
149
	public Map getInput() {
150
		return fOperation.getResolverErrors();
151
	}
152
153
	public boolean isEmpty() {
154
		return fOperation.getState().getHighestBundleId() == -1;
155
	}
156
157
	protected State getState() {
158
		return fOperation.getState();
159
	}
160
161
}
(-)src/org/eclipse/pde/internal/ui/launcher/LaunchConfigurationListener.java (-48 lines)
Removed Link Here
1
/*******************************************************************************
2
 *  Copyright (c) 2005, 2008 IBM Corporation and others.
3
 *  All rights reserved. This program and the accompanying materials
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 *  which accompanies this distribution, and is available at
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
13
import java.io.File;
14
import org.eclipse.debug.core.*;
15
import org.eclipse.pde.internal.core.util.CoreUtility;
16
17
public class LaunchConfigurationListener implements ILaunchConfigurationListener {
18
19
	/* (non-Javadoc)
20
	 * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationAdded(org.eclipse.debug.core.ILaunchConfiguration)
21
	 */
22
	public void launchConfigurationAdded(ILaunchConfiguration configuration) {
23
	}
24
25
	/* (non-Javadoc)
26
	 * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationChanged(org.eclipse.debug.core.ILaunchConfiguration)
27
	 */
28
	public void launchConfigurationChanged(ILaunchConfiguration configuration) {
29
	}
30
31
	/* (non-Javadoc)
32
	 * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse.debug.core.ILaunchConfiguration)
33
	 */
34
	public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
35
		File configDir = LaunchConfigurationHelper.getConfigurationLocation(configuration);
36
		if (configDir.exists()) {
37
			// rename the config area if it was auto-set by PDE when the launch configuration is renamed
38
			ILaunchConfiguration destination = DebugPlugin.getDefault().getLaunchManager().getMovedTo(configuration);
39
			boolean delete = true;
40
			if (destination != null) {
41
				delete = !configDir.renameTo(LaunchConfigurationHelper.getConfigurationLocation(destination));
42
			}
43
			if (delete)
44
				CoreUtility.deleteContent(configDir);
45
		}
46
	}
47
48
}
(-)src/org/eclipse/pde/internal/ui/launcher/PluginBlock.java (-3 / +7 lines)
Lines 12-25 Link Here
12
 *******************************************************************************/
12
 *******************************************************************************/
13
package org.eclipse.pde.internal.ui.launcher;
13
package org.eclipse.pde.internal.ui.launcher;
14
14
15
import org.eclipse.pde.launching.*;
16
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
17
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
18
15
import java.util.*;
19
import java.util.*;
16
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.debug.core.ILaunchConfiguration;
21
import org.eclipse.debug.core.ILaunchConfiguration;
18
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
22
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
19
import org.eclipse.pde.core.plugin.*;
23
import org.eclipse.pde.core.plugin.*;
20
import org.eclipse.pde.internal.core.util.IdUtil;
24
import org.eclipse.pde.internal.core.util.IdUtil;
21
import org.eclipse.pde.internal.ui.IPDEUIConstants;
25
import org.eclipse.pde.internal.launching.IPDEConstants;
22
import org.eclipse.pde.ui.launcher.*;
26
import org.eclipse.pde.internal.launching.launcher.*;
23
27
24
public class PluginBlock extends AbstractPluginBlock {
28
public class PluginBlock extends AbstractPluginBlock {
25
29
Lines 216-222 Link Here
216
				String configType = fLaunchConfig.getType().getIdentifier();
220
				String configType = fLaunchConfig.getType().getIdentifier();
217
				String attribute = configType.equals(EclipseLaunchShortcut.CONFIGURATION_TYPE) ? IPDELauncherConstants.APPLICATION : IPDELauncherConstants.APP_TO_TEST;
221
				String attribute = configType.equals(EclipseLaunchShortcut.CONFIGURATION_TYPE) ? IPDELauncherConstants.APPLICATION : IPDELauncherConstants.APP_TO_TEST;
218
				String application = fLaunchConfig.getAttribute(attribute, TargetPlatform.getDefaultApplication());
222
				String application = fLaunchConfig.getAttribute(attribute, TargetPlatform.getDefaultApplication());
219
				if (!IPDEUIConstants.CORE_TEST_APPLICATION.equals(application))
223
				if (!IPDEConstants.CORE_TEST_APPLICATION.equals(application))
220
					validateLaunchId(application);
224
					validateLaunchId(application);
221
			}
225
			}
222
		} catch (CoreException e) {
226
		} catch (CoreException e) {
(-)src/org/eclipse/pde/internal/ui/launcher/EclipsePluginValidationOperation.java (-122 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     EclipseSource Corporation - ongoing enhancements
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.launcher;
13
14
import java.util.HashMap;
15
import java.util.Map;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.debug.core.ILaunchConfiguration;
19
import org.eclipse.osgi.service.resolver.BundleDescription;
20
import org.eclipse.osgi.util.NLS;
21
import org.eclipse.pde.core.plugin.*;
22
import org.eclipse.pde.internal.core.util.IdUtil;
23
import org.eclipse.pde.internal.ui.*;
24
import org.eclipse.pde.internal.ui.elements.NamedElement;
25
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
26
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
27
import org.eclipse.swt.graphics.Image;
28
29
public class EclipsePluginValidationOperation extends LaunchValidationOperation {
30
31
	private Map fExtensionErrors = new HashMap(2);
32
	private static Object[] EMPTY = new Object[0];
33
34
	public EclipsePluginValidationOperation(ILaunchConfiguration configuration) {
35
		super(configuration);
36
	}
37
38
	protected IPluginModelBase[] getModels() throws CoreException {
39
		return BundleLauncherHelper.getMergedBundles(fLaunchConfiguration, false);
40
	}
41
42
	public void run(IProgressMonitor monitor) throws CoreException {
43
		super.run(monitor);
44
		if (fExtensionErrors.size() > 0)
45
			fExtensionErrors.clear();
46
		validateExtensions();
47
	}
48
49
	private void validateExtensions() {
50
		try {
51
			if (fLaunchConfiguration.getAttribute(IPDELauncherConstants.USE_PRODUCT, false)) {
52
				String product = fLaunchConfiguration.getAttribute(IPDELauncherConstants.PRODUCT, (String) null);
53
				if (product != null) {
54
					validateExtension(product);
55
					String application = getApplication(product);
56
					if (application != null)
57
						validateExtension(application);
58
				}
59
			} else {
60
				String configType = fLaunchConfiguration.getType().getIdentifier();
61
				String attribute = configType.equals(EclipseLaunchShortcut.CONFIGURATION_TYPE) ? IPDELauncherConstants.APPLICATION : IPDELauncherConstants.APP_TO_TEST;
62
				String application = fLaunchConfiguration.getAttribute(attribute, TargetPlatform.getDefaultApplication());
63
				if (!IPDEUIConstants.CORE_TEST_APPLICATION.equals(application)) {
64
					validateExtension(application);
65
				}
66
			}
67
		} catch (CoreException e) {
68
			PDEPlugin.log(e);
69
		}
70
	}
71
72
	private String getApplication(String product) {
73
		String bundleID = product.substring(0, product.lastIndexOf('.'));
74
		BundleDescription bundle = getState().getBundle(bundleID, null);
75
		if (bundle != null) {
76
			IPluginModelBase model = PluginRegistry.findModel(bundle);
77
			if (model != null) {
78
				IPluginExtension[] extensions = model.getPluginBase().getExtensions();
79
				for (int i = 0; i < extensions.length; i++) {
80
					IPluginExtension ext = extensions[i];
81
					String point = ext.getPoint();
82
					if ("org.eclipse.core.runtime.products".equals(point) //$NON-NLS-1$
83
							&& product.equals(IdUtil.getFullId(ext))) {
84
						if (ext.getChildCount() == 1) {
85
							IPluginElement prod = (IPluginElement) ext.getChildren()[0];
86
							if (prod.getName().equals("product")) { //$NON-NLS-1$
87
								IPluginAttribute attr = prod.getAttribute("application"); //$NON-NLS-1$
88
								return attr != null ? attr.getValue() : null;
89
							}
90
						}
91
					}
92
				}
93
			}
94
		}
95
		return null;
96
	}
97
98
	private void validateExtension(String id) {
99
		int index = id.lastIndexOf('.');
100
		if (index == -1)
101
			return;
102
		String bundleID = id.substring(0, index);
103
		BundleDescription bundle = getState().getBundle(bundleID, null);
104
		if (bundle == null) {
105
			String name = NLS.bind(PDEUIMessages.EclipsePluginValidationOperation_pluginMissing, bundleID);
106
			PDELabelProvider provider = PDEPlugin.getDefault().getLabelProvider();
107
			Image image = provider.get(PDEPluginImages.DESC_PLUGIN_OBJ);
108
			fExtensionErrors.put(new NamedElement(name, image), EMPTY);
109
		}
110
	}
111
112
	public boolean hasErrors() {
113
		return super.hasErrors() || fExtensionErrors.size() >= 1;
114
	}
115
116
	public Map getInput() {
117
		Map map = super.getInput();
118
		map.putAll(fExtensionErrors);
119
		return map;
120
	}
121
122
}
(-)src/org/eclipse/pde/internal/ui/launcher/LaunchPluginValidator.java (-133 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
13
import java.util.*;
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.jdt.core.IJavaProject;
18
import org.eclipse.jdt.core.JavaCore;
19
import org.eclipse.jface.dialogs.IDialogConstants;
20
import org.eclipse.pde.core.plugin.*;
21
import org.eclipse.pde.internal.core.PDECore;
22
import org.eclipse.pde.internal.core.SearchablePluginsManager;
23
import org.eclipse.pde.internal.ui.IPDEUIConstants;
24
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
25
import org.eclipse.swt.widgets.Display;
26
27
public class LaunchPluginValidator {
28
29
	private static IPluginModelBase[] getSelectedWorkspacePlugins(ILaunchConfiguration configuration) throws CoreException {
30
31
		boolean usedefault = configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true);
32
		boolean useFeatures = configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false);
33
34
		IPluginModelBase[] models = PluginRegistry.getWorkspaceModels();
35
36
		if (usedefault || useFeatures || models.length == 0)
37
			return models;
38
39
		Collection result = null;
40
		Map bundles = BundleLauncherHelper.getWorkspaceBundleMap(configuration, null, IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS);
41
		result = bundles.keySet();
42
		return (IPluginModelBase[]) result.toArray(new IPluginModelBase[result.size()]);
43
	}
44
45
	/**
46
	 * 
47
	 * @param configuration launchConfiguration to get the attribute value
48
	 * @param attribute launch configuration attribute to containing plug-in information
49
	 * @return a TreeSet containing IPluginModelBase objects which are represented by the value of the attribute
50
	 * @throws CoreException
51
	 */
52
	public static Set parsePlugins(ILaunchConfiguration configuration, String attribute) throws CoreException {
53
		HashSet set = new HashSet();
54
		String ids = configuration.getAttribute(attribute, (String) null);
55
		if (ids != null) {
56
			String[] entries = ids.split(","); //$NON-NLS-1$
57
			Map unmatchedEntries = new HashMap();
58
			for (int i = 0; i < entries.length; i++) {
59
				int index = entries[i].indexOf('@');
60
				if (index < 0) { // if no start levels, assume default
61
					entries[i] = entries[i].concat("@default:default"); //$NON-NLS-1$
62
					index = entries[i].indexOf('@');
63
				}
64
				String idVersion = entries[i].substring(0, index);
65
				int versionIndex = entries[i].indexOf(BundleLauncherHelper.VERSION_SEPARATOR);
66
				String id = (versionIndex > 0) ? idVersion.substring(0, versionIndex) : idVersion;
67
				String version = (versionIndex > 0) ? idVersion.substring(versionIndex + 1) : null;
68
				ModelEntry entry = PluginRegistry.findEntry(id);
69
				if (entry != null) {
70
					IPluginModelBase matchingModels[] = attribute.equals(IPDELauncherConstants.SELECTED_TARGET_PLUGINS) ? entry.getExternalModels() : entry.getWorkspaceModels();
71
					for (int j = 0; j < matchingModels.length; j++) {
72
						if (matchingModels[j].isEnabled()) {
73
							// TODO Very similar logic to BundleLauncherHelper
74
							// the logic here is this (see bug 225644)
75
							// a) if we come across a bundle that has the right version, immediately add it
76
							// b) if there's no version, add it
77
							// c) if there's only one instance of that bundle in the list of ids... add it
78
							if (version == null || matchingModels[j].getPluginBase().getVersion().equals(version)) {
79
								set.add(matchingModels[j]);
80
							} else if (matchingModels.length == 1) {
81
								if (unmatchedEntries.remove(id) == null) {
82
									unmatchedEntries.put(id, matchingModels[j]);
83
								}
84
							}
85
						}
86
					}
87
				}
88
			}
89
			set.addAll(unmatchedEntries.values());
90
		}
91
		return set;
92
	}
93
94
	public static IProject[] getAffectedProjects(ILaunchConfiguration config) throws CoreException {
95
		// if restarting, no need to check projects for errors
96
		if (config.getAttribute(IPDEUIConstants.RESTART, false))
97
			return new IProject[0];
98
		ArrayList projects = new ArrayList();
99
		IPluginModelBase[] models = getSelectedWorkspacePlugins(config);
100
		for (int i = 0; i < models.length; i++) {
101
			IProject project = models[i].getUnderlyingResource().getProject();
102
			if (project.hasNature(JavaCore.NATURE_ID))
103
				projects.add(project);
104
		}
105
106
		// add fake "Java Search" project
107
		SearchablePluginsManager manager = PDECore.getDefault().getSearchablePluginsManager();
108
		IJavaProject proxy = manager.getProxyProject();
109
		if (proxy != null) {
110
			projects.add(proxy.getProject());
111
		}
112
		return (IProject[]) projects.toArray(new IProject[projects.size()]);
113
	}
114
115
	public static void runValidationOperation(final LaunchValidationOperation op, IProgressMonitor monitor) throws CoreException {
116
		op.run(monitor);
117
		if (op.hasErrors()) {
118
			final int[] result = new int[1];
119
			final Display display = LauncherUtils.getDisplay();
120
			display.syncExec(new Runnable() {
121
				public void run() {
122
					PluginStatusDialog dialog = new PluginStatusDialog(display.getActiveShell());
123
					dialog.showCancelButton(true);
124
					dialog.setInput(op.getInput());
125
					result[0] = dialog.open();
126
				}
127
			});
128
			if (result[0] == IDialogConstants.CANCEL_ID)
129
				throw new CoreException(Status.CANCEL_STATUS);
130
		}
131
	}
132
133
}
(-)src/org/eclipse/pde/internal/ui/launcher/ProgramBlock.java (-1 / +2 lines)
Lines 11-16 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.launcher;
12
package org.eclipse.pde.internal.ui.launcher;
13
13
14
import org.eclipse.pde.launching.IPDELauncherConstants;
15
14
import java.util.StringTokenizer;
16
import java.util.StringTokenizer;
15
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.debug.core.ILaunchConfiguration;
18
import org.eclipse.debug.core.ILaunchConfiguration;
Lines 21-27 Link Here
21
import org.eclipse.pde.internal.ui.PDEUIMessages;
23
import org.eclipse.pde.internal.ui.PDEUIMessages;
22
import org.eclipse.pde.internal.ui.SWTFactory;
24
import org.eclipse.pde.internal.ui.SWTFactory;
23
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
25
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
24
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
25
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.events.*;
27
import org.eclipse.swt.events.*;
27
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridData;
(-)src/org/eclipse/pde/internal/ui/launcher/JREBlock.java (-1 / +4 lines)
Lines 11-16 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.launcher;
12
package org.eclipse.pde.internal.ui.launcher;
13
13
14
import org.eclipse.pde.launching.IPDELauncherConstants;
15
16
import org.eclipse.pde.internal.launching.launcher.VMHelper;
17
14
import java.util.Arrays;
18
import java.util.Arrays;
15
import java.util.Comparator;
19
import java.util.Comparator;
16
import org.eclipse.core.runtime.*;
20
import org.eclipse.core.runtime.*;
Lines 25-31 Link Here
25
import org.eclipse.pde.internal.ui.SWTFactory;
29
import org.eclipse.pde.internal.ui.SWTFactory;
26
import org.eclipse.pde.internal.ui.util.SWTUtil;
30
import org.eclipse.pde.internal.ui.util.SWTUtil;
27
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
31
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
28
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
29
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.events.*;
33
import org.eclipse.swt.events.*;
31
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.layout.GridData;
(-)src/org/eclipse/pde/internal/ui/launcher/LauncherUtils.java (-413 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     EclipseSource Corporation - ongoing enhancements
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.launcher;
13
14
import java.io.*;
15
import java.net.MalformedURLException;
16
import java.net.URL;
17
import java.util.*;
18
import org.eclipse.core.resources.*;
19
import org.eclipse.core.runtime.*;
20
import org.eclipse.debug.core.ILaunchConfiguration;
21
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
22
import org.eclipse.jdt.core.*;
23
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
24
import org.eclipse.jface.dialogs.IDialogConstants;
25
import org.eclipse.jface.dialogs.MessageDialog;
26
import org.eclipse.jface.preference.IPreferenceStore;
27
import org.eclipse.ltk.core.refactoring.Change;
28
import org.eclipse.osgi.service.datalocation.Location;
29
import org.eclipse.osgi.util.NLS;
30
import org.eclipse.pde.core.plugin.IPluginModelBase;
31
import org.eclipse.pde.core.plugin.PluginRegistry;
32
import org.eclipse.pde.internal.core.*;
33
import org.eclipse.pde.internal.core.util.CoreUtility;
34
import org.eclipse.pde.internal.ui.*;
35
import org.eclipse.pde.internal.ui.wizards.tools.OrganizeManifestsProcessor;
36
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
37
import org.eclipse.swt.widgets.Display;
38
import org.eclipse.swt.widgets.Shell;
39
import org.eclipse.ui.IWorkbenchWindow;
40
import org.osgi.framework.*;
41
42
public class LauncherUtils {
43
44
	private static final String TIMESTAMP = "timestamp"; //$NON-NLS-1$
45
	private static final String FILE_NAME = "dep-timestamp.properties"; //$NON-NLS-1$
46
	private static Properties fLastRun;
47
48
	public static Display getDisplay() {
49
		Display display = Display.getCurrent();
50
		if (display == null) {
51
			display = Display.getDefault();
52
		}
53
		return display;
54
	}
55
56
	public final static Shell getActiveShell() {
57
		IWorkbenchWindow window = PDEPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
58
		if (window == null) {
59
			IWorkbenchWindow[] windows = PDEPlugin.getDefault().getWorkbench().getWorkbenchWindows();
60
			if (windows.length > 0)
61
				return windows[0].getShell();
62
		} else
63
			return window.getShell();
64
		return getDisplay().getActiveShell();
65
	}
66
67
	public static boolean clearWorkspace(ILaunchConfiguration configuration, String workspace, IProgressMonitor monitor) throws CoreException {
68
69
		// If the workspace is not defined, there is no workspace to clear
70
		// What will happen is that the workspace chooser dialog will be 
71
		// brought up because no -data parameter will be specified on the 
72
		// launch
73
		if (workspace.length() == 0) {
74
			monitor.done();
75
			return true;
76
		}
77
78
		// Check if the workspace is already in use, if so, open a message and stop the launch before clearing
79
		boolean isLocked = false;
80
		try {
81
			BundleContext context = PDECore.getDefault().getBundleContext();
82
			ServiceReference[] references = context.getServiceReferences(Location.class.getName(), "(type=osgi.configuration.area)"); //$NON-NLS-1$
83
			if (references.length > 0) {
84
				Object service = context.getService(references[0]);
85
				if (service instanceof Location) {
86
					URL workspaceURL = new Path(workspace).toFile().toURI().toURL();
87
					Location targetLocation = ((Location) service).createLocation(null, workspaceURL, false);
88
					targetLocation.set(targetLocation.getDefault(), false);
89
					isLocked = targetLocation.isLocked();
90
				}
91
			}
92
		} catch (InvalidSyntaxException e) {
93
			PDECore.log(e);
94
			isLocked = false;
95
		} catch (MalformedURLException e) {
96
			PDECore.log(e);
97
			isLocked = false;
98
		} catch (IOException e) {
99
			PDECore.log(e);
100
			isLocked = false;
101
		}
102
103
		if (isLocked) {
104
			generateErrorDialog(PDEUIMessages.LauncherUtils_workspaceLocked, NLS.bind(PDEUIMessages.LauncherUtils_cannotLaunchApplication, workspace));
105
			monitor.done();
106
			return false;
107
		}
108
109
		File workspaceFile = new Path(workspace).toFile().getAbsoluteFile();
110
		if (configuration.getAttribute(IPDELauncherConstants.DOCLEAR, false) && workspaceFile.exists()) {
111
			if (configuration.getAttribute(IPDELauncherConstants.ASKCLEAR, true)) {
112
				int result;
113
				if (configuration.getAttribute(IPDEUIConstants.DOCLEARLOG, false)) {
114
					result = generateDialog(PDEUIMessages.LauncherUtils_clearLogFile);
115
				} else {
116
					result = generateDialog(NLS.bind(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_confirmDeleteWorkspace, workspaceFile.getPath()));
117
				}
118
119
				if (result == 2 /*Cancel Button*/|| result == -1 /*Dialog close button*/) {
120
					monitor.done();
121
					return false;
122
				} else if (result == 0) {
123
					if (configuration.getAttribute(IPDEUIConstants.DOCLEARLOG, false)) {
124
						LauncherUtils.clearWorkspaceLog(workspace);
125
					} else {
126
						CoreUtility.deleteContent(workspaceFile);
127
					}
128
				}
129
			} else if (configuration.getAttribute(IPDEUIConstants.DOCLEARLOG, false)) {
130
				LauncherUtils.clearWorkspaceLog(workspace);
131
			} else {
132
				CoreUtility.deleteContent(workspaceFile);
133
			}
134
		}
135
136
		monitor.done();
137
		return true;
138
	}
139
140
	public static boolean generateConfigIni() {
141
		String message = PDEUIMessages.LauncherUtils_generateConfigIni;
142
		return generateDialog(message) == 0;
143
	}
144
145
	/**
146
	 * Creates a message dialog using a syncExec in case we are launching in the background.
147
	 * Dialog will be a question dialog with Yes, No and Cancel buttons.
148
	 * @param message Message to use in the dialog
149
	 * @return int representing the button clicked (-1 or 2 for cancel, 0 for yes, 1 for no).
150
	 */
151
	private static int generateDialog(final String message) {
152
		final int[] result = new int[1];
153
		getDisplay().syncExec(new Runnable() {
154
			public void run() {
155
				String title = PDEUIMessages.LauncherUtils_title;
156
				MessageDialog dialog = new MessageDialog(getActiveShell(), title, null, message, MessageDialog.QUESTION, new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL}, 0);
157
				result[0] = dialog.open();
158
			}
159
		});
160
		return result[0];
161
	}
162
163
	private static void generateErrorDialog(final String title, final String message) {
164
		getDisplay().syncExec(new Runnable() {
165
			public void run() {
166
				MessageDialog dialog = new MessageDialog(getActiveShell(), title, null, message, MessageDialog.ERROR, new String[] {IDialogConstants.OK_LABEL}, 0);
167
				dialog.open();
168
			}
169
		});
170
	}
171
172
	public static void validateProjectDependencies(ILaunchConfiguration launch, final IProgressMonitor monitor) {
173
		IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore();
174
		if (!store.getBoolean(IPreferenceConstants.PROP_AUTO_MANAGE))
175
			return;
176
177
		String timeStamp;
178
		boolean useDefault, autoAdd;
179
		try {
180
			timeStamp = launch.getAttribute(TIMESTAMP, "0"); //$NON-NLS-1$
181
			autoAdd = launch.getAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
182
			useDefault = launch.getAttribute(IPDELauncherConstants.USE_DEFAULT, true);
183
			useDefault |= launch.getAttribute(IPDELauncherConstants.USEFEATURES, false);
184
			final ArrayList projects = new ArrayList();
185
			if (useDefault)
186
				handleUseDefault(timeStamp, projects);
187
			else if (autoAdd)
188
				handleDeselectedPlugins(launch, timeStamp, projects);
189
			else
190
				handleSelectedPlugins(launch, timeStamp, projects);
191
192
			if (!projects.isEmpty())
193
				Display.getDefault().syncExec(new Runnable() {
194
					public void run() {
195
						OrganizeManifestsProcessor processor = new OrganizeManifestsProcessor(projects);
196
						initializeProcessor(processor);
197
						try {
198
							Change change = processor.createChange(monitor);
199
							change.perform(monitor);
200
							// update table for each project with current time stamp
201
							Properties table = getLastRun();
202
							String ts = Long.toString(System.currentTimeMillis());
203
							Iterator it = projects.iterator();
204
							while (it.hasNext())
205
								table.put(((IProject) it.next()).getName(), ts);
206
						} catch (OperationCanceledException e) {
207
						} catch (CoreException e) {
208
						}
209
					}
210
				});
211
212
			ILaunchConfigurationWorkingCopy wc = null;
213
			if (launch.isWorkingCopy())
214
				wc = (ILaunchConfigurationWorkingCopy) launch;
215
			else
216
				wc = launch.getWorkingCopy();
217
			wc.setAttribute(TIMESTAMP, Long.toString(System.currentTimeMillis()));
218
			wc.doSave();
219
		} catch (CoreException e) {
220
		}
221
	}
222
223
	private static void initializeProcessor(OrganizeManifestsProcessor processor) {
224
		processor.setAddMissing(false);
225
		processor.setRemoveUnresolved(false);
226
		processor.setModifyDep(false);
227
		processor.setRemoveLazy(false);
228
		processor.setRemoveUselessFiles(false);
229
		processor.setAddDependencies(true);
230
		processor.setCalculateUses(false);
231
		processor.setMarkInternal(false);
232
		processor.setPrefixIconNL(false);
233
		processor.setUnusedDependencies(false);
234
		processor.setUnusedKeys(false);
235
	}
236
237
	private static String getTimeStamp(IProject project) {
238
		IJavaProject jp = JavaCore.create(project);
239
		try {
240
			long timeStamp = 0;
241
			IClasspathEntry[] entries = jp.getResolvedClasspath(true);
242
			for (int i = 0; i < entries.length; i++) {
243
				if (entries[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
244
					File file;
245
					IPath location = entries[i].getOutputLocation();
246
					if (location == null)
247
						location = jp.getOutputLocation();
248
					IResource res = project.getWorkspace().getRoot().findMember(location);
249
					IPath path = res == null ? null : res.getLocation();
250
					if (path == null)
251
						continue;
252
					file = path.toFile();
253
					Stack files = new Stack();
254
					files.push(file);
255
					while (!files.isEmpty()) {
256
						file = (File) files.pop();
257
						if (file.isDirectory()) {
258
							File[] children = file.listFiles();
259
							if (children != null) {
260
								for (int j = 0; j < children.length; j++)
261
									files.push(children[j]);
262
							}
263
						} else if (file.getName().endsWith(".class") && timeStamp < file.lastModified()) //$NON-NLS-1$
264
							timeStamp = file.lastModified();
265
					}
266
				}
267
			}
268
			String[] otherFiles = {ICoreConstants.BUNDLE_FILENAME_DESCRIPTOR, ICoreConstants.BUILD_FILENAME_DESCRIPTOR};
269
			for (int i = 0; i < otherFiles.length; i++) {
270
				IResource file = project.getFile(otherFiles[i]);
271
				if (file != null) {
272
					long fileTimeStamp = file.getRawLocation().toFile().lastModified();
273
					if (timeStamp < fileTimeStamp)
274
						timeStamp = fileTimeStamp;
275
				}
276
			}
277
			return Long.toString(timeStamp);
278
		} catch (JavaModelException e) {
279
		}
280
		return "0"; //$NON-NLS-1$
281
	}
282
283
	private static void handleUseDefault(String launcherTimeStamp, ArrayList projects) {
284
		IProject[] projs = ResourcesPlugin.getWorkspace().getRoot().getProjects();
285
		for (int i = 0; i < projs.length; i++) {
286
			if (!WorkspaceModelManager.isPluginProject(projs[i]))
287
				continue;
288
			String timestamp = getTimeStamp(projs[i]);
289
			if (timestamp.compareTo(launcherTimeStamp) > 0 && shouldAdd(projs[i], launcherTimeStamp, timestamp))
290
				projects.add(projs[i]);
291
		}
292
	}
293
294
	private static void handleSelectedPlugins(ILaunchConfiguration config, String timeStamp, ArrayList projects) throws CoreException {
295
		Map selectedPlugins = BundleLauncherHelper.getWorkspaceBundleMap(config, null, IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS);
296
		Iterator it = selectedPlugins.keySet().iterator();
297
		while (it.hasNext()) {
298
			IPluginModelBase model = (IPluginModelBase) it.next();
299
			IResource res = model.getUnderlyingResource();
300
			if (res != null) {
301
				IProject project = res.getProject();
302
				String projTimeStamp = getTimeStamp(project);
303
				if (projTimeStamp.compareTo(timeStamp) > 0 && shouldAdd(project, timeStamp, projTimeStamp))
304
					projects.add(project);
305
			}
306
		}
307
	}
308
309
	private static void handleDeselectedPlugins(ILaunchConfiguration config, String launcherTimeStamp, ArrayList projects) throws CoreException {
310
		Map deSelectedPlugins = BundleLauncherHelper.getWorkspaceBundleMap(config, null, IPDELauncherConstants.DESELECTED_WORKSPACE_PLUGINS);
311
		IProject[] projs = ResourcesPlugin.getWorkspace().getRoot().getProjects();
312
		for (int i = 0; i < projs.length; i++) {
313
			if (!WorkspaceModelManager.isPluginProject(projs[i]))
314
				continue;
315
			IPluginModelBase base = PluginRegistry.findModel(projs[i]);
316
			if (base == null || base != null && deSelectedPlugins.containsKey(base))
317
				continue;
318
			String timestamp = getTimeStamp(projs[i]);
319
			if (timestamp.compareTo(launcherTimeStamp) > 0 && shouldAdd(projs[i], launcherTimeStamp, timestamp))
320
				projects.add(projs[i]);
321
		}
322
	}
323
324
	public static final void shutdown() {
325
		if (fLastRun == null)
326
			return;
327
		FileOutputStream stream = null;
328
		try {
329
			stream = new FileOutputStream(new File(getDirectory(), FILE_NAME));
330
			fLastRun.store(stream, "Cached timestamps"); //$NON-NLS-1$
331
			stream.flush();
332
			stream.close();
333
		} catch (IOException e) {
334
			PDECore.logException(e);
335
		} finally {
336
			try {
337
				if (stream != null)
338
					stream.close();
339
			} catch (IOException e1) {
340
			}
341
		}
342
	}
343
344
	private static File getDirectory() {
345
		IPath path = PDECore.getDefault().getStateLocation().append(".cache"); //$NON-NLS-1$
346
		File directory = new File(path.toOSString());
347
		if (!directory.exists() || !directory.isDirectory())
348
			directory.mkdirs();
349
		return directory;
350
	}
351
352
	private static Properties getLastRun() {
353
		if (fLastRun == null) {
354
			fLastRun = new Properties();
355
			FileInputStream fis = null;
356
			try {
357
				File file = new File(getDirectory(), FILE_NAME);
358
				if (file.exists()) {
359
					fis = new FileInputStream(file);
360
					fLastRun.load(fis);
361
					fis.close();
362
				}
363
			} catch (IOException e) {
364
				PDECore.logException(e);
365
			} finally {
366
				try {
367
					if (fis != null)
368
						fis.close();
369
				} catch (IOException e1) {
370
				}
371
			}
372
		}
373
		return fLastRun;
374
	}
375
376
	private static boolean shouldAdd(IProject proj, String launcherTS, String fileSystemTS) {
377
		String projTS = (String) getLastRun().get(proj.getName());
378
		if (projTS == null)
379
			return true;
380
		return ((projTS.compareTo(launcherTS) < 0) || (projTS.compareTo(fileSystemTS) < 0));
381
	}
382
383
	public static boolean requiresUI(ILaunchConfiguration configuration) {
384
		try {
385
			String projectID = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
386
			if (projectID.length() > 0) {
387
				IResource project = PDEPlugin.getWorkspace().getRoot().findMember(projectID);
388
				if (project instanceof IProject) {
389
					IPluginModelBase model = PluginRegistry.findModel((IProject) project);
390
					if (model != null) {
391
						Set plugins = DependencyManager.getSelfAndDependencies(model);
392
						return plugins.contains("org.eclipse.swt"); //$NON-NLS-1$
393
					}
394
				}
395
			}
396
		} catch (CoreException e) {
397
		}
398
		return true;
399
	}
400
401
	public static boolean clearWorkspaceLog(String workspace) {
402
		File logFile = new File(workspace, ".metadata" + File.separator + ".log"); //$NON-NLS-1$ //$NON-NLS-2$
403
		if (logFile != null && logFile.exists()) {
404
			return logFile.delete();
405
		}
406
		return true;
407
	}
408
409
	public static IStatus createErrorStatus(String message) {
410
		return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), IStatus.OK, message, null);
411
	}
412
413
}
(-)src/org/eclipse/pde/internal/ui/launcher/ConfigurationAreaBlock.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-21 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
11
package org.eclipse.pde.internal.ui.launcher;
12
12
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
13
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
16
import org.eclipse.pde.internal.ui.PDEUIMessages;
18
import org.eclipse.pde.internal.ui.PDEUIMessages;
17
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
19
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
18
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
19
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.events.SelectionAdapter;
21
import org.eclipse.swt.events.SelectionAdapter;
21
import org.eclipse.swt.events.SelectionEvent;
22
import org.eclipse.swt.events.SelectionEvent;
(-)src/org/eclipse/pde/internal/ui/wizards/exports/BaseExportWizard.java (-3 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 *  Copyright (c) 2000, 2008 IBM Corporation and others.
2
 *  Copyright (c) 2000, 2009 IBM Corporation and others.
3
 *  All rights reserved. This program and the accompanying materials
3
 *  All rights reserved. This program and the accompanying materials
4
 *  are made available under the terms of the Eclipse Public License v1.0
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 *  which accompanies this distribution, and is available at
5
 *  which accompanies this distribution, and is available at
Lines 14-23 Link Here
14
import org.eclipse.jface.viewers.IStructuredSelection;
14
import org.eclipse.jface.viewers.IStructuredSelection;
15
import org.eclipse.jface.wizard.IWizardPage;
15
import org.eclipse.jface.wizard.IWizardPage;
16
import org.eclipse.jface.wizard.Wizard;
16
import org.eclipse.jface.wizard.Wizard;
17
import org.eclipse.pde.internal.ui.*;
17
import org.eclipse.pde.internal.launching.ILaunchingPreferenceConstants;
18
import org.eclipse.pde.internal.ui.PDEPlugin;
19
import org.eclipse.pde.internal.ui.PDEUIMessages;
18
import org.eclipse.ui.*;
20
import org.eclipse.ui.*;
19
21
20
public abstract class BaseExportWizard extends Wizard implements IExportWizard, IPreferenceConstants {
22
public abstract class BaseExportWizard extends Wizard implements IExportWizard, ILaunchingPreferenceConstants {
21
23
22
	protected IStructuredSelection fSelection;
24
	protected IStructuredSelection fSelection;
23
25
(-)src/org/eclipse/pde/internal/ui/wizards/feature/PluginListPage.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.wizards.feature;
11
package org.eclipse.pde.internal.ui.wizards.feature;
12
12
13
import org.eclipse.pde.launching.IPDELauncherConstants;
14
13
import com.ibm.icu.text.Collator;
15
import com.ibm.icu.text.Collator;
14
import java.util.TreeSet;
16
import java.util.TreeSet;
15
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
Lines 25-31 Link Here
25
import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
27
import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
26
import org.eclipse.pde.internal.ui.wizards.ListUtil;
28
import org.eclipse.pde.internal.ui.wizards.ListUtil;
27
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
29
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
28
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
29
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.events.SelectionAdapter;
31
import org.eclipse.swt.events.SelectionAdapter;
31
import org.eclipse.swt.events.SelectionEvent;
32
import org.eclipse.swt.events.SelectionEvent;
(-)src/org/eclipse/pde/internal/ui/wizards/feature/CreateFeatureProjectFromLaunchOperation.java (-2 / +4 lines)
Lines 12-17 Link Here
12
12
13
package org.eclipse.pde.internal.ui.wizards.feature;
13
package org.eclipse.pde.internal.ui.wizards.feature;
14
14
15
import org.eclipse.pde.launching.IPDELauncherConstants;
16
17
import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper;
18
15
import org.eclipse.core.resources.IProject;
19
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IPath;
Lines 21-29 Link Here
21
import org.eclipse.pde.core.plugin.IPluginModelBase;
25
import org.eclipse.pde.core.plugin.IPluginModelBase;
22
import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel;
26
import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel;
23
import org.eclipse.pde.internal.core.ifeature.IFeature;
27
import org.eclipse.pde.internal.core.ifeature.IFeature;
24
import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper;
25
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
28
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
26
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
27
import org.eclipse.swt.widgets.Shell;
29
import org.eclipse.swt.widgets.Shell;
28
30
29
public class CreateFeatureProjectFromLaunchOperation extends CreateFeatureProjectOperation {
31
public class CreateFeatureProjectFromLaunchOperation extends CreateFeatureProjectOperation {
(-)plugin.xml (-66 / +64 lines)
Lines 18-24 Link Here
18
   <extension-point id="newExtension" name="%expoint.newExtension.name" schema="schema/newExtension.exsd"/>
18
   <extension-point id="newExtension" name="%expoint.newExtension.name" schema="schema/newExtension.exsd"/>
19
   <extension-point id="templates" name="%expoint.templates.name" schema="schema/templates.exsd"/>
19
   <extension-point id="templates" name="%expoint.templates.name" schema="schema/templates.exsd"/>
20
   <extension-point id="samples" name="%expoint.samples.name" schema="schema/samples.exsd"/>
20
   <extension-point id="samples" name="%expoint.samples.name" schema="schema/samples.exsd"/>
21
   <extension-point id="osgiFrameworks" name="%expoint.osgiLauncher.name" schema="schema/osgiFrameworks.exsd"/>
22
   <extension-point id="targetProvisioners" name="%extension-point.name.0" schema="schema/targetProvisioners.exsd"/>
21
   <extension-point id="targetProvisioners" name="%extension-point.name.0" schema="schema/targetProvisioners.exsd"/>
23
   <extension-point id="launchShortcuts" name="%extension-point.name.1" schema="schema/launchShortcuts.exsd"/>
22
   <extension-point id="launchShortcuts" name="%extension-point.name.1" schema="schema/launchShortcuts.exsd"/>
24
23
Lines 895-936 Link Here
895
      </objectContribution>
894
      </objectContribution>
896
   </extension>
895
   </extension>
897
   <extension
896
   <extension
898
         point="org.eclipse.debug.core.launchConfigurationTypes">
899
      <launchConfigurationType
900
            delegate="org.eclipse.pde.ui.launcher.EclipseApplicationLaunchConfiguration"
901
            delegateDescription="%PDELaunchDelegate.description"
902
            delegateName="%PDELaunchDelegate.name"
903
            id="org.eclipse.pde.ui.RuntimeWorkbench"
904
            migrationDelegate="org.eclipse.pde.internal.ui.launcher.PDEMigrationDelegate"
905
            modes="run, debug"
906
            name="%launchConfigurationType.name"
907
            sourceLocatorId="org.eclipse.pde.ui.launcher.PDESourceLookupDirector"
908
            sourcePathComputerId="org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer">
909
      </launchConfigurationType>
910
      <launchConfigurationType
911
            delegate="org.eclipse.pde.ui.launcher.JUnitLaunchConfigurationDelegate"
912
            delegateDescription="%JUnitPluginLaunchDelegate.description"
913
            delegateName="%JUnitPluginLaunchDelegate.name"
914
            id="org.eclipse.pde.ui.JunitLaunchConfig"
915
            migrationDelegate="org.eclipse.pde.internal.ui.launcher.PDEMigrationDelegate"
916
            modes="run, debug"
917
            name="%launcher.junit.name"
918
            sourceLocatorId="org.eclipse.pde.ui.launcher.PDESourceLookupDirector"
919
            sourcePathComputerId="org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer">
920
      </launchConfigurationType>
921
      <launchConfigurationType
922
            delegate="org.eclipse.pde.ui.launcher.OSGiLaunchConfigurationDelegate"
923
            delegateDescription="%OSGiLaunchDelegate.description"
924
            delegateName="%OSGiLaunchDelegate.name"
925
            id="org.eclipse.pde.ui.EquinoxLauncher"
926
            migrationDelegate="org.eclipse.pde.internal.ui.launcher.OSGiMigrationDelegate"
927
            modes="run, debug"
928
            name="%launcher.framework.name"
929
            public="true"
930
            sourceLocatorId="org.eclipse.pde.ui.launcher.PDESourceLookupDirector"
931
            sourcePathComputerId="org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer"/>
932
   </extension>
933
   <extension
934
         point="org.eclipse.debug.ui.launchConfigurationTypeImages">
897
         point="org.eclipse.debug.ui.launchConfigurationTypeImages">
935
      <launchConfigurationTypeImage
898
      <launchConfigurationTypeImage
936
            icon="$nl$/icons/etool16/eclipse_launcher.gif"
899
            icon="$nl$/icons/etool16/eclipse_launcher.gif"
Lines 994-1005 Link Here
994
      </launchConfigurationTabGroup>
957
      </launchConfigurationTabGroup>
995
   </extension>
958
   </extension>
996
   <extension
959
   <extension
997
         point="org.eclipse.jdt.junit.junitLaunchConfigs">
998
      <launchConfigType
999
            configTypeID="org.eclipse.pde.ui.JunitLaunchConfig">
1000
      </launchConfigType>
1001
   </extension>
1002
   <extension
1003
         point="org.eclipse.debug.ui.launchShortcuts">
960
         point="org.eclipse.debug.ui.launchShortcuts">
1004
      <shortcut
961
      <shortcut
1005
            class="org.eclipse.pde.ui.launcher.JUnitWorkbenchLaunchShortcut"
962
            class="org.eclipse.pde.ui.launcher.JUnitWorkbenchLaunchShortcut"
Lines 1221-1233 Link Here
1221
            id="org.eclipse.pde.ui.dependencyExtentResultPage"/>
1178
            id="org.eclipse.pde.ui.dependencyExtentResultPage"/>
1222
   </extension>
1179
   </extension>
1223
   <extension
1180
   <extension
1224
         point="org.eclipse.jdt.launching.classpathProviders">
1225
      <classpathProvider
1226
            class="org.eclipse.pde.ui.launcher.PDESourcePathProvider"
1227
            id="org.eclipse.pde.ui.workbenchClasspathProvider">
1228
      </classpathProvider>
1229
   </extension>
1230
   <extension
1231
         point="org.eclipse.ui.intro.configExtension">
1181
         point="org.eclipse.ui.intro.configExtension">
1232
      <standbyContentPart
1182
      <standbyContentPart
1233
            pluginId="org.eclipse.pde.ui"
1183
            pluginId="org.eclipse.pde.ui"
Lines 1637-1649 Link Here
1637
         </description>
1587
         </description>
1638
       </fontDefinition>
1588
       </fontDefinition>
1639
    </extension>
1589
    </extension>
1640
    <extension point="org.eclipse.debug.core.sourceLocators">
1641
   		<sourceLocator
1642
   			id="org.eclipse.pde.ui.launcher.PDESourceLookupDirector"
1643
   			class="org.eclipse.pde.internal.ui.launcher.PDESourceLookupDirector"
1644
   			name="%pde.sourcelocator">
1645
   		</sourceLocator>
1646
   </extension>
1647
   <extension
1590
   <extension
1648
          point="org.eclipse.ui.perspectiveExtensions">
1591
          point="org.eclipse.ui.perspectiveExtensions">
1649
       <perspectiveExtension
1592
       <perspectiveExtension
Lines 1720-1733 Link Here
1720
      </perspectiveExtension>
1663
      </perspectiveExtension>
1721
    </extension>
1664
    </extension>
1722
    <extension
1665
    <extension
1723
         point="org.eclipse.pde.ui.osgiFrameworks">
1724
      <framework
1725
            launcherDelegate="org.eclipse.pde.ui.launcher.EquinoxLaunchConfiguration"
1726
            id="org.eclipse.pde.ui.EquinoxFramework"
1727
            name="%Equinox.shortcut.label" 
1728
            initializer="org.eclipse.pde.internal.ui.launcher.EquinoxInitializer"/>
1729
    </extension>
1730
    <extension
1731
          point="org.eclipse.ui.ide.markerSupport">
1666
          point="org.eclipse.ui.ide.markerSupport">
1732
       <markerTypeCategory
1667
       <markerTypeCategory
1733
             name="%marker.category">
1668
             name="%marker.category">
Lines 2026-2030 Link Here
2026
                   tooltip="%showErrorInStackTraceConsoleAction.label">
1961
                   tooltip="%showErrorInStackTraceConsoleAction.label">
2027
             </action>
1962
             </action>
2028
          </viewContribution>
1963
          </viewContribution>
2029
	</extension>>
1964
	</extension>
1965
	<extension
1966
         point="org.eclipse.debug.core.statusHandlers">
1967
      <statusHandler
1968
            class="org.eclipse.pde.internal.ui.launcher.LaunchTerminationStatusHandler"
1969
            code="13"
1970
            id="org.eclipse.pde.launching.ERR13"
1971
            plugin="org.eclipse.pde.launching">
1972
      </statusHandler>
1973
      <statusHandler
1974
            class="org.eclipse.pde.internal.ui.launcher.LaunchTerminationStatusHandler"
1975
            code="15"
1976
            id="org.eclipse.pde.launching.ERR15"
1977
            plugin="org.eclipse.pde.launching">
1978
      </statusHandler>
1979
      <statusHandler
1980
            class="org.eclipse.pde.internal.ui.launcher.GenericExceptionStatusHandler"
1981
            code="42"
1982
            id="org.eclipse.pde.launching.GENERIC_EXCEPTION"
1983
            plugin="org.eclipse.pde.launching">
1984
      </statusHandler>
1985
      <statusHandler
1986
            class="org.eclipse.pde.internal.ui.launcher.PluginValidationStatusHandler"
1987
            code="1000"
1988
            id="org.eclipse.pde.launching.CREATE_EXTENSION_ERROR"
1989
            plugin="org.eclipse.pde.launching">
1990
      </statusHandler>
1991
      <statusHandler
1992
            class="org.eclipse.pde.internal.ui.launcher.PluginValidationStatusHandler"
1993
            code="1001"
1994
            id="org.eclipse.pde.launching.DISPLAY_VALIDATION_ERROR"
1995
            plugin="org.eclipse.pde.launching">
1996
      </statusHandler>
1997
      <statusHandler
1998
            class="org.eclipse.pde.internal.ui.launcher.LauncherUtilsStatusHandler"
1999
            code="2000"
2000
            id="org.eclipse.pde.launching.WORKSPACE_LOCKED"
2001
            plugin="org.eclipse.pde.launching">
2002
      </statusHandler>
2003
      <statusHandler
2004
            class="org.eclipse.pde.internal.ui.launcher.LauncherUtilsStatusHandler"
2005
            code="2001"
2006
            id="org.eclipse.pde.launching.CLEAR_LOG"
2007
            plugin="org.eclipse.pde.launching">
2008
      </statusHandler>
2009
      <statusHandler
2010
            class="org.eclipse.pde.internal.ui.launcher.LauncherUtilsStatusHandler"
2011
            code="2002"
2012
            id="org.eclipse.pde.launching.DELETE_WORKSPACE"
2013
            plugin="org.eclipse.pde.launching">
2014
      </statusHandler>
2015
      <statusHandler
2016
            class="org.eclipse.pde.internal.ui.launcher.LauncherUtilsStatusHandler"
2017
            code="2003"
2018
            id="org.eclipse.pde.launching.CREATE_CONFIG_INI"
2019
            plugin="org.eclipse.pde.launching">
2020
      </statusHandler>
2021
      <statusHandler
2022
            class="org.eclipse.pde.internal.ui.launcher.LauncherUtilsStatusHandler"
2023
            code="2004"
2024
            id="org.eclipse.pde.launching.ORGANIZE_MANIFESTS"
2025
            plugin="org.eclipse.pde.launching">
2026
      </statusHandler>
2027
   </extension>	
2030
</plugin>
2028
</plugin>
(-)plugin.properties (-12 lines)
Lines 20-32 Link Here
20
expoint.samples.name = Code Samples
20
expoint.samples.name = Code Samples
21
expoint.osgiLauncher.name = OSGi Launcher
21
expoint.osgiLauncher.name = OSGi Launcher
22
22
23
PDELaunchDelegate.name=Eclipse Application Launcher
24
PDELaunchDelegate.description=The Eclipse Application launcher is used to run or debug a separate instance of an Eclipse application
25
OSGiLaunchDelegate.name=OSGi Framework Launcher
26
OSGiLaunchDelegate.description=The OSGi Framework launcher is used to launch an OSGi framework and run or debug OSGi bundles
27
JUnitPluginLaunchDelegate.name= JUnit Plugin Test Launcher
28
JUnitPluginLaunchDelegate.description=The JUnit Plugin Test launcher is used to run and debug test suites for plug-in projects
29
30
RunPDELaunchShortcut.description=Runs a separate Eclipse application
23
RunPDELaunchShortcut.description=Runs a separate Eclipse application
31
DebugPDELaunchShortcut.description=Debugs a separate Eclipse application
24
DebugPDELaunchShortcut.description=Debugs a separate Eclipse application
32
RunOSGiLaunchShortcut.description=Runs an OSGi framework
25
RunOSGiLaunchShortcut.description=Runs an OSGi framework
Lines 132-147 Link Here
132
launcher.shortcut.label= Eclipse Application
125
launcher.shortcut.label= Eclipse Application
133
EclipseApplicationShortcut.description.debug = Debug Eclipse Application
126
EclipseApplicationShortcut.description.debug = Debug Eclipse Application
134
EclipseApplicationShortcut.description.run = Run Eclipse Application
127
EclipseApplicationShortcut.description.run = Run Eclipse Application
135
Equinox.shortcut.label = Equinox
136
OSGiShortcut.description.debug = Debug OSGi Framework
128
OSGiShortcut.description.debug = Debug OSGi Framework
137
OSGiShortcut.description.run = Run OSGi Framework
129
OSGiShortcut.description.run = Run OSGi Framework
138
launcher.junit.name = JUnit Plug-in Test
130
launcher.junit.name = JUnit Plug-in Test
139
JUnitApplicationShortcut.description.debug = Debug JUnit Plug-in Test
131
JUnitApplicationShortcut.description.debug = Debug JUnit Plug-in Test
140
JUnitApplicationShortcut.description.run = Run JUnit Plug-in Test
132
JUnitApplicationShortcut.description.run = Run JUnit Plug-in Test
141
133
142
launchConfigurationType.name = Eclipse Application
143
launcher.framework.name = OSGi Framework
144
145
osgiLauncherTabGroup.description.debug=Create a configuration to launch the OSGi framework in debug mode.
134
osgiLauncherTabGroup.description.debug=Create a configuration to launch the OSGi framework in debug mode.
146
osgiLauncherTabGroup.description.run=Create a configuration to launch the OSGi framework.
135
osgiLauncherTabGroup.description.run=Create a configuration to launch the OSGi framework.
147
workbenchLauncherTabGroup.description.debug=Create a configuration to launch an Eclipse application in debug mode.
136
workbenchLauncherTabGroup.description.debug=Create a configuration to launch an Eclipse application in debug mode.
Lines 182-188 Link Here
182
editor.target.name = Target Editor
171
editor.target.name = Target Editor
183
fontDefinition.label.0 = Manifest compare text font
172
fontDefinition.label.0 = Manifest compare text font
184
fontDefinition.description.0 = The MANIFEST.MF compare text font is used by Bundle manifest compare/merge tools.
173
fontDefinition.description.0 = The MANIFEST.MF compare text font is used by Bundle manifest compare/merge tools.
185
pde.sourcelocator = PDE Source Lookup Director
186
174
187
category.source.name = Manifest Editor Source
175
category.source.name = Manifest Editor Source
188
category.source.description = PDE Source Page actions
176
category.source.description = PDE Source Page actions
(-)src/org/eclipse/pde/internal/ui/IPDEUIConstants.java (-17 / +2 lines)
Lines 12-19 Link Here
12
package org.eclipse.pde.internal.ui;
12
package org.eclipse.pde.internal.ui;
13
13
14
import org.eclipse.core.runtime.QualifiedName;
14
import org.eclipse.core.runtime.QualifiedName;
15
import org.eclipse.pde.internal.launching.IPDEConstants;
15
16
16
public interface IPDEUIConstants {
17
public interface IPDEUIConstants extends IPDEConstants {
17
	String PLUGIN_ID = "org.eclipse.pde.ui"; //$NON-NLS-1$
18
	String PLUGIN_ID = "org.eclipse.pde.ui"; //$NON-NLS-1$
18
19
19
	String MANIFEST_EDITOR_ID = PLUGIN_ID + ".manifestEditor"; //$NON-NLS-1$
20
	String MANIFEST_EDITOR_ID = PLUGIN_ID + ".manifestEditor"; //$NON-NLS-1$
Lines 40-58 Link Here
40
41
41
	String PLUGIN_DOC_ROOT = "/org.eclipse.pde.doc.user/"; //$NON-NLS-1$
42
	String PLUGIN_DOC_ROOT = "/org.eclipse.pde.doc.user/"; //$NON-NLS-1$
42
43
43
	// JUnit application identifiers
44
	String LEGACY_UI_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.legacytestapplication"; //$NON-NLS-1$
45
	String NON_UI_THREAD_APPLICATION = "org.eclipse.pde.junit.runtime.nonuithreadtestapplication"; //$NON-NLS-1$
46
	String UI_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.uitestapplication"; //$NON-NLS-1$
47
	String CORE_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.coretestapplication"; //$NON-NLS-1$
48
49
	/**
50
	 * Launch configuration attribute key.  The value is a boolean specifies
51
	 * whether the launch configuration is being restarted.  This does not need to 
52
	 * be promoted to IPDELauncherConstants since clients should not need to know 
53
	 * about restarts.  
54
	 */
55
	String RESTART = "restart"; //$NON-NLS-1$
56
	/**
44
	/**
57
	 * Launch configuration attribute key. The value is a boolean specifying
45
	 * Launch configuration attribute key. The value is a boolean specifying
58
	 * whether the workspace log for an Eclipse application should be cleared
46
	 * whether the workspace log for an Eclipse application should be cleared
Lines 60-68 Link Here
60
	 * 
48
	 * 
61
	 * TODO, move to IPDELauncherConstants in 3.4
49
	 * TODO, move to IPDELauncherConstants in 3.4
62
	 */
50
	 */
63
	String DOCLEARLOG = "clearwslog"; //$NON-NLS-1$
64
	String LAUNCHER_PDE_VERSION = "pde.version"; //$NON-NLS-1$
65
	String APPEND_ARGS_EXPLICITLY = "append.args"; //$NON-NLS-1$
66
	String GENERATED_CONFIG = "pde.generated.config"; //$NON-NLS-1$
51
	String GENERATED_CONFIG = "pde.generated.config"; //$NON-NLS-1$
67
52
68
}
53
}
(-)src/org/eclipse/pde/internal/ui/pderesources.properties (-14 lines)
Lines 548-566 Link Here
548
ConfigurationTab_fileDialogMessage=Select a config.ini file:
548
ConfigurationTab_fileDialogMessage=Select a config.ini file:
549
549
550
550
551
WorkbenchLauncherConfigurationDelegate_noJRE = Cannot locate JRE definition: "{0}". Launch aborted.
552
WorkbenchLauncherConfigurationDelegate_jrePathNotFound = The installation path to the specified JRE could not be found.  Launch aborted.
553
WorkbenchLauncherConfigurationDelegate_badFeatureSetup = When in feature mode, plug-ins must be in the 'plugins' directory and features in 'features' directory in the workspace.
554
WorkbenchLauncherConfigurationDelegate_noStartup = Launching failed. Bootstrap code cannot be found.
555
WorkbenchLauncherConfigurationDelegate_confirmDeleteWorkspace = Do you really want to clear the run-time workspace data in {0}?
551
WorkbenchLauncherConfigurationDelegate_confirmDeleteWorkspace = Do you really want to clear the run-time workspace data in {0}?
556
JUnitLaunchConfiguration_error_notaplugin = Could not launch the JUnit plug-in tests because project ''{0}'' is not a plug-in project.
557
JUnitLaunchConfiguration_error_missingPlugin = Required plug-in ''{0}'' could not be found.
558
552
559
Launcher_error_title=Launch Error
553
Launcher_error_title=Launch Error
560
LauncherSection_desc=Customize the executable that is used to launch the product.
554
LauncherSection_desc=Customize the executable that is used to launch the product.
561
LauncherSection_ico=Use a single ICO file containing the 6 images:
555
LauncherSection_ico=Use a single ICO file containing the 6 images:
562
LauncherUtils_workspaceLocked=Workspace Cannot Be Locked
556
LauncherUtils_workspaceLocked=Workspace Cannot Be Locked
563
LauncherUtils_cannotLaunchApplication=Could not launch the application because the associated workspace is currently in use by another Eclipse application.\n\n{0}
564
LauncherUtils_clearLogFile=Do you really want to clear the log file?
557
LauncherUtils_clearLogFile=Do you really want to clear the log file?
565
LauncherUtils_title=Launcher
558
LauncherUtils_title=Launcher
566
LauncherPage_title=Launching
559
LauncherPage_title=Launching
Lines 568-574 Link Here
568
LauncherSection_icon=Icon:
561
LauncherSection_icon=Icon:
569
LauncherSection_tiny=Tiny:
562
LauncherSection_tiny=Tiny:
570
Launcher_error_code13=The application could not start.  Would you like to view the log?
563
Launcher_error_code13=The application could not start.  Would you like to view the log?
571
Launcher_error_code15=Could not launch the configuration because the associated workspace is currently in use.
572
Launcher_error_displayInLogView=Yes, in the Error Log view
564
Launcher_error_displayInLogView=Yes, in the Error Log view
573
LauncherUtils_generateConfigIni=The config.ini template file you specified does not exist.  Continue launching with a generated config.ini file?
565
LauncherUtils_generateConfigIni=The config.ini template file you specified does not exist.  Continue launching with a generated config.ini file?
574
Launcher_error_displayInSystemEditor=Yes, in an editor
566
Launcher_error_displayInSystemEditor=Yes, in an editor
Lines 2008-2014 Link Here
2008
InternationalizeWizard_NLSFragmentGenerator_errorMessage = An error occured while generating an NL Fragment.
2000
InternationalizeWizard_NLSFragmentGenerator_errorMessage = An error occured while generating an NL Fragment.
2009
2001
2010
MainTab_jreSection = Java Runtime Environment
2002
MainTab_jreSection = Java Runtime Environment
2011
EquinoxLaunchConfiguration_oldTarget=The org.eclipse.osgi plug-in is missing from this configuration.
2012
EquinoxPluginBlock_levelColumn=Start Level
2003
EquinoxPluginBlock_levelColumn=Start Level
2013
EquinoxPluginsTab_defaultStart=Default S&tart level:
2004
EquinoxPluginsTab_defaultStart=Default S&tart level:
2014
EquinoxPluginBlock_autoColumn=Auto-Start
2005
EquinoxPluginBlock_autoColumn=Auto-Start
Lines 2185-2192 Link Here
2185
EditorSourcePage_name=Source
2176
EditorSourcePage_name=Source
2186
EditTargetNode_0=New Target Definition
2177
EditTargetNode_0=New Target Definition
2187
OSGiBundlesTab_frameworkLabel=&Framework:
2178
OSGiBundlesTab_frameworkLabel=&Framework:
2188
OSGiLaunchConfiguration_cannotFindLaunchConfiguration=Cannot find the {0} OSGi framework.
2189
OSGiLaunchConfiguration_selected=selected
2190
OSGiFrameworkPreferencePage_default=(default)
2179
OSGiFrameworkPreferencePage_default=(default)
2191
OSGiFrameworkPreferencePage_installed=Installed <a>OSGi frameworks</a>:
2180
OSGiFrameworkPreferencePage_installed=Installed <a>OSGi frameworks</a>:
2192
OSGiFrameworkPreferencePage_installed_nolink=Installed OSGi frameworks:
2181
OSGiFrameworkPreferencePage_installed_nolink=Installed OSGi frameworks:
Lines 2218-2224 Link Here
2218
UpdateSplashHandlerInModelAction_nameEnterprise=Enterprise
2207
UpdateSplashHandlerInModelAction_nameEnterprise=Enterprise
2219
UpdateSplashProgressAction_msgErrorTextFileBuffer=Text file buffer is NULL
2208
UpdateSplashProgressAction_msgErrorTextFileBuffer=Text file buffer is NULL
2220
UpdateSplashHandlerInModelAction_nameLanguages=Languages
2209
UpdateSplashHandlerInModelAction_nameLanguages=Languages
2221
EclipsePluginValidationOperation_pluginMissing={0} is missing
2222
SplashProgressSection_progressName=Customization
2210
SplashProgressSection_progressName=Customization
2223
SplashProgressSection_progressSectionDesc=Create a custom splash screen using one of the provided templates or by adding a progress bar and message.
2211
SplashProgressSection_progressSectionDesc=Create a custom splash screen using one of the provided templates or by adding a progress bar and message.
2224
UpdateSplashHandlerInModelAction_templateTypeInteractive=Interactive - A simulated log-in session
2212
UpdateSplashHandlerInModelAction_templateTypeInteractive=Interactive - A simulated log-in session
Lines 2274-2281 Link Here
2274
PDECompilersConfigurationBlock_warning = Warning
2262
PDECompilersConfigurationBlock_warning = Warning
2275
PDECompilersConfigurationBlock_ignore = Ignore
2263
PDECompilersConfigurationBlock_ignore = Ignore
2276
2264
2277
VMHelper_cannotFindExecEnv=Cannot locate Execution Environment definition: "{0}". Launch aborted.
2278
2279
LicensingPage_title=Licensing
2265
LicensingPage_title=Licensing
2280
LicenseSection_title=License
2266
LicenseSection_title=License
2281
LicenseSection_description=Specify the license text and URL for the product.
2267
LicenseSection_description=Specify the license text and URL for the product.
(-)src/org/eclipse/pde/internal/ui/PDEPlugin.java (-90 / +2 lines)
Lines 16-27 Link Here
16
import org.eclipse.core.resources.IWorkspace;
16
import org.eclipse.core.resources.IWorkspace;
17
import org.eclipse.core.resources.ResourcesPlugin;
17
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.runtime.*;
18
import org.eclipse.core.runtime.*;
19
import org.eclipse.debug.core.DebugPlugin;
20
import org.eclipse.debug.core.ILaunchConfigurationListener;
21
import org.eclipse.jface.dialogs.ErrorDialog;
19
import org.eclipse.jface.dialogs.ErrorDialog;
22
import org.eclipse.jface.preference.IPreferenceStore;
20
import org.eclipse.jface.preference.IPreferenceStore;
23
import org.eclipse.pde.internal.core.PDEPreferencesManager;
21
import org.eclipse.pde.internal.core.PDEPreferencesManager;
24
import org.eclipse.pde.internal.ui.launcher.*;
22
import org.eclipse.pde.internal.ui.launcher.PDELogFileProvider;
25
import org.eclipse.pde.internal.ui.util.SWTUtil;
23
import org.eclipse.pde.internal.ui.util.SWTUtil;
26
import org.eclipse.swt.widgets.Display;
24
import org.eclipse.swt.widgets.Display;
27
import org.eclipse.swt.widgets.Shell;
25
import org.eclipse.swt.widgets.Shell;
Lines 33-50 Link Here
33
import org.eclipse.ui.internal.views.log.LogFilesManager;
31
import org.eclipse.ui.internal.views.log.LogFilesManager;
34
import org.eclipse.ui.plugin.AbstractUIPlugin;
32
import org.eclipse.ui.plugin.AbstractUIPlugin;
35
import org.eclipse.ui.texteditor.IDocumentProvider;
33
import org.eclipse.ui.texteditor.IDocumentProvider;
36
import org.osgi.framework.*;
34
import org.osgi.framework.BundleContext;
37
35
38
public class PDEPlugin extends AbstractUIPlugin implements IPDEUIConstants {
36
public class PDEPlugin extends AbstractUIPlugin implements IPDEUIConstants {
39
37
40
	// Shared instance
38
	// Shared instance
41
	private static PDEPlugin fInstance;
39
	private static PDEPlugin fInstance;
42
40
43
	// Launches listener
44
	private LaunchListener fLaunchListener;
45
46
	private BundleContext fBundleContext;
47
48
	private Hashtable fCounters;
41
	private Hashtable fCounters;
49
42
50
	// Provides Launch Configurations log files to Log View
43
	// Provides Launch Configurations log files to Log View
Lines 55-73 Link Here
55
	private PDELabelProvider fLabelProvider;
48
	private PDELabelProvider fLabelProvider;
56
49
57
	/**
50
	/**
58
	 * Utility class to help setup the launch configuration listener
59
	 * without loading the debug plugin
60
	 */
61
	private DebugPluginUtil fDebugPluginUtil;
62
63
	/**
64
	 * The shared text file document provider.
51
	 * The shared text file document provider.
65
	 * @since 3.2
52
	 * @since 3.2
66
	 */
53
	 */
67
	private IDocumentProvider fTextFileDocumentProvider;
54
	private IDocumentProvider fTextFileDocumentProvider;
68
55
69
	private OSGiFrameworkManager fOSGiFrameworkManager;
70
71
	private PDEPreferencesManager fPreferenceManager;
56
	private PDEPreferencesManager fPreferenceManager;
72
57
73
	public PDEPlugin() {
58
	public PDEPlugin() {
Lines 183-231 Link Here
183
	 */
168
	 */
184
	public void start(BundleContext context) throws Exception {
169
	public void start(BundleContext context) throws Exception {
185
		super.start(context);
170
		super.start(context);
186
		fBundleContext = context;
187
		setupLaunchConfigurationListener();
188
		fLogFileProvider = new PDELogFileProvider();
171
		fLogFileProvider = new PDELogFileProvider();
189
		LogFilesManager.addLogFileProvider(fLogFileProvider);
172
		LogFilesManager.addLogFileProvider(fLogFileProvider);
190
	}
173
	}
191
174
192
	/**
193
	 * Add the launch configuration listener if the debug plugin
194
	 * is started.  Otherwise, setup a bundle listener to install
195
	 * the listener when the debug plugin loads.
196
	 * @param context bundle context needed to get current bundles
197
	 */
198
	private void setupLaunchConfigurationListener() {
199
		boolean listenerStarted = false;
200
		Bundle bundle = Platform.getBundle("org.eclipse.debug.core"); //$NON-NLS-1$
201
		if (bundle != null && bundle.getState() == Bundle.ACTIVE) {
202
			fDebugPluginUtil = new DebugPluginUtil();
203
			fDebugPluginUtil.addListener();
204
			listenerStarted = true;
205
		}
206
		if (!listenerStarted) {
207
			fBundleContext.addBundleListener(new BundleListener() {
208
				public void bundleChanged(BundleEvent event) {
209
					if (event.getType() == BundleEvent.STARTED && "org.eclipse.debug.core".equals(event.getBundle().getSymbolicName())) { //$NON-NLS-1$
210
						fDebugPluginUtil = new DebugPluginUtil();
211
						fDebugPluginUtil.addListener();
212
						fBundleContext.removeBundleListener(this);
213
					}
214
				}
215
			});
216
		}
217
	}
218
219
	public BundleContext getBundleContext() {
220
		return fBundleContext;
221
	}
222
223
	/* (non-Javadoc)
175
	/* (non-Javadoc)
224
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
176
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
225
	 */
177
	 */
226
	public void stop(BundleContext context) throws Exception {
178
	public void stop(BundleContext context) throws Exception {
227
		if (fLaunchListener != null)
228
			fLaunchListener.shutdown();
229
		if (fFormColors != null) {
179
		if (fFormColors != null) {
230
			fFormColors.dispose();
180
			fFormColors.dispose();
231
			fFormColors = null;
181
			fFormColors = null;
Lines 234-247 Link Here
234
			fLabelProvider.dispose();
184
			fLabelProvider.dispose();
235
			fLabelProvider = null;
185
			fLabelProvider = null;
236
		}
186
		}
237
		if (fDebugPluginUtil != null) {
238
			fDebugPluginUtil.removeListener();
239
		}
240
		if (fLogFileProvider != null) {
187
		if (fLogFileProvider != null) {
241
			LogFilesManager.removeLogFileProvider(fLogFileProvider);
188
			LogFilesManager.removeLogFileProvider(fLogFileProvider);
242
			fLogFileProvider = null;
189
			fLogFileProvider = null;
243
		}
190
		}
244
		LauncherUtils.shutdown();
245
		super.stop(context);
191
		super.stop(context);
246
	}
192
	}
247
193
Lines 251-268 Link Here
251
		return fLabelProvider;
197
		return fLabelProvider;
252
	}
198
	}
253
199
254
	public LaunchListener getLaunchListener() {
255
		if (fLaunchListener == null)
256
			fLaunchListener = new LaunchListener();
257
		return fLaunchListener;
258
	}
259
260
	public OSGiFrameworkManager getOSGiFrameworkManager() {
261
		if (fOSGiFrameworkManager == null)
262
			fOSGiFrameworkManager = new OSGiFrameworkManager();
263
		return fOSGiFrameworkManager;
264
	}
265
266
	public static boolean isFullNameModeEnabled() {
200
	public static boolean isFullNameModeEnabled() {
267
		IPreferenceStore store = getDefault().getPreferenceStore();
201
		IPreferenceStore store = getDefault().getPreferenceStore();
268
		return store.getString(IPreferenceConstants.PROP_SHOW_OBJECTS).equals(IPreferenceConstants.VALUE_USE_NAMES);
202
		return store.getString(IPreferenceConstants.PROP_SHOW_OBJECTS).equals(IPreferenceConstants.VALUE_USE_NAMES);
Lines 280-305 Link Here
280
		return fTextFileDocumentProvider;
214
		return fTextFileDocumentProvider;
281
	}
215
	}
282
216
283
	/**
284
	 * Utility class that creates and controls a the PDE launch configuration listener.
285
	 * This is done in a separate class to avoid loading the debug plugin.
286
	 * @since 3.4
287
	 */
288
	private class DebugPluginUtil {
289
		private ILaunchConfigurationListener fLaunchConfigurationListener;
290
291
		public void addListener() {
292
			if (fLaunchConfigurationListener == null) {
293
				fLaunchConfigurationListener = new LaunchConfigurationListener();
294
			}
295
			DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(fLaunchConfigurationListener);
296
		}
297
298
		public void removeListener() {
299
			if (fLaunchConfigurationListener != null) {
300
				DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(fLaunchConfigurationListener);
301
				fLaunchConfigurationListener = null;
302
			}
303
		}
304
	}
305
}
217
}
(-)src/org/eclipse/pde/internal/ui/IPreferenceConstants.java (-5 / +3 lines)
Lines 11-28 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui;
12
package org.eclipse.pde.internal.ui;
13
13
14
import org.eclipse.pde.internal.launching.ILaunchingPreferenceConstants;
15
14
/**
16
/**
15
 * Listing of constants used in PDE preferences
17
 * Listing of constants used in PDE preferences
16
 * 
18
 * 
17
 * @noimplement This interface is not intended to be implemented by clients.
19
 * @noimplement This interface is not intended to be implemented by clients.
18
 */
20
 */
19
public interface IPreferenceConstants {
21
public interface IPreferenceConstants extends ILaunchingPreferenceConstants {
20
22
21
	// Main preference page	
23
	// Main preference page	
22
	public static final String PROP_SHOW_OBJECTS = "Preferences.MainPage.showObjects"; //$NON-NLS-1$
24
	public static final String PROP_SHOW_OBJECTS = "Preferences.MainPage.showObjects"; //$NON-NLS-1$
23
	public static final String VALUE_USE_IDS = "useIds"; //$NON-NLS-1$
25
	public static final String VALUE_USE_IDS = "useIds"; //$NON-NLS-1$
24
	public static final String VALUE_USE_NAMES = "useNames"; //$NON-NLS-1$
26
	public static final String VALUE_USE_NAMES = "useNames"; //$NON-NLS-1$
25
	public static final String PROP_AUTO_MANAGE = "Preferences.MainPage.automanageDependencies"; //$NON-NLS-1$
26
	public static final String PROP_SHOW_SOURCE_BUNDLES = "Preferences.MainPage.showSourceBundles"; //$NON-NLS-1$
27
	public static final String PROP_SHOW_SOURCE_BUNDLES = "Preferences.MainPage.showSourceBundles"; //$NON-NLS-1$
27
	public static final String OVERWRITE_BUILD_FILES_ON_EXPORT = "Preferences.MainPage.overwriteBuildFilesOnExport"; //$NON-NLS-1$
28
	public static final String OVERWRITE_BUILD_FILES_ON_EXPORT = "Preferences.MainPage.overwriteBuildFilesOnExport"; //$NON-NLS-1$
28
	public static final String PROP_PROMPT_REMOVE_TARGET = "Preferences.MainPage.promptRemoveTarget"; //$NON-NLS-1$
29
	public static final String PROP_PROMPT_REMOVE_TARGET = "Preferences.MainPage.promptRemoveTarget"; //$NON-NLS-1$
Lines 37-43 Link Here
37
	public static final String DEPS_VIEW_SHOW_CALLERS = "DependenciesView.show.callers"; //$NON-NLS-1$
38
	public static final String DEPS_VIEW_SHOW_CALLERS = "DependenciesView.show.callers"; //$NON-NLS-1$
38
	public static final String DEPS_VIEW_SHOW_LIST = "DependenciesView.show.list"; //$NON-NLS-1$
39
	public static final String DEPS_VIEW_SHOW_LIST = "DependenciesView.show.list"; //$NON-NLS-1$
39
	public static final String DEPS_VIEW_SHOW_STATE = "DependenciesView.show.state"; //$NON-NLS-1$
40
	public static final String DEPS_VIEW_SHOW_STATE = "DependenciesView.show.state"; //$NON-NLS-1$
40
41
	// OSGi Frameworks
42
	public static final String DEFAULT_OSGI_FRAMEOWRK = "Preference.default.osgi.framework"; //$NON-NLS-1$
43
}
41
}
(-)src/org/eclipse/pde/internal/ui/PDEUIMessages.java (-17 lines)
Lines 52-59 Link Here
52
52
53
	public static String DependencyPropertiesDialog_exportGroupText;
53
	public static String DependencyPropertiesDialog_exportGroupText;
54
54
55
	public static String EclipsePluginValidationOperation_pluginMissing;
56
57
	public static String ExternalizeStringsOperation_editNames_addComment;
55
	public static String ExternalizeStringsOperation_editNames_addComment;
58
56
59
	public static String ExternalizeStringsOperation_editNames_insertProperty;
57
	public static String ExternalizeStringsOperation_editNames_insertProperty;
Lines 179-186 Link Here
179
177
180
	public static String LauncherUtils_workspaceLocked;
178
	public static String LauncherUtils_workspaceLocked;
181
179
182
	public static String LauncherUtils_cannotLaunchApplication;
183
184
	public static String LauncherUtils_clearLogFile;
180
	public static String LauncherUtils_clearLogFile;
185
181
186
	public static String LauncherUtils_generateConfigIni;
182
	public static String LauncherUtils_generateConfigIni;
Lines 895-907 Link Here
895
	public static String ConfigurationSection_selection;
891
	public static String ConfigurationSection_selection;
896
	public static String ConfigurationTab_fileDialogMessage;
892
	public static String ConfigurationTab_fileDialogMessage;
897
893
898
	public static String WorkbenchLauncherConfigurationDelegate_noJRE;
899
	public static String WorkbenchLauncherConfigurationDelegate_jrePathNotFound;
900
	public static String WorkbenchLauncherConfigurationDelegate_badFeatureSetup;
901
	public static String WorkbenchLauncherConfigurationDelegate_noStartup;
902
	public static String WorkbenchLauncherConfigurationDelegate_confirmDeleteWorkspace;
894
	public static String WorkbenchLauncherConfigurationDelegate_confirmDeleteWorkspace;
903
	public static String JUnitLaunchConfiguration_error_notaplugin;
904
	public static String JUnitLaunchConfiguration_error_missingPlugin;
905
895
906
	public static String Launcher_error_title;
896
	public static String Launcher_error_title;
907
	public static String LauncherSection_desc;
897
	public static String LauncherSection_desc;
Lines 910-916 Link Here
910
	public static String LauncherSection_icon;
900
	public static String LauncherSection_icon;
911
	public static String LauncherSection_tiny;
901
	public static String LauncherSection_tiny;
912
	public static String Launcher_error_code13;
902
	public static String Launcher_error_code13;
913
	public static String Launcher_error_code15;
914
	public static String Launcher_error_displayInLogView;
903
	public static String Launcher_error_displayInLogView;
915
	public static String Launcher_error_displayInSystemEditor;
904
	public static String Launcher_error_displayInSystemEditor;
916
	public static String LauncherSection_browse;
905
	public static String LauncherSection_browse;
Lines 933-940 Link Here
933
	public static String OpenLogDialog_cannotDisplay;
922
	public static String OpenLogDialog_cannotDisplay;
934
923
935
	public static String OSGiBundlesTab_frameworkLabel;
924
	public static String OSGiBundlesTab_frameworkLabel;
936
	public static String OSGiLaunchConfiguration_cannotFindLaunchConfiguration;
937
	public static String OSGiLaunchConfiguration_selected;
938
925
939
	// Preferences ####################################
926
	// Preferences ####################################
940
	public static String Preferences_MainPage_Description;
927
	public static String Preferences_MainPage_Description;
Lines 2103-2110 Link Here
2103
2090
2104
	public static String EquinoxSettingsTab_name;
2091
	public static String EquinoxSettingsTab_name;
2105
2092
2106
	public static String EquinoxLaunchConfiguration_oldTarget;
2107
2108
	public static String ModelChangeLabelProvider_instance;
2093
	public static String ModelChangeLabelProvider_instance;
2109
2094
2110
	public static String ModelChangeLabelProvider_instances;
2095
	public static String ModelChangeLabelProvider_instances;
Lines 2758-2765 Link Here
2758
	public static String HyperlinkActionOpenBundle;
2743
	public static String HyperlinkActionOpenBundle;
2759
	public static String HyperlinkActionOpenPackage;
2744
	public static String HyperlinkActionOpenPackage;
2760
2745
2761
	public static String VMHelper_cannotFindExecEnv;
2762
2763
	public static String HyperlinkActionOpenResource;
2746
	public static String HyperlinkActionOpenResource;
2764
	public static String HyperlinkActionOpenSchema;
2747
	public static String HyperlinkActionOpenSchema;
2765
	public static String HyperlinkActionOpenTranslation;
2748
	public static String HyperlinkActionOpenTranslation;
(-)src/org/eclipse/pde/internal/ui/editor/plugin/DependencyManagementSection.java (-3 / +4 lines)
Lines 19-25 Link Here
19
import org.eclipse.core.runtime.NullProgressMonitor;
19
import org.eclipse.core.runtime.NullProgressMonitor;
20
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
20
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
21
import org.eclipse.jface.action.*;
21
import org.eclipse.jface.action.*;
22
import org.eclipse.jface.preference.IPreferenceStore;
23
import org.eclipse.jface.util.IPropertyChangeListener;
22
import org.eclipse.jface.util.IPropertyChangeListener;
24
import org.eclipse.jface.util.PropertyChangeEvent;
23
import org.eclipse.jface.util.PropertyChangeEvent;
25
import org.eclipse.jface.viewers.*;
24
import org.eclipse.jface.viewers.*;
Lines 33-38 Link Here
33
import org.eclipse.pde.internal.core.plugin.ExternalPluginModel;
32
import org.eclipse.pde.internal.core.plugin.ExternalPluginModel;
34
import org.eclipse.pde.internal.core.plugin.WorkspacePluginModel;
33
import org.eclipse.pde.internal.core.plugin.WorkspacePluginModel;
35
import org.eclipse.pde.internal.core.text.build.BuildEntry;
34
import org.eclipse.pde.internal.core.text.build.BuildEntry;
35
import org.eclipse.pde.internal.launching.ILaunchingPreferenceConstants;
36
import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
36
import org.eclipse.pde.internal.ui.*;
37
import org.eclipse.pde.internal.ui.*;
37
import org.eclipse.pde.internal.ui.dialogs.PluginSelectionDialog;
38
import org.eclipse.pde.internal.ui.dialogs.PluginSelectionDialog;
38
import org.eclipse.pde.internal.ui.editor.*;
39
import org.eclipse.pde.internal.ui.editor.*;
Lines 393-400 Link Here
393
					entry.addToken(pmodel.getPlugin().getId());
394
					entry.addToken(pmodel.getPlugin().getId());
394
				}
395
				}
395
				markDirty();
396
				markDirty();
396
				IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore();
397
				PDEPreferencesManager store = PDELaunchingPlugin.getDefault().getPreferenceManager();
397
				store.setDefault(IPreferenceConstants.PROP_AUTO_MANAGE, true);
398
				store.setDefault(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE, true);
398
			} catch (CoreException e) {
399
			} catch (CoreException e) {
399
				PDEPlugin.logException(e);
400
				PDEPlugin.logException(e);
400
			}
401
			}
(-)schema/osgiFrameworks.exsd (-159 lines)
Removed Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.pde.ui">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.pde.ui" id="osgiFrameworks" name="OSGi Frameworks"/>
7
      </appInfo>
8
      <documentation>
9
         &lt;p&gt;
10
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 &lt;b&gt;OSGi Framework&lt;/b&gt; launch configuration.
11
&lt;/p&gt;
12
&lt;p&gt;Registered OSGi frameworks appear on the &lt;b&gt;Plug-in Development &gt; OSGi frameworks&lt;/b&gt; preference page, where a default framework can be set.
13
&lt;/p&gt;
14
      </documentation>
15
   </annotation>
16
17
   <element name="extension">
18
      <complexType>
19
         <sequence>
20
            <element ref="framework" minOccurs="1" maxOccurs="unbounded"/>
21
         </sequence>
22
         <attribute name="point" type="string" use="required">
23
            <annotation>
24
               <documentation>
25
                  
26
               </documentation>
27
            </annotation>
28
         </attribute>
29
         <attribute name="id" type="string">
30
            <annotation>
31
               <documentation>
32
                  
33
               </documentation>
34
            </annotation>
35
         </attribute>
36
         <attribute name="name" type="string">
37
            <annotation>
38
               <documentation>
39
                  
40
               </documentation>
41
               <appInfo>
42
                  <meta.attribute translatable="true"/>
43
               </appInfo>
44
            </annotation>
45
         </attribute>
46
      </complexType>
47
   </element>
48
49
   <element name="framework">
50
      <complexType>
51
         <attribute name="id" type="string" use="required">
52
            <annotation>
53
               <documentation>
54
                  a unique identifier of the framework
55
               </documentation>
56
            </annotation>
57
         </attribute>
58
         <attribute name="name" type="string" use="required">
59
            <annotation>
60
               <documentation>
61
                  human-readable name of the OSGi framework
62
               </documentation>
63
               <appInfo>
64
                  <meta.attribute translatable="true"/>
65
               </appInfo>
66
            </annotation>
67
         </attribute>
68
         <attribute name="launcherDelegate" type="string" use="required">
69
            <annotation>
70
               <documentation>
71
                  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 &lt;code&gt;org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration&lt;/code&gt;.
72
               </documentation>
73
               <appInfo>
74
                  <meta.attribute kind="java" basedOn="org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration"/>
75
               </appInfo>
76
            </annotation>
77
         </attribute>
78
         <attribute name="initializer" type="string">
79
            <annotation>
80
               <documentation>
81
                  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 &lt;code&gt;org.eclipse.pde.ui.launcher.OSGiLaunchConfigurationInitializer&lt;/code&gt;.  If not specified, the default initializer &lt;code&gt;org.eclipse.pde.ui.launcher.OSGiLaunchConfigurationInitializer&lt;/code&gt; is instantiated.
82
               </documentation>
83
               <appInfo>
84
                  <meta.attribute kind="java" basedOn="org.eclipse.pde.ui.launcher.OSGiLaunchConfigurationInitializer"/>
85
               </appInfo>
86
            </annotation>
87
         </attribute>
88
      </complexType>
89
   </element>
90
91
   <annotation>
92
      <appInfo>
93
         <meta.section type="since"/>
94
      </appInfo>
95
      <documentation>
96
         3.3
97
      </documentation>
98
   </annotation>
99
100
   <annotation>
101
      <appInfo>
102
         <meta.section type="examples"/>
103
      </appInfo>
104
      <documentation>
105
         &lt;p&gt;
106
The following is an example of the extension point:
107
&lt;pre&gt;
108
   &lt;extension
109
         point=&quot;org.eclipse.pde.ui.osgiFrameworks&quot;&gt;
110
      &lt;framework
111
            launcherDelegate=&quot;org.eclipse.pde.ui.launcher.EquinoxLaunchConfiguration&quot;
112
            id=&quot;org.eclipse.pde.ui.EquinoxFramework&quot;
113
            name=&quot;%Equinox.shortcut.label&quot; 
114
            initializer=&quot;org.eclipse.pde.internal.ui.launcher.EquinoxInitializer&quot;/&gt;
115
   &lt;/extension&gt;
116
&lt;/pre&gt;
117
      </documentation>
118
   </annotation>
119
120
   <annotation>
121
      <appInfo>
122
         <meta.section type="apiInfo"/>
123
      </appInfo>
124
      <documentation>
125
         &lt;p&gt;
126
The value of the attribute &lt;code&gt;launcherDelegate&lt;/code&gt; must be a fully qualified name of a Java class that extends &lt;code&gt;org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration&lt;/code&gt;.  If the launcher is to provide its own source lookup order, then the method &lt;code&gt;setDefaultSourceLocator&lt;/code&gt; should be overridden.
127
&lt;/p&gt;
128
&lt;p&gt;
129
The value of the attribute &lt;code&gt;initializer&lt;/code&gt; must be a fully qualified name of a Java class that extends &lt;code&gt;org.eclipse.ui.launcher.OSGiLaunchConfigurationInitializer&lt;/code&gt;.
130
&lt;/p&gt;
131
      </documentation>
132
   </annotation>
133
134
   <annotation>
135
      <appInfo>
136
         <meta.section type="implementation"/>
137
      </appInfo>
138
      <documentation>
139
         &lt;p&gt;
140
PDE supplies the Equinox OSGi Framework extension to launch Equinox frameworks.
141
&lt;/p&gt;
142
      </documentation>
143
   </annotation>
144
145
   <annotation>
146
      <appInfo>
147
         <meta.section type="copyright"/>
148
      </appInfo>
149
      <documentation>
150
         Copyright (c) 2006 IBM Corporation and others.
151
&lt;br&gt;
152
All rights reserved. This program and the accompanying materials are made 
153
available under the terms of the Eclipse Public License v1.0 which 
154
accompanies this distribution, and is available at 
155
&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;.
156
      </documentation>
157
   </annotation>
158
159
</schema>
(-)src/org/eclipse/pde/internal/ui/wizards/product/ProductFileWizardPage.java (-1 / +2 lines)
Lines 11-16 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.wizards.product;
12
package org.eclipse.pde.internal.ui.wizards.product;
13
13
14
import org.eclipse.pde.launching.IPDELauncherConstants;
15
14
import java.util.ArrayList;
16
import java.util.ArrayList;
15
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.resources.IResource;
Lines 24-30 Link Here
24
import org.eclipse.pde.internal.ui.*;
26
import org.eclipse.pde.internal.ui.*;
25
import org.eclipse.pde.internal.ui.wizards.PDEWizardNewFileCreationPage;
27
import org.eclipse.pde.internal.ui.wizards.PDEWizardNewFileCreationPage;
26
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
28
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
27
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
28
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.events.SelectionAdapter;
30
import org.eclipse.swt.events.SelectionAdapter;
30
import org.eclipse.swt.events.SelectionEvent;
31
import org.eclipse.swt.events.SelectionEvent;
(-)src/org/eclipse/pde/internal/ui/wizards/product/ProductFromConfigOperation.java (-2 / +4 lines)
Lines 11-16 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.wizards.product;
12
package org.eclipse.pde.internal.ui.wizards.product;
13
13
14
import org.eclipse.pde.launching.IPDELauncherConstants;
15
16
import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper;
17
14
import java.util.*;
18
import java.util.*;
15
import org.eclipse.core.resources.IContainer;
19
import org.eclipse.core.resources.IContainer;
16
import org.eclipse.core.resources.IFile;
20
import org.eclipse.core.resources.IFile;
Lines 21-28 Link Here
21
import org.eclipse.pde.internal.core.iproduct.*;
25
import org.eclipse.pde.internal.core.iproduct.*;
22
import org.eclipse.pde.internal.core.iproduct.IProduct;
26
import org.eclipse.pde.internal.core.iproduct.IProduct;
23
import org.eclipse.pde.internal.ui.PDEPlugin;
27
import org.eclipse.pde.internal.ui.PDEPlugin;
24
import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper;
25
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
26
28
27
/**
29
/**
28
 * This operation generates a product configuration filling in fields based on information
30
 * This operation generates a product configuration filling in fields based on information
(-)META-INF/MANIFEST.MF (-2 / +3 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %name
3
Bundle-Name: %name
4
Bundle-SymbolicName: org.eclipse.pde.ui; singleton:=true
4
Bundle-SymbolicName: org.eclipse.pde.ui; singleton:=true
5
Bundle-Version: 3.5.100.qualifier
5
Bundle-Version: 3.6.0.qualifier
6
Bundle-Activator: org.eclipse.pde.internal.ui.PDEPlugin
6
Bundle-Activator: org.eclipse.pde.internal.ui.PDEPlugin
7
Bundle-Vendor: %provider-name
7
Bundle-Vendor: %provider-name
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
Lines 103-109 Link Here
103
 org.eclipse.equinox.p2.metadata.repository;bundle-version="[1.0.100,2.0.0)",
103
 org.eclipse.equinox.p2.metadata.repository;bundle-version="[1.0.100,2.0.0)",
104
 org.eclipse.equinox.frameworkadmin;bundle-version="[1.0.100,2.0.0)",
104
 org.eclipse.equinox.frameworkadmin;bundle-version="[1.0.100,2.0.0)",
105
 org.eclipse.equinox.frameworkadmin.equinox;bundle-version="[1.0.100,2.0.0)",
105
 org.eclipse.equinox.frameworkadmin.equinox;bundle-version="[1.0.100,2.0.0)",
106
 org.eclipse.equinox.p2.repository;bundle-version="[1.0.0,2.0.0)"
106
 org.eclipse.equinox.p2.repository;bundle-version="[1.0.0,2.0.0)",
107
 org.eclipse.pde.launching;bundle-version="[3.6.0,4.0.0)";visibility:=reexport
107
Eclipse-LazyStart: true
108
Eclipse-LazyStart: true
108
Import-Package: com.ibm.icu.text,
109
Import-Package: com.ibm.icu.text,
109
 org.eclipse.jdt.debug.core
110
 org.eclipse.jdt.debug.core
(-)src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizardPage.java (-3 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-20 Link Here
14
import org.eclipse.jface.dialogs.Dialog;
14
import org.eclipse.jface.dialogs.Dialog;
15
import org.eclipse.jface.dialogs.IDialogSettings;
15
import org.eclipse.jface.dialogs.IDialogSettings;
16
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
16
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
17
import org.eclipse.pde.internal.ui.*;
17
import org.eclipse.pde.internal.launching.ILaunchingPreferenceConstants;
18
import org.eclipse.pde.internal.ui.IHelpContextIds;
19
import org.eclipse.pde.internal.ui.PDEUIMessages;
18
import org.eclipse.pde.internal.ui.refactoring.PDERefactor;
20
import org.eclipse.pde.internal.ui.refactoring.PDERefactor;
19
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.events.*;
22
import org.eclipse.swt.events.*;
Lines 23-29 Link Here
23
import org.eclipse.swt.widgets.*;
25
import org.eclipse.swt.widgets.*;
24
import org.eclipse.ui.PlatformUI;
26
import org.eclipse.ui.PlatformUI;
25
27
26
public class OrganizeManifestsWizardPage extends UserInputWizardPage implements IPreferenceConstants, IOrganizeManifestsSettings {
28
public class OrganizeManifestsWizardPage extends UserInputWizardPage implements ILaunchingPreferenceConstants, IOrganizeManifestsSettings {
27
29
28
	private Button fRemoveUnresolved;
30
	private Button fRemoveUnresolved;
29
	private Button fCalculateUses;
31
	private Button fCalculateUses;
(-)src/org/eclipse/pde/internal/ui/editor/product/ProductValidateAction.java (-1 / +1 lines)
Lines 21-28 Link Here
21
import org.eclipse.pde.internal.core.*;
21
import org.eclipse.pde.internal.core.*;
22
import org.eclipse.pde.internal.core.ifeature.*;
22
import org.eclipse.pde.internal.core.ifeature.*;
23
import org.eclipse.pde.internal.core.iproduct.*;
23
import org.eclipse.pde.internal.core.iproduct.*;
24
import org.eclipse.pde.internal.launching.launcher.*;
24
import org.eclipse.pde.internal.ui.*;
25
import org.eclipse.pde.internal.ui.*;
25
import org.eclipse.pde.internal.ui.launcher.*;
26
26
27
public class ProductValidateAction extends Action {
27
public class ProductValidateAction extends Action {
28
28
(-)src/org/eclipse/pde/internal/ui/editor/PDEMultiPageContentOutline.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 *  Copyright (c) 2000, 2008 IBM Corporation and others.
2
 *  Copyright (c) 2000, 2009 IBM Corporation and others.
3
 *  All rights reserved. This program and the accompanying materials
3
 *  All rights reserved. This program and the accompanying materials
4
 *  are made available under the terms of the Eclipse Public License v1.0
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 *  which accompanies this distribution, and is available at
5
 *  which accompanies this distribution, and is available at
Lines 13-18 Link Here
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import org.eclipse.jface.action.*;
14
import org.eclipse.jface.action.*;
15
import org.eclipse.jface.viewers.*;
15
import org.eclipse.jface.viewers.*;
16
import org.eclipse.pde.internal.launching.ILaunchingPreferenceConstants;
16
import org.eclipse.pde.internal.ui.*;
17
import org.eclipse.pde.internal.ui.*;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.events.FocusListener;
19
import org.eclipse.swt.events.FocusListener;
Lines 24-30 Link Here
24
import org.eclipse.ui.part.PageBook;
25
import org.eclipse.ui.part.PageBook;
25
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
26
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
26
27
27
public class PDEMultiPageContentOutline extends Page implements IContentOutlinePage, ISelectionProvider, ISelectionChangedListener, IPreferenceConstants {
28
public class PDEMultiPageContentOutline extends Page implements IContentOutlinePage, ISelectionProvider, ISelectionChangedListener, ILaunchingPreferenceConstants {
28
	private PageBook pagebook;
29
	private PageBook pagebook;
29
	private ISelection selection;
30
	private ISelection selection;
30
	private ArrayList listeners;
31
	private ArrayList listeners;
(-)src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java (-1 / +2 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.wizards.imports;
11
package org.eclipse.pde.internal.ui.wizards.imports;
12
12
13
import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper;
14
13
import java.util.*;
15
import java.util.*;
14
import org.eclipse.core.resources.ResourcesPlugin;
16
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
Lines 22-28 Link Here
22
import org.eclipse.pde.core.plugin.IPluginModelBase;
24
import org.eclipse.pde.core.plugin.IPluginModelBase;
23
import org.eclipse.pde.internal.core.SourceLocationManager;
25
import org.eclipse.pde.internal.core.SourceLocationManager;
24
import org.eclipse.pde.internal.ui.*;
26
import org.eclipse.pde.internal.ui.*;
25
import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper;
26
import org.eclipse.swt.widgets.Shell;
27
import org.eclipse.swt.widgets.Shell;
27
import org.eclipse.ui.IImportWizard;
28
import org.eclipse.ui.IImportWizard;
28
import org.eclipse.ui.IWorkbench;
29
import org.eclipse.ui.IWorkbench;
(-)src/org/eclipse/pde/internal/ui/launcher/PluginValidationStatusHandler.java (+57 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 eXXcellent solutions gmbh, EclipseSource Corporation
3
 * and others.
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *     Achim Demelt, eXXcellent solutions gmbh - initial API and implementation
11
 *     EclipseSource - initial API and implementation, ongoing enhancements
12
 *******************************************************************************/
13
package org.eclipse.pde.internal.ui.launcher;
14
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.debug.core.IStatusHandler;
17
import org.eclipse.jface.dialogs.IDialogConstants;
18
import org.eclipse.osgi.util.NLS;
19
import org.eclipse.pde.internal.launching.PDEMessages;
20
import org.eclipse.pde.internal.launching.launcher.*;
21
import org.eclipse.pde.internal.ui.*;
22
import org.eclipse.pde.internal.ui.elements.NamedElement;
23
import org.eclipse.swt.graphics.Image;
24
import org.eclipse.swt.widgets.Display;
25
26
public class PluginValidationStatusHandler implements IStatusHandler {
27
	public Object handleStatus(IStatus status, Object source) throws CoreException {
28
		if (status.getCode() == EclipsePluginValidationOperation.CREATE_EXTENSION_ERROR_CODE)
29
			return createExtensionError((String) source);
30
		else if (status.getCode() == LaunchPluginValidator.DISPLAY_VALIDATION_ERROR_CODE)
31
			displayValidationError((LaunchValidationOperation) source);
32
		return null;
33
	}
34
35
	private Object createExtensionError(String bundleID) {
36
		String name = NLS.bind(PDEMessages.EclipsePluginValidationOperation_pluginMissing, bundleID);
37
		PDELabelProvider provider = PDEPlugin.getDefault().getLabelProvider();
38
		Image image = provider.get(PDEPluginImages.DESC_PLUGIN_OBJ);
39
		return new NamedElement(name, image);
40
	}
41
42
	private void displayValidationError(final LaunchValidationOperation op) throws CoreException {
43
		final int[] result = new int[1];
44
		final Display display = LauncherUtilsStatusHandler.getDisplay();
45
		display.syncExec(new Runnable() {
46
			public void run() {
47
				PluginStatusDialog dialog = new PluginStatusDialog(display.getActiveShell());
48
				dialog.showCancelButton(true);
49
				dialog.setInput(op.getInput());
50
				result[0] = dialog.open();
51
			}
52
		});
53
		if (result[0] == IDialogConstants.CANCEL_ID)
54
			throw new CoreException(Status.CANCEL_STATUS);
55
	}
56
57
}
(-)src/org/eclipse/pde/internal/ui/launcher/LauncherUtilsStatusHandler.java (+148 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 eXXcellent solutions gmbh, EclipseSource Corporation
3
 * and others.
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *     Achim Demelt, eXXcellent solutions gmbh - initial API and implementation
11
 *     EclipseSource - initial API and implementation, ongoing enhancements
12
 *******************************************************************************/
13
package org.eclipse.pde.internal.ui.launcher;
14
15
import java.util.*;
16
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.runtime.*;
18
import org.eclipse.debug.core.IStatusHandler;
19
import org.eclipse.jface.dialogs.IDialogConstants;
20
import org.eclipse.jface.dialogs.MessageDialog;
21
import org.eclipse.ltk.core.refactoring.Change;
22
import org.eclipse.osgi.util.NLS;
23
import org.eclipse.pde.internal.launching.PDEMessages;
24
import org.eclipse.pde.internal.launching.launcher.LauncherUtils;
25
import org.eclipse.pde.internal.ui.PDEPlugin;
26
import org.eclipse.pde.internal.ui.PDEUIMessages;
27
import org.eclipse.pde.internal.ui.wizards.tools.OrganizeManifestsProcessor;
28
import org.eclipse.swt.widgets.Display;
29
import org.eclipse.swt.widgets.Shell;
30
import org.eclipse.ui.IWorkbenchWindow;
31
32
public class LauncherUtilsStatusHandler implements IStatusHandler {
33
34
	public Object handleStatus(IStatus status, Object source) throws CoreException {
35
		if (status.getCode() == LauncherUtils.WORKSPACE_LOCKED)
36
			handleWorkspaceLocked((String) source);
37
		else if (status.getCode() == LauncherUtils.CLEAR_LOG)
38
			return clearLog();
39
		else if (status.getCode() == LauncherUtils.DELETE_WORKSPACE)
40
			return deleteWorkspace((String) source);
41
		else if (status.getCode() == LauncherUtils.GENERATE_CONFIG_INI)
42
			return generateConfigIni();
43
		else if (status.getCode() == LauncherUtils.ORGANIZE_MANIFESTS) {
44
			Object[] args = (Object[]) source;
45
			organizeManifests((ArrayList) args[0], (IProgressMonitor) args[1], (Properties) args[2]);
46
		}
47
		return null;
48
	}
49
50
	private Boolean generateConfigIni() {
51
		String message = PDEUIMessages.LauncherUtils_generateConfigIni;
52
		return Boolean.valueOf(generateDialog(message).intValue() == 0);
53
	}
54
55
	private Integer deleteWorkspace(String path) {
56
		return generateDialog(NLS.bind(PDEUIMessages.WorkbenchLauncherConfigurationDelegate_confirmDeleteWorkspace, path));
57
	}
58
59
	private Integer clearLog() {
60
		return generateDialog(PDEUIMessages.LauncherUtils_clearLogFile);
61
	}
62
63
	private void handleWorkspaceLocked(String workspace) {
64
		generateErrorDialog(PDEUIMessages.LauncherUtils_workspaceLocked, NLS.bind(PDEMessages.LauncherUtils_cannotLaunchApplication, workspace));
65
	}
66
67
	private void organizeManifests(final ArrayList projects, final IProgressMonitor monitor, final Properties lastRun) {
68
		Display.getDefault().syncExec(new Runnable() {
69
			public void run() {
70
				OrganizeManifestsProcessor processor = new OrganizeManifestsProcessor(projects);
71
				initializeProcessor(processor);
72
				try {
73
					Change change = processor.createChange(monitor);
74
					change.perform(monitor);
75
					// update table for each project with current time stamp
76
					Properties table = lastRun;
77
					String ts = Long.toString(System.currentTimeMillis());
78
					Iterator it = projects.iterator();
79
					while (it.hasNext())
80
						table.put(((IProject) it.next()).getName(), ts);
81
				} catch (OperationCanceledException e) {
82
				} catch (CoreException e) {
83
				}
84
			}
85
		});
86
	}
87
88
	public static Display getDisplay() {
89
		Display display = Display.getCurrent();
90
		if (display == null) {
91
			display = Display.getDefault();
92
		}
93
		return display;
94
	}
95
96
	public final static Shell getActiveShell() {
97
		IWorkbenchWindow window = PDEPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
98
		if (window == null) {
99
			IWorkbenchWindow[] windows = PDEPlugin.getDefault().getWorkbench().getWorkbenchWindows();
100
			if (windows.length > 0)
101
				return windows[0].getShell();
102
		} else
103
			return window.getShell();
104
		return getDisplay().getActiveShell();
105
	}
106
107
	private static void initializeProcessor(OrganizeManifestsProcessor processor) {
108
		processor.setAddMissing(false);
109
		processor.setRemoveUnresolved(false);
110
		processor.setModifyDep(false);
111
		processor.setRemoveLazy(false);
112
		processor.setRemoveUselessFiles(false);
113
		processor.setAddDependencies(true);
114
		processor.setCalculateUses(false);
115
		processor.setMarkInternal(false);
116
		processor.setPrefixIconNL(false);
117
		processor.setUnusedDependencies(false);
118
		processor.setUnusedKeys(false);
119
	}
120
121
	/**
122
	 * Creates a message dialog using a syncExec in case we are launching in the background.
123
	 * Dialog will be a question dialog with Yes, No and Cancel buttons.
124
	 * @param message Message to use in the dialog
125
	 * @return int representing the button clicked (-1 or 2 for cancel, 0 for yes, 1 for no).
126
	 */
127
	private static Integer generateDialog(final String message) {
128
		final int[] result = new int[1];
129
		getDisplay().syncExec(new Runnable() {
130
			public void run() {
131
				String title = PDEUIMessages.LauncherUtils_title;
132
				MessageDialog dialog = new MessageDialog(getActiveShell(), title, null, message, MessageDialog.QUESTION, new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL}, 0);
133
				result[0] = dialog.open();
134
			}
135
		});
136
		return new Integer(result[0]);
137
	}
138
139
	private static void generateErrorDialog(final String title, final String message) {
140
		getDisplay().syncExec(new Runnable() {
141
			public void run() {
142
				MessageDialog dialog = new MessageDialog(getActiveShell(), title, null, message, MessageDialog.ERROR, new String[] {IDialogConstants.OK_LABEL}, 0);
143
				dialog.open();
144
			}
145
		});
146
	}
147
148
}
(-)src/org/eclipse/pde/internal/ui/launcher/LaunchTerminationStatusHandler.java (+87 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 eXXcellent solutions gmbh, EclipseSource Corporation
3
 * and others.
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *     Achim Demelt, eXXcellent solutions gmbh - initial API and implementation
11
 *     EclipseSource - initial API and implementation, ongoing enhancements
12
 *******************************************************************************/
13
package org.eclipse.pde.internal.ui.launcher;
14
15
import java.io.File;
16
import org.eclipse.core.filesystem.EFS;
17
import org.eclipse.core.filesystem.IFileStore;
18
import org.eclipse.core.runtime.*;
19
import org.eclipse.debug.core.ILaunch;
20
import org.eclipse.debug.core.IStatusHandler;
21
import org.eclipse.jface.dialogs.IDialogConstants;
22
import org.eclipse.jface.dialogs.MessageDialog;
23
import org.eclipse.pde.internal.launching.PDEMessages;
24
import org.eclipse.pde.internal.launching.launcher.LaunchListener;
25
import org.eclipse.pde.internal.ui.PDEPlugin;
26
import org.eclipse.pde.internal.ui.PDEUIMessages;
27
import org.eclipse.swt.widgets.Display;
28
import org.eclipse.ui.*;
29
import org.eclipse.ui.ide.IDE;
30
import org.eclipse.ui.internal.views.log.LogView;
31
32
public class LaunchTerminationStatusHandler implements IStatusHandler {
33
	// different ways to open the error log
34
	public static final int OPEN_IN_ERROR_LOG_VIEW = 0;
35
	public static final int OPEN_IN_SYSTEM_EDITOR = 1;
36
37
	public Object handleStatus(IStatus status, Object source) throws CoreException {
38
		if (status.getCode() == 13)
39
			handleOtherReasonsFoundInLog((ILaunch) source);
40
		else if (status.getCode() == 15)
41
			handleWorkspaceInUse();
42
		return null;
43
	}
44
45
	private void handleWorkspaceInUse() {
46
		Display.getDefault().asyncExec(new Runnable() {
47
			public void run() {
48
				MessageDialog.openError(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.Launcher_error_title, PDEMessages.Launcher_error_code15);
49
			}
50
		});
51
	}
52
53
	private void handleOtherReasonsFoundInLog(final ILaunch launch) {
54
		Display.getDefault().asyncExec(new Runnable() {
55
			public void run() {
56
				try {
57
					File log = LaunchListener.getMostRecentLogFile(launch.getLaunchConfiguration());
58
					if (log != null && log.exists()) {
59
						MessageDialog dialog = new MessageDialog(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.Launcher_error_title, null, // accept the default window icon
60
								PDEUIMessages.Launcher_error_code13, MessageDialog.ERROR, new String[] {PDEUIMessages.Launcher_error_displayInLogView, PDEUIMessages.Launcher_error_displayInSystemEditor, IDialogConstants.NO_LABEL}, OPEN_IN_ERROR_LOG_VIEW);
61
						int dialog_value = dialog.open();
62
						if (dialog_value == OPEN_IN_ERROR_LOG_VIEW) {
63
							LogView errlog = (LogView) PDEPlugin.getActivePage().showView("org.eclipse.pde.runtime.LogView"); //$NON-NLS-1$
64
							errlog.handleImportPath(log.getAbsolutePath());
65
							errlog.sortByDateDescending();
66
						} else if (dialog_value == OPEN_IN_SYSTEM_EDITOR) {
67
							openInEditor(log);
68
						}
69
					}
70
				} catch (CoreException e) {
71
				}
72
			}
73
		});
74
	}
75
76
	private void openInEditor(File log) {
77
		IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(log.getAbsolutePath()));
78
		if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) {
79
			IWorkbenchWindow ww = PDEPlugin.getActiveWorkbenchWindow();
80
			IWorkbenchPage page = ww.getActivePage();
81
			try {
82
				IDE.openEditorOnFileStore(page, fileStore);
83
			} catch (PartInitException e) {
84
			}
85
		}
86
	}
87
}
(-)src/org/eclipse/pde/internal/ui/launcher/GenericExceptionStatusHandler.java (+25 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 eXXcellent solutions gmbh and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Achim Demelt, eXXcellent solutions gmbh - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.debug.core.IStatusHandler;
16
import org.eclipse.pde.internal.ui.PDEPlugin;
17
18
public class GenericExceptionStatusHandler implements IStatusHandler {
19
20
	public Object handleStatus(IStatus status, Object source) throws CoreException {
21
		PDEPlugin.logException(status.getException());
22
		return null;
23
	}
24
25
}

Return to bug 278845