Search in sources :

Example 81 with MenuManager

use of org.eclipse.jface.action.MenuManager in project knime-core by knime.

the class WorkflowContextMenuProvider method getSubNodeMenuManager.

private static IMenuManager getSubNodeMenuManager(final IMenuManager subNodeManagerOrNull, final IMenuManager parentMenuManager) {
    if (subNodeManagerOrNull == null) {
        MenuManager m = new MenuManager("Wrapped Metanode", ImageRepository.getIconDescriptor(KNIMEEditorPlugin.PLUGIN_ID, "/icons/meta/meta_menu.png"), null);
        m.add(new Separator(GROUP_SUBNODE));
        m.add(new Separator(GROUP_SUBNODE_LINKS));
        parentMenuManager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, m);
        return m;
    }
    return subNodeManagerOrNull;
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Example 82 with MenuManager

use of org.eclipse.jface.action.MenuManager in project dbeaver by dbeaver.

the class QueryLogViewer method createContextMenu.

private void createContextMenu() {
    MenuManager menuMgr = new MenuManager();
    Menu menu = menuMgr.createContextMenu(logTable);
    menuMgr.addMenuListener(manager -> {
        IAction editorAction = new Action("Open in SQL console", DBeaverIcons.getImageDescriptor(UIIcon.SQL_CONSOLE)) {

            @Override
            public void run() {
                openSelectionInEditor();
            }
        };
        IAction copyAction = new Action(CoreMessages.controls_querylog_action_copy) {

            @Override
            public void run() {
                copySelectionToClipboard(false);
            }
        };
        copyAction.setEnabled(logTable.getSelectionCount() > 0);
        copyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
        IAction copyAllAction = new Action(CoreMessages.controls_querylog_action_copy_all_fields) {

            @Override
            public void run() {
                copySelectionToClipboard(true);
            }
        };
        copyAllAction.setEnabled(logTable.getSelectionCount() > 0);
        copyAllAction.setActionDefinitionId(CoreCommands.CMD_COPY_SPECIAL);
        IAction selectAllAction = new Action(CoreMessages.controls_querylog_action_select_all) {

            @Override
            public void run() {
                selectAll();
            }
        };
        selectAllAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_SELECT_ALL);
        IAction clearLogAction = new Action(CoreMessages.controls_querylog_action_clear_log) {

            @Override
            public void run() {
                clearLog();
            }
        };
        boolean hasStatements = false;
        for (TableItem item : logTable.getSelection()) {
            if (((QMMetaEvent) item.getData()).getObject() instanceof QMMStatementExecuteInfo) {
                hasStatements = true;
                break;
            }
        }
        if (hasStatements) {
            manager.add(editorAction);
            manager.add(new Separator());
        }
        manager.add(copyAction);
        manager.add(copyAllAction);
        manager.add(selectAllAction);
        manager.add(clearLogAction);
    // manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    });
    menuMgr.setRemoveAllWhenShown(true);
    logTable.setMenu(menu);
    site.registerContextMenu(menuMgr, this);
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) MenuManager(org.eclipse.jface.action.MenuManager) Separator(org.eclipse.jface.action.Separator)

Example 83 with MenuManager

use of org.eclipse.jface.action.MenuManager in project dbeaver by dbeaver.

the class GenericFilterValueEdit method addContextMenu.

void addContextMenu(Action[] actions) {
    MenuManager menuMgr = new MenuManager();
    menuMgr.addMenuListener(manager -> {
        UIUtils.fillDefaultTableContextMenu(manager, table.getTable());
        manager.add(new Separator());
        for (Action act : actions) {
            manager.add(act);
        }
    });
    menuMgr.setRemoveAllWhenShown(true);
    table.getTable().setMenu(menuMgr.createContextMenu(table.getTable()));
}
Also used : Action(org.eclipse.jface.action.Action) MenuManager(org.eclipse.jface.action.MenuManager) Separator(org.eclipse.jface.action.Separator)

Example 84 with MenuManager

use of org.eclipse.jface.action.MenuManager in project yamcs-studio by yamcs.

the class ApplicationActionBarAdvisor method fillMenuBar.

@Override
protected void fillMenuBar(IMenuManager menuBar) {
    beforeFillMenuBar();
    MenuManager fileMenu = new MenuManager("File", IWorkbenchActionConstants.M_FILE);
    MenuManager windowMenu = new MenuManager("Window", IWorkbenchActionConstants.M_WINDOW);
    MenuManager helpMenu = new MenuManager("Help", IWorkbenchActionConstants.M_HELP);
    menuBar.add(fileMenu);
    menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    menuBar.add(windowMenu);
    menuBar.add(helpMenu);
    // File
    fileMenu.add(new Separator());
    fileMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    fileMenu.add(new Separator());
    // fileMenu.add(exitAction);
    // Window
    windowMenu.add(bringAllToFrontAction);
    // Help
    helpMenu.add(onlineHelpAction);
    helpMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    helpMenu.add(new Separator());
    helpMenu.add(raiseIssueAction);
    helpMenu.add(new Separator());
    helpMenu.add(aboutAction);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) GroupMarker(org.eclipse.jface.action.GroupMarker) Separator(org.eclipse.jface.action.Separator)

Example 85 with MenuManager

use of org.eclipse.jface.action.MenuManager in project vorto by eclipse.

the class AbstractModelRepositoryViewPart method initContextMenu.

/**
 * Create the context menu
 */
private void initContextMenu() {
    final MenuManager menuMgr = new MenuManager("#PopupMenu");
    Menu menu = menuMgr.createContextMenu(viewer.getControl());
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            if (viewer.getStructuredSelection().isEmpty()) {
                return;
            }
            ModelResource model = (ModelResource) viewer.getStructuredSelection().getFirstElement();
            if (model.getId().getModelType() == ModelType.InformationModel || model.getId().getModelType() == ModelType.Functionblock) {
                addListGeneratorsToMenu(manager, model);
            }
            menuMgr.add(new PreviewSharedModelAction(model));
        }
    });
    menuMgr.setRemoveAllWhenShown(true);
    viewer.getControl().setMenu(menu);
}
Also used : ModelResource(org.eclipse.vorto.core.api.repository.ModelResource) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuListener(org.eclipse.jface.action.IMenuListener)

Aggregations

MenuManager (org.eclipse.jface.action.MenuManager)657 IMenuManager (org.eclipse.jface.action.IMenuManager)498 Menu (org.eclipse.swt.widgets.Menu)303 IMenuListener (org.eclipse.jface.action.IMenuListener)246 Separator (org.eclipse.jface.action.Separator)220 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)65 Point (org.eclipse.swt.graphics.Point)63 Action (org.eclipse.jface.action.Action)55 Composite (org.eclipse.swt.widgets.Composite)49 IAction (org.eclipse.jface.action.IAction)48 SelectionEvent (org.eclipse.swt.events.SelectionEvent)44 GridData (org.eclipse.swt.layout.GridData)44 GroupMarker (org.eclipse.jface.action.GroupMarker)43 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)43 Transfer (org.eclipse.swt.dnd.Transfer)35 GridLayout (org.eclipse.swt.layout.GridLayout)32 List (java.util.List)30 EditingDomainViewerDropAdapter (org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter)30 LocalTransfer (org.eclipse.emf.edit.ui.dnd.LocalTransfer)30 ViewerDragAdapter (org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter)30