Search in sources :

Example 51 with IExtensionRegistry

use of org.eclipse.core.runtime.IExtensionRegistry in project knime-core by knime.

the class StartupMessage method getAllStartupMessages.

/**
 * Returns all startup messages.
 *
 * @return a list with all startup messages, never <code>null</code>
 */
public static List<StartupMessage> getAllStartupMessages() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point = registry.getExtensionPoint("org.knime.workbench.ui.startupMessages");
    assert point != null : "Invalid extension point id: org.knime.workbench.ui.startupMessages";
    List<StartupMessage> messages = new ArrayList<>();
    for (IExtension ext : point.getExtensions()) {
        IConfigurationElement[] elements = ext.getConfigurationElements();
        for (IConfigurationElement providerElement : elements) {
            try {
                StartupMessageProvider provider = (StartupMessageProvider) providerElement.createExecutableExtension("class");
                messages.addAll(provider.getMessages());
            } catch (CoreException ex) {
                NodeLogger.getLogger(StartupMessage.class).error("Could not create startup message provider " + providerElement.getAttribute("class") + " from plug-in " + providerElement.getNamespaceIdentifier() + ": " + ex.getMessage(), ex);
            }
        }
    }
    return messages;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) ArrayList(java.util.ArrayList) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 52 with IExtensionRegistry

use of org.eclipse.core.runtime.IExtensionRegistry in project knime-core by knime.

the class KNIMEApplicationActionBarAdvisor method createMultiInstanceViewActions.

private List<IAction> createMultiInstanceViewActions() {
    List<IAction> result = new LinkedList<IAction>();
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point = registry.getExtensionPoint("org.knime.workbench.ui.multipleInstanceViews");
    if (point == null) {
        return result;
    }
    IExtension[] ext = point.getExtensions();
    if (ext == null) {
        return result;
    }
    for (IExtension extension : ext) {
        IConfigurationElement[] conf = extension.getConfigurationElements();
        if (conf == null) {
            continue;
        }
        for (IConfigurationElement c : conf) {
            String viewId = c.getAttribute("id");
            if (viewId == null || viewId.isEmpty()) {
                continue;
            }
            IAction viewAction = createViewAction(viewId);
            if (viewAction == null) {
                continue;
            }
            result.add(viewAction);
        }
    }
    // sort actions by view name
    Collections.sort(result, new Comparator<IAction>() {

        @Override
        public int compare(final IAction o1, final IAction o2) {
            if (o1 == null) {
                return -1;
            }
            if (o2 == null) {
                return 1;
            }
            return o1.getText().compareTo(o2.getText());
        }
    });
    return result;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IAction(org.eclipse.jface.action.IAction) IExtension(org.eclipse.core.runtime.IExtension) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) LinkedList(java.util.LinkedList) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 53 with IExtensionRegistry

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

the class AutoCompleteUIPlugin method readExtensionRegistry.

private void readExtensionRegistry() throws Exception {
    // Registry lookup
    final IExtensionRegistry registry = RegistryFactory.getRegistry();
    final IConfigurationElement[] configs = registry.getConfigurationElementsFor(EXT_ID);
    if (configs.length > 1)
        throw new Exception("Found " + configs.length + " Auto-Complete UI Helper implementations, expecting at most one");
    if (configs.length == 1) {
        // Use implementations from extension point
        Logger.getLogger(getClass().getName()).config("UI Helper provided by " + configs[0].getContributor().getName());
        AutoCompleteUIPlugin.ui = (UIHelper) configs[0].createExecutableExtension("ui");
    } else {
        // Use default implementations
        AutoCompleteUIPlugin.ui = new UIHelper();
    }
}
Also used : UIHelper(org.csstudio.autocomplete.ui.util.UIHelper) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 54 with IExtensionRegistry

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

the class WidgetsService method loadAllFeedbackFactories.

@SuppressWarnings("nls")
private void loadAllFeedbackFactories() {
    IExtensionRegistry extReg = Platform.getExtensionRegistry();
    IConfigurationElement[] confElements = extReg.getConfigurationElementsFor(OPIBuilderPlugin.EXTPOINT_FEEDBACK_FACTORY);
    for (IConfigurationElement element : confElements) {
        String typeId = element.getAttribute("typeId");
        if (typeId != null) {
            try {
                feedbackFactoriesMap.put(typeId, (IGraphicalFeedbackFactory) element.createExecutableExtension("class"));
            } catch (CoreException e) {
                OPIBuilderPlugin.getLogger().log(Level.WARNING, "Cannot load feedback provider", e);
            }
        }
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 55 with IExtensionRegistry

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

the class SimplePVLayer method getAllPVFactoryExtensions.

/**
 * Get all available PV Factory extensions.
 *
 * @return the IDs of all available PV Factory extensions.
 */
public static String[] getAllPVFactoryExtensions() {
    IExtensionRegistry extReg = Platform.getExtensionRegistry();
    IConfigurationElement[] confElements = extReg.getConfigurationElementsFor(EXTPOINT_PVFACTORY);
    String[] result = new String[confElements.length];
    int i = 0;
    for (IConfigurationElement element : confElements) {
        String name = element.getAttribute("id");
        result[i++] = name;
    }
    return result;
}
Also used : IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Aggregations

IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)55 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)50 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)33 CoreException (org.eclipse.core.runtime.CoreException)25 IExtension (org.eclipse.core.runtime.IExtension)20 ArrayList (java.util.ArrayList)13 HashMap (java.util.HashMap)11 Platform (org.eclipse.core.runtime.Platform)9 Map (java.util.Map)8 Optional (java.util.Optional)8 Stream (java.util.stream.Stream)8 NodeLogger (org.knime.core.node.NodeLogger)8 Collection (java.util.Collection)7 List (java.util.List)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6 DataTableSpec (org.knime.core.data.DataTableSpec)5 GlobalClassCreator (org.knime.core.eclipseUtil.GlobalClassCreator)5 SerializerMethodLoader (org.knime.core.internal.SerializerMethodLoader)5 File (java.io.File)4 Collections (java.util.Collections)4