Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 269111 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/ui/launcher/OSGiValidationOperation.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2007, 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     EclipseSource Corporation - ongoing enhancements
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
package org.eclipse.pde.internal.ui.launcher;
12
13
Lines 21-27 Link Here
21
	}
22
	}
22
23
23
	protected IPluginModelBase[] getModels() throws CoreException {
24
	protected IPluginModelBase[] getModels() throws CoreException {
24
		return BundleLauncherHelper.getMergedBundles(fLaunchConfiguration);
25
		return BundleLauncherHelper.getMergedBundles(fLaunchConfiguration, true);
25
	}
26
	}
26
27
27
}
28
}
(-)src/org/eclipse/pde/internal/ui/launcher/LaunchPluginValidator.java (-164 / +2 lines)
Lines 14-157 Link Here
14
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.runtime.*;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
18
import org.eclipse.jdt.core.IJavaProject;
17
import org.eclipse.jdt.core.IJavaProject;
19
import org.eclipse.jdt.core.JavaCore;
18
import org.eclipse.jdt.core.JavaCore;
20
import org.eclipse.jface.dialogs.IDialogConstants;
19
import org.eclipse.jface.dialogs.IDialogConstants;
21
import org.eclipse.osgi.service.resolver.BundleDescription;
22
import org.eclipse.pde.core.plugin.*;
20
import org.eclipse.pde.core.plugin.*;
23
import org.eclipse.pde.internal.build.IPDEBuildConstants;
21
import org.eclipse.pde.internal.core.PDECore;
24
import org.eclipse.pde.internal.core.*;
22
import org.eclipse.pde.internal.core.SearchablePluginsManager;
25
import org.eclipse.pde.internal.ui.IPDEUIConstants;
23
import org.eclipse.pde.internal.ui.IPDEUIConstants;
26
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
24
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
27
import org.eclipse.swt.widgets.Display;
25
import org.eclipse.swt.widgets.Display;
28
26
29
public class LaunchPluginValidator {
27
public class LaunchPluginValidator {
30
28
31
	public static void checkBackwardCompatibility(ILaunchConfiguration configuration, boolean save) throws CoreException {
32
		ILaunchConfigurationWorkingCopy wc = null;
33
		if (configuration.isWorkingCopy()) {
34
			wc = (ILaunchConfigurationWorkingCopy) configuration;
35
		} else {
36
			wc = configuration.getWorkingCopy();
37
		}
38
39
		String value = configuration.getAttribute("wsproject", (String) null); //$NON-NLS-1$
40
		if (value != null) {
41
			wc.setAttribute("wsproject", (String) null); //$NON-NLS-1$
42
			if (value.indexOf(';') != -1) {
43
				value = value.replace(';', ',');
44
			} else if (value.indexOf(':') != -1) {
45
				value = value.replace(':', ',');
46
			}
47
			value = (value.length() == 0 || value.equals(",")) //$NON-NLS-1$
48
			? null
49
					: value.substring(0, value.length() - 1);
50
51
			boolean automatic = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
52
			String attr = automatic ? IPDELauncherConstants.DESELECTED_WORKSPACE_PLUGINS : IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS;
53
			wc.setAttribute(attr, value);
54
		}
55
56
		String value2 = configuration.getAttribute("extplugins", (String) null); //$NON-NLS-1$
57
		if (value2 != null) {
58
			wc.setAttribute("extplugins", (String) null); //$NON-NLS-1$
59
			if (value2.indexOf(';') != -1) {
60
				value2 = value2.replace(';', ',');
61
			} else if (value2.indexOf(':') != -1) {
62
				value2 = value2.replace(':', ',');
63
			}
64
			value2 = (value2.length() == 0 || value2.equals(",")) ? null : value2.substring(0, value2.length() - 1); //$NON-NLS-1$
65
			wc.setAttribute(IPDELauncherConstants.SELECTED_TARGET_PLUGINS, value2);
66
		}
67
68
		String version = configuration.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, (String) null);
69
		boolean newApp = TargetPlatformHelper.usesNewApplicationModel();
70
		boolean upgrade = !"3.3".equals(version) && newApp; //$NON-NLS-1$
71
		if (!upgrade)
72
			upgrade = TargetPlatformHelper.getTargetVersion() >= 3.2 && version == null;
73
		if (upgrade) {
74
			wc.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, newApp ? "3.3" : "3.2a"); //$NON-NLS-1$ //$NON-NLS-2$
75
			boolean usedefault = configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true);
76
			boolean useFeatures = configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false);
77
			boolean automaticAdd = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
78
			if (!usedefault && !useFeatures) {
79
				ArrayList list = new ArrayList();
80
				if (version == null) {
81
					list.add("org.eclipse.core.contenttype"); //$NON-NLS-1$
82
					list.add("org.eclipse.core.jobs"); //$NON-NLS-1$
83
					list.add(IPDEBuildConstants.BUNDLE_EQUINOX_COMMON);
84
					list.add("org.eclipse.equinox.preferences"); //$NON-NLS-1$
85
					list.add("org.eclipse.equinox.registry"); //$NON-NLS-1$
86
					list.add("org.eclipse.core.runtime.compatibility.registry"); //$NON-NLS-1$
87
				}
88
				if (!"3.3".equals(version) && newApp) //$NON-NLS-1$
89
					list.add("org.eclipse.equinox.app"); //$NON-NLS-1$
90
				StringBuffer extensions = new StringBuffer(configuration.getAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS, "")); //$NON-NLS-1$
91
				StringBuffer target = new StringBuffer(configuration.getAttribute(IPDELauncherConstants.SELECTED_TARGET_PLUGINS, "")); //$NON-NLS-1$
92
				for (int i = 0; i < list.size(); i++) {
93
					String plugin = list.get(i).toString();
94
					IPluginModelBase model = PluginRegistry.findModel(plugin);
95
					if (model == null)
96
						continue;
97
					if (model.getUnderlyingResource() != null) {
98
						if (automaticAdd)
99
							continue;
100
						if (extensions.length() > 0)
101
							extensions.append(","); //$NON-NLS-1$
102
						extensions.append(plugin);
103
					} else {
104
						if (target.length() > 0)
105
							target.append(","); //$NON-NLS-1$
106
						target.append(plugin);
107
					}
108
				}
109
				if (extensions.length() > 0)
110
					wc.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS, extensions.toString());
111
				if (target.length() > 0)
112
					wc.setAttribute(IPDELauncherConstants.SELECTED_TARGET_PLUGINS, target.toString());
113
			}
114
		}
115
116
		if (save && (value != null || value2 != null || upgrade))
117
			wc.doSave();
118
	}
119
120
	private static void addToMap(Map map, IPluginModelBase[] models) {
121
		for (int i = 0; i < models.length; i++) {
122
			addToMap(map, models[i]);
123
		}
124
	}
125
126
	private static void addToMap(Map map, IPluginModelBase model) {
127
		BundleDescription desc = model.getBundleDescription();
128
		if (desc != null) {
129
			String id = desc.getSymbolicName();
130
			// the reason that we are using a map is to easily check
131
			// if a plug-in with a certain id is among the plug-ins we are launching with.
132
			// Therefore, now that we support multiple plug-ins by the same ID,
133
			// once a particular ID is used up as a key, the rest can be entered
134
			// with key == id_version, for easy retrieval of values later on,
135
			// and without the need to create complicated data structures for values.
136
			if (!map.containsKey(id)) {
137
				map.put(id, model);
138
			} else {
139
				// since other code grabs only the model matching the "id", we want to make
140
				// sure the model matching the "id" has the highest version (because for singletons
141
				// the runtime will only resolve the highest version).  Bug 218393
142
				IPluginModelBase oldModel = (IPluginModelBase) map.get(id);
143
				String oldVersion = oldModel.getPluginBase().getVersion();
144
				String newVersion = model.getPluginBase().getVersion();
145
				if (oldVersion.compareTo(newVersion) < 0) {
146
					map.put(id + "_" + oldModel.getBundleDescription().getBundleId(), oldModel); //$NON-NLS-1$
147
					map.put(id, model);
148
				} else {
149
					map.put(id + "_" + desc.getBundleId(), model); //$NON-NLS-1$
150
				}
151
			}
152
		}
153
	}
