Search in sources :

Example 21 with IExtensionPoint

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

the class AlphabetsManager method loadAlphabetPlugin.

/**
 * Loads the alphabets Plug-in
 *
 * @return An instance of the loaded <i>AbstractAlphabetStore</i>
 */
private void loadAlphabetPlugin() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint extensionPoint = registry.getExtensionPoint(OperationsPlugin.PLUGIN_ID, IOperationsConstants.PL_ALPHABETS);
    IExtension[] extensions = extensionPoint.getExtensions();
    for (int i = 0; i < extensions.length; i++) {
        if (extensions[i].getNamespaceIdentifier().equals("org.jcryptool.crypto.classic.alphabets")) {
            // $NON-NLS-1$
            IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
            for (int j = 0; j < configElements.length; j++) {
                if (configElements[j].getName().equals(IOperationsConstants.PL_ALPHABETS)) {
                    try {
                        store = (AbstractAlphabetStore) configElements[j].createExecutableExtension(IOperationsConstants.ATT_CLASS);
                    } catch (CoreException e) {
                        LogUtil.logError(OperationsPlugin.PLUGIN_ID, "Exception while loading the AlphabetStore", e, // $NON-NLS-1$
                        true);
                    }
                }
            }
        }
    }
}
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)

Example 22 with IExtensionPoint

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

the class NewOperationManager method loadExtensions.

private static void loadExtensions() {
    // $NON-NLS-1$
    LogUtil.logInfo("loading extensions");
    // $NON-NLS-1$
    IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(FlexiProviderAlgorithmsPlugin.PLUGIN_ID, "newOperation");
    IExtension[] extensions = extensionPoint.getExtensions();
    for (IExtension extension : extensions) {
        IConfigurationElement[] configElements = extension.getConfigurationElements();
        for (IConfigurationElement configElement : configElements) {
            try {
                // $NON-NLS-1$
                INewOperationListener newListener = (INewOperationListener) configElement.createExecutableExtension("listenerClass");
                listeners.add(newListener);
            } catch (CoreException e) {
                // $NON-NLS-1$
                LogUtil.logError(FlexiProviderAlgorithmsPlugin.PLUGIN_ID, "CoreException while creating a new INewOperationListener", e, false);
            }
        }
    }
}
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)

Example 23 with IExtensionPoint

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

the class ProviderManager2 method loadProviders.

private void loadProviders() {
    IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(OperationsPlugin.PLUGIN_ID, IOperationsConstants.PL_PROVIDERS2);
    if (extensionPoint == null) {
        LogUtil.logError(OperationsPlugin.PLUGIN_ID, "extension point " + IOperationsConstants.PL_PROVIDERS2 + " not available", new NullPointerException(), // $NON-NLS-1$ //$NON-NLS-2$
        true);
        return;
    }
    IExtension[] extensions = extensionPoint.getExtensions();
    for (int i = 0; i < extensions.length; i++) {
        IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
        for (int j = 0; j < configElements.length; j++) {
            try {
                String[] attribs = configElements[j].getAttributeNames();
                for (int k = 0; k < attribs.length; k++) {
                    // $NON-NLS-1$
                    LogUtil.logInfo("attribName: " + attribs[k]);
                }
                AbstractProviderController controller = (AbstractProviderController) configElements[j].createExecutableExtension(// $NON-NLS-1$
                "providerController");
                addProviders(controller.addProviders());
            } catch (CoreException e) {
                // $NON-NLS-1$
                LogUtil.logError(// $NON-NLS-1$
                OperationsPlugin.PLUGIN_ID, // $NON-NLS-1$
                "CoreException while accessing a provider controller", e, false);
            }
        }
    }
    // $NON-NLS-1$
    LogUtil.logInfo("activated providers:");
    Iterator<String> it = availableProviders.iterator();
    while (it.hasNext()) {
        LogUtil.logInfo(it.next());
    }
}
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)

Example 24 with IExtensionPoint

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

the class ProvidersManager method loadPluginProviders.

/**
 * Loads the meta information about providers provided by plug-ins.
 */
private void loadPluginProviders() {
    // $NON-NLS-1$
    LogUtil.logInfo("Loading Providers provided by a plug-in");
    IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(OperationsPlugin.PLUGIN_ID, IOperationsConstants.PL_PROVIDERS);
    IExtension[] extensions = extensionPoint.getExtensions();
    for (int i = 0; i < extensions.length; i++) {
        IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
        for (int j = 0; j < configElements.length; j++) {
            String name = configElements[j].getAttribute(IOperationsConstants.ATT_PROVIDER_NAME);
            String info = configElements[j].getAttribute(IOperationsConstants.ATT_PROVIDER_INFO);
            ProviderDescriptor installedProvider = new ProviderDescriptor(extensions[i].getUniqueIdentifier(), name, info);
            availableProviders.put(name, installedProvider);
        }
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 25 with IExtensionPoint

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

the class CommandFactory method loadExtensions.

public static List<Command> loadExtensions() {
    // TODO: load aliases as single, own commands, but mark them as aliases
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    // $NON-NLS-1$
    IExtensionPoint extensionPoint = registry.getExtensionPoint("org.jcryptool.commands.core.commands");
    IConfigurationElement[] points = extensionPoint.getConfigurationElements();
    List<Command> commands = new LinkedList<Command>();
    for (IConfigurationElement point : points) {
        if (isExtendedCommand(point)) {
            ProxiedExtendedCommand cmdMainObj = new ProxiedExtendedCommand(point, false);
            commands.add(cmdMainObj);
            // Add "duplicate" command objects to the pool which are marked as aliases
            for (String alias : cmdMainObj.getAliases()) {
                ProxiedExtendedCommand aliasObj = new ProxiedExtendedCommand(point, true);
                aliasObj.setCommandName(alias);
                commands.add(aliasObj);
            }
        } else {
            commands.add(new ProxiedCommand(point));
        }
    }
    return commands;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) LinkedList(java.util.LinkedList) 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