Search in sources :

Example 16 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project linuxtools by eclipse.

the class LinuxtoolsPathPropertyPage method fillPaths.

private String[][] fillPaths() {
    LinkedList<String[]> list = new LinkedList<>();
    for (String[] t : DEFAULT_PATHS) {
        list.add(t);
    }
    IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(LaunchCoreConstants.PLUGIN_ID, LINUXTOOLS_PATH_EXT_POINT);
    IConfigurationElement[] configs = extPoint.getConfigurationElements();
    for (IConfigurationElement config : configs) if (config.getName().equals(LINUXTOOLS_PATH_OPTION)) {
        String path = config.getAttribute(LINUXTOOLS_PATH_OPTION_PATH);
        String name = config.getAttribute(LINUXTOOLS_PATH_OPTION_NAME);
        list.add(new String[] { name, path });
    }
    return list.toArray(new String[0][0]);
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) LinkedList(java.util.LinkedList)

Example 17 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project linuxtools by eclipse.

the class ChangeLogDocumentSetupParticipant method setup.

@Override
public void setup(IDocument document) {
    IExtensionPoint editorExtensions = null;
    IEditorChangeLogContrib editorContrib = null;
    // get editor which is stored in preference.
    IPreferenceStore store = ChangelogPlugin.getDefault().getPreferenceStore();
    String pref_Editor = store.getString(// $NON-NLS-1$
    "IChangeLogConstants.DEFAULT_EDITOR");
    editorExtensions = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.linuxtools.changelog.core", // $NON-NLS-1$ //$NON-NLS-2$
    "editorContribution");
    if (editorExtensions != null) {
        IConfigurationElement[] elements = editorExtensions.getConfigurationElements();
        for (int i = 0; i < elements.length; i++) {
            if (// $NON-NLS-1$
            elements[i].getName().equals("editor") && (elements[i].getAttribute("name").equals(pref_Editor))) {
                try {
                    // If editor has a special setup routine, use it.
                    IConfigurationElement bob = elements[i];
                    editorContrib = (IEditorChangeLogContrib) bob.createExecutableExtension(// $NON-NLS-1$
                    "class");
                    editorContrib.setup(document);
                } catch (CoreException e) {
                    ChangelogPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
                }
            }
        }
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IEditorChangeLogContrib(org.eclipse.linuxtools.changelog.core.IEditorChangeLogContrib) CoreException(org.eclipse.core.runtime.CoreException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 18 with IExtensionPoint

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

the class MissingCellHandlerFactoryManager method registerExtensionPoints.

/**
 * Registers all extension point implementations.
 * @param extPointId id of the extension point
 * @param extPointAttrDf attribute of the factory class within the handler extension point
 */
protected void registerExtensionPoints(final String extPointId, final String extPointAttrDf) {
    try {
        final IExtensionRegistry registry = Platform.getExtensionRegistry();
        final IExtensionPoint point = registry.getExtensionPoint(extPointId);
        if (point == null) {
            LOGGER.error("Invalid extension point: " + extPointId);
            throw new IllegalStateException("ACTIVATION ERROR: " + " --> Invalid extension point: " + extPointId);
        }
        for (final IConfigurationElement elem : point.getConfigurationElements()) {
            final String operator = elem.getAttribute(extPointAttrDf);
            final String decl = elem.getDeclaringExtension().getUniqueIdentifier();
            if ((operator == null) || operator.isEmpty()) {
                LOGGER.error("The extension '" + decl + "' doesn't provide the required attribute '" + extPointAttrDf + "'");
                LOGGER.error("Extension " + decl + " ignored.");
                continue;
            }
            try {
                final MissingCellHandlerFactory factory = (MissingCellHandlerFactory) elem.createExecutableExtension(extPointAttrDf);
                addMissingCellHandlerFactory(factory);
            } catch (final Exception t) {
                LOGGER.error("Problems during initialization of missing value handler factory (with id '" + operator + "'.)");
                if (decl != null) {
                    LOGGER.error("Extension " + decl + " ignored.", t);
                }
            }
        }
    } catch (final Exception e) {
        LOGGER.error("Exception while registering MissingCellHandler extensions");
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) DoNothingMissingCellHandlerFactory(org.knime.base.node.preproc.pmml.missingval.handlers.DoNothingMissingCellHandlerFactory) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 19 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project vorto by eclipse.

the class ModelParserFactory method getModelParser.

public IModelParser getModelParser() {
    IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(IModelParser.EXTENSIONPOINT_ID);
    IExtension[] modelParserExtensions = extensionPoint.getExtensions();
    if (modelParserExtensions.length == 0) {
        throw new RuntimeException("No Vorto Model Parser found!");
    } else if (modelParserExtensions.length > 1) {
        throw new RuntimeException("More than 1 Vorto Model Parser found. Cannot decide which one to bind. ");
    }
    try {
        return (IModelParser) modelParserExtensions[0].getConfigurationElements()[0].createExecutableExtension("class");
    } catch (Exception e) {
        throw new RuntimeException("Problem binding Vorto Model Parser", e);
    }
}
Also used : IModelParser(org.eclipse.vorto.core.ui.parser.IModelParser) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension)

Example 20 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project core by jcryptool.

the class OperationsPlugin method retrieveAlgorithmsManager.

/**
 * Retrieves the algorithms manager. The extension registry is used to fetch the specific contributor of the
 * <i>org.jcryptool.core.operations</i> plug-in.
 *
 * @return null if there is no specific manager found and an object of AbstractOperationsManager if a manager is
 *         found
 */
private static AbstractOperationsManager retrieveAlgorithmsManager() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    // $NON-NLS-1$
    IExtensionPoint extensionPoint = registry.getExtensionPoint(PLUGIN_ID, "operationsManager");
    IExtension[] extensions = extensionPoint.getExtensions();
    for (int i = 0; i < extensions.length; i++) {
        if (// $NON-NLS-1$
        "org.jcryptool.core.operations.algorithm.AlgorithmRegistry".equals(extensions[i].getUniqueIdentifier())) {
            IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
            for (int j = 0; j < configElements.length; j++) {
                IConfigurationElement element = configElements[j];
                if ("manager".equals(element.getName())) {
                    // $NON-NLS-1$
                    try {
                        AbstractOperationsManager manager = (AbstractOperationsManager) element.createExecutableExtension(IOperationsConstants.ATT_CLASS);
                        return manager;
                    } catch (CoreException ex) {
                        LogUtil.logError(PLUGIN_ID, ex);
                    }
                }
            }
        }
    }
    return null;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Aggregations

IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)187 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)160 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)107 IExtension (org.eclipse.core.runtime.IExtension)92 CoreException (org.eclipse.core.runtime.CoreException)70 ArrayList (java.util.ArrayList)29 HashMap (java.util.HashMap)17 Platform (org.eclipse.core.runtime.Platform)17 Stream (java.util.stream.Stream)16 List (java.util.List)15 NodeLogger (org.knime.core.node.NodeLogger)15 Map (java.util.Map)14 Optional (java.util.Optional)14 Collection (java.util.Collection)9 Bundle (org.osgi.framework.Bundle)9 Collectors (java.util.stream.Collectors)8 IOException (java.io.IOException)6 Collections (java.util.Collections)6 LinkedList (java.util.LinkedList)6 Objects (java.util.Objects)6