use of org.eclipse.core.runtime.IConfigurationElement 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);
}
use of org.eclipse.core.runtime.IConfigurationElement in project bndtools by bndtools.
the class CategorisedPrioritisedConfigurationElementTreeContentProvider method inputChanged.
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
data.clear();
// Dump input into categories
if (newInput instanceof IConfigurationElement[]) {
IConfigurationElement[] array = (IConfigurationElement[]) newInput;
for (IConfigurationElement element : array) categorise(element);
} else if (newInput instanceof Collection) {
@SuppressWarnings("unchecked") Collection<IConfigurationElement> coll = (Collection<IConfigurationElement>) newInput;
for (IConfigurationElement element : coll) categorise(element);
}
// Sort within each category
CategorisedConfigurationElementComparator comparator = new CategorisedConfigurationElementComparator(true);
for (Entry<ConfigurationElementCategory, List<IConfigurationElement>> entry : data.entrySet()) {
List<IConfigurationElement> list = entry.getValue();
Collections.sort(list, comparator);
}
}
use of org.eclipse.core.runtime.IConfigurationElement in project bndtools by bndtools.
the class AbstractTemplateSelectionWizardPage method setSelectionFromConfigElement.
private void setSelectionFromConfigElement(IConfigurationElement element) {
showTemplateDescription(element);
IConfigurationElement old = this.selectedElement;
this.selectedElement = element;
propSupport.firePropertyChange(PROP_ELEMENT, old, element);
}
use of org.eclipse.core.runtime.IConfigurationElement in project bndtools by bndtools.
the class PluginsPart method doEdit.
void doEdit() {
HeaderClause header = (HeaderClause) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
if (header != null) {
Attrs copyOfProperties = new Attrs(header.getAttribs());
IConfigurationElement configElem = configElements.get(header.getName());
PluginEditWizard wizard = new PluginEditWizard(configElem, copyOfProperties);
WizardDialog dialog = new WizardDialog(getManagedForm().getForm().getShell(), wizard);
if (dialog.open() == Window.OK && wizard.isChanged()) {
header.getAttribs().clear();
header.getAttribs().putAll(copyOfProperties);
viewer.update(header, null);
markDirty();
}
}
}
use of org.eclipse.core.runtime.IConfigurationElement in project bndtools by bndtools.
the class PluginClassSelectionPage method setSelectedElement.
public void setSelectedElement(IConfigurationElement selectedElement) {
IConfigurationElement old = this.selectedElement;
this.selectedElement = selectedElement;
if (Display.getCurrent() != null && table != null && !table.isDisposed()) {
if (!programmaticChange) {
try {
programmaticChange = true;
if (selectedElement == null)
viewer.setSelection(StructuredSelection.EMPTY);
else
viewer.setSelection(new StructuredSelection(selectedElement), true);
} finally {
programmaticChange = false;
}
}
// updateDescription();
validate();
getContainer().updateButtons();
}
propSupport.firePropertyChange("selectedElement", old, selectedElement);
}
Aggregations