|
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 |
} |