use of org.eclipse.core.runtime.IExtensionPoint in project knime-core by knime.
the class NodeFactoryExtensionManager method collectNodeSetFactoryExtensions.
private void collectNodeSetFactoryExtensions() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(ID_NODE_SET);
CheckUtils.checkState(point != null, "Invalid extension point: %s", ID_NODE_SET);
m_nodeSetFactoryExtensions = //
Arrays.stream(point.getExtensions()).flatMap(//
ext -> Stream.of(ext.getConfigurationElements())).parallel().map(//
NodeSetFactoryExtension::from).filter(//
Optional::isPresent).map(//
Optional::get).collect(Collectors.toList());
for (NodeSetFactoryExtension nodeSetFactoryExtension : m_nodeSetFactoryExtensions) {
nodeSetFactoryExtension.getClassNameToFactoryMap().keySet().stream().forEach(clName -> m_factoryNameToNodeSetFactoryExtensionMap.put(clName, nodeSetFactoryExtension));
}
}
use of org.eclipse.core.runtime.IExtensionPoint in project knime-core by knime.
the class NodeFactoryExtensionManager method collectNodeFactoryExtensions.
private void collectNodeFactoryExtensions() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(ID_NODE);
CheckUtils.checkState(point != null, "Invalid extension point: %s", ID_NODE);
@SuppressWarnings("null") Iterator<IConfigurationElement> it = //
Arrays.stream(point.getExtensions()).flatMap(ext -> Stream.of(ext.getConfigurationElements())).iterator();
while (it.hasNext()) {
try {
NodeFactoryExtension nodeFactoryExtension = new NodeFactoryExtension(it.next());
m_factoryNameToNodeFactoryExtensionMap.put(nodeFactoryExtension.getFactoryClassName(), nodeFactoryExtension);
} catch (IllegalArgumentException iae) {
LOGGER.error(iae.getMessage(), iae);
}
}
}
use of org.eclipse.core.runtime.IExtensionPoint in project knime-core by knime.
the class PortTypeRegistry method availablePortTypes.
/**
* Returns a collection with all known data types (that registered at the extension point
* <tt>org.knime.core.DataType</tt>. The returned collection is not sorted in any particular order.
*
* @return a (possibly empty) collection with data types
*/
public synchronized Collection<PortType> availablePortTypes() {
// perform lazy initialization
if (!m_allPortTypesRead) {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
Stream.of(point.getExtensions()).flatMap(ext -> Stream.of(ext.getConfigurationElements())).filter(e -> getObjectClass(e.getAttribute("objectClass")).isPresent()).forEach(e -> createPortTypes(e));
m_allPortTypesRead = true;
}
return m_allPortTypes.values();
}
use of org.eclipse.core.runtime.IExtensionPoint in project knime-core by knime.
the class TableStoreFormatRegistry method createInstance.
private static TableStoreFormatRegistry createInstance() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
List<TableStoreFormat> formatList = Stream.of(point.getExtensions()).flatMap(ext -> Stream.of(ext.getConfigurationElements())).map(cfe -> readFormat(cfe)).filter(f -> f != null).sorted(Comparator.comparing(f -> f.getClass().getSimpleName(), (a, b) -> {
// sort formats so that the "KNIME standard" format comes first.
if (Objects.equals(a, b)) {
return 0;
} else if (DefaultTableStoreFormat.class.getName().equals(a)) {
return -1;
} else if (DefaultTableStoreFormat.class.getName().equals(b)) {
return +1;
} else {
return a.compareTo(b);
}
})).collect(Collectors.toList());
boolean hasFallback = formatList.stream().anyMatch(f -> f.getClass().equals(DefaultTableStoreFormat.class));
CheckUtils.checkState(hasFallback, "No fallback table format registered, expected '%s' but not present in '%s'", DefaultTableStoreFormat.class.getName(), StringUtils.join(formatList.stream().map(f -> f.getClass().getName()).iterator(), ", "));
return new TableStoreFormatRegistry(formatList);
}
use of org.eclipse.core.runtime.IExtensionPoint in project knime-core by knime.
the class ImagePortObject method collectImageContentFactories.
private static Map<String, ImageContentFactory> collectImageContentFactories() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(ImageContentFactory.EXT_POINT_ID);
if (point == null) {
LOGGER.error("Invalid extension point: " + ImageContentFactory.EXT_POINT_ID);
return Collections.emptyMap();
}
Map<String, ImageContentFactory> resultList = new HashMap<>();
for (IConfigurationElement elem : point.getConfigurationElements()) {
String imageContentCLName = elem.getAttribute(ImageContentFactory.EXT_POINT_ATTR_CLASS_NAME);
String decl = elem.getDeclaringExtension().getUniqueIdentifier();
if (imageContentCLName == null || imageContentCLName.isEmpty()) {
LOGGER.error("The extension '" + decl + "' doesn't provide the required attribute '" + ImageContentFactory.EXT_POINT_ATTR_CLASS_NAME + "' - ignoring it");
continue;
}
ImageContentFactory instance = null;
try {
instance = (ImageContentFactory) elem.createExecutableExtension(ImageContentFactory.EXT_POINT_ATTR_CLASS_NAME);
} catch (Throwable t) {
LOGGER.error("Problems during initialization of image content factory (with id '" + imageContentCLName + "'.)", t);
if (decl != null) {
LOGGER.error("Extension " + decl + " ignored.");
}
}
if (instance != null) {
// We do not want to add invalid image content impls to this list.
resultList.put(instance.getImageContentClass().getName(), instance);
}
}
// add the image content implementations from core
resultList.put(PNGImageContent.class.getName(), new ImageContentFactory() {
@Override
public Class<? extends ImageContent> getImageContentClass() {
return PNGImageContent.class;
}
@Override
public ImageContent create(final InputStream in) throws IOException {
return new PNGImageContent(in);
}
});
return Collections.unmodifiableMap(resultList);
}
Aggregations