Search in sources :

Example 76 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project knime-core by knime.

the class ExtensibleUtilityFactory method readRenderersFromExtensionPoint.

private void readRenderersFromExtensionPoint() {
    if (m_renderers != null) {
        return;
    }
    synchronized (m_logger) {
        if (m_renderers != null) {
            return;
        }
        Map<String, DataValueRendererFactory> renderers = new HashMap<String, DataValueRendererFactory>();
        IExtensionRegistry registry = Platform.getExtensionRegistry();
        IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
        assert point != null : "Invalid extension point id: " + EXT_POINT_ID;
        String defaultRendererId = null;
        for (IExtension ext : point.getExtensions()) {
            IConfigurationElement[] elements = ext.getConfigurationElements();
            for (IConfigurationElement valueClassElement : elements) {
                String valueClassName = valueClassElement.getAttribute("valueClass");
                if (!m_valueClass.getName().equals(valueClassName)) {
                    continue;
                }
                for (IConfigurationElement rendererClassElement : valueClassElement.getChildren()) {
                    boolean suggestAsDefault = Boolean.parseBoolean(rendererClassElement.getAttribute("suggestAsDefault"));
                    try {
                        DataValueRendererFactory rendererFactory = (DataValueRendererFactory) rendererClassElement.createExecutableExtension("rendererFactoryClass");
                        renderers.put(rendererFactory.getId(), rendererFactory);
                        if (suggestAsDefault || (defaultRendererId == null)) {
                            defaultRendererId = rendererFactory.getId();
                            CORE_DEFAULT_PREFS.put(getPreferenceKey(), defaultRendererId);
                        }
                    } catch (CoreException ex) {
                        m_logger.error("Could not load registered renderer factory " + rendererClassElement.getAttribute("rendererFactoryClass") + " for " + valueClassName + " from plug-in " + valueClassElement.getNamespaceIdentifier() + ": " + ex.getMessage(), ex);
                    }
                }
            }
        }
        m_renderers = renderers;
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) HashMap(java.util.HashMap) IExtension(org.eclipse.core.runtime.IExtension) DataValueRendererFactory(org.knime.core.data.renderer.DataValueRendererFactory) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 77 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project knime-core by knime.

the class MissingCellHandlerFactoryManager method registerExtensionPoints.

/**
 * Registers all extension point implementations.
 * @param extPointId id of the extension point
 * @param extPointAttrDf attribute of the factory class within the handler extension point
 */
protected void registerExtensionPoints(final String extPointId, final String extPointAttrDf) {
    try {
        final IExtensionRegistry registry = Platform.getExtensionRegistry();
        final IExtensionPoint point = registry.getExtensionPoint(extPointId);
        if (point == null) {
            LOGGER.error("Invalid extension point: " + extPointId);
            throw new IllegalStateException("ACTIVATION ERROR: " + " --> Invalid extension point: " + extPointId);
        }
        for (final IConfigurationElement elem : point.getConfigurationElements()) {
            final String operator = elem.getAttribute(extPointAttrDf);
            final String decl = elem.getDeclaringExtension().getUniqueIdentifier();
            if ((operator == null) || operator.isEmpty()) {
                LOGGER.error("The extension '" + decl + "' doesn't provide the required attribute '" + extPointAttrDf + "'");
                LOGGER.error("Extension " + decl + " ignored.");
                continue;
            }
            try {
                final MissingCellHandlerFactory factory = (MissingCellHandlerFactory) elem.createExecutableExtension(extPointAttrDf);
                addMissingCellHandlerFactory(factory);
            } catch (final Exception t) {
                LOGGER.error("Problems during initialization of missing value handler factory (with id '" + operator + "'.)");
                if (decl != null) {
                    LOGGER.error("Extension " + decl + " ignored.", t);
                }
            }
        }
    } catch (final Exception e) {
        LOGGER.error("Exception while registering MissingCellHandler extensions");
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) DoNothingMissingCellHandlerFactory(org.knime.base.node.preproc.pmml.missingval.handlers.DoNothingMissingCellHandlerFactory) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 78 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project knime-core by knime.

the class AbstractWizardNodeView method getAllWizardNodeViews.

/**
 * Queries extension point for additional {@link AbstractWizardNodeView} implementations.
 * @return A list with all registered view implementations.
 */
@SuppressWarnings("unchecked")
public static List<WizardNodeViewExtension> getAllWizardNodeViews() {
    List<WizardNodeViewExtension> viewExtensionList = new ArrayList<WizardNodeViewExtension>();
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
    assert point != null : "Invalid extension point id: " + EXT_POINT_ID;
    for (IExtension ext : point.getExtensions()) {
        IConfigurationElement[] elements = ext.getConfigurationElements();
        for (IConfigurationElement viewElement : elements) {
            String viewClassName = viewElement.getAttribute("viewClass");
            String viewName = viewElement.getAttribute("name");
            String viewDesc = viewElement.getAttribute("description");
            Class<AbstractWizardNodeView<?, ?, ?>> viewClass;
            try {
                viewClass = (Class<AbstractWizardNodeView<?, ?, ?>>) Class.forName(viewClassName);
                viewExtensionList.add(new WizardNodeViewExtension(viewClass, viewName, viewDesc));
            } catch (ClassNotFoundException ex) {
                NodeLogger.getLogger(AbstractWizardNodeView.class).coding("Could not find implementation for " + viewClassName, ex);
            }
        }
    }
    return viewExtensionList;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension) ArrayList(java.util.ArrayList) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 79 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project knime-core by knime.

the class WebResourceController method getConfigurationFromID.

private static IConfigurationElement getConfigurationFromID(final String extensionPointId, final String configurationID, final String jsObjectID) {
    if (jsObjectID != null) {
        IExtensionRegistry registry = Platform.getExtensionRegistry();
        IConfigurationElement[] configurationElements = registry.getConfigurationElementsFor(extensionPointId);
        for (IConfigurationElement element : configurationElements) {
            if (jsObjectID.equals(element.getAttribute(configurationID))) {
                return element;
            }
        }
    }
    return null;
}
Also used : IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 80 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project bndtools by bndtools.

the class PluginsPart method doEdit.

void doEdit() {
    HeaderClause header = (HeaderClause) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
    if (header != null) {
        Attrs copyOfProperties = new Attrs(header.getAttribs());
        IConfigurationElement configElem = configElements.get(header.getName());
        PluginEditWizard wizard = new PluginEditWizard(configElem, copyOfProperties);
        WizardDialog dialog = new WizardDialog(getManagedForm().getForm().getShell(), wizard);
        if (dialog.open() == Window.OK && wizard.isChanged()) {
            header.getAttribs().clear();
            header.getAttribs().putAll(copyOfProperties);
            viewer.update(header, null);
            markDirty();
        }
    }
}
Also used : Attrs(aQute.bnd.header.Attrs) HeaderClause(aQute.bnd.build.model.clauses.HeaderClause) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)189 CoreException (org.eclipse.core.runtime.CoreException)75 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)64 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)50 ArrayList (java.util.ArrayList)39 IExtension (org.eclipse.core.runtime.IExtension)30 IStatus (org.eclipse.core.runtime.IStatus)24 Status (org.eclipse.core.runtime.Status)24 HashMap (java.util.HashMap)16 HashSet (java.util.HashSet)16 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)11 List (java.util.List)9 Map (java.util.Map)9 Platform (org.eclipse.core.runtime.Platform)9 File (java.io.File)8 Collection (java.util.Collection)8 Stream (java.util.stream.Stream)8 LinkedList (java.util.LinkedList)7 Optional (java.util.Optional)5 IFile (org.eclipse.core.resources.IFile)5