Search in sources :

Example 41 with IConfigurationElement

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

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

the class SpellingEngineRegistry 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() {
    List<SpellingEngineDescriptor> descriptors = new ArrayList<>();
    fDescriptorsMap = new HashMap<>();
    fDefaultDescriptor = null;
    IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, SPELLING_ENGINE_EXTENSION_POINT);
    for (int i = 0; i < elements.length; i++) {
        SpellingEngineDescriptor descriptor = new SpellingEngineDescriptor(elements[i]);
        descriptors.add(descriptor);
        fDescriptorsMap.put(descriptor.getId(), descriptor);
        if (fDefaultDescriptor == null && descriptor.isDefault())
            fDefaultDescriptor = descriptor;
    }
    fDescriptors = descriptors.toArray(new SpellingEngineDescriptor[descriptors.size()]);
    fLoaded = true;
    if (fDefaultDescriptor == null && fDescriptors.length > 0)
        fDefaultDescriptor = fDescriptors[0];
}
Also used : ArrayList(java.util.ArrayList) SpellingEngineDescriptor(org.eclipse.ui.texteditor.spelling.SpellingEngineDescriptor) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 43 with IConfigurationElement

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

the class ExtensionsRegistry method readContentType.

/**
 * Reads the value from the given configuration element for the given attribute name and remembers
 * the configuration element in the given map under the individual content type of the attribute value.
 *
 * @param attributeName the name of the attribute
 * @param element the configuration element
 * @param map the map which remembers the configuration element
 */
private void readContentType(String attributeName, IConfigurationElement element, Map<Object, Set<IConfigurationElement>> map) {
    String value = element.getAttribute(attributeName);
    if (value != null) {
        IContentType contentType = fContentTypeManager.getContentType(value);
        if (contentType == null) {
            log(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, NLSUtility.format(FileBuffersMessages.ExtensionsRegistry_error_contentTypeDoesNotExist, value), null));
            return;
        }
        ContentTypeAdapter adapter = new ContentTypeAdapter(contentType);
        Set<IConfigurationElement> s = map.get(adapter);
        if (s == null) {
            s = new HashSet<>();
            map.put(adapter, s);
        }
        s.add(element);
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IContentType(org.eclipse.core.runtime.content.IContentType) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 44 with IConfigurationElement

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

the class ExtensionsRegistry method getDocumentSetupParticipants.

/**
 * Returns the set of setup participants for the given file name or extension.
 *
 * @param nameOrExtension the name or extension to be used for lookup
 * @return the sharable set of document setup participants
 */
protected List<IDocumentSetupParticipant> getDocumentSetupParticipants(String nameOrExtension) {
    Set<IConfigurationElement> set = fSetupParticipantDescriptors.get(nameOrExtension);
    if (set == null)
        return null;
    List<IDocumentSetupParticipant> participants = new ArrayList<>();
    Iterator<IConfigurationElement> e = set.iterator();
    while (e.hasNext()) {
        IConfigurationElement entry = e.next();
        IDocumentSetupParticipant participant = getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
        if (participant != null)
            participants.add(participant);
    }
    return participants;
}
Also used : ArrayList(java.util.ArrayList) IDocumentSetupParticipant(org.eclipse.core.filebuffers.IDocumentSetupParticipant) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 45 with IConfigurationElement

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

the class ExtensionsRegistry method doGetDocumentFactory.

/**
 * Returns a sharable document factory for the given content types.
 *
 * @param contentTypes the content types used to find the factory
 * @return the sharable document factory or <code>null</code>
 * @deprecated As of 3.5
 */
@Deprecated
protected org.eclipse.core.filebuffers.IDocumentFactory doGetDocumentFactory(IContentType[] contentTypes) {
    Set<IConfigurationElement> set = null;
    int i = 0;
    while (i < contentTypes.length && set == null) {
        set = fFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
    }
    if (set != null) {
        IConfigurationElement entry = selectConfigurationElement(set);
        return getExtension(entry, fFactories, org.eclipse.core.filebuffers.IDocumentFactory.class);
    }
    return null;
}
Also used : IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

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