Search in sources :

Example 1 with AbstractDataSetTableContextAction

use of org.talend.sqlbuilder.dataset.actions.AbstractDataSetTableContextAction in project tdi-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(ptable);
                    action.setTableCursor(pcursor);
                    if (action.isAvailable()) {
                        menu.add(action);
                    }
                }
            } catch (Throwable ex) {
                //$NON-NLS-1$
                SqlBuilderPlugin.log(Messages.getString("DataSetTableActionGroup.logMessage1"), ex);
            }
        }
    }
    menu.add(new Separator());
    // add export options
    //$NON-NLS-1$
    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(ptable);
                    action.setTableCursor(pcursor);
                    if (action.isAvailable()) {
                        subMenu.add(action);
                    }
                }
            } catch (Throwable ex) {
                //$NON-NLS-1$
                SqlBuilderPlugin.log(Messages.getString("DataSetTableActionGroup.logMessage1"), ex);
            }
        }
    }
    menu.add(subMenu);
    menu.add(new Separator());
    menu.add(pcopyTableAction);
}
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(org.talend.sqlbuilder.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)

Aggregations

IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtension (org.eclipse.core.runtime.IExtension)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 Separator (org.eclipse.jface.action.Separator)1 AbstractDataSetTableContextAction (org.talend.sqlbuilder.dataset.actions.AbstractDataSetTableContextAction)1