Search in sources :

Example 61 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project webtools.sourceediting by eclipse.

the class JSPTranslator method getELTranslator.

/**
 * Discover and instantiate an EL translator.
 */
public IJSPELTranslator getELTranslator() {
    if (fELTranslator == null) {
        /*
			 * name of plugin that exposes this extension point
			 */
        // -
        IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(JSP_CORE_PLUGIN_ID, EL_TRANSLATOR_EXTENSION_NAME);
        // extension
        // id
        // Iterate over all declared extensions of this extension point.
        // A single plugin may extend the extension point more than once,
        // although it's not recommended.
        IConfigurationElement bestTranslator = null;
        IExtension[] extensions = extensionPoint.getExtensions();
        for (int curExtension = 0; curExtension < extensions.length; curExtension++) {
            IExtension extension = extensions[curExtension];
            IConfigurationElement[] translators = extension.getConfigurationElements();
            for (int curTranslator = 0; curTranslator < translators.length; curTranslator++) {
                IConfigurationElement elTranslator = translators[curTranslator];
                if (!EL_TRANSLATOR_EXTENSION_NAME.equals(elTranslator.getName())) {
                    // configElement
                    continue;
                }
                // $NON-NLS-1$
                String idString = elTranslator.getAttribute("id");
                if (null != idString && idString.equals(fELTranslatorID) || (null == bestTranslator && DEFAULT_JSP_EL_TRANSLATOR_ID.equals(idString))) {
                    bestTranslator = elTranslator;
                }
            }
        }
        if (null != bestTranslator) {
            try {
                // $NON-NLS-1$
                Object execExt = bestTranslator.createExecutableExtension("class");
                if (execExt instanceof IJSPELTranslator) {
                    return fELTranslator = (IJSPELTranslator) execExt;
                }
            } catch (CoreException e) {
                Logger.logException(e);
            }
        }
    }
    return fELTranslator;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) IJSPELTranslator(org.eclipse.jst.jsp.core.jspel.IJSPELTranslator) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 62 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project webtools.sourceediting by eclipse.

the class EmbeddedTypeRegistryReader method readRegistry.

/**
 * We simply require an 'add' method, of what ever it is we are to read
 * into
 */
void readRegistry(Set set) {
    IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
    IExtensionPoint point = extensionRegistry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
    if (point != null) {
        IConfigurationElement[] elements = point.getConfigurationElements();
        for (int i = 0; i < elements.length; i++) {
            EmbeddedTypeHandler embeddedContentType = readElement(elements[i]);
            // element
            if (embeddedContentType != null) {
                set.add(embeddedContentType);
            }
        }
    }
}
Also used : EmbeddedTypeHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 63 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project webtools.sourceediting by eclipse.

the class PluginContributedFactoryReader method loadRegistry.

protected List loadRegistry(Object contentType) {
    // new Vector();
    List factoryList = null;
    IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
    IExtensionPoint point = extensionRegistry.getExtensionPoint(SSECorePlugin.ID, EXTENSION_POINT_ID);
    if (point != null) {
        IConfigurationElement[] elements = point.getConfigurationElements();
        if (elements.length > 0) {
            // this is called a lot, so don't create vector unless really
            // needed
            // TODO: could eventually cache in a hashtable, or something,
            // to avoid repeat processing
            factoryList = new Vector();
            for (int i = 0; i < elements.length; i++) {
                INodeAdapterFactory factory = loadFactoryFromConfigurationElement(elements[i], contentType);
                if (factory != null)
                    factoryList.add(factory);
            }
        }
    }
    return factoryList;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) List(java.util.List) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) Vector(java.util.Vector) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 64 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project webtools.sourceediting by eclipse.

the class SchemaProcessorRegistryReader method readRegistry.

/**
 * read from plugin registry and parse it.
 */
