Search in sources :

Example 46 with IExtensionPoint

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

the class DetailTabManager method createTabs.

/**
 * Returns a list of all available tabs for a given node. These tabs can be
 * standard or plugin tabs.
 *
 * @param node for which to find tabs.
 * @return List of tabs
 */
private static List<IDetailTab> createTabs(INode node) {
    if (_logger.isDebugEnabled()) {
        // $NON-NLS-1$
        _logger.debug("Creating tabs for: " + node.getUniqueIdentifier());
    }
    ArrayList<IDetailTab> tabList = new ArrayList<IDetailTab>();
    // create connection info tab if needed
    if (node instanceof DatabaseNode) {
        IDetailTab dbTab = new ConnectionInfoTab();
        dbTab.setNode(node);
        tabList.add(dbTab);
    }
    // create our basic table tabs
    if (node instanceof TableNode) {
        IDetailTab tab1 = new ColumnInfoTab();
        IDetailTab tab2 = new TableInfoTab();
        IDetailTab tab3 = new PreviewTab();
        IDetailTab tab4 = new RowCountTab();
        IDetailTab tab5 = new PrimaryKeysTab();
        IDetailTab tab6 = new ExportedKeysTab();
        IDetailTab tab7 = new ImportedKeysTab();
        IDetailTab tab8 = new IndexesTab();
        IDetailTab tab9 = new PriviligesTab();
        IDetailTab tab10 = new ColumnPriviligesTab();
        IDetailTab tab11 = new RowIdsTab();
        IDetailTab tab12 = new VersionsTab();
        tab1.setNode(node);
        tab2.setNode(node);
        tab3.setNode(node);
        tab4.setNode(node);
        tab5.setNode(node);
        tab6.setNode(node);
        tab7.setNode(node);
        tab8.setNode(node);
        tab9.setNode(node);
        tab10.setNode(node);
        tab11.setNode(node);
        tab12.setNode(node);
        tabList.add(tab1);
        tabList.add(tab2);
        tabList.add(tab3);
        tabList.add(tab4);
        tabList.add(tab5);
        tabList.add(tab6);
        tabList.add(tab7);
        tabList.add(tab8);
        tabList.add(tab9);
        tabList.add(tab10);
        tabList.add(tab11);
        tabList.add(tab12);
    }
    // create extension point tabs
    String databaseProductName = node.getSession().getRoot().getDatabaseProductName().toLowerCase().trim();
    String nodeType = node.getType().toLowerCase().trim();
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    // $NON-NLS-1$ $NON-NLS-2$
    IExtensionPoint point = registry.getExtensionPoint("net.sourceforge.sqlexplorer", "nodeDetailTab");
    IExtension[] extensions = point.getExtensions();
    for (int i = 0; i < extensions.length; i++) {
        IExtension e = extensions[i];
        IConfigurationElement[] ces = e.getConfigurationElements();
        for (int j = 0; j < ces.length; j++) {
            try {
                boolean isValidProduct = false;
                boolean isValidNodeType = false;
                // $NON-NLS-1$ $NON-NLS-2$
                String[] validProducts = ces[j].getAttribute("database-product-name").split(",");
                // $NON-NLS-1$ $NON-NLS-2$
                String[] validNodeTypes = ces[j].getAttribute("node-type").split(",");
                // check if tab is valid for current database product
                for (int k = 0; k < validProducts.length; k++) {
                    String product = validProducts[k].toLowerCase().trim();
                    if (product.length() == 0) {
                        continue;
                    }
                    if (product.equals("*")) {
                        // $NON-NLS-1$
                        isValidProduct = true;
                        break;
                    }
                    // $NON-NLS-1$ $NON-NLS-2$
                    String regex = TextUtil.replaceChar(product, '*', ".*");
                    if (databaseProductName.matches(regex)) {
                        isValidProduct = true;
                        break;
                    }
                }
                if (!isValidProduct) {
                    continue;
                }
                // check if tab is valid for current node type
                for (int k = 0; k < validNodeTypes.length; k++) {
                    String type = validNodeTypes[k].toLowerCase().trim();
                    if (type.length() == 0) {
                        continue;
                    }
                    if (type.equals("*")) {
                        // $NON-NLS-1$
                        isValidNodeType = true;
                        break;
                    }
                    // $NON-NLS-1$ $NON-NLS-2$
                    String regex = TextUtil.replaceChar(type, '*', ".*");
                    if (nodeType.matches(regex)) {
                        isValidNodeType = true;
                        break;
                    }
                }
                if (!isValidNodeType) {
                    continue;
                }
                // add tab to list
                // $NON-NLS-1$
                IDetailTab tab = (IDetailTab) ces[j].createExecutableExtension("class");
                tab.setNode(node);
                tabList.add(tab);
            } catch (Throwable ex) {
                SQLExplorerPlugin.error(Messages.getString("DataSetTableActionGroup.cannotCreateMenuAction"), ex);
            }
        }
    }
    return tabList;
}
Also used : ArrayList(java.util.ArrayList) TableInfoTab(net.sourceforge.sqlexplorer.dbdetail.tab.TableInfoTab) RowIdsTab(net.sourceforge.sqlexplorer.dbdetail.tab.RowIdsTab) ColumnPriviligesTab(net.sourceforge.sqlexplorer.dbdetail.tab.ColumnPriviligesTab) PriviligesTab(net.sourceforge.sqlexplorer.dbdetail.tab.PriviligesTab) VersionsTab(net.sourceforge.sqlexplorer.dbdetail.tab.VersionsTab) DatabaseNode(net.sourceforge.sqlexplorer.dbstructure.nodes.DatabaseNode) IExtension(org.eclipse.core.runtime.IExtension) PreviewTab(net.sourceforge.sqlexplorer.dbdetail.tab.PreviewTab) ColumnInfoTab(net.sourceforge.sqlexplorer.dbdetail.tab.ColumnInfoTab) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) ColumnPriviligesTab(net.sourceforge.sqlexplorer.dbdetail.tab.ColumnPriviligesTab) ImportedKeysTab(net.sourceforge.sqlexplorer.dbdetail.tab.ImportedKeysTab) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) ConnectionInfoTab(net.sourceforge.sqlexplorer.dbdetail.tab.ConnectionInfoTab) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) PrimaryKeysTab(net.sourceforge.sqlexplorer.dbdetail.tab.PrimaryKeysTab) RowCountTab(net.sourceforge.sqlexplorer.dbdetail.tab.RowCountTab) TableNode(net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode) IndexesTab(net.sourceforge.sqlexplorer.dbdetail.tab.IndexesTab) ExportedKeysTab(net.sourceforge.sqlexplorer.dbdetail.tab.ExportedKeysTab)

