Search in sources :

Example 81 with IExtensionPoint

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

the class DataTypeRegistry method getExtensionPoint.

private static IExtensionPoint getExtensionPoint() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
    assert point != null : "Invalid extension point id: " + EXT_POINT_ID;
    return point;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 82 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint 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 83 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project xtext-eclipse by eclipse.

the class SharedStateContributionRegistryImpl method initializeContributions.

private synchronized ImmutableList<? extends SharedStateContribution> initializeContributions() {
    if (contributions == null) {
        final ImmutableList.Builder<SharedStateContribution> listBuilder = ImmutableList.builder();
        IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(EXTENSION_POINT);
        IExtension[] extensions = extensionPoint.getExtensions();
        for (IExtension extension : extensions) {
            IConfigurationElement[] configurationElements = extension.getConfigurationElements();
            for (IConfigurationElement configurationElement : configurationElements) {
                try {
                    Module childModule = (Module) configurationElement.createExecutableExtension("class");
                    SharedStateContribution contribution = createContribution(childModule);
                    listBuilder.add(contribution);
                } catch (CoreException e) {
                    logger.error(e.getMessage(), e);
                } catch (ProvisionException e) {
                    logger.error(e.getMessage(), e);
                }
            }
        }
        contributions = listBuilder.build();
    }
    return contributions;
}
Also used : ProvisionException(com.google.inject.ProvisionException) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) ImmutableList(com.google.common.collect.ImmutableList) IExtension(org.eclipse.core.runtime.IExtension) Module(com.google.inject.Module) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) SharedStateContribution(org.eclipse.xtext.ui.shared.contribution.SharedStateContribution)

Example 84 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project xtext-eclipse by eclipse.

the class Activator method initializeInjector.

protected void initializeInjector(BundleContext context) throws CoreException {
    IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID + ".overridingGuiceModule");
    IExtension[] extensions = point.getExtensions();
    Module module = new SharedModule(context);
    if (extensions.length != 0) {
        int numberOfMixedInModules = 0;
        for (IExtension iExtension : extensions) {
            IConfigurationElement[] elements = iExtension.getConfigurationElements();
            for (IConfigurationElement e : elements) {
                try {
                    Module m = (Module) e.createExecutableExtension("class");
                    module = Modules.override(module).with(m);
                    numberOfMixedInModules++;
                    if (numberOfMixedInModules == 2) {
                        log.warn("Multiple overriding guice modules. Will use them in unspecified order.");
                    }
                } catch (CoreException e1) {
                    log.error(e1.getMessage(), e1);
                }
            }
        }
    }
    try {
        injector = Guice.createInjector(module);
        injector.createChildInjector(new Module() {

            @Override
            public void configure(Binder binder) {
                binder.bind(EagerContributionInitializer.class);
            }
        }).injectMembers(this);
    } catch (Throwable t) {
        handleGuiceInitializationError(t);
    }
}
Also used : Binder(com.google.inject.Binder) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) Module(com.google.inject.Module) DefaultUiModule(org.eclipse.xtext.ui.DefaultUiModule) DefaultIdeModule(org.eclipse.xtext.ide.DefaultIdeModule) XtextRuntimeModule(org.eclipse.xtext.XtextRuntimeModule) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 85 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project xtext-eclipse by eclipse.

the class RegisteredGenmodelTest method testCanResolveGenmodelURIs.

@Ignore
@Test
public void testCanResolveGenmodelURIs() {
    String declaringPlugin = "org.eclipse.emf.ecore";
    String pointId = "generated_package";
    IExtensionPoint point = registry.getExtensionPoint(declaringPlugin + "." + pointId);
    IExtension[] extensions = point.getExtensions();
    for (IExtension extension : extensions) {
        IConfigurationElement[] configurationElements = extension.getConfigurationElements();
        for (IConfigurationElement configurationElement : configurationElements) {
            String attribute = configurationElement.getAttribute("genModel");
            if (attribute != null && attribute.length() != 0) {
                String name = extension.getContributor().getName();
                String uriAsString = "platform:/plugin/" + name + "/" + attribute;
                URI uri = URI.createURI(uriAsString);
                boolean exists = URIConverter.INSTANCE.exists(uri, Collections.emptyMap());
                if (!exists) {
                    fail(uriAsString + " does not exist");
                }
            }
        }
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) URI(org.eclipse.emf.common.util.URI) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)187 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)160 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)107 IExtension (org.eclipse.core.runtime.IExtension)92 CoreException (org.eclipse.core.runtime.CoreException)70 ArrayList (java.util.ArrayList)29 HashMap (java.util.HashMap)17 Platform (org.eclipse.core.runtime.Platform)17 Stream (java.util.stream.Stream)16 List (java.util.List)15 NodeLogger (org.knime.core.node.NodeLogger)15 Map (java.util.Map)14 Optional (java.util.Optional)14 Collection (java.util.Collection)9 Bundle (org.osgi.framework.Bundle)9 Collectors (java.util.stream.Collectors)8 IOException (java.io.IOException)6 Collections (java.util.Collections)6 LinkedList (java.util.LinkedList)6 Objects (java.util.Objects)6