protected void readRegistry() {
    IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry();
    IExtensionPoint point = pluginRegistry.getExtensionPoint(JSONCorePlugin.getDefault().getBundle().getSymbolicName(), EXTENSION_POINT_ID);
    if (point != null) {
        IConfigurationElement[] elements = point.getConfigurationElements();
        for (int i = 0; i < elements.length; i++) {
            readElement(elements[i]);
        }
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 65 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project webtools.sourceediting by eclipse.

the class RuntimePresetMappingRegistry method readDescriptors.

private void readDescriptors() {
    descriptors = new ArrayList<MappingDescriptor>();
    IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(WSTWebPlugin.PLUGIN_ID, EXTENSION_POINT);
    if (point == null)
        return;
    IConfigurationElement[] elements = point.getConfigurationElements();
    for (int i = 0; i < elements.length; i++) {
        IConfigurationElement element = elements[i];
        if (ELEMENT_MAPPING.equals(element.getName())) {
            String id = element.getAttribute(ATTRIBUTE_ID);
            if (null == id || id.trim().length() == 0) {
                // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                WSTWebPlugin.logError("Extension: " + EXTENSION_POINT + " Element: " + ELEMENT_MAPPING + " is missing attribute " + ATTRIBUTE_ID);
                continue;
            }
            String runtimeID = element.getAttribute(ATTRIBUTE_FACET_RUNTIME_TYPE_ID);
            if (null == runtimeID || runtimeID.trim().length() == 0) {
                // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                WSTWebPlugin.logError("Extension: " + EXTENSION_POINT + " Element: " + ELEMENT_MAPPING + " is missing attribute " + ATTRIBUTE_FACET_RUNTIME_TYPE_ID);
                continue;
            }
            List<String> staticRuntimeIDs = getStaticTokens(runtimeID);
            List<IRuntimeComponentType> staticRuntimeTypes = new ArrayList<IRuntimeComponentType>();
            for (String staticRuntimeID : staticRuntimeIDs) {
                try {
                    IRuntimeComponentType runtimeType = RuntimeManager.getRuntimeComponentType(staticRuntimeID);
                    if (runtimeType != null) {
                        staticRuntimeTypes.add(runtimeType);
                    }
                } catch (IllegalArgumentException e) {
                    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                    WSTWebPlugin.logError("Extension: " + EXTENSION_POINT + " Element: " + ELEMENT_MAPPING + " defined invalid attribute " + ATTRIBUTE_FACET_RUNTIME_TYPE_ID + ": " + runtimeID + " unable to resolve runtime: " + staticRuntimeID, e);
                }
            }
            String runtimeVersionStr = element.getAttribute(ATTRIBUTE_FACET_RUNTIME_VERSION);
            if (null == runtimeVersionStr || runtimeVersionStr.trim().length() == 0) {
                // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                WSTWebPlugin.logError("Extension: " + EXTENSION_POINT + " Element: " + ELEMENT_MAPPING + " is missing attribute " + ATTRIBUTE_FACET_RUNTIME_VERSION);
                continue;
            }
            if (!staticRuntimeTypes.isEmpty()) {
                List<String> staticRuntimeVersions = getStaticTokens(runtimeVersionStr);
                for (String staticVersion : staticRuntimeVersions) {
                    boolean foundVersion = false;
                    for (int k = 0; k < staticRuntimeTypes.size() && !foundVersion; k++) {
                        IRuntimeComponentType runtimeType = staticRuntimeTypes.get(k);
                        try {
                            runtimeType.getVersion(staticVersion);
                            foundVersion = true;
                        } catch (IllegalArgumentException e) {
                        // eat it
                        }
                    }
                    if (!foundVersion) {
                        // $NON-NLS-1$
                        StringBuffer validVersions = new StringBuffer(" valid versions include: ");
                        for (IRuntimeComponentType runtimeType : staticRuntimeTypes) {
                            // $NON-NLS-1$
                            validVersions.append("\n");
                            validVersions.append(runtimeType.getId());
                            // $NON-NLS-1$
                            validVersions.append(": ");
                            for (Iterator<IRuntimeComponentVersion> iterator = runtimeType.getVersions().iterator(); iterator.hasNext(); ) {
                                validVersions.append(iterator.next().getVersionString());
                                if (iterator.hasNext()) {
                                    // $NON-NLS-1$
                                    validVersions.append(" ");
                                }
                            }
                        }
                        WSTWebPlugin.logError(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                        "Extension: " + EXTENSION_POINT + " Element: " + ELEMENT_MAPPING + " defined invalid attribute " + ATTRIBUTE_FACET_RUNTIME_VERSION + ": " + staticVersion + validVersions);
                    }
                }
            }
            String facetID = element.getAttribute(ATTRIBUTE_FACET_ID);
            if (null == facetID || facetID.trim().length() == 0) {
                // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                WSTWebPlugin.logError("Extension: " + EXTENSION_POINT + " Element: " + ELEMENT_MAPPING + " is missing attribute " + ATTRIBUTE_FACET_ID);
                continue;
            }
            List<String> staticFacetIDs = getStaticTokens(facetID);
            List<IProjectFacet> staticFacets = new ArrayList<IProjectFacet>();
            for (String staticFacetID : staticFacetIDs) {
                try {
                    IProjectFacet facet = ProjectFacetsManager.getProjectFacet(staticFacetID);
                    if (null != facet) {
                        staticFacets.add(facet);
                    }
                } catch (IllegalArgumentException e) {
                    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                    WSTWebPlugin.logError("Extension: " + EXTENSION_POINT + " Element: " + ELEMENT_MAPPING + " defined invalid attribute " + ATTRIBUTE_FACET_ID + ": " + staticFacetID, e);
                }
            }
            String facetVersionStr = element.getAttribute(ATTRIBUTE_FACET_VERSION);
            if (null == facetVersionStr || facetVersionStr.trim().length() == 0) {
                // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                WSTWebPlugin.logError("Extension: " + EXTENSION_POINT + " Element: " + ELEMENT_MAPPING + " is missing attribute " + ATTRIBUTE_FACET_VERSION);
                continue;
            }
            List<String> staticFacetVersionStrs = getStaticTokens(facetVersionStr);
            if (!staticFacets.isEmpty() && !staticFacetVersionStrs.isEmpty()) {
                for (String staticFacetVersion : staticFacetVersionStrs) {
                    boolean foundFacetVersion = false;
                    for (int k = 0; k < staticFacets.size() && !foundFacetVersion; k++) {
                        IProjectFacet staticFacet = staticFacets.get(k);
                        try {
                            IProjectFacetVersion staticVersion = staticFacet.getVersion(staticFacetVersion);
                            if (staticVersion != null) {
                                foundFacetVersion = true;
                            }
                        } catch (IllegalArgumentException e) {
                        // eat it
                        }
                    }
                    if (!foundFacetVersion) {
                        // $NON-NLS-1$
                        StringBuffer validVersions = new StringBuffer(" valid versions include: ");
                        for (IProjectFacet staticFacet : staticFacets) {
                            // $NON-NLS-1$
                            validVersions.append("\n");
                            validVersions.append(staticFacet.getId());
                            // $NON-NLS-1$
                            validVersions.append(": ");
                            for (Iterator<IProjectFacetVersion> iterator = staticFacet.getVersions().iterator(); iterator.hasNext(); ) {
                                validVersions.append(iterator.next().getVersionString());
                                if (iterator.hasNext()) {
                                    // $NON-NLS-1$
                                    validVersions.append(" ");
                                }
                            }
                        }
                        WSTWebPlugin.logError(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                        "Extension: " + EXTENSION_POINT + " Element: " + ELEMENT_MAPPING + " defined invalid attribute " + ATTRIBUTE_FACET_VERSION + ": " + staticFacetVersion + validVersions);
                        continue;
                    }
                }
            }
            String presetID = element.getAttribute(ATTRIBUTE_PRESET_ID);
            if (null == presetID || presetID.trim().length() == 0) {
                // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                WSTWebPlugin.logError("Extension: " + EXTENSION_POINT + " Element: " + ELEMENT_MAPPING + " is missing attribute " + ATTRIBUTE_PRESET_ID);
                continue;
            }
            try {
                ProjectFacetsManager.getPreset(presetID);
            } catch (IllegalArgumentException e) {
                // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                WSTWebPlugin.logError("Extension: " + EXTENSION_POINT + " Element: " + ELEMENT_MAPPING + " defined invalid attribute " + ATTRIBUTE_PRESET_ID + ": " + presetID, e);
                continue;
            }
            MappingDescriptor descriptor = new MappingDescriptor(element);
            descriptors.add(descriptor);
        } else {
            // $NON-NLS-1$ //$NON-NLS-2$
            WSTWebPlugin.logError("Elements must be named: " + ELEMENT_MAPPING + " within the extension: " + EXTENSION_POINT);
            // $NON-NLS-1$ //$NON-NLS-2$
            WSTWebPlugin.logError("Element: " + element.getName() + " is invalid within the extension: " + EXTENSION_POINT);
        }
    }
}
Also used : IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) ArrayList(java.util.ArrayList) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IRuntimeComponentVersion(org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponentVersion) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet) IRuntimeComponentType(org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponentType)

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