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 232841
Collapse All | Expand All

(-)src/org/eclipse/pde/internal/core/SourceLocationManager.java (+18 lines)
Lines 58-63 Link Here
58
			result = searchBundleManifestLocations(pluginBase);
58
			result = searchBundleManifestLocations(pluginBase);
59
			if (result == null) {
59
			if (result == null) {
60
				result = searchExtensionLocations(relativePath);
60
				result = searchExtensionLocations(relativePath);
61
				if (result == null) {
62
					result = searchWorkspaceBundleManifestLocations(pluginBase);
63
				}
61
			}
64
			}
62
		}
65
		}
63
		return result;
66
		return result;
Lines 88-94 Link Here
88
					PDECore.log(e);
91
					PDECore.log(e);
89
				}
92
				}
90
			}
93
			}
94
91
			result = searchExtensionLocations(relativePath);
95
			result = searchExtensionLocations(relativePath);
96
97
			if (result == null) {
98
				result = searchWorkspaceBundleManifestLocations(pluginBase);
99
			}
92
		}
100
		}
93
		if (result != null) {
101
		if (result != null) {
94
			try {
102
			try {
Lines 297-302 Link Here
297
		return null;
305
		return null;
298
	}
306
	}
299
307
308
	private IPath searchWorkspaceBundleManifestLocations(IPluginBase pluginBase) {
309
		BundleManifestSourceLocationManager manager = new BundleManifestSourceLocationManager();
310
		manager.setPlugins(PDECore.getDefault().getModelManager().getWorkspaceModels());
311
		SourceLocation location = manager.getSourceLocation(pluginBase.getId(), new Version(pluginBase.getVersion()));
312
		if (location != null && location.getPath().toFile().exists()) {
313
			return location.getPath();
314
		}
315
		return null;
316
	}
317
300
	/**
318
	/**
301
	 * Parses serialized source locations into an array list of user specified source locations
319
	 * Parses serialized source locations into an array list of user specified source locations
302
	 * @param text text to parse
320
	 * @param text text to parse
(-)src/org/eclipse/pde/internal/core/BundleManifestSourceLocationManager.java (-42 / +34 lines)
Lines 10-35 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core;
11
package org.eclipse.pde.internal.core;
12
12
13
import java.util.ArrayList;
13
import java.util.*;
14
import java.util.Collection;
14
import org.eclipse.core.runtime.*;
15
import java.util.HashMap;
16
import java.util.HashSet;
17
import java.util.Iterator;
18
import java.util.Map;
19
import java.util.Set;
20
21
import org.eclipse.core.runtime.IPath;
22
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.core.runtime.Path;
24
import org.eclipse.core.runtime.Status;
25
import org.eclipse.osgi.util.ManifestElement;
15
import org.eclipse.osgi.util.ManifestElement;
26
import org.eclipse.osgi.util.NLS;
16
import org.eclipse.osgi.util.NLS;
27
import org.eclipse.pde.core.plugin.IPluginBase;
17
import org.eclipse.pde.core.plugin.IPluginBase;
28
import org.eclipse.pde.core.plugin.IPluginModelBase;
18
import org.eclipse.pde.core.plugin.IPluginModelBase;
19
import org.eclipse.pde.internal.core.bundle.BundlePluginBase;
29
import org.eclipse.pde.internal.core.plugin.PluginBase;
20
import org.eclipse.pde.internal.core.plugin.PluginBase;
30
import org.osgi.framework.BundleException;
21
import org.osgi.framework.*;
31
import org.osgi.framework.Constants;
32
import org.osgi.framework.Version;
33
22
34
/**
23
/**
35
 * Stores location information about bundles that provide source for
24
 * Stores location information about bundles that provide source for
Lines 202-236 Link Here
202
		fPluginToSourceBundle = new HashMap();
191
		fPluginToSourceBundle = new HashMap();
203
		for (int i = 0; i < externalModels.length; i++) {
192
		for (int i = 0; i < externalModels.length; i++) {
204
			IPluginBase currentPlugin = externalModels[i].getPluginBase();
193
			IPluginBase currentPlugin = externalModels[i].getPluginBase();
194
			String bundleSourceEntry = null;
205
			if (currentPlugin instanceof PluginBase) {
195
			if (currentPlugin instanceof PluginBase) {
206
				String bundleSourceEntry = ((PluginBase) currentPlugin).getBundleSourceEntry();
196
				bundleSourceEntry = ((PluginBase) currentPlugin).getBundleSourceEntry();
207
				if (bundleSourceEntry != null) {
197
			} else if (currentPlugin instanceof BundlePluginBase) {
208
					ManifestElement[] manifestElements = null;
198
				bundleSourceEntry = ((BundlePluginBase) currentPlugin).getBundleSourceEntry();
209
					try {
199
			}
210
						manifestElements = ManifestElement.parseHeader(ICoreConstants.ECLIPSE_SOURCE_BUNDLE, bundleSourceEntry);
200
			if (bundleSourceEntry != null) {
211
					} catch (BundleException e) {
201
				ManifestElement[] manifestElements = null;
212
						PDECore.log(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, PDECoreMessages.SourceLocationManager_problemProcessingBundleManifestSourceHeader, e));
202
				try {
213
						manifestElements = null;
203
					manifestElements = ManifestElement.parseHeader(ICoreConstants.ECLIPSE_SOURCE_BUNDLE, bundleSourceEntry);
214
					}
204
				} catch (BundleException e) {
215
					if (manifestElements != null) {
205
					PDECore.log(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, PDECoreMessages.SourceLocationManager_problemProcessingBundleManifestSourceHeader, e));
216
						IPath path = new Path(externalModels[i].getInstallLocation());
206
					manifestElements = null;
217
						if (path.toFile().exists()) {
207
				}
218
							for (int j = 0; j < manifestElements.length; j++) {
208
				if (manifestElements != null) {
219
								ManifestElement currentElement = manifestElements[j];
209
					IPath path = new Path(externalModels[i].getInstallLocation());
220
								String binaryPluginName = currentElement.getValue();
210
					if (path.toFile().exists()) {
221
								String versionEntry = currentElement.getAttribute(Constants.VERSION_ATTRIBUTE);
211
						for (int j = 0; j < manifestElements.length; j++) {
222
								// Currently the version attribute is required
212
							ManifestElement currentElement = manifestElements[j];
223
								if (binaryPluginName != null && binaryPluginName.length() > 0 && versionEntry != null && versionEntry.length() > 0) {
213
							String binaryPluginName = currentElement.getValue();
224
									Version version = null;
214
							String versionEntry = currentElement.getAttribute(Constants.VERSION_ATTRIBUTE);
225
									try {
215
							// Currently the version attribute is required
226
										version = new Version(versionEntry);
216
							if (binaryPluginName != null && binaryPluginName.length() > 0 && versionEntry != null && versionEntry.length() > 0) {
227
									} catch (IllegalArgumentException e) {
217
								Version version = null;
228
										PDECore.log(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, PDECoreMessages.SourceLocationManager_problemProcessingBundleManifestSourceHeader, e));
218
								try {
229
									}
219
									version = new Version(versionEntry);
230
									fPluginToSourceBundle.put(new SourceLocationKey(binaryPluginName, version), externalModels[i]);
220
								} catch (IllegalArgumentException e) {
231
								} else {
221
									PDECore.log(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, PDECoreMessages.SourceLocationManager_problemProcessingBundleManifestSourceHeader, e));
232
									PDECore.log(new Status(IStatus.WARNING, PDECore.PLUGIN_ID, NLS.bind(PDECoreMessages.BundleManifestSourceLocationManager_problemProcessBundleManifestHeaderAttributeMissing, currentPlugin.getName())));
233
								}
222
								}
223
								fPluginToSourceBundle.put(new SourceLocationKey(binaryPluginName, version), externalModels[i]);
224
							} else {
225
								PDECore.log(new Status(IStatus.WARNING, PDECore.PLUGIN_ID, NLS.bind(PDECoreMessages.BundleManifestSourceLocationManager_problemProcessBundleManifestHeaderAttributeMissing, currentPlugin.getName())));
234
							}
226
							}
235
						}
227
						}
236
					}
228
					}
(-)src/org/eclipse/pde/internal/core/bundle/BundlePluginBase.java (+5 lines)
Lines 974-977 Link Here
974
		throw ce;
974
		throw ce;
975
	}
975
	}
976
976
977
	public String getBundleSourceEntry() {
978
		IManifestHeader header = getManifestHeader(ICoreConstants.ECLIPSE_SOURCE_BUNDLE);
979
		return header != null ? header.getValue() : null;
980
	}
981
977
}
982
}
(-)src/org/eclipse/pde/internal/ui/preferences/TargetSourceTab.java (-4 / +14 lines)
Lines 44-49 Link Here
44
public class TargetSourceTab {
44
public class TargetSourceTab {
45
	private Image fFolderImage;
45
	private Image fFolderImage;
46
	private TreeViewer fTreeViewer;
46
	private TreeViewer fTreeViewer;
47
	private Image fJarImage;
47
	private Image fExtensionImage;
48
	private Image fExtensionImage;
48
	private Image fUserImage;
49
	private Image fUserImage;
49
50
Lines 103-117 Link Here
103
		public String getText(Object obj) {
104
		public String getText(Object obj) {
104
			if (obj instanceof SourceLocation) {
105
			if (obj instanceof SourceLocation) {
105
				SourceLocation location = (SourceLocation) obj;
106
				SourceLocation location = (SourceLocation) obj;
106
				return location.getPath().toOSString();
107
				IPath path = location.getPath();
108
				if (path.toFile().isDirectory()) {
109
					return path.toOSString();
110
				}
111
				return new StringBuffer().append(path.lastSegment()).append(" (").append(path.toOSString()).append(")").toString(); //$NON-NLS-1$//$NON-NLS-2$
107
			}
112
			}
108
			return super.getText(obj);
113
			return super.getText(obj);
109
		}
114
		}
110
115
111
		public Image getImage(Object obj) {
116
		public Image getImage(Object obj) {
112
			if (obj instanceof SourceLocation)
117
			if (obj instanceof SourceLocation) {
113
				return fFolderImage;
118
				if (((SourceLocation) obj).getPath().toFile().isDirectory()) {
114
119
					return fFolderImage;
120
				}
121
				return fJarImage;
122
			}
115
			return obj.equals(fUserNode) ? fUserImage : fExtensionImage;
123
			return obj.equals(fUserNode) ? fUserImage : fExtensionImage;
116
		}
124
		}
117
	}
125
	}
Lines 131-136 Link Here
131
139
132
	private void initializeImages() {
140
	private void initializeImages() {
133
		fExtensionImage = PDEPluginImages.DESC_SOURCE_ATTACHMENT_OBJ.createImage();
141
		fExtensionImage = PDEPluginImages.DESC_SOURCE_ATTACHMENT_OBJ.createImage();
142
		fJarImage = PDEPluginImages.DESC_JAR_LIB_OBJ.createImage();
134
		ImageDescriptor userDesc = new OverlayIcon(PDEPluginImages.DESC_SOURCE_ATTACHMENT_OBJ, new ImageDescriptor[][] {{PDEPluginImages.DESC_DOC_CO}});
143
		ImageDescriptor userDesc = new OverlayIcon(PDEPluginImages.DESC_SOURCE_ATTACHMENT_OBJ, new ImageDescriptor[][] {{PDEPluginImages.DESC_DOC_CO}});
135
		fUserImage = userDesc.createImage();
144
		fUserImage = userDesc.createImage();
136
		fFolderImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
145
		fFolderImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
Lines 153-158 Link Here
153
	}
162
	}
154
163
155
	public void dispose() {
164
	public void dispose() {
165
		fJarImage.dispose();
156
		fExtensionImage.dispose();
166
		fExtensionImage.dispose();
157
		fUserImage.dispose();
167
		fUserImage.dispose();
158
	}
168
	}

Return to bug 232841