Example 47 with IExtensionPoint

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

the class DataSetTableActionGroup method fillContextMenu.

/**
 * Fill the context menu with all the correct actions.
 * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
 */
public void fillContextMenu(IMenuManager menu) {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    // $NON-NLS-1$ $NON-NLS-2$
    IExtensionPoint point = registry.getExtensionPoint("net.sourceforge.sqlexplorer", "dataSetTableContextAction");
    IExtension[] extensions = point.getExtensions();
    for (int i = 0; i < extensions.length; i++) {
        IExtension e = extensions[i];
        IConfigurationElement[] ces = e.getConfigurationElements();
        for (int j = 0; j < ces.length; j++) {
            try {
                // $NON-NLS-1$
                String group = ces[j].getAttribute("group");
                if (group == null || !group.equalsIgnoreCase("export")) {
                    // $NON-NLS-1$
                    // check if the action thinks it is suitable..
                    AbstractDataSetTableContextAction action = (AbstractDataSetTableContextAction) ces[j].createExecutableExtension(// $NON-NLS-1$
                    "class");
                    action.setTable(_table);
                    action.setTableCursor(_cursor);
                    if (action.isAvailable()) {
                        menu.add(action);
                    }
                }
            } catch (Throwable ex) {
                SQLExplorerPlugin.error(Messages.getString("DataSetTableActionGroup.cannotCreateMenuAction"), ex);
            }
        }
    }
    menu.add(new Separator());
    // add export options
    MenuManager subMenu = new MenuManager(Messages.getString("DataSetTable.Actions.ExportSubMenu"));
    for (int i = 0; i < extensions.length; i++) {
        IExtension e = extensions[i];
        IConfigurationElement[] ces = e.getConfigurationElements();
        for (int j = 0; j < ces.length; j++) {
            try {
                // $NON-NLS-1$
                String group = ces[j].getAttribute("group");
                if (group != null && group.equalsIgnoreCase("export")) {
                    // $NON-NLS-1$
                    // check if the action thinks it is suitable..
                    AbstractDataSetTableContextAction action = (AbstractDataSetTableContextAction) ces[j].createExecutableExtension(// $NON-NLS-1$
                    "class");
                    action.setTable(_table);
                    action.setTableCursor(_cursor);
                    if (action.isAvailable()) {
                        subMenu.add(action);
                    }
                }
            } catch (Throwable ex) {
                SQLExplorerPlugin.error(Messages.getString("DataSetTableActionGroup.cannotCreateMenuAction"), ex);
            }
        }
    }
    menu.add(subMenu);
    menu.add(new Separator());
    menu.add(_copyTableAction);
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) AbstractDataSetTableContextAction(net.sourceforge.sqlexplorer.dataset.actions.AbstractDataSetTableContextAction) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) Separator(org.eclipse.jface.action.Separator) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 48 with IExtensionPoint

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