154
155
	private static IPluginModelBase[] getSelectedWorkspacePlugins(ILaunchConfiguration configuration) throws CoreException {
29
	private static IPluginModelBase[] getSelectedWorkspacePlugins(ILaunchConfiguration configuration) throws CoreException {
156
30
157
		boolean usedefault = configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true);
31
		boolean usedefault = configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true);
Lines 217-258 Link Here
217
		return set;
91
		return set;
218
	}
92
	}
219
93
220
	public static IPluginModelBase[] getPluginList(ILaunchConfiguration config) throws CoreException {
221
		Map map = getPluginsToRun(config);
222
		return (IPluginModelBase[]) map.values().toArray(new IPluginModelBase[map.size()]);
223
	}
224
225
	public static Map getPluginsToRun(ILaunchConfiguration config) throws CoreException {
226
227
		checkBackwardCompatibility(config, true);
228
229
		TreeMap map = new TreeMap();
230
		if (config.getAttribute(IPDELauncherConstants.USE_DEFAULT, true)) {
231
			addToMap(map, PluginRegistry.getActiveModels());
232
			return map;
233
		}
234
235
		if (config.getAttribute(IPDELauncherConstants.USEFEATURES, false)) {
236
			addToMap(map, PluginRegistry.getWorkspaceModels());
237
			return map;
238
		}
239
240
		addToMap(map, getSelectedWorkspacePlugins(config));
241
242
		Map exModels = BundleLauncherHelper.getTargetBundleMap(config, null, IPDELauncherConstants.SELECTED_TARGET_PLUGINS);
243
244
		Iterator it = exModels.keySet().iterator();
245
		while (it.hasNext()) {
246
			IPluginModelBase model = (IPluginModelBase) it.next();
247
			String id = model.getPluginBase().getId();
248
			IPluginModelBase existing = (IPluginModelBase) map.get(id);
249
			// only allow dups if plug-in existing in map is not a workspace plug-in
250
			if (existing == null || existing.getUnderlyingResource() == null)
251
				addToMap(map, model);
252
		}
253
		return map;
254
	}
255
256
	public static IProject[] getAffectedProjects(ILaunchConfiguration config) throws CoreException {
94
	public static IProject[] getAffectedProjects(ILaunchConfiguration config) throws CoreException {
257
		// if restarting, no need to check projects for errors
95
		// if restarting, no need to check projects for errors
258
		if (config.getAttribute(IPDEUIConstants.RESTART, false))
96
		if (config.getAttribute(IPDEUIConstants.RESTART, false))
(-)src/org/eclipse/pde/internal/ui/launcher/BundleLauncherHelper.java (-6 / +122 lines)
Lines 14-23 Link Here
14
import java.util.*;
14
import java.util.*;
15
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17
import org.eclipse.osgi.service.resolver.BundleDescription;
18
import org.eclipse.osgi.service.resolver.BundleDescription;
18
import org.eclipse.pde.core.plugin.*;
19
import org.eclipse.pde.core.plugin.*;
19
import org.eclipse.pde.internal.build.IPDEBuildConstants;
20
import org.eclipse.pde.internal.build.IPDEBuildConstants;
20
import org.eclipse.pde.internal.core.TargetPlatformHelper;
21
import org.eclipse.pde.internal.core.TargetPlatformHelper;
22
import org.eclipse.pde.internal.ui.IPDEUIConstants;
21
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
23
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
22
24
23
public class BundleLauncherHelper {
25
public class BundleLauncherHelper {
Lines 32-46 Link Here
32
		return getTargetBundleMap(configuration, null, IPDELauncherConstants.TARGET_BUNDLES);
34
		return getTargetBundleMap(configuration, null, IPDELauncherConstants.TARGET_BUNDLES);
33
	}
35
	}
34
36
35
	public static Map getMergedBundleMap(ILaunchConfiguration configuration) throws CoreException {
37
	public static Map getMergedBundleMap(ILaunchConfiguration configuration, boolean osgi) throws CoreException {
36
		Set set = new HashSet();
38
		Set set = new HashSet();
37
		Map map = getWorkspaceBundleMap(configuration, set, IPDELauncherConstants.WORKSPACE_BUNDLES);
39
		Map map = new HashMap();
38
		map.putAll(getTargetBundleMap(configuration, set, IPDELauncherConstants.TARGET_BUNDLES));
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));
39
		return map;
67
		return map;
40
	}
68
	}
41
69
42
	public static IPluginModelBase[] getMergedBundles(ILaunchConfiguration configuration) throws CoreException {
70
	public static IPluginModelBase[] getMergedBundles(ILaunchConfiguration configuration, boolean osgi) throws CoreException {
43
		Map map = getMergedBundleMap(configuration);
71
		Map map = getMergedBundleMap(configuration, osgi);
44
		return (IPluginModelBase[]) map.keySet().toArray(new IPluginModelBase[map.size()]);
72
		return (IPluginModelBase[]) map.keySet().toArray(new IPluginModelBase[map.size()]);
45
	}
73
	}
46
74
Lines 67-73 Link Here
67
				for (int i = 0; i < models.length; i++) {
95
				for (int i = 0; i < models.length; i++) {
68
					IPluginBase base = models[i].getPluginBase();
96
					IPluginBase base = models[i].getPluginBase();
69
97
70
					// TODO Very similar to logic in LaunchPluginValidator
71
					// match only if...
98
					// match only if...
72
					// a) if we have the same version
99
					// a) if we have the same version
73
					// b) no version
100
					// b) no version
Lines 191-194 Link Here
191
		return buffer.toString();
218
		return buffer.toString();
192
	}
219
	}
193
220
221
	public static void checkBackwardCompatibility(ILaunchConfiguration configuration, boolean save) throws CoreException {
222
		ILaunchConfigurationWorkingCopy wc = null;
223
		if (configuration.isWorkingCopy()) {
224
			wc = (ILaunchConfigurationWorkingCopy) configuration;
225
		} else {
226
			wc = configuration.getWorkingCopy();
227
		}
228
229
		String value = configuration.getAttribute("wsproject", (String) null); //$NON-NLS-1$
230
		if (value != null) {
231
			wc.setAttribute("wsproject", (String) null); //$NON-NLS-1$
232
			if (value.indexOf(';') != -1) {
233
				value = value.replace(';', ',');
234
			} else if (value.indexOf(':') != -1) {
235
				value = value.replace(':', ',');
236
			}
237
			value = (value.length() == 0 || value.equals(",")) //$NON-NLS-1$
238
			? null
239
					: value.substring(0, value.length() - 1);
240
241
			boolean automatic = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
242
			String attr = automatic ? IPDELauncherConstants.DESELECTED_WORKSPACE_PLUGINS : IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS;
243
			wc.setAttribute(attr, value);
244
		}
245
246
		String value2 = configuration.getAttribute("extplugins", (String) null); //$NON-NLS-1$
247
		if (value2 != null) {
248
			wc.setAttribute("extplugins", (String) null); //$NON-NLS-1$
249
			if (value2.indexOf(';') != -1) {
250
				value2 = value2.replace(';', ',');
251
			} else if (value2.indexOf(':') != -1) {
252
				value2 = value2.replace(':', ',');
253
			}
254
			value2 = (value2.length() == 0 || value2.equals(",")) ? null : value2.substring(0, value2.length() - 1); //$NON-NLS-1$
255
			wc.setAttribute(IPDELauncherConstants.SELECTED_TARGET_PLUGINS, value2);
256
		}
257
258
		String version = configuration.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, (String) null);
259
		boolean newApp = TargetPlatformHelper.usesNewApplicationModel();
260
		boolean upgrade = !"3.3".equals(version) && newApp; //$NON-NLS-1$
261
		if (!upgrade)
262
			upgrade = TargetPlatformHelper.getTargetVersion() >= 3.2 && version == null;
263
		if (upgrade) {
264
			wc.setAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, newApp ? "3.3" : "3.2a"); //$NON-NLS-1$ //$NON-NLS-2$
265
			boolean usedefault = configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true);
266
			boolean useFeatures = configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false);
267
			boolean automaticAdd = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
