Search in sources :

Example 11 with IExtensionRegistry

use of org.eclipse.core.runtime.IExtensionRegistry in project eclipse.platform.text by eclipse.

the class HyperlinkDetectorDescriptor method getContributedHyperlinkDetectors.

/**
 * Returns descriptors for all hyperlink detector extensions.
 *
 * @return an array with the contributed hyperlink detectors
 */
public static HyperlinkDetectorDescriptor[] getContributedHyperlinkDetectors() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IConfigurationElement[] elements = registry.getConfigurationElementsFor(HYPERLINK_DETECTORS_EXTENSION_POINT);
    HyperlinkDetectorDescriptor[] hyperlinkDetectorDescs = createDescriptors(elements);
    return hyperlinkDetectorDescs;
}
Also used : IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 12 with IExtensionRegistry

use of org.eclipse.core.runtime.IExtensionRegistry in project eclipse.platform.text by eclipse.

the class HyperlinkDetectorTargetDescriptor method getContributedHyperlinkDetectorTargets.

/**
 * Returns descriptors for all hyperlink detector extensions.
 *
 * @return an array with the contributed hyperlink detectors
 */
public static HyperlinkDetectorTargetDescriptor[] getContributedHyperlinkDetectorTargets() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IConfigurationElement[] elements = registry.getConfigurationElementsFor(HYPERLINK_DETECTOR_TARGETS_EXTENSION_POINT);
    HyperlinkDetectorTargetDescriptor[] hyperlinkDetectorDescs = createDescriptors(elements);
    return hyperlinkDetectorDescs;
}
Also used : IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 13 with IExtensionRegistry

use of org.eclipse.core.runtime.IExtensionRegistry in project eclipse.platform.text by eclipse.

the class RulerColumnRegistry method reload.

/**
 * Reloads the extensions to the extension point.
 * <p>
 * This method can be called more than once in order to reload from
 * a changed extension registry.
 * </p>
 */
public void reload() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    List<IConfigurationElement> elements = new ArrayList<>(Arrays.asList(registry.getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, EXTENSION_POINT)));
    List<RulerColumnDescriptor> descriptors = new ArrayList<>();
    Map<String, RulerColumnDescriptor> descriptorMap = new HashMap<>();
    for (Iterator<IConfigurationElement> iter = elements.iterator(); iter.hasNext(); ) {
        IConfigurationElement element = iter.next();
        try {
            RulerColumnDescriptor desc = new RulerColumnDescriptor(element, this);
            String id = desc.getId();
            if (descriptorMap.containsKey(id)) {
                noteDuplicateId(desc);
                continue;
            }
            descriptors.add(desc);
            descriptorMap.put(id, desc);
        } catch (InvalidRegistryObjectException x) {
            /*
				 * Element is not valid any longer as the contributing plug-in was unloaded or for
				 * some other reason. Do not include the extension in the list and inform the user
				 * about it.
				 */
            noteInvalidExtension(element, x);
        } catch (CoreException x) {
            warnUser(x.getStatus());
        }
    }
    sort(descriptors);
    synchronized (this) {
        fDescriptors = Collections.unmodifiableList(descriptors);
        fDescriptorMap = Collections.unmodifiableMap(descriptorMap);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InvalidRegistryObjectException(org.eclipse.core.runtime.InvalidRegistryObjectException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 14 with IExtensionRegistry

use of org.eclipse.core.runtime.IExtensionRegistry in project eclipse.platform.text by eclipse.

the class QuickDiffExtensionsRegistry method reloadExtensions.

/**
 * Reads all extensions.
 * <p>
 * This method can be called more than once in
 * order to reload from a changed extension registry.
 * </p>
 */
public synchronized void reloadExtensions() {
    fDefaultDescriptor = null;
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    List<ReferenceProviderDescriptor> list = new ArrayList<>();
    IConfigurationElement[] elements = registry.getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, TextEditorPlugin.REFERENCE_PROVIDER_EXTENSION_POINT);
    for (int i = 0; i < elements.length; i++) {
        ReferenceProviderDescriptor desc = new ReferenceProviderDescriptor(elements[i]);
        if (// $NON-NLS-1$
        desc.getId().equals("org.eclipse.ui.internal.editors.quickdiff.LastSaveReferenceProvider"))
            fDefaultDescriptor = desc;
        list.add(desc);
    }
    // make sure the default is the first one in the list
    if (fDefaultDescriptor != null) {
        list.remove(fDefaultDescriptor);
        list.add(0, fDefaultDescriptor);
    }
    fDescriptors = Collections.unmodifiableList(list);
}
Also used : ReferenceProviderDescriptor(org.eclipse.ui.texteditor.quickdiff.ReferenceProviderDescriptor) ArrayList(java.util.ArrayList) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 15 with IExtensionRegistry

use of org.eclipse.core.runtime.IExtensionRegistry in project linuxtools by eclipse.

the class STBinutilsFactoryManager method getBinutilsFactoryImpl.

/**
 * Try to find an extension point matching the given cpu; Then test availability of the tools. If no match, return
 * default binutils factory
 * @param cpu The cpu identifier.
 * @return The factory.
 */
private static ISTBinutilsFactory getBinutilsFactoryImpl(String cpu) {
    try {
        IExtensionRegistry reg = Platform.getExtensionRegistry();
        // $NON-NLS-1$
        IExtensionPoint ep = reg.getExtensionPoint("org.eclipse.linuxtools.binutils.crossCompilerBinutils");
        IExtension[] exts = ep.getExtensions();
        for (IExtension extension : exts) {
            IConfigurationElement[] elems = extension.getConfigurationElements();
            for (IConfigurationElement configurationElement : elems) {
                // $NON-NLS-1$
                String s = configurationElement.getAttribute("CPU");
                if (cpu.equals(s)) {
                    ISTBinutilsFactory factory = (ISTBinutilsFactory) configurationElement.createExecutableExtension(// $NON-NLS-1$
                    "binutilsFactory");
                    if (factory.testAvailability())
                        return factory;
                }
            }
        }
    } catch (CoreException e) {
        Activator.getDefault().getLog().log(e.getStatus());
    }
    if (defaultFactory == null) {
        defaultFactory = new DefaultBinutilsFactory();
    }
    return defaultFactory;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Aggregations

IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)55 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)50 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)33 CoreException (org.eclipse.core.runtime.CoreException)25 IExtension (org.eclipse.core.runtime.IExtension)20 ArrayList (java.util.ArrayList)13 HashMap (java.util.HashMap)11 Platform (org.eclipse.core.runtime.Platform)9 Map (java.util.Map)8 Optional (java.util.Optional)8 Stream (java.util.stream.Stream)8 NodeLogger (org.knime.core.node.NodeLogger)8 Collection (java.util.Collection)7 List (java.util.List)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6 DataTableSpec (org.knime.core.data.DataTableSpec)5 GlobalClassCreator (org.knime.core.eclipseUtil.GlobalClassCreator)5 SerializerMethodLoader (org.knime.core.internal.SerializerMethodLoader)5 File (java.io.File)4 Collections (java.util.Collections)4