Search in sources :

Example 46 with IMenuListener

use of org.eclipse.jface.action.IMenuListener in project tdi-studio-se by Talend.

the class ThreadFilteredTree method createContextMenu.

/**
     * Creates the context menu.
     * 
     * @param actionBars The action bars
     */
private void createContextMenu(IActionBars actionBars) {
    configureColumnsAction = new ConfigureColumnsAction(this);
    final CopyAction copyAction = CopyAction.createCopyAction(actionBars);
    getViewer().addSelectionChangedListener(copyAction);
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            manager.add(copyAction);
            manager.add(new Separator());
            manager.add(configureColumnsAction);
        }
    });
    Menu menu = menuMgr.createContextMenu(getViewer().getControl());
    getViewer().getControl().setMenu(menu);
}
Also used : CopyAction(org.talend.designer.runtime.visualization.internal.actions.CopyAction) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) ConfigureColumnsAction(org.talend.designer.runtime.visualization.internal.actions.ConfigureColumnsAction) IMenuListener(org.eclipse.jface.action.IMenuListener) Separator(org.eclipse.jface.action.Separator)

Example 47 with IMenuListener

use of org.eclipse.jface.action.IMenuListener in project tdi-studio-se by Talend.

the class BuildInDBStructure method addContextMenu.

/**
     * qzhang Comment method "addContextMenu".
     */
private void addContextMenu() {
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("Menu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            manager.add(generateSelectAction);
        }
    });
    Menu contextMenu = menuMgr.createContextMenu(treeViewer.getTree());
    treeViewer.getTree().setMenu(contextMenu);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 48 with IMenuListener

use of org.eclipse.jface.action.IMenuListener in project tdi-studio-se by Talend.

the class DBStructureComposite method addContextMenu.

/**
     * Add context menu.
     * 
     * method description.
     * 
     * @param
     * @return
     * @exception
     */
private void addContextMenu() {
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("Menu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            fillContextMenu(manager);
        }

        @SuppressWarnings("unchecked")
        private void fillContextMenu(IMenuManager manager) {
            // GenerateSelectSQL
            manager.add(generateSelectAction);
            // open editor
            builderDialog.getConnParameters().setQueryObject(null);
            manager.add(openNewEditorAction);
            // Separator
            manager.add(separator);
            // refresh
            ((RefreshConnectionAction) refreshConnectionAction).init();
            manager.add(refreshConnectionAction);
            manager.add(separator);
            // metadata refresh
            manager.add(metadataRefreshAction);
            manager.add(separator);
            manager.add(openQueryAction);
            manager.add(deleteQueryAction);
            manager.add(showQueryPropertyAction);
        }
    });
    Menu contextMenu = menuMgr.createContextMenu(treeViewer.getTree());
    treeViewer.getTree().setMenu(contextMenu);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener)

Aggregations

IMenuListener (org.eclipse.jface.action.IMenuListener)48 IMenuManager (org.eclipse.jface.action.IMenuManager)48 MenuManager (org.eclipse.jface.action.MenuManager)47 Menu (org.eclipse.swt.widgets.Menu)43 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 Separator (org.eclipse.jface.action.Separator)9 GridData (org.eclipse.swt.layout.GridData)8 Action (org.eclipse.jface.action.Action)6 GridLayout (org.eclipse.swt.layout.GridLayout)6 IAction (org.eclipse.jface.action.IAction)5 TreeViewer (org.eclipse.jface.viewers.TreeViewer)5 FocusEvent (org.eclipse.swt.events.FocusEvent)5 Composite (org.eclipse.swt.widgets.Composite)5 List (java.util.List)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4 TreeColumn (org.eclipse.swt.widgets.TreeColumn)4 TableViewer (org.eclipse.jface.viewers.TableViewer)3 ITreeContextualAction (org.talend.commons.ui.swt.actions.ITreeContextualAction)3 ConfigureColumnsAction (org.talend.designer.runtime.visualization.internal.actions.ConfigureColumnsAction)3 CopyAction (org.talend.designer.runtime.visualization.internal.actions.CopyAction)3