268
			if (!usedefault && !useFeatures) {
269
				ArrayList list = new ArrayList();
270
				if (version == null) {
271
					list.add("org.eclipse.core.contenttype"); //$NON-NLS-1$
272
					list.add("org.eclipse.core.jobs"); //$NON-NLS-1$
273
					list.add(IPDEBuildConstants.BUNDLE_EQUINOX_COMMON);
274
					list.add("org.eclipse.equinox.preferences"); //$NON-NLS-1$
275
					list.add("org.eclipse.equinox.registry"); //$NON-NLS-1$
276
					list.add("org.eclipse.core.runtime.compatibility.registry"); //$NON-NLS-1$
277
				}
278
				if (!"3.3".equals(version) && newApp) //$NON-NLS-1$
279
					list.add("org.eclipse.equinox.app"); //$NON-NLS-1$
280
				StringBuffer extensions = new StringBuffer(configuration.getAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS, "")); //$NON-NLS-1$
281
				StringBuffer target = new StringBuffer(configuration.getAttribute(IPDELauncherConstants.SELECTED_TARGET_PLUGINS, "")); //$NON-NLS-1$
282
				for (int i = 0; i < list.size(); i++) {
283
					String plugin = list.get(i).toString();
284
					IPluginModelBase model = PluginRegistry.findModel(plugin);
285
					if (model == null)
286
						continue;
287
					if (model.getUnderlyingResource() != null) {
288
						if (automaticAdd)
289
							continue;
290
						if (extensions.length() > 0)
291
							extensions.append(","); //$NON-NLS-1$
292
						extensions.append(plugin);
293
					} else {
294
						if (target.length() > 0)
295
							target.append(","); //$NON-NLS-1$
296
						target.append(plugin);
297
					}
298
				}
299
				if (extensions.length() > 0)
300
					wc.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS, extensions.toString());
301
				if (target.length() > 0)
302
					wc.setAttribute(IPDELauncherConstants.SELECTED_TARGET_PLUGINS, target.toString());
303
			}
304
		}
305
306
		if (save && (value != null || value2 != null || upgrade))
307
			wc.doSave();
308
	}
309
194
}
310
}
(-)src/org/eclipse/pde/internal/ui/launcher/LaunchConfigurationHelper.java (-49 / +63 lines)
Lines 79-85 Link Here
79
		return mgr.performStringSubstitution(text);
79
		return mgr.performStringSubstitution(text);
80
	}
80
	}
81
81
82
	public static Properties createConfigIniFile(ILaunchConfiguration configuration, String productID, Map map, File directory) throws CoreException {
82
	public static Properties createConfigIniFile(ILaunchConfiguration configuration, String productID, Map bundles, Map bundlesWithStartLevels, File directory) throws CoreException {
83
		Properties properties = null;
83
		Properties properties = null;
84
		// if we are to generate a config.ini, start with the values in the target platform's config.ini - bug 141918
84
		// if we are to generate a config.ini, start with the values in the target platform's config.ini - bug 141918
85
		if (configuration.getAttribute(IPDELauncherConstants.CONFIG_GENERATE_DEFAULT, true)) {
85
		if (configuration.getAttribute(IPDELauncherConstants.CONFIG_GENERATE_DEFAULT, true)) {
Lines 93-99 Link Here
93
			// if target's config.ini has the osgi.bundles header, then parse and compute the proper osgi.bundles value
93
			// if target's config.ini has the osgi.bundles header, then parse and compute the proper osgi.bundles value
94
			String bundleList = properties.getProperty(PROP_OSGI_BUNDLES);
94
			String bundleList = properties.getProperty(PROP_OSGI_BUNDLES);
95
			if (bundleList != null)
95
			if (bundleList != null)
96
				properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatformHelper.stripPathInformation(bundleList), map));
96
				properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatformHelper.stripPathInformation(bundleList), bundles, bundlesWithStartLevels));
97
		} else {
97
		} else {
98
			String templateLoc = configuration.getAttribute(IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, (String) null);
98
			String templateLoc = configuration.getAttribute(IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, (String) null);
99
			if (templateLoc != null) {
99
			if (templateLoc != null) {
Lines 106-112 Link Here
106
		}
106
		}
107
		// whether we create a new config.ini or read from one as a template, we should add the required properties - bug 161265
107
		// whether we create a new config.ini or read from one as a template, we should add the required properties - bug 161265
108
		if (properties != null) {
108
		if (properties != null) {
109
			addRequiredProperties(properties, productID, map);
109
			addRequiredProperties(properties, productID, bundles, bundlesWithStartLevels);
110
		} else {
110
		} else {
111
			properties = new Properties();
111
			properties = new Properties();
112
		}
112
		}
Lines 119-168 Link Here
119
		boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, false);
119
		boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, false);
120
120
121
		// if we are launching using P2, write out P2 files (bundles.txt) and add P2 property to config.ini
121
		// if we are launching using P2, write out P2 files (bundles.txt) and add P2 property to config.ini
122
		if (osgiBundles != null && osgiBundles.indexOf(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR) != -1 && map.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) {
122
		if (osgiBundles != null && osgiBundles.indexOf(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR) != -1 && bundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) {
123
124
			// TODO we need to clean this up... our original list should have start level information
125
			// this causes a performance impact
126
			URL bundlesTxt = null;
123
			URL bundlesTxt = null;
127
			boolean usedefault = configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true);
124
			boolean usedefault = configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true);
128
			boolean useFeatures = configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false);
125
			boolean useFeatures = configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false);
129
			if (usedefault || useFeatures) {
126
			if (usedefault || useFeatures) {
130
				bundlesTxt = P2Utils.writeBundlesTxt(map.values(), osgiBundles, directory);
127
				bundlesTxt = P2Utils.writeBundlesTxt(bundlesWithStartLevels, 4, false, directory, osgiBundles);
131
			} else {
128
			} else {
132
				Map models = new HashMap();
129
				bundlesTxt = P2Utils.writeBundlesTxt(bundlesWithStartLevels, start, autostart, directory, null);
133
				Map modelsWithStartLevels = new HashMap();
134
				modelsWithStartLevels.putAll(BundleLauncherHelper.getTargetBundleMap(configuration, Collections.EMPTY_SET, IPDELauncherConstants.SELECTED_TARGET_PLUGINS));
135
				boolean automaticAdd = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
136
				String attribute = automaticAdd ? IPDELauncherConstants.DESELECTED_WORKSPACE_PLUGINS : IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS;
137
				modelsWithStartLevels.putAll(BundleLauncherHelper.getWorkspaceBundleMap(configuration, null, attribute));
138
				IPluginModelBase[] plugins = (IPluginModelBase[]) map.values().toArray(new IPluginModelBase[map.size()]);
139
				for (int i = 0; i < plugins.length; i++) {
140
					IPluginModelBase model = plugins[i];
141
					String startLevel = (String) modelsWithStartLevels.get(model);
142
					if (startLevel != null) {
143
						models.put(model, startLevel);
144
					}
145
				}
146
				bundlesTxt = P2Utils.writeBundlesTxt(models, start, autostart, directory);
147
			}
130
			}
148
131
149
			if (bundlesTxt != null) {
132
			if (bundlesTxt != null) {
150
				properties.setProperty("org.eclipse.equinox.simpleconfigurator.configUrl", bundlesTxt.toString()); //$NON-NLS-1$
133
				properties.setProperty("org.eclipse.equinox.simpleconfigurator.configUrl", bundlesTxt.toString()); //$NON-NLS-1$
151
152
				// if we have simple configurator and update configurator together, ensure update doesn't reconcile
134
				// if we have simple configurator and update configurator together, ensure update doesn't reconcile
153
				if (map.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) {
135
				if (bundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) {
154
					properties.setProperty("org.eclipse.update.reconcile", "false"); //$NON-NLS-1$ //$NON-NLS-2$
136
					properties.setProperty("org.eclipse.update.reconcile", "false"); //$NON-NLS-1$ //$NON-NLS-2$
155
				}
137
				}
156
			}
138
			}
157
		}
139
		}
158
140
159
		setBundleLocations(map, properties);
141
		setBundleLocations(bundles, properties);
160
142
161
		save(new File(directory, "config.ini"), properties); //$NON-NLS-1$
143
		save(new File(directory, "config.ini"), properties); //$NON-NLS-1$
162
		return properties;
144
		return properties;
163
	}
145
	}
