use of org.eclipse.core.runtime.IContributor in project bndtools by bndtools.
the class ExtensionRegistryTemplateLoader method findTemplates.
@Override
public Promise<List<Template>> findTemplates(String type, Reporter reporter) {
List<Template> templates;
String extPoint = typeToExtPoint.get(type);
if (extPoint != null) {
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(Plugin.PLUGIN_ID, extPoint);
if (elements == null)
elements = new IConfigurationElement[0];
templates = new ArrayList<>(elements.length);
float total = elements.length;
float worked = 0f;
for (IConfigurationElement element : elements) {
String elementName = element.getName();
IContributor contributor = element.getContributor();
try {
Template extTemplate = (Template) element.createExecutableExtension("class");
templates.add(extTemplate);
} catch (CoreException e) {
Plugin.getDefault().getLog().log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, String.format("Error loading template '%s' from bundle %s", elementName, contributor.getName()), e));
} finally {
worked += 1f;
reporter.progress(total / worked, "Loading templates");
}
}
} else {
templates = Collections.emptyList();
}
return Promises.resolved(templates);
}
Aggregations