the class Activator method loadProtocolHandlers.

private void loadProtocolHandlers() {
    final IExtensionRegistry reg = getExtensionRegistry();
    if (reg != null) {
        final IExtensionPoint retrieveExtensionPoint = reg.getExtensionPoint(RETRIEVE_FILETRANSFER_PROTOCOL_FACTORY_EPOINT);
        if (retrieveExtensionPoint != null)
            addRetrieveExtensions(retrieveExtensionPoint.getConfigurationElements());
        // Now do it with send
        final IExtensionPoint sendExtensionPoint = reg.getExtensionPoint(SEND_FILETRANSFER_PROTOCOL_FACTORY_EPOINT);
        if (sendExtensionPoint != null)
            addSendExtensions(sendExtensionPoint.getConfigurationElements());
        // Now for browse
        final IExtensionPoint browseExtensionPoint = reg.getExtensionPoint(BROWSE_FILETRANSFER_PROTOCOL_FACTORY_EPOINT);
        if (browseExtensionPoint != null)
            addBrowseExtensions(browseExtensionPoint.getConfigurationElements());
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 49 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project InformationSystem by ObeoNetwork.

the class FilterContainerItemProvider method addExternalChildDescriptors.

/**
 * This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
 * describing all of the children that can be created under this object.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
@SuppressWarnings({ "unchecked", "deprecation" })
protected void addExternalChildDescriptors(Collection newChildDescriptors, Object object) {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint extensionPoint = registry.getExtensionPoint(CHILD_DESCRIPTOR_EXTENSION_ID);
    if (extensionPoint == null || extensionPoint.getExtensions().length == 0) {
        EcorePlugin.INSTANCE.log("Extension point '" + CHILD_DESCRIPTOR_EXTENSION_ID + "' not found");
    } else {
        Bundle theBundle = null;
        IExtension[] extensions = extensionPoint.getExtensions();
        for (int i = 0; i < extensions.length; i++) {
            IExtension extension = extensions[i];
            IConfigurationElement[] members = extension.getConfigurationElements();
            for (int j = 0; j < members.length; j++) {
                IConfigurationElement member = members[j];
                String conditionClass = member.getAttribute("implementation");
                theBundle = Platform.getBundle(member.getNamespace());
                if (conditionClass != null) {
                    try {
                        Class c = theBundle.loadClass(conditionClass);
                        Object instance = c.newInstance();
                        if (instance instanceof IChildDescriptorProvider) {
                            IChildDescriptorProvider childDescriptorProvider = (IChildDescriptorProvider) instance;
                            CommandParameter parameter = childDescriptorProvider.getEntityFilter(object);
                            if (parameter != null) {
                                newChildDescriptors.add(parameter);
                            }
                        }
                    } catch (ClassNotFoundException e) {
                        EcorePlugin.INSTANCE.log(e);
                    } catch (InstantiationException e) {
                        EcorePlugin.INSTANCE.log(e);
                    } catch (IllegalAccessException e) {
                        EcorePlugin.INSTANCE.log(e);
                    }
                }
            }
        }
    }
}
Also used : CommandParameter(org.eclipse.emf.edit.command.CommandParameter) Bundle(org.osgi.framework.Bundle) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IChildDescriptorProvider(org.obeonetwork.dsl.environment.edit.specific.extensions.IChildDescriptorProvider) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 50 with IExtensionPoint

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

the class AllTests method suite.

public static Test suite() throws CoreException {
    TestSuite suite = new TestSuite();
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint extensionPoint = registry.getExtensionPoint("tests.utils.tests");
    IExtension[] extensions = extensionPoint.getExtensions();
    for (IExtension extension : extensions) {
        for (IConfigurationElement element : extension.getConfigurationElements()) {
            suite.addTestSuite(element.createExecutableExtension("class").getClass());
        }
    }
    return suite;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) TestSuite(junit.framework.TestSuite) IExtension(org.eclipse.core.runtime.IExtension) 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