164
146
165
	private static void addRequiredProperties(Properties properties, String productID, Map map) {
147
	private static void addRequiredProperties(Properties properties, String productID, Map bundles, Map bundlesWithStartLevels) {
166
		if (!properties.containsKey("osgi.install.area")) //$NON-NLS-1$
148
		if (!properties.containsKey("osgi.install.area")) //$NON-NLS-1$
167
			properties.setProperty("osgi.install.area", "file:" + TargetPlatform.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$
149
			properties.setProperty("osgi.install.area", "file:" + TargetPlatform.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$
168
		if (!properties.containsKey("osgi.configuration.cascaded")) //$NON-NLS-1$
150
		if (!properties.containsKey("osgi.configuration.cascaded")) //$NON-NLS-1$
Lines 170-181 Link Here
170
		if (!properties.containsKey(PROP_OSGI_FRAMEWORK))
152
		if (!properties.containsKey(PROP_OSGI_FRAMEWORK))
171
			properties.setProperty(PROP_OSGI_FRAMEWORK, IPDEBuildConstants.BUNDLE_OSGI);
153
			properties.setProperty(PROP_OSGI_FRAMEWORK, IPDEBuildConstants.BUNDLE_OSGI);
172
		if (!properties.containsKey("osgi.splashPath") && productID != null) //$NON-NLS-1$
154
		if (!properties.containsKey("osgi.splashPath") && productID != null) //$NON-NLS-1$
173
			addSplashLocation(properties, productID, map);
155
			addSplashLocation(properties, productID, bundles);
174
		// if osgi.splashPath is set, try to resolve relative paths to absolute paths
156
		// if osgi.splashPath is set, try to resolve relative paths to absolute paths
175
		if (properties.containsKey("osgi.splashPath")) //$NON-NLS-1$
157
		if (properties.containsKey("osgi.splashPath")) //$NON-NLS-1$
176
			resolveLocationPath(properties.getProperty("osgi.splashPath"), properties, map); //$NON-NLS-1$
158
			resolveLocationPath(properties.getProperty("osgi.splashPath"), properties, bundles); //$NON-NLS-1$
177
		if (!properties.containsKey(PROP_OSGI_BUNDLES))
159
		if (!properties.containsKey(PROP_OSGI_BUNDLES))
178
			properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatform.getBundleList(), map));
160
			properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatform.getBundleList(), bundles, bundlesWithStartLevels));
179
		if (!properties.containsKey("osgi.bundles.defaultStartLevel")) //$NON-NLS-1$
161
		if (!properties.containsKey("osgi.bundles.defaultStartLevel")) //$NON-NLS-1$
180
			properties.setProperty("osgi.bundles.defaultStartLevel", "4"); //$NON-NLS-1$ //$NON-NLS-2$
162
			properties.setProperty("osgi.bundles.defaultStartLevel", "4"); //$NON-NLS-1$ //$NON-NLS-2$
181
	}
163
	}
Lines 186-201 Link Here
186
	 * launching with.  The list of bundles must have already had it's path information
168
	 * launching with.  The list of bundles must have already had it's path information
187
	 * removed.
169
	 * removed.
188
	 * @param bundleList list of bundles without path information
170
	 * @param bundleList list of bundles without path information
189
	 * @param map map of bundle id to bundle model, contains all bundles being launched with
171
	 * @param bundles map of bundle id to bundle model, contains all bundles being launched with
172
	 * @param bundlesWithStartLevels map of bundles of start level
190
	 * @return string list of osgi bundles
173
	 * @return string list of osgi bundles
191
	 */
174
	 */
192
	private static String computeOSGiBundles(String bundleList, Map map) {
175
	private static String computeOSGiBundles(String bundleList, Map bundles, Map bundlesWithStartLevels) {
193
176
194
		// if p2 and only simple configurator and 
177
		// if p2 and only simple configurator and 
195
		// if simple configurator isn't selected & isn't in bundle list... hack it
178
		// if simple configurator isn't selected & isn't in bundle list... hack it
196
179
197
		// if using p2's simple configurator, a bundles.txt will be written, so we only need simple configurator in the config.ini
180
		// if using p2's simple configurator, a bundles.txt will be written, so we only need simple configurator in the config.ini
198
		if (map.get(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR) != null)
181
		if (bundles.get(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR) != null)
199
			return "org.eclipse.equinox.simpleconfigurator@1:start"; //$NON-NLS-1$
182
			return "org.eclipse.equinox.simpleconfigurator@1:start"; //$NON-NLS-1$
200
183
201
		StringBuffer buffer = new StringBuffer();
184
		StringBuffer buffer = new StringBuffer();
Lines 205-211 Link Here
205
			String token = tokenizer.nextToken();
188
			String token = tokenizer.nextToken();
206
			int index = token.indexOf('@');
189
			int index = token.indexOf('@');
207
			String id = index != -1 ? token.substring(0, index) : token;
190
			String id = index != -1 ? token.substring(0, index) : token;
208
			if (map.containsKey(id)) {
191
			if (bundles.containsKey(id)) {
209
				if (buffer.length() > 0)
192
				if (buffer.length() > 0)
210
					buffer.append(',');
193
					buffer.append(',');
211
				buffer.append(id);
194
				buffer.append(id);
Lines 218-234 Link Here
218
		// if org.eclipse.update.configurator is not included (LIKE IN BASIC RCP APPLICATION), then write out all bundles in osgi.bundles - bug 170772
201
		// if org.eclipse.update.configurator is not included (LIKE IN BASIC RCP APPLICATION), then write out all bundles in osgi.bundles - bug 170772
219
		if (!initialBundleSet.contains(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR)) {
202
		if (!initialBundleSet.contains(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR)) {
220
			initialBundleSet.add(IPDEBuildConstants.BUNDLE_OSGI);
203
			initialBundleSet.add(IPDEBuildConstants.BUNDLE_OSGI);
221
			Iterator iter = map.keySet().iterator();
204
			Iterator iter = bundlesWithStartLevels.keySet().iterator();
222
			while (iter.hasNext()) {
205
			while (iter.hasNext()) {
223
				String id = iter.next().toString();
206
				IPluginModelBase model = (IPluginModelBase) iter.next();
207
				String id = model.getPluginBase().getId();
224
				if (!initialBundleSet.contains(id)) {
208
				if (!initialBundleSet.contains(id)) {
225
					if (buffer.length() > 0)
209
					if (buffer.length() > 0)
226
						buffer.append(',');
210
						buffer.append(',');
211
212
					String slinfo = (String) bundlesWithStartLevels.get(model);
227
					buffer.append(id);
213
					buffer.append(id);
228
					// if we are working with core.runtime, we need to ensure it's started
214
					buffer.append('@');
229
					if (IPDEBuildConstants.BUNDLE_CORE_RUNTIME.equals(id)) {
215
					buffer.append(slinfo);
230
						buffer.append("@start"); //$NON-NLS-1$
231
					}
232
				}
216
				}
233
			}
217
			}
234
		}
218
		}
Lines 360-374 Link Here
360
			while (tokenizer.hasMoreTokens()) {
344
			while (tokenizer.hasMoreTokens()) {
361
				String token = tokenizer.nextToken().trim();
345
				String token = tokenizer.nextToken().trim();
362
				String url = getBundleURL(token, map, false);
346
				String url = getBundleURL(token, map, false);
363
				int index = -1;
347
				int i = -1;
364
				if (url == null) {
348
				if (url == null) {
365
					index = token.indexOf('@');
349
					i = token.indexOf('@');
366
					if (index != -1)
350
					if (i != -1) {
367
						url = getBundleURL(token.substring(0, index), map, false);
351
						url = getBundleURL(token.substring(0, i), map, false);
352
					}
368
					if (url == null) {
353
					if (url == null) {
369
						index = token.indexOf(':');
354
						i = token.indexOf(':');
370
						if (index != -1)
355
						if (i != -1)
371
							url = getBundleURL(token.substring(0, index), map, false);
356
							url = getBundleURL(token.substring(0, i), map, false);
372
					}
357
					}
373
				}
358
				}
374
				if (url != null) {
359
				if (url != null) {
Lines 376-389 Link Here
376
						buffer.append(","); //$NON-NLS-1$
361
						buffer.append(","); //$NON-NLS-1$
377
					}
362
					}
378
					buffer.append("reference:" + url); //$NON-NLS-1$
363
					buffer.append("reference:" + url); //$NON-NLS-1$
379
					if (index != -1)
364
					if (i != -1) {
380
						buffer.append(token.substring(index));
365
						String slinfo = token.substring(i + 1);
366
						buffer.append(getStartData(slinfo, false));
367
					}
381
				}
368
				}
382
			}
369
			}
383
			properties.setProperty(PROP_OSGI_BUNDLES, buffer.toString());
370
			properties.setProperty(PROP_OSGI_BUNDLES, buffer.toString());
384
		}
371
		}
