Search in sources :

Example 26 with IExtensionPoint

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

the class ShowEditorsPulldownMenuAction method run.

/**
 * Rhe implementation of the on click action.
 */
public void run(IAction action) {
    // connects to the extension point
    // $NON-NLS-1$
    IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint("org.jcryptool.core.editorButton");
    IExtension extension = point.getExtensions()[0];
    IConfigurationElement element = extension.getConfigurationElements()[0];
    final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
    IEvaluationContext evaluationContext = handlerService.createContextSnapshot(true);
    ExecutionEvent event = new ExecutionEvent(null, Collections.EMPTY_MAP, null, evaluationContext);
    try {
        // runs the defined action
        // $NON-NLS-1$
        IHandler handler = (IHandler) element.createExecutableExtension("OnClickClass");
        handler.execute(event);
    } catch (CoreException ex) {
        LogUtil.logError(CorePlugin.PLUGIN_ID, ex);
    } catch (ExecutionException ex) {
        LogUtil.logError(CorePlugin.PLUGIN_ID, ex);
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IHandlerService(org.eclipse.ui.handlers.IHandlerService) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) IHandler(org.eclipse.core.commands.IHandler) ExecutionException(org.eclipse.core.commands.ExecutionException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 27 with IExtensionPoint

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

the class ViewProviderPaletteViewer method createTree.

/**
 * Creates a tree from the extension point structure.
 *
 * @param needles the search string to filter the elements
 */
private void createTree(String[] needles) {
    invisibleRoot = new PaletteRoot();
    TreeMap<String, PaletteEntry> sortList = new TreeMap<String, PaletteEntry>();
    IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(extensionPointId);
    // $NON-NLS-1$
    String label = "";
    if (extensionPoint.getLabel().equals("analysis")) {
        // $NON-NLS-1$
        label = AlgorithmView.MENU_TEXT_ANALYSIS;
    } else if (extensionPoint.getLabel().equals("games")) {
        // $NON-NLS-1$
        label = AlgorithmView.MENU_TEXT_GAMES;
    } else if (extensionPoint.getLabel().equals("visuals")) {
        // $NON-NLS-1$
        label = AlgorithmView.MENU_TEXT_VISUALS;
    }
    PaletteDrawer category = new PaletteDrawer(label);
    category.setSmallIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_FOLDER));
    category.setLargeIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_FOLDER));
    invisibleRoot.add(category);
    IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
    for (IConfigurationElement element : elements) {
        // $NON-NLS-1$
        String name = element.getAttribute("name");
        // filter
        boolean show = true;
        for (String needle : needles) {
            if (// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            !needle.equals("") && !name.toLowerCase().matches(".*" + needle.toLowerCase() + ".*"))
                show = false;
        }
        if (show) {
            SelectionToolEntry paletteEntry = new SelectionToolEntry(element.getAttribute("name"), // $NON-NLS-1$ //$NON-NLS-2$
            "");
            paletteEntry.setSmallIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_ITEM_JCT));
            paletteEntry.setLargeIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_ITEM_JCT));
            paletteEntry.setUserModificationPermission(PaletteEntry.PERMISSION_NO_MODIFICATION);
            // $NON-NLS-1$
            paletteEntry.setType("");
            sortList.put(paletteEntry.getLabel(), paletteEntry);
        }
    }
    // attach items to the category
    for (PaletteEntry entry : sortList.values()) {
        category.add(entry);
    }
}
Also used : PaletteRoot(org.eclipse.gef.palette.PaletteRoot) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) SelectionToolEntry(org.eclipse.gef.palette.SelectionToolEntry) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) PaletteEntry(org.eclipse.gef.palette.PaletteEntry) TreeMap(java.util.TreeMap) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 28 with IExtensionPoint

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

the class CheckOperationManager method loadExtensions.

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

use of org.eclipse.core.runtime.IExtensionPoint in project tmdm-studio-se by Talend.

the class RepositoryViewObjectResourceChangeManager method initListenerDefine.

private void initListenerDefine() {
    listeners = new ArrayList<AbstractRepositoryResourceChangeListener>();
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    // 
    IExtensionPoint extensionPoint = registry.getExtensionPoint(RepositoryPlugin.PLUGIN_ID, EXTENSION_POINT_TEMPLATE);
    if (extensionPoint != null && extensionPoint.isValid()) {
        IExtension[] extensions = extensionPoint.getExtensions();
        for (IExtension s : extensions) {
            IConfigurationElement[] elements = s.getConfigurationElements();
            for (IConfigurationElement element : elements) {
                if (element.getAttribute(PROP_CLASS) != null) {
                    try {
                        AbstractRepositoryResourceChangeListener configuration = (AbstractRepositoryResourceChangeListener) element.createExecutableExtension(PROP_CLASS);
                        listeners.add(configuration);
                    } catch (CoreException e) {
                        log.error(e.getMessage(), e);
                    }
                }
            }
        }
    }
}
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) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 30 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project tmdm-studio-se by Talend.

the class RepositoryNodeConfigurationManager method initTemplateDefine.

private static void initTemplateDefine() {
    if (!inited) {
        IExtensionRegistry registry = Platform.getExtensionRegistry();
        // 
        IExtensionPoint extensionPoint = registry.getExtensionPoint(RepositoryPlugin.PLUGIN_ID, EXTENSION_POINT_TEMPLATE);
        if (extensionPoint != null && extensionPoint.isValid()) {
            IExtension[] extensions = extensionPoint.getExtensions();
            for (IExtension s : extensions) {
                IConfigurationElement[] elements = s.getConfigurationElements();
                for (IConfigurationElement element : elements) {
                    if (element.getAttribute(PROP_CLASS) != null) {
                        try {
                            IRepositoryNodeConfiguration configuration = (IRepositoryNodeConfiguration) element.createExecutableExtension(PROP_CLASS);
                            configurations.add(configuration);
                        } catch (CoreException e) {
                            log.error(e.getMessage(), e);
                        }
                    }
                }
            }
        // Bean2EObjUtil.getInstance().dumpMap();
        }
        inited = true;
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) 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