Search in sources :

Example 81 with IConfigurationElement

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);
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 82 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project bndtools by bndtools.

the class PluginClassSorter method compare.

@Override
public int compare(Viewer viewer, Object e1, Object e2) {
    IConfigurationElement elem1 = (IConfigurationElement) e1;
    IConfigurationElement elem2 = (IConfigurationElement) e2;
    // Sort undeprecated plugins before deprecated ones.
    int result = sortDeprecation(elem1, elem2);
    if (result != 0)
        return result;
    // Sort by rank
    result = sortByRank(elem1, elem2);
    if (result != 0)
        return result;
    // Finally sort on name
    return sortName(elem1, elem2);
}
Also used : IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 83 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project yamcs-studio by yamcs.

the class SimplePVLayer method createPVFactory.

private static AbstractPVFactory createPVFactory(String pvFactoryID) throws CoreException {
    IExtensionRegistry extReg = Platform.getExtensionRegistry();
    IConfigurationElement[] confElements = extReg.getConfigurationElementsFor(EXTPOINT_PVFACTORY);
    for (IConfigurationElement element : confElements) {
        String name = element.getAttribute("id");
        if (name.equals(pvFactoryID)) {
            Object object = element.createExecutableExtension("class");
            if (object instanceof AbstractPVFactory) {
                return (AbstractPVFactory) object;
            }
        }
    }
    return null;
}
Also used : IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 84 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project yamcs-studio by yamcs.

the class WidgetsService method loadAllWidgets.

/**
 * Load all widgets information from extensions.
 */
private void loadAllWidgets() {
    IExtensionRegistry extReg = Platform.getExtensionRegistry();
    IConfigurationElement[] confElements = extReg.getConfigurationElementsFor(OPIBuilderPlugin.EXTPOINT_WIDGET);
    List<IConfigurationElement> boyElements = new LinkedList<IConfigurationElement>();
    List<IConfigurationElement> otherElements = new LinkedList<IConfigurationElement>();
    // Sort elements. opibuilder.widgets should always appear first.
    for (IConfigurationElement element : confElements) {
        if (element.getContributor().getName().equals(BOY_WIDGETS_PLUGIN_NAME))
            boyElements.add(element);
        else
            otherElements.add(element);
    }
    boyElements.addAll(otherElements);
    for (IConfigurationElement element : boyElements) {
        // $NON-NLS-1$
        String typeId = element.getAttribute("typeId");
        // $NON-NLS-1$
        String name = element.getAttribute("name");
        // $NON-NLS-1$
        String icon = element.getAttribute("icon");
        // //$NON-NLS-1$
        String onlineHelpHtml = element.getAttribute("onlineHelpHtml");
        String pluginId = element.getDeclaringExtension().getNamespaceIdentifier();
        String description = element.getAttribute("description");
        if (description == null || description.trim().length() == 0) {
            description = "";
        }
        String category = element.getAttribute("category");
        if (category == null || category.trim().length() == 0) {
            category = DEFAULT_CATEGORY;
        }
        if (typeId != null) {
            List<String> list = allCategoriesMap.get(category);
            if (list == null) {
                list = new ArrayList<String>();
                allCategoriesMap.put(category, list);
            }
            // ensure no duplicates in the widgets palette
            if (!list.contains(typeId))
                list.add(typeId);
            allWidgetDescriptorsMap.put(typeId, new WidgetDescriptor(element, typeId, name, description, icon, category, pluginId, onlineHelpHtml));
        }
    }
// sort the widget in the categories
// for(List<String> list : allCategoriesMap.values())
// Collections.sort(list);
}
Also used : IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) LinkedList(java.util.LinkedList) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 85 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project flux by eclipse.

the class ContributionContextTypeRegistry method createContextType.

/**
	 * Tries to create a context type given an id. Contributions to the
	 * <code>org.eclipse.ui.editors.templates</code> extension point are
	 * searched for the given identifier and the specified context type
	 * instantiated if it is found. Any contributed
	 * {@link org.eclipse.jface.text.templates.TemplateVariableResolver}s
	 * are also instantiated and added to the context type.
	 *
	 * @param id the id for the context type as specified in XML
	 * @return the instantiated and configured context type, or
	 *         <code>null</code> if it is not found or cannot be instantiated
	 */
public static TemplateContextType createContextType(String id) {
    Assert.isNotNull(id);
    IConfigurationElement[] extensions = getTemplateExtensions();
    TemplateContextType type;
    try {
        type = createContextType(extensions, id);
        if (type != null) {
            TemplateVariableResolver[] resolvers = createResolvers(extensions, id);
            for (int i = 0; i < resolvers.length; i++) type.addResolver(resolvers[i]);
        }
    } catch (CoreException e) {
        //EditorsPlugin.log(e);
        type = null;
    }
    return type;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType) TemplateVariableResolver(org.eclipse.jface.text.templates.TemplateVariableResolver)

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