use of org.eclipse.core.runtime.IConfigurationElement in project eclipse.platform.text by eclipse.
the class ExtensionsRegistry method initialize.
/**
* Initializes this registry. It retrieves all implementers of the given
* extension point and remembers those implementers based on the
* file name extensions in the given map.
*
* @param extensionPointName the name of the extension point
* @param childElementName the name of the child elements
* @param isContentTypeId the child element is a content type id
* @param descriptors the map to be filled
*/
private void initialize(String extensionPointName, String childElementName, boolean isContentTypeId, Map<Object, Set<IConfigurationElement>> descriptors) {
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(FileBuffersPlugin.PLUGIN_ID, extensionPointName);
if (extensionPoint == null) {
log(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, 0, NLSUtility.format(FileBuffersMessages.ExtensionsRegistry_error_extensionPointNotFound, extensionPointName), null));
return;
}
IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
for (IConfigurationElement element : elements) {
if (isContentTypeId)
readContentType(childElementName, element, descriptors);
else
read(childElementName, element, descriptors);
}
}
use of org.eclipse.core.runtime.IConfigurationElement in project eclipse.platform.text by eclipse.
the class ExtensionsRegistry method doGetDocumentSetupParticipants.
/**
* Returns the set of setup participants for the given content types.
*
* @param contentTypes the contentTypes to be used for lookup
* @return the sharable set of document setup participants
*/
private List<IDocumentSetupParticipant> doGetDocumentSetupParticipants(IContentType[] contentTypes) {
Set<IConfigurationElement> resultSet = new HashSet<>();
int i = 0;
while (i < contentTypes.length) {
Set<IConfigurationElement> set = fSetupParticipantDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
if (set != null)
resultSet.addAll(set);
}
List<IDocumentSetupParticipant> participants = new ArrayList<>();
Iterator<IConfigurationElement> e = resultSet.iterator();
while (e.hasNext()) {
IConfigurationElement entry = e.next();
IDocumentSetupParticipant participant = getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
if (participant != null)
participants.add(participant);
}
return participants.isEmpty() ? null : participants;
}
use of org.eclipse.core.runtime.IConfigurationElement in project linuxtools by eclipse.
the class STSymbolManager method getBinaryParser.
/**
* Retrieve the list of binary parsers defined for the given project.
* @param project The project.
* @return The binary parsers for this project.
*/
private List<IBinaryParser> getBinaryParser(IProject project) {
List<IBinaryParser> parsers = new LinkedList<>();
ICProjectDescription projDesc = CCorePlugin.getDefault().getProjectDescription(project);
if (projDesc == null) {
return parsers;
}
ICConfigurationDescription[] cfgs = projDesc.getConfigurations();
String[] binaryParserIds = CoreModelUtil.getBinaryParserIds(cfgs);
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.BINARY_PARSER_SIMPLE_ID);
for (String id : binaryParserIds) {
IExtension extension = extensionPoint.getExtension(id);
if (extension != null) {
IConfigurationElement[] element = extension.getConfigurationElements();
for (IConfigurationElement element2 : element) {
if (element2.getName().equalsIgnoreCase("cextension")) {
// $NON-NLS-1$
try {
// $NON-NLS-1$
IBinaryParser parser = (IBinaryParser) element2.createExecutableExtension("run");
if (parser != null) {
parsers.add(parser);
}
} catch (CoreException e) {
// TODO: handle exception ?
}
}
}
}
}
return parsers;
}
use of org.eclipse.core.runtime.IConfigurationElement in project linuxtools by eclipse.
the class ProviderFramework method getTabGroupProvider.
/**
* Get a profiling tab that provides the specified type of profiling. This
* looks through extensions of the extension point
* <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code> that have a
* specific type attribute.
*
* @param type A profiling type (eg. memory, snapshot, timing, etc.)
* @return a tab that implements <code>ProfileLaunchConfigurationTabGroup</code>
* and provides the necessary profiling type, or <code>null</code> if none could be found.
* @since 2.0
*/
public static ProfileLaunchConfigurationTabGroup getTabGroupProvider(String type) {
IConfigurationElement[] configs = getConfigurationElements();
for (IConfigurationElement config : configs) {
if (config.getName().equals("provider")) {
// $NON-NLS-1$
// $NON-NLS-1$
String currentType = config.getAttribute("type");
// $NON-NLS-1$
String shortcut = config.getAttribute("tabgroup");
if (currentType != null && shortcut != null && currentType.equals(type)) {
try {
Object obj = config.createExecutableExtension(// $NON-NLS-1$
"tabgroup");
if (obj instanceof ProfileLaunchConfigurationTabGroup) {
return (ProfileLaunchConfigurationTabGroup) obj;
}
} catch (CoreException e) {
// continue, perhaps another configuration will succeed
}
}
}
}
return null;
}
use of org.eclipse.core.runtime.IConfigurationElement in project linuxtools by eclipse.
the class ProviderFramework method getConfigurationDelegateFromId.
/**
* Get a launch configuration delegate that is associated with the specified id.
* This looks through extensions of the extension point
* <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code> that
* have a specific delegate attribute.
*
* @param id a unique identifier
* @return a launch configuration delegate that implements
* <code>AbstractCLaunchDelegate</code> , or <code>null</code> if
* none could be found.
* @since 1.2
*/
public static AbstractCLaunchDelegate getConfigurationDelegateFromId(String id) {
IConfigurationElement[] configs = getConfigurationElements();
for (IConfigurationElement config : configs) {
if (config.getName().equals("provider")) {
// $NON-NLS-1$
// $NON-NLS-1$
String currentId = config.getAttribute("id");
// $NON-NLS-1$
String tabgroup = config.getAttribute("delegate");
if (currentId != null && tabgroup != null && currentId.equals(id)) {
try {
Object obj = config.createExecutableExtension(// $NON-NLS-1$
"delegate");
if (obj instanceof AbstractCLaunchDelegate) {
return (AbstractCLaunchDelegate) obj;
}
} catch (CoreException e) {
// continue, perhaps another configuration will succeed
}
}
}
}
return null;
}
Aggregations