how to get other plugins’ info ( toc as example)
2005/10/09 § 5条评论
contributingPlugins2IndexPaths = new HashMap();
Collection contributedTocFiles = new ArrayList();
Collection ignored = getIgnoredTocs(); get the ignored plugins
// find extension point
IExtensionPoint xpt = Platform.getExtensionRegistry()
.getExtensionPoint(HelpPlugin.PLUGIN_ID, TOC_XP_NAME); get the extension point of toc
if (xpt == null)
return contributedTocFiles;
// get all extensions
IExtension[] extensions = xpt.getExtensions(); get plugins extends the extension point
IExtension[] extensions = xpt.getExtensions(); get plugins extends the extension point
for (int i = 0; i < extensions.length; i++) {
String pluginId = extensions[i].getNamespace(); get the plugin name
if(!contributingPlugins2IndexPaths.containsKey(pluginId)) {
contributingPlugins2IndexPaths.put(pluginId, null);
}
IConfigurationElement[] configElements = extensions[i]
.getConfigurationElements();
.getConfigurationElements();
for (int j = 0; j < configElements.length; j++){
if (configElements[j].getName().equals(TOC_ELEMENT_NAME)) { TOC_ELEMENT_NAME = toc
// add to TocFiles declared in this extension
String href = configElements[j].getAttribute("file"); //$NON-NLS-1$ may be toc.xml
if (href == null
|| ignored.contains("/" + pluginId + "/" + href)) { //$NON-NLS-1$ //$NON-NLS-2$
continue;
}
boolean isPrimary = "true".equals( //$NON-NLS-1$
configElements[j].getAttribute("primary")); //$NON-NLS-1$
configElements[j].getAttribute("primary")); //$NON-NLS-1$
String extraDir = configElements[j]
.getAttribute("extradir"); //$NON-NLS-1$
contributedTocFiles.add(new TocFile(pluginId, href,
isPrimary, locale, extraDir));
isPrimary, locale, extraDir));
} else if (configElements[j].getName().equals(INDEX_ELEMENT_NAME)) { index
// add to index paths declared in this extension
String path = configElements[j].getAttribute("path"); //$NON-NLS-1$
String path = configElements[j].getAttribute("path"); //$NON-NLS-1$
if (path == null
|| path.length()==0) {
continue;
}
|| path.length()==0) {
continue;
}
// override entry map entry with new one, only one index path per plugin allowed
contributingPlugins2IndexPaths.put(pluginId, path);
contributingPlugins2IndexPaths.put(pluginId, path);
}
}