385
	}
372
	}
386
373
374
	/**
375
	 * Convenience method to parses the startData ("startLevel:autoStart"), convert it to the
376
	 * format expected by the OSGi bundles property, and append to a StringBuffer.
377
	 * @param startData data to parse ("startLevel:autoStart")
378
	 * @param defaultAuto default auto start setting
379
	 */
380
	public static String getStartData(String startData, boolean defaultAuto) {
381
		StringBuffer buffer = new StringBuffer();
382
		int index = startData.indexOf(':');
383
		String level = index > 0 ? startData.substring(0, index) : "default"; //$NON-NLS-1$
384
		String auto = index > 0 && index < startData.length() - 1 ? startData.substring(index + 1) : "default"; //$NON-NLS-1$
385
		if ("default".equals(auto)) //$NON-NLS-1$
386
			auto = Boolean.toString(defaultAuto);
387
		if (!level.equals("default") || "true".equals(auto) || "start".equals(auto)) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
388
			buffer.append("@"); //$NON-NLS-1$
389
390
		if (!level.equals("default")) { //$NON-NLS-1$
391
			buffer.append(level);
392
			if ("start".equals(auto) || "true".equals(auto)) //$NON-NLS-1$ //$NON-NLS-2$
393
				buffer.append(":"); //$NON-NLS-1$
394
		}
395
		if ("start".equals(auto) || "true".equals(auto)) { //$NON-NLS-1$ //$NON-NLS-2$
396
			buffer.append("start"); //$NON-NLS-1$
397
		}
398
		return buffer.toString();
399
	}
