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);
}
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];
}
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);
}
}
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;
}
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;
}
Aggregations