use of org.eclipse.core.runtime.IExtensionRegistry in project knime-core by knime.
the class PortTypeRegistry method scanExtensionPointForObjectSerializer.
private <T extends PortObject> Optional<PortObjectSerializer<T>> scanExtensionPointForObjectSerializer(final String objectClassName) {
// not found => scan extension point
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
Optional<IConfigurationElement> o = Stream.of(point.getExtensions()).flatMap(ext -> Stream.of(ext.getConfigurationElements())).filter(cfe -> cfe.getAttribute("objectClass").equals(objectClassName)).findFirst();
if (o.isPresent()) {
IConfigurationElement configElement = o.get();
return createObjectSerializer(configElement);
} else {
return Optional.empty();
}
}
use of org.eclipse.core.runtime.IExtensionRegistry in project knime-core by knime.
the class DatabaseUtilityRegistry method loadUtilities.
/**
*/
private void loadUtilities() {
final IExtensionRegistry registry = Platform.getExtensionRegistry();
final IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
assert point != null : "Invalid extension point id: " + EXT_POINT_ID;
for (IExtension ext : point.getExtensions()) {
final IConfigurationElement[] elements = ext.getConfigurationElements();
for (IConfigurationElement utilityElement : elements) {
try {
final DatabaseUtility utility = (DatabaseUtility) utilityElement.createExecutableExtension("class");
addUtility(utility);
} catch (CoreException ex) {
NodeLogger.getLogger(DatabaseUtilityRegistry.class).error("Could not create registered database utility " + utilityElement.getAttribute("class") + " from plug-in " + utilityElement.getNamespaceIdentifier() + ": " + ex.getMessage(), ex);
}
}
}
}
use of org.eclipse.core.runtime.IExtensionRegistry in project eclipse.platform.swt by eclipse.
the class LauncherPlugin method getLaunchItemTree.
/**
* Constructs a list of available programs from registered extensions.
*
* @return an ItemTreeNode representing the root of a tree of items (the root is not to be displayed)
*/
public static ItemTreeNode getLaunchItemTree() {
ItemTreeNode categoryTree = new ItemTreeNode(new ItemDescriptor("<<Root>>", "<<Root>>", null, null, null, null, null, null));
// get the platform's public plugin registry
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
// retrieve all configuration elements registered at our launchItems extension-point
IConfigurationElement[] configurationElements = extensionRegistry.getConfigurationElementsFor(LAUNCH_ITEMS_POINT_ID);
if (configurationElements == null || configurationElements.length == 0) {
logError(getResourceString("error.CouldNotFindRegisteredExtensions"), null);
return categoryTree;
}
/* Collect all launch categories -- coalesce those with same ID */
HashMap<String, ItemTreeNode> idMap = new HashMap<>();
for (IConfigurationElement ce : configurationElements) {
final String ceName = ce.getName();
final String attribId = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ID, null);
if (idMap.containsKey(attribId))
continue;
if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_CATEGORY)) {
final String attribName = getItemName(ce);
ItemDescriptor theDescriptor = new ItemDescriptor(attribId, attribName, getItemDescription(ce), null, null, null, null, ce);
idMap.put(attribId, new ItemTreeNode(theDescriptor));
}
}
/* Generate launch category hierarchy */
// used to prevent duplicates from being entered into the tree
Set<String> tempIdSet = new HashSet<>();
for (IConfigurationElement ce : configurationElements) {
final String ceName = ce.getName();
final String attribId = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ID, null);
if (tempIdSet.contains(attribId))
continue;
if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_CATEGORY)) {
final ItemTreeNode theNode = idMap.get(attribId);
addItemByCategory(ce, categoryTree, theNode, idMap);
tempIdSet.add(attribId);
}
}
/* Generate program tree */
for (IConfigurationElement ce : configurationElements) {
final String ceName = ce.getName();
final String attribId = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ID, null);
if (idMap.containsKey(attribId))
continue;
if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_CATEGORY)) {
// ignore
} else if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_ITEM)) {
final String enabled = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ENABLED, LAUNCH_ITEMS_XML_VALUE_TRUE);
if (enabled.equalsIgnoreCase(LAUNCH_ITEMS_XML_VALUE_FALSE))
continue;
ItemDescriptor theDescriptor = createItemDescriptor(ce, attribId);
if (theDescriptor != null) {
final ItemTreeNode theNode = new ItemTreeNode(theDescriptor);
addItemByCategory(ce, categoryTree, theNode, idMap);
idMap.put(attribId, theNode);
}
}
}
return categoryTree;
}
use of org.eclipse.core.runtime.IExtensionRegistry in project linuxtools by eclipse.
the class LibHover method getLibHoverDocs.
public static synchronized void getLibHoverDocs() {
if (docsFetched) {
return;
}
libraries.clear();
helpBooks.clear();
helpBooksMap.clear();
// Check if caching of library info is enabled and if so, get any
// cached library hover info.
IPreferenceStore ps = LibhoverPlugin.getDefault().getPreferenceStore();
if (ps.getBoolean(PreferenceConstants.CACHE_EXT_LIBHOVER)) {
// Look for cached libhover files in the plugin state location
IPath stateLocation = LibhoverPlugin.getDefault().getStateLocation();
IFileSystem fs = EFS.getLocalFileSystem();
// $NON-NLS-1$
IPath CLibraryLocation = stateLocation.append("C");
// $NON-NLS-1$
IPath CPPLibraryLocation = stateLocation.append("CPP");
IFileStore cDir = fs.getStore(CLibraryLocation);
if (cDir.fetchInfo().exists()) {
// $NON-NLS-1$
getCachedLibraries(cDir, "C");
}
IFileStore cppDir = fs.getStore(CPPLibraryLocation);
if (cppDir.fetchInfo().exists()) {
// $NON-NLS-1$
getCachedLibraries(cppDir, "C++");
}
}
IExtensionRegistry x = RegistryFactory.getRegistry();
IConfigurationElement[] ces = x.getConfigurationElementsFor(LIBHOVER_DOC_EXTENSION);
for (int i = 0; i < ces.length; ++i) {
IConfigurationElement ce = ces[i];
if (ce.getName().equals("library")) {
// $NON-NLS-1$
// see comment in initialize()
// Use the FileLocator class to open the magic hover doc file
// in the plugin's jar.
// Either open the html file or file system file depending
// on what has been specified.
// $NON-NLS-1$
String location = ce.getAttribute("location");
// $NON-NLS-1$
String name = ce.getAttribute("name");
// $NON-NLS-1$
String helpdocs = ce.getAttribute("docs");
// $NON-NLS-1$
String type = ce.getAttribute("type");
String nameSpace = ce.getContributor().getName();
// If library not already cached, create it
ICHelpBook book = helpBooksMap.get(name);
if (book == null) {
HelpBook h = new HelpBook(name, type);
helpBooks.add(h);
helpBooksMap.put(name, h);
LibHoverLibrary l = new LibHoverLibrary(name, location, helpdocs, nameSpace, // $NON-NLS-1$
"C++".equals(type));
libraries.put(h, l);
} else {
LibHoverLibrary l = libraries.get(book);
if (l != null) {
l.setDocs(helpdocs);
}
}
docsFetched = true;
}
}
}
use of org.eclipse.core.runtime.IExtensionRegistry in project knime-core by knime.
the class NodeFactoryClassMapper method collectNodeFactoryMappers.
private static List<NodeFactoryClassMapper> collectNodeFactoryMappers() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
if (point == null) {
LOGGER.error("Invalid extension point: " + EXT_POINT_ID);
return Collections.emptyList();
}
List<NodeFactoryClassMapper> resultList = new ArrayList<NodeFactoryClassMapper>();
for (IConfigurationElement elem : point.getConfigurationElements()) {
String classMapperCLName = elem.getAttribute(EXT_POINT_ATTR_CLASS_NAME);
String decl = elem.getDeclaringExtension().getUniqueIdentifier();
if (classMapperCLName == null || classMapperCLName.isEmpty()) {
LOGGER.error("The extension '" + decl + "' doesn't provide the required attribute '" + EXT_POINT_ATTR_CLASS_NAME + "' - ignoring it");
continue;
}
NodeFactoryClassMapper instance = null;
try {
instance = (NodeFactoryClassMapper) elem.createExecutableExtension(EXT_POINT_ATTR_CLASS_NAME);
} catch (Throwable t) {
LOGGER.error("Problems during initialization of node factory class mapper (with id '" + classMapperCLName + "'.)", t);
if (decl != null) {
LOGGER.error("Extension " + decl + " ignored.");
}
}
resultList.add(instance);
}
return Collections.unmodifiableList(resultList);
}
Aggregations