400
387
	public static void save(File file, Properties properties) {
401
	public static void save(File file, Properties properties) {
388
		try {
402
		try {
389
			FileOutputStream stream = new FileOutputStream(file);
403
			FileOutputStream stream = new FileOutputStream(file);
(-)src/org/eclipse/pde/internal/ui/launcher/EclipsePluginValidationOperation.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2007, 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     EclipseSource Corporation - ongoing enhancements
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
package org.eclipse.pde.internal.ui.launcher;
12
13
Lines 35-41 Link Here
35
	}
36
	}
36
37
37
	protected IPluginModelBase[] getModels() throws CoreException {
38
	protected IPluginModelBase[] getModels() throws CoreException {
38
		return LaunchPluginValidator.getPluginList(fLaunchConfiguration);
39
		return BundleLauncherHelper.getMergedBundles(fLaunchConfiguration, false);
39
	}
40
	}
40
41
41
	public void run(IProgressMonitor monitor) throws CoreException {
42
	public void run(IProgressMonitor monitor) throws CoreException {
(-)src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfigurationTabGroup.java (-3 / +4 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     EclipseSource Corporation - ongoing enhancements
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
12
package org.eclipse.pde.ui.launcher;
12
13
Lines 18-25 Link Here
18
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
19
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
19
import org.eclipse.pde.internal.core.TargetPlatformHelper;
20
import org.eclipse.pde.internal.core.TargetPlatformHelper;
20
import org.eclipse.pde.internal.ui.IPDEUIConstants;
21
import org.eclipse.pde.internal.ui.IPDEUIConstants;
22
import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper;
21
import org.eclipse.pde.internal.ui.launcher.LaunchArgumentsHelper;
23
import org.eclipse.pde.internal.ui.launcher.LaunchArgumentsHelper;
22
import org.eclipse.pde.internal.ui.launcher.LaunchPluginValidator;
23
import org.eclipse.swt.custom.BusyIndicator;
24
import org.eclipse.swt.custom.BusyIndicator;
24
import org.eclipse.swt.widgets.Display;
25
import org.eclipse.swt.widgets.Display;
25
26
Lines 93-99 Link Here
93
			wc.setAttribute(IPDELauncherConstants.LOCATION, value);
94
			wc.setAttribute(IPDELauncherConstants.LOCATION, value);
94
		}
95
		}
95
96
96
		LaunchPluginValidator.checkBackwardCompatibility(wc, false);
97
		BundleLauncherHelper.checkBackwardCompatibility(wc, false);
97
		if (wc.isDirty()) {
98
		if (wc.isDirty()) {
98
			wc.doSave();
99
			wc.doSave();
99
		}
100
		}
(-)src/org/eclipse/pde/ui/launcher/EquinoxLaunchConfiguration.java (-3 / +4 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     EclipseSource Corporation - ongoing enhancements
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
12
package org.eclipse.pde.ui.launcher;
12
13
Lines 74-80 Link Here
74
		String bundles = null;
75
		String bundles = null;
75
		if (fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) {
76
		if (fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) {
76
			// If simple configurator is being used, we need to write out the bundles.txt instead of writing out the list in the config.ini
77
			// If simple configurator is being used, we need to write out the bundles.txt instead of writing out the list in the config.ini
77
			URL bundlesTxt = P2Utils.writeBundlesTxt(fModels, start, autostart, getConfigDir(configuration));
78
			URL bundlesTxt = P2Utils.writeBundlesTxt(fModels, start, autostart, getConfigDir(configuration), null);
78
			if (bundlesTxt != null) {
79
			if (bundlesTxt != null) {
79
				properties.setProperty("org.eclipse.equinox.simpleconfigurator.configUrl", bundlesTxt.toString()); //$NON-NLS-1$
80
				properties.setProperty("org.eclipse.equinox.simpleconfigurator.configUrl", bundlesTxt.toString()); //$NON-NLS-1$
80
				if (fAllBundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) {
81
				if (fAllBundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) {
Lines 153-159 Link Here
153
	 * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
154
	 * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
154
	 */
155
	 */
155
	protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
156
	protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
156
		fModels = BundleLauncherHelper.getMergedBundleMap(configuration);
157
		fModels = BundleLauncherHelper.getMergedBundleMap(configuration, true);
157
		fAllBundles = new HashMap(fModels.size());
158
		fAllBundles = new HashMap(fModels.size());
158
		Iterator iter = fModels.keySet().iterator();
159
		Iterator iter = fModels.keySet().iterator();
159
		while (iter.hasNext()) {
160
		while (iter.hasNext()) {
(-)src/org/eclipse/pde/ui/launcher/AbstractPDELaunchConfiguration.java (-1 / +1 lines)
Lines 207-213 Link Here
207
	public String[] getVMArguments(ILaunchConfiguration configuration) throws CoreException {
207
	public String[] getVMArguments(ILaunchConfiguration configuration) throws CoreException {
208
		String[] vmArgs = new ExecutionArguments(LaunchArgumentsHelper.getUserVMArguments(configuration), "").getVMArgumentsArray(); //$NON-NLS-1$
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
209
		// For p2 target, add "-Declipse.p2.data.area=@config.dir/p2" unless already specified by user
210
		Map bundleMap = LaunchPluginValidator.getPluginsToRun(configuration);
210
		Map bundleMap = BundleLauncherHelper.getMergedBundleMap(configuration, false);
211
		if (bundleMap.containsKey("org.eclipse.equinox.p2.core")) { //$NON-NLS-1$
211
		if (bundleMap.containsKey("org.eclipse.equinox.p2.core")) { //$NON-NLS-1$
212
			for (int i = 0; i < vmArgs.length; i++) {
212
			for (int i = 0; i < vmArgs.length; i++) {
213
				String arg = vmArgs[i];
213
				String arg = vmArgs[i];
(-)src/org/eclipse/pde/ui/launcher/EclipseApplicationLaunchConfiguration.java (-9 / +21 lines)
Lines 37-42 Link Here
37
 */
37
 */
38
public class EclipseApplicationLaunchConfiguration extends AbstractPDELaunchConfiguration {
38
public class EclipseApplicationLaunchConfiguration extends AbstractPDELaunchConfiguration {
39
39
40
	// used to generate the dev classpath entries
41
	// key is bundle ID, value is a model
42
	private Map fAllBundles;
43
44
	// key is a model, value is startLevel:autoStart
45
	private Map fModels;
46
40
	/**
47
	/**
41
	 * To avoid duplicating variable substitution (and duplicate prompts)
48
	 * To avoid duplicating variable substitution (and duplicate prompts)
42
	 * this variable will store the substituted workspace location.
49
	 * this variable will store the substituted workspace location.
Lines 76-84 Link Here
76
		}
83
		}
77
84
78
		boolean showSplash = true;
85
		boolean showSplash = true;
79
		// TODO fix getPluginstoRun to return a map that is model/startlevel
80
		// model after EquinoxLaunchConfiguration
81
		Map pluginMap = LaunchPluginValidator.getPluginsToRun(configuration);
82
		if (configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false)) {
86
		if (configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false)) {
83
			validateFeatures();
87
			validateFeatures();
84
			IPath installPath = PDEPlugin.getWorkspace().getRoot().getLocation();
88
			IPath installPath = PDEPlugin.getWorkspace().getRoot().getLocation();
Lines 94-114 Link Here
94
			programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", true)); //$NON-NLS-1$
98
			programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", true)); //$NON-NLS-1$
95
		} else {
99
		} else {
96
			String productID = LaunchConfigurationHelper.getProductID(configuration);
100
			String productID = LaunchConfigurationHelper.getProductID(configuration);
97
			Properties prop = LaunchConfigurationHelper.createConfigIniFile(configuration, productID, pluginMap, getConfigDir(configuration));
101
			Properties prop = LaunchConfigurationHelper.createConfigIniFile(configuration, productID, fAllBundles, fModels, getConfigDir(configuration));
98
			showSplash = prop.containsKey("osgi.splashPath") || prop.containsKey("splashLocation"); //$NON-NLS-1$ //$NON-NLS-2$
102
			showSplash = prop.containsKey("osgi.splashPath") || prop.containsKey("splashLocation"); //$NON-NLS-1$ //$NON-NLS-2$
99
			String brandingId = LaunchConfigurationHelper.getContributingPlugin(productID);
103
			String brandingId = LaunchConfigurationHelper.getContributingPlugin(productID);
100
			TargetPlatform.createPlatformConfiguration(getConfigDir(configuration), (IPluginModelBase[]) pluginMap.values().toArray(new IPluginModelBase[pluginMap.size()]), brandingId != null ? (IPluginModelBase) pluginMap.get(brandingId) : null);
104
			TargetPlatform.createPlatformConfiguration(getConfigDir(configuration), (IPluginModelBase[]) fAllBundles.values().toArray(new IPluginModelBase[fAllBundles.size()]), brandingId != null ? (IPluginModelBase) fAllBundles.get(brandingId) : null);
101
			TargetPlatformHelper.checkPluginPropertiesConsistency(pluginMap, getConfigDir(configuration));
105
			TargetPlatformHelper.checkPluginPropertiesConsistency(fAllBundles, getConfigDir(configuration));
102
			programArgs.add("-configuration"); //$NON-NLS-1$
106
			programArgs.add("-configuration"); //$NON-NLS-1$
103
			programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
107
			programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
104
108
105
			// add the output folder names
109
			// add the output folder names
106
			programArgs.add("-dev"); //$NON-NLS-1$
110
			programArgs.add("-dev"); //$NON-NLS-1$
107
			programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", pluginMap)); //$NON-NLS-1$
111
			programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", fAllBundles)); //$NON-NLS-1$
108
		}
112
		}
109
		// necessary for PDE to know how to load plugins when target platform = host platform
113
		// necessary for PDE to know how to load plugins when target platform = host platform
110
		// see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode()
114
		// see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode()
111
		IPluginModelBase base = (IPluginModelBase) pluginMap.get(PDECore.PLUGIN_ID);
115
		IPluginModelBase base = (IPluginModelBase) fAllBundles.get(PDECore.PLUGIN_ID);
112
		if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) < 0) //$NON-NLS-1$
116
		if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) < 0) //$NON-NLS-1$
113
			programArgs.add("-pdelaunch"); //$NON-NLS-1$
117
			programArgs.add("-pdelaunch"); //$NON-NLS-1$
114
118
Lines 238-243 Link Here
238
	 */
242
	 */
239
	protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
243
	protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
240
		fWorkspaceLocation = null;
244
		fWorkspaceLocation = null;
245
246
		fModels = BundleLauncherHelper.getMergedBundleMap(configuration, false);
247
		fAllBundles = new HashMap(fModels.size());
248
		Iterator iter = fModels.keySet().iterator();
249
		while (iter.hasNext()) {
250
			IPluginModelBase model = (IPluginModelBase) iter.next();
251
			fAllBundles.put(model.getPluginBase().getId(), model);
252
		}
241
		validateConfigIni(configuration);
253
		validateConfigIni(configuration);
242
		super.preLaunchCheck(configuration, launch, monitor);
254
		super.preLaunchCheck(configuration, launch, monitor);
243
	}
255
	}
Lines 263-269 Link Here
263
	 */
275
	 */
264
	public String[] getVMArguments(ILaunchConfiguration configuration) throws CoreException {
276
	public String[] getVMArguments(ILaunchConfiguration configuration) throws CoreException {
265
		String[] vmArgs = super.getVMArguments(configuration);
277
		String[] vmArgs = super.getVMArguments(configuration);
266
		IPluginModelBase base = (IPluginModelBase) LaunchPluginValidator.getPluginsToRun(configuration).get(PDECore.PLUGIN_ID);
278
		IPluginModelBase base = (IPluginModelBase) fAllBundles.get(PDECore.PLUGIN_ID);
267
		if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) >= 0) { //$NON-NLS-1$
279
		if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) >= 0) { //$NON-NLS-1$
268
			// necessary for PDE to know how to load plugins when target platform = host platform
280
			// necessary for PDE to know how to load plugins when target platform = host platform
269
			// see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode()
281
			// see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode()
(-)src/org/eclipse/pde/ui/launcher/JUnitLaunchConfigurationDelegate.java (-18 / +26 lines)
Lines 7-21 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Code 9 Corporation - ongoing enhancements
10
 *     EclipseSource Corporation - ongoing enhancements
11
 *     David Saff <saff@mit.edu> - bug 102632
11
 *     David Saff <saff@mit.edu> - bug 102632
12
 *     Ketan Padegaonkar <KetanPadegaonkar@gmail.com> - bug 250340
12
 *     Ketan Padegaonkar <KetanPadegaonkar@gmail.com> - bug 250340
13
 *******************************************************************************/
13
 *******************************************************************************/
14
package org.eclipse.pde.ui.launcher;
14
package org.eclipse.pde.ui.launcher;
15
15
16
import java.io.File;
16
import java.io.File;
17
import java.util.List;
17
import java.util.*;
18
import java.util.Map;
19
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.resources.IProject;
20
import org.eclipse.core.runtime.*;
19
import org.eclipse.core.runtime.*;
21
import org.eclipse.debug.core.*;
20
import org.eclipse.debug.core.*;
Lines 47-53 Link Here
47
46
48
	protected File fConfigDir = null;
47
	protected File fConfigDir = null;
49
48
50
	private Map fPluginMap;
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;
51
55
52
	/*
56
	/*
53
	 * (non-Javadoc)
57
	 * (non-Javadoc)
Lines 123-139 Link Here
123
127
124
		// Create the platform configuration for the runtime workbench
128
		// Create the platform configuration for the runtime workbench
125
		String productID = LaunchConfigurationHelper.getProductID(configuration);
129
		String productID = LaunchConfigurationHelper.getProductID(configuration);
126
		LaunchConfigurationHelper.createConfigIniFile(configuration, productID, fPluginMap, getConfigurationDirectory(configuration));
130
		LaunchConfigurationHelper.createConfigIniFile(configuration, productID, fAllBundles, fModels, getConfigurationDirectory(configuration));
127
		String brandingId = LaunchConfigurationHelper.getContributingPlugin(productID);
131
		String brandingId = LaunchConfigurationHelper.getContributingPlugin(productID);
128
		TargetPlatform.createPlatformConfiguration(getConfigurationDirectory(configuration), (IPluginModelBase[]) fPluginMap.values().toArray(new IPluginModelBase[fPluginMap.size()]), brandingId != null ? (IPluginModelBase) fPluginMap.get(brandingId) : null);
132
		TargetPlatform.createPlatformConfiguration(getConfigurationDirectory(configuration), (IPluginModelBase[]) fAllBundles.values().toArray(new IPluginModelBase[fAllBundles.size()]), brandingId != null ? (IPluginModelBase) fAllBundles.get(brandingId) : null);
129
		TargetPlatformHelper.checkPluginPropertiesConsistency(fPluginMap, getConfigurationDirectory(configuration));
133
		TargetPlatformHelper.checkPluginPropertiesConsistency(fAllBundles, getConfigurationDirectory(configuration));
130
134
131
		programArgs.add("-configuration"); //$NON-NLS-1$
135
		programArgs.add("-configuration"); //$NON-NLS-1$
132
		programArgs.add("file:" + new Path(getConfigurationDirectory(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
136
		programArgs.add("file:" + new Path(getConfigurationDirectory(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
133
137
134
		// Specify the output folder names
138
		// Specify the output folder names
135
		programArgs.add("-dev"); //$NON-NLS-1$
139
		programArgs.add("-dev"); //$NON-NLS-1$
136
		programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigurationDirectory(configuration).toString() + "/dev.properties", fPluginMap)); //$NON-NLS-1$
140
		programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigurationDirectory(configuration).toString() + "/dev.properties", fAllBundles)); //$NON-NLS-1$
137
141
138
		// necessary for PDE to know how to load plugins when target platform = host platform
142
		// necessary for PDE to know how to load plugins when target platform = host platform
139
		// see PluginPathFinder.getPluginPaths()
143
		// see PluginPathFinder.getPluginPaths()
Lines 207-213 Link Here
207
		// if application is not set, we should launch the default UI test app
211
		// if application is not set, we should launch the default UI test app
208
		// Check to see if we should launch the legacy UI app
212
		// Check to see if we should launch the legacy UI app
209
		if (application == null) {
213
		if (application == null) {
210
			IPluginModelBase model = (IPluginModelBase) fPluginMap.get("org.eclipse.pde.junit.runtime"); //$NON-NLS-1$
214
			IPluginModelBase model = (IPluginModelBase) fAllBundles.get("org.eclipse.pde.junit.runtime"); //$NON-NLS-1$
211
			BundleDescription desc = model != null ? model.getBundleDescription() : null;
215
			BundleDescription desc = model != null ? model.getBundleDescription() : null;
212
			if (desc != null) {
216
			if (desc != null) {
213
				Version version = desc.getVersion();
217
				Version version = desc.getVersion();
Lines 252-265 Link Here
252
		String vmArgs = LaunchArgumentsHelper.getUserVMArguments(configuration);
256
		String vmArgs = LaunchArgumentsHelper.getUserVMArguments(configuration);
253
257
254
		// necessary for PDE to know how to load plugins when target platform = host platform
258
		// necessary for PDE to know how to load plugins when target platform = host platform
255
		// see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode()
259
		IPluginModelBase base = (IPluginModelBase) fAllBundles.get(PDECore.PLUGIN_ID);
256
		Map pluginsToRun = LaunchPluginValidator.getPluginsToRun(configuration);
257
		IPluginModelBase base = (IPluginModelBase) pluginsToRun.get(PDECore.PLUGIN_ID);
258
		if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) >= 0) { //$NON-NLS-1$
260
		if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) >= 0) { //$NON-NLS-1$
259
			vmArgs = concatArg(vmArgs, "-Declipse.pde.launch=true"); //$NON-NLS-1$
261
			vmArgs = concatArg(vmArgs, "-Declipse.pde.launch=true"); //$NON-NLS-1$
260
		}
262
		}
261
		// For p2 target, add "-Declipse.p2.data.area=@config.dir/p2" unless already specified by user
263
		// For p2 target, add "-Declipse.p2.data.area=@config.dir/p2" unless already specified by user
262
		if (pluginsToRun.containsKey("org.eclipse.equinox.p2.core")) { //$NON-NLS-1$
264
		if (fAllBundles.containsKey("org.eclipse.equinox.p2.core")) { //$NON-NLS-1$
263
			if (vmArgs.indexOf("-Declipse.p2.data.area=") < 0) { //$NON-NLS-1$
265
			if (vmArgs.indexOf("-Declipse.p2.data.area=") < 0) { //$NON-NLS-1$
264
				vmArgs = concatArg(vmArgs, "-Declipse.p2.data.area=@config.dir" + File.separator + "p2"); //$NON-NLS-1$ //$NON-NLS-2$
266
				vmArgs = concatArg(vmArgs, "-Declipse.p2.data.area=@config.dir" + File.separator + "p2"); //$NON-NLS-1$ //$NON-NLS-2$
265
			}
267
			}
Lines 381-397 Link Here
381
	 * @see org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
383
	 * @see org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
382
	 */
384
	 */
383
	protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
385
	protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
384
		// Get the list of plug-ins to run
385
		fPluginMap = LaunchPluginValidator.getPluginsToRun(configuration);
386
387
		fWorkspaceLocation = null;
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
		}
388
394
389
		// implicitly add the plug-ins required for JUnit testing if necessary
395
		// implicitly add the plug-ins required for JUnit testing if necessary
390
		String[] requiredPlugins = getRequiredPlugins(configuration);
396
		String[] requiredPlugins = getRequiredPlugins(configuration);
391
		for (int i = 0; i < requiredPlugins.length; i++) {
397
		for (int i = 0; i < requiredPlugins.length; i++) {
392
			String id = requiredPlugins[i];
398
			String id = requiredPlugins[i];
393
			if (!fPluginMap.containsKey(id)) {
399
			if (!fAllBundles.containsKey(id)) {
394
				fPluginMap.put(id, findPlugin(id));
400
				IPluginModelBase model = findPlugin(id);
401
				fAllBundles.put(id, model);
402
				fModels.put(model, "default:default"); //$NON-NLS-1$
395
			}
403
			}
396
		}
404
		}
397
405
(-)src/org/eclipse/pde/internal/ui/wizards/feature/CreateFeatureProjectFromLaunchOperation.java (-4 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2008 IBM Corporation and others.
2
 * Copyright (c) 2007, 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     EclipseSource Corporation - ongoing enhancements
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.pde.internal.ui.wizards.feature;
13
package org.eclipse.pde.internal.ui.wizards.feature;
Lines 21-27 Link Here
21
import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel;
22
import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel;
22
import org.eclipse.pde.internal.core.ifeature.IFeature;
23
import org.eclipse.pde.internal.core.ifeature.IFeature;
23
import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper;
24
import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper;
24
import org.eclipse.pde.internal.ui.launcher.LaunchPluginValidator;
25
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
25
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
26
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
26
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
27
import org.eclipse.swt.widgets.Shell;
27
import org.eclipse.swt.widgets.Shell;
Lines 47-56 Link Here
47
			String id = type.getIdentifier();
47
			String id = type.getIdentifier();
48
			// if it is an Eclipse launch
48
			// if it is an Eclipse launch
49
			if (id.equals(EclipseLaunchShortcut.CONFIGURATION_TYPE))
49
			if (id.equals(EclipseLaunchShortcut.CONFIGURATION_TYPE))
50
				models = LaunchPluginValidator.getPluginList(fLaunchConfig);
50
				models = BundleLauncherHelper.getMergedBundles(fLaunchConfig, false);
51
			// else if it is an OSGi launch
51
			// else if it is an OSGi launch
52
			else if (id.equals(IPDELauncherConstants.OSGI_CONFIGURATION_TYPE))
52
			else if (id.equals(IPDELauncherConstants.OSGI_CONFIGURATION_TYPE))
53
				models = BundleLauncherHelper.getMergedBundles(fLaunchConfig);
53
				models = BundleLauncherHelper.getMergedBundles(fLaunchConfig, true);
54
		} catch (CoreException e) {
54
		} catch (CoreException e) {
55
		}
55
		}
56
		IPluginBase[] result = new IPluginBase[models == null ? 0 : models.length];
56
		IPluginBase[] result = new IPluginBase[models == null ? 0 : models.length];
(-)src/org/eclipse/pde/internal/core/P2Utils.java (-71 / +29 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     EclipseSource Corporation - ongoing enhancements
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.pde.internal.core;
12
package org.eclipse.pde.internal.core;
12
13
Lines 18-24 Link Here
18
import org.eclipse.core.runtime.*;
19
import org.eclipse.core.runtime.*;
19
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
20
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
20
import org.eclipse.equinox.internal.provisional.simpleconfigurator.manipulator.SimpleConfiguratorManipulator;
21
import org.eclipse.equinox.internal.provisional.simpleconfigurator.manipulator.SimpleConfiguratorManipulator;
21
import org.eclipse.osgi.service.resolver.BundleDescription;
22
import org.eclipse.pde.core.plugin.IPluginBase;
22
import org.eclipse.pde.core.plugin.IPluginBase;
23
import org.eclipse.pde.core.plugin.IPluginModelBase;
23
import org.eclipse.pde.core.plugin.IPluginModelBase;
24
import org.eclipse.pde.internal.build.BundleHelper;
24
import org.eclipse.pde.internal.build.BundleHelper;
Lines 189-200 Link Here
189
	 * @param defaultStartLevel start level to use when "default" is the start level
189
	 * @param defaultStartLevel start level to use when "default" is the start level
190
	 * @param defaultAutoStart auto start setting to use when "default" is the auto start setting
190
	 * @param defaultAutoStart auto start setting to use when "default" is the auto start setting
191
	 * @param directory configuration directory to create the files in
191
	 * @param directory configuration directory to create the files in
192
	 * @param osgiBundleList a list of bundles coming from a template config.ini
192
	 * @return URL location of the bundles.info or <code>null</code>
193
	 * @return URL location of the bundles.info or <code>null</code>
193
	 */
194
	 */
194
	public static URL writeBundlesTxt(Map bundles, int defaultStartLevel, boolean defaultAutoStart, File directory) {
195
	public static URL writeBundlesTxt(Map bundles, int defaultStartLevel, boolean defaultAutoStart, File directory, String osgiBundleList) {
195
		if (bundles.size() == 0) {
196
		if (bundles.size() == 0) {
196
			return null;
197
			return null;
197
		}
198
		}
199
200
		// Parse the osgi bundle list for start levels
201
		Map osgiStartLevels = new HashMap();
202
		if (osgiBundleList != null) {
203
			StringTokenizer tokenizer = new StringTokenizer(osgiBundleList, ","); //$NON-NLS-1$
204
			while (tokenizer.hasMoreTokens()) {
205
				String token = tokenizer.nextToken();
206
				int index = token.indexOf('@');
207
				if (index != -1) {
208
					String modelName = token.substring(0, index);
209
					String startData = token.substring(index + 1);
210
					index = startData.indexOf(':');
211
					String level = index > 0 ? startData.substring(0, index) : "default"; //$NON-NLS-1$
212
					String auto = index > 0 && index < startData.length() - 1 ? startData.substring(index + 1) : "default"; //$NON-NLS-1$
213
					if ("start".equals(auto)) { //$NON-NLS-1$
214
						auto = "true"; //$NON-NLS-1$
215
					}
216
					osgiStartLevels.put(modelName, level + ':' + auto);
217
				}
218
			}
219
		}
220
198
		List bundleInfo = new ArrayList(bundles.size());
221
		List bundleInfo = new ArrayList(bundles.size());
199
		List sourceInfo = new ArrayList(bundles.size());
222
		List sourceInfo = new ArrayList(bundles.size());
200
		for (Iterator iterator = bundles.keySet().iterator(); iterator.hasNext();) {
223
		for (Iterator iterator = bundles.keySet().iterator(); iterator.hasNext();) {
Lines 215-220 Link Here
215
					info.setSymbolicName(base.getId());
238
					info.setSymbolicName(base.getId());
216
					info.setVersion(base.getVersion());
239
					info.setVersion(base.getVersion());
217
					String currentLevel = (String) bundles.get(currentModel);
240
					String currentLevel = (String) bundles.get(currentModel);
241
					// override the start level setting if something comes from the config.ini
242
					if (osgiStartLevels.containsKey(base.getId())) {
243
						currentLevel = (String) osgiStartLevels.get(base.getId());
244
					}
218
					int index = currentLevel.indexOf(':');
245
					int index = currentLevel.indexOf(':');
219
					String levelString = index > 0 ? currentLevel.substring(0, index) : "default"; //$NON-NLS-1$
246
					String levelString = index > 0 ? currentLevel.substring(0, index) : "default"; //$NON-NLS-1$
220
					String auto = index > 0 && index < currentLevel.length() - 1 ? currentLevel.substring(index + 1) : "default"; //$NON-NLS-1$
247
					String auto = index > 0 && index < currentLevel.length() - 1 ? currentLevel.substring(index + 1) : "default"; //$NON-NLS-1$
Lines 269-341 Link Here
269
		}
296
		}
270
	}
297
	}
271
298
272
	/**
273
	 * Creates a bundles.info file in the given directory containing the name,
274
	 * version, location, start level and expected state of every bundle in the
275
	 * given collection.  Will also create a source.info file containing
276
	 * a list of all source bundles found in the given collection. If a bundle
277
	 * has a specified start level in the osgi bundle list, that value is used
278
	 * instead of the default.  Returns the URL location of the bundle.txt or 
279
	 * <code>null</code> if there was a problem creating it.
280
	 * 
281
	 * @param bundles collection of IPluginModelBase objects to write into the bundles.info/source.info
282
	 * @param osgiBundleList comma separated list of bundles specified in a template config.ini, used to override start levels
283
	 * @param directory directory to create the bundles.info and source.info files in
284
	 * @return URL location of the bundles.info or <code>null</code>
285
	 */
286
	public static URL writeBundlesTxt(Collection bundles, String osgiBundleList, File directory) {
287
		// Parse the osgi bundle list for start levels
288
		Map osgiStartLevels = new HashMap();
289
		StringTokenizer tokenizer = new StringTokenizer(osgiBundleList, ","); //$NON-NLS-1$
290
		while (tokenizer.hasMoreTokens()) {
291
			String token = tokenizer.nextToken();
292
			int index = token.indexOf('@');
293
			if (index != -1) {
294
				String modelName = token.substring(0, index);
295
				String startData = token.substring(index + 1);
296
				index = startData.indexOf(':');
297
				String level = index > 0 ? startData.substring(0, index) : "default"; //$NON-NLS-1$
298
				String auto = index > 0 && index < startData.length() - 1 ? startData.substring(index + 1) : "default"; //$NON-NLS-1$
299
				if ("start".equals(auto)) { //$NON-NLS-1$
300
					auto = "true"; //$NON-NLS-1$
301
				}
302
				osgiStartLevels.put(modelName, level + ':' + auto);
303
			}
304
		}
305
306
		// Create a map of bundles to start levels
307
		String defaultAppend = "default:default"; //$NON-NLS-1$
308
		Map bundleMap = new HashMap(bundles.size());
309
		for (Iterator iterator = bundles.iterator(); iterator.hasNext();) {
310
			IPluginModelBase currentModel = (IPluginModelBase) iterator.next();
311
			BundleDescription desc = currentModel.getBundleDescription();
312
			if (desc != null) {
313
				String modelName = desc.getSymbolicName();
314
				if (modelName != null && osgiStartLevels.containsKey(modelName)) {
315
					bundleMap.put(currentModel, osgiStartLevels.get(modelName));
316
				} else if (IPDEBuildConstants.BUNDLE_DS.equals(modelName)) {
317
					bundleMap.put(currentModel, "1:true"); //$NON-NLS-1$ 
318
				} else if (IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR.equals(modelName)) {
319
					bundleMap.put(currentModel, "1:true"); //$NON-NLS-1$
320
				} else if (IPDEBuildConstants.BUNDLE_EQUINOX_COMMON.equals(modelName)) {
321
					bundleMap.put(currentModel, "2:true"); //$NON-NLS-1$
322
				} else if (IPDEBuildConstants.BUNDLE_OSGI.equals(modelName)) {
323
					bundleMap.put(currentModel, "-1:true"); //$NON-NLS-1$
324
				} else if (IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR.equals(modelName)) {
325
					bundleMap.put(currentModel, "3:true"); //$NON-NLS-1$
326
				} else if (IPDEBuildConstants.BUNDLE_CORE_RUNTIME.equals(modelName)) {
327
					if (TargetPlatformHelper.getTargetVersion() > 3.1) {
328
						bundleMap.put(currentModel, "default:true"); //$NON-NLS-1$
329
					} else {
330
						bundleMap.put(currentModel, "2:true"); //$NON-NLS-1$
331
					}
332
				} else {
333
					bundleMap.put(currentModel, defaultAppend);
334
				}
335
			}
336
		}
337
338
		return writeBundlesTxt(bundleMap, 4, false, directory);
339
	}
340
341
}
299
}

Return to bug 269111