Search in sources :

Example 46 with IMenuManager

use of org.eclipse.jface.action.IMenuManager in project dbeaver by serge-rider.

the class ERDEditorContributor method contributeToMenu.

@Override
public void contributeToMenu(IMenuManager manager) {
    super.contributeToMenu(manager);
    IMenuManager editMenu = manager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
    if (editMenu != null) {
    //editMenu.add(new Separator());
    //editMenu.add(new Separator());
    //editMenu.add(executeStatementAction);
    //editMenu.add(executeScriptAction);
    }
}
Also used : IMenuManager(org.eclipse.jface.action.IMenuManager)

Example 47 with IMenuManager

use of org.eclipse.jface.action.IMenuManager in project cubrid-manager by CUBRID.

the class SQLEditorComposite method createContextMenu.

protected void createContextMenu() {
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            IAction copyAction = ActionManager.getInstance().getAction(CopyAction.ID);
            if (copyAction != null) {
                manager.add(copyAction);
            }
            IAction cutAction = ActionManager.getInstance().getAction(CutAction.ID);
            if (cutAction != null) {
                manager.add(cutAction);
            }
            IAction pasteAction = ActionManager.getInstance().getAction(PasteAction.ID);
            if (pasteAction != null) {
                manager.add(pasteAction);
            }
            manager.add(new Separator());
            IAction findAction = ActionManager.getInstance().getAction(FindReplaceAction.ID);
            if (findAction != null) {
                manager.add(findAction);
            }
            manager.add(new Separator());
            IAction runQueryAction = ActionManager.getInstance().getAction(RunQueryAction.ID);
            if (runQueryAction != null) {
                manager.add(runQueryAction);
            }
            IAction runSqlmapQueryAction = ActionManager.getInstance().getAction(ParseSqlmapQueryAction.ID);
            if (runSqlmapQueryAction != null) {
                manager.add(runSqlmapQueryAction);
            }
            IAction runQueryPlanAction = ActionManager.getInstance().getAction(RunQueryPlanAction.ID);
            if (runQueryPlanAction != null) {
                manager.add(runQueryPlanAction);
            }
            IAction favoriteQueryAction = ActionManager.getInstance().getAction(AddQueryToFavoriteAction.ID);
            if (favoriteQueryAction != null) {
                manager.add(favoriteQueryAction);
            }
            manager.add(new Separator());
            IAction showSchemaViewAction = ActionManager.getInstance().getAction(ShowSchemaAction.ID);
            if (showSchemaViewAction != null) {
                manager.add(showSchemaViewAction);
            }
            manager.add(new Separator());
            IAction queryTunerRunAction = ActionManager.getInstance().getAction(QueryTunerRunAction.ID);
            manager.add(queryTunerRunAction);
            manager.add(new Separator());
            IAction createPhpCodeAction = ActionManager.getInstance().getAction(CreateSqlPhpCodeAction.ID);
            if (createPhpCodeAction != null) {
                manager.add(createPhpCodeAction);
            }
            IAction createJavaCodeAction = ActionManager.getInstance().getAction(CreateSqlJavaCodeAction.ID);
            if (createJavaCodeAction != null) {
                manager.add(createJavaCodeAction);
            }
            manager.add(new Separator());
            IAction reformatColumnsAliasAction = ActionManager.getInstance().getAction(ReformatColumnsAliasAction.ID);
            if (reformatColumnsAliasAction != null) {
                manager.add(reformatColumnsAliasAction);
            }
        }
    });
    Menu contextMenu = menuManager.createContextMenu(text);
    text.setMenu(contextMenu);
}
Also used : IAction(org.eclipse.jface.action.IAction) 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) Separator(org.eclipse.jface.action.Separator)

Example 48 with IMenuManager

use of org.eclipse.jface.action.IMenuManager in project cubrid-manager by CUBRID.

the class ActionManager method changeActionMenu.

/**
	 * 
	 * Change action menu
	 * 
	 */
private void changeActionMenu() {
    WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    IMenuManager menuBarManager = window.getMenuBarManager();
    if (menuBarManager == null) {
        return;
    }
    IMenuManager actionMenuManager = menuBarManager.findMenuUsingPath(IActionConstants.MENU_ACTION);
    if (actionMenuManager != null) {
        actionMenuManager.removeAll();
        setActionsMenu(actionMenuManager);
        menuBarManager.update(true);
    }
}
Also used : WorkbenchWindow(org.eclipse.ui.internal.WorkbenchWindow) IMenuManager(org.eclipse.jface.action.IMenuManager)

Example 49 with IMenuManager

use of org.eclipse.jface.action.IMenuManager in project cubrid-manager by CUBRID.

the class MenuProvider method buildMenu.

/**
	 * Build the context menu and menubar menu according to the selected cubrid
	 * node
	 *
	 * @param manager the parent menu manager
	 * @param node the ICubridNode object
	 */
public void buildMenu(IMenuManager manager, ICubridNode node) {
    // fill Action Menu according to node type
    String type = node.getType();
    if (NodeType.STORED_PROCEDURE_FOLDER.equals(type)) {
        addActionToManager(manager, getAction(AddFunctionAction.ID));
        addActionToManager(manager, getAction(AddProcedureAction.ID));
    } else if (NodeType.STORED_PROCEDURE_FUNCTION_FOLDER.equals(type)) {
        addActionToManager(manager, getAction(AddFunctionAction.ID));
    } else if (NodeType.STORED_PROCEDURE_FUNCTION.equals(type)) {
        addActionToManager(manager, getAction(EditFunctionAction.ID));
        addActionToManager(manager, getAction(DeleteFunctionAction.ID));
    } else if (NodeType.STORED_PROCEDURE_PROCEDURE_FOLDER.equals(type)) {
        addActionToManager(manager, getAction(AddProcedureAction.ID));
    } else if (NodeType.STORED_PROCEDURE_PROCEDURE.equals(type)) {
        addActionToManager(manager, getAction(EditProcedureAction.ID));
        addActionToManager(manager, getAction(DeleteProcedureAction.ID));
    } else if (NodeType.TRIGGER_FOLDER.equals(type)) {
        // trigger
        addActionToManager(manager, getAction(NewTriggerAction.ID));
    } else if (NodeType.TRIGGER.equals(type)) {
        // trigger instance
        addActionToManager(manager, getAction(AlterTriggerAction.ID));
        addActionToManager(manager, getAction(DropTriggerAction.ID));
    } else if (NodeType.SERIAL_FOLDER.equals(type)) {
        addActionToManager(manager, getAction(CreateSerialAction.ID));
    } else if (NodeType.SERIAL.equals(type)) {
        addActionToManager(manager, getAction(EditSerialAction.ID));
        addActionToManager(manager, getAction(DeleteSerialAction.ID));
    } else if (NodeType.SYSTEM_TABLE.equals(type)) {
        buildSystemTableMenu(manager);
    } else if (NodeType.SYSTEM_VIEW.equals(type)) {
        buildSystemViewMenu(manager);
    } else if (NodeType.TABLE_FOLDER.equals(type)) {
        addActionToManager(manager, getAction(NewTableAction.ID));
        manager.add(new Separator());
        addActionToManager(manager, getAction(ExportTableDefinitionAction.ID));
        manager.add(new Separator());
        // Install Schema Comment
        addActionToManager(manager, getAction(SchemaCommentInstallAction.ID));
        manager.add(new Separator());
        IMenuManager perparedMenu = new MenuManager(Messages.preparedTableDataMenuName);
        manager.add(perparedMenu);
        addActionToManager(perparedMenu, getAction(PstmtOneDataAction.ID));
        addActionToManager(perparedMenu, getAction(PstmtMultiDataAction.ID));
        //			addActionToManager(manager, getAction(RunSQLFileAction.ID));
        manager.add(new Separator());
        // Export & Import Actions
        addActionToManager(manager, getAction(ExportWizardAction.ID));
        addActionToManager(manager, getAction(ImportWizardAction.ID));
        manager.add(new Separator());
    } else if (NodeType.USER_PARTITIONED_TABLE_FOLDER.equals(type)) {
        // partition table
        buildUserTableMenu(manager, node);
    } else if (NodeType.USER_PARTITIONED_TABLE.equals(type)) {
        // partition table/subtable
        buildPartitionedTableMenu(manager);
    } else if (NodeType.USER_TABLE.equals(type)) {
        buildUserTableMenu(manager, node);
    } else if (NodeType.USER_VIEW.equals(type)) {
        // User schema/View instance
        buildUserViewMenu(manager);
    } else if (NodeType.VIEW_FOLDER.equals(type)) {
        addActionToManager(manager, getAction(CreateViewAction.ID));
    } else if (NodeType.TABLE_COLUMN.equals(type)) {
        addActionToManager(manager, getAction(ColumnSelectSqlAction.ID));
        addActionToManager(manager, getAction(ColumnSelectCountAction.ID));
    } else if (NodeType.GROUP.equals(type)) {
        addActionToManager(manager, getAction(GroupPropertyAction.ID));
        manager.add(new Separator());
    }
    manager.update(true);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Example 50 with IMenuManager

use of org.eclipse.jface.action.IMenuManager in project cubrid-manager by CUBRID.

the class CubridNavigatorView method buildViewMenu.

/**
	 * Build the view menu
	 *
	 * @param menuManager IMenuManager
	 */
protected void buildViewMenu(final IMenuManager menuManager) {
    ActionManager actionManager = ActionManager.getInstance();
    if (isSupportGroup()) {
        IMenuManager topLevel = new MenuManager(Messages.topLevelElements);
        menuManager.add(topLevel);
        {
            TopGroupItemAction groupAction = (TopGroupItemAction) actionManager.getAction(TopGroupItemAction.ID);
            if (groupAction == null) {
                LOGGER.warn("The groupAction is a null.");
                return;
            }
            groupAction.setNavigatorView(this);
            topLevel.add(groupAction);
            TopGroupAction connAction = (TopGroupAction) actionManager.getAction(TopGroupAction.ID);
            if (connAction == null) {
                LOGGER.warn("The connAction is a null.");
                return;
            }
            connAction.setNavigatorView(this);
            topLevel.add(connAction);
        }
        menuManager.add(new Separator());
        GroupSettingAction gsAction = (GroupSettingAction) actionManager.getAction(GroupSettingAction.ID);
        if (gsAction == null) {
            LOGGER.warn("The gsAction is a null.");
            return;
        }
        gsAction.setNavigatorView(this);
        menuManager.add(gsAction);
    }
    //add the showTooTip action
    menuManager.add(new Separator());
    ShowToolTipAction showToolTipAction = new ShowToolTipAction(Messages.showToolTipActionName, null);
    menuManager.add(showToolTipAction);
    menuManager.add(new Separator());
    CollapseAllAction collapseAllAction = (CollapseAllAction) actionManager.getAction(CollapseAllAction.ID);
    if (collapseAllAction == null) {
        LOGGER.warn("The collapseAllAction is a null.");
        return;
    }
    collapseAllAction.setTargetTreeViewer(tv);
    menuManager.add(collapseAllAction);
    //add the root node filter action
    menuManager.add(new Separator());
    //add filter setting action
    IAction action = actionManager.getAction(FilterSettingAction.ID);
    if (action instanceof FilterSettingAction) {
        ((FilterSettingAction) action).setTv(tv);
        menuManager.add(action);
    }
    Object inputObj = tv.getInput();
    if (!(inputObj instanceof List<?>)) {
        return;
    }
    List<?> list = (List<?>) inputObj;
    int i = 1;
    for (Object obj : list) {
        if (!(obj instanceof ICubridNode)) {
            continue;
        }
        ICubridNode node = (ICubridNode) obj;
        String label = "&" + i + " " + node.getLabel();
        if (node.getLabel().indexOf("@") >= 0) {
            //if text have @ character, the sub string of the last @ will be as accelerator, hence add @
            label += "@";
        }
        NodeFilterAction nodeFilterAction = new NodeFilterAction(label, null, tv, node);
        nodeFilterAction.setChecked(NodeFilterManager.getInstance().isExistIdFilter(node.getId()));
        menuManager.add(nodeFilterAction);
        i++;
    }
}
Also used : IAction(org.eclipse.jface.action.IAction) ShowToolTipAction(com.cubrid.common.ui.common.action.ShowToolTipAction) FilterSettingAction(com.cubrid.common.ui.common.action.FilterSettingAction) NodeFilterAction(com.cubrid.common.ui.common.action.NodeFilterAction) GroupSettingAction(com.cubrid.common.ui.common.action.GroupSettingAction) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Point(org.eclipse.swt.graphics.Point) ActionManager(com.cubrid.common.ui.spi.action.ActionManager) TopGroupAction(com.cubrid.common.ui.common.action.TopGroupAction) CollapseAllAction(com.cubrid.common.ui.common.action.CollapseAllAction) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) TopGroupItemAction(com.cubrid.common.ui.common.action.TopGroupItemAction) List(java.util.List) ArrayList(java.util.ArrayList) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Aggregations

IMenuManager (org.eclipse.jface.action.IMenuManager)88 MenuManager (org.eclipse.jface.action.MenuManager)72 IMenuListener (org.eclipse.jface.action.IMenuListener)48 Menu (org.eclipse.swt.widgets.Menu)43 Separator (org.eclipse.jface.action.Separator)31 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)16 IAction (org.eclipse.jface.action.IAction)9 TreeViewer (org.eclipse.jface.viewers.TreeViewer)9 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)8 GridData (org.eclipse.swt.layout.GridData)8 Action (org.eclipse.jface.action.Action)7 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)7 Composite (org.eclipse.swt.widgets.Composite)7 GridLayout (org.eclipse.swt.layout.GridLayout)6 List (java.util.List)5 ICoolBarManager (org.eclipse.jface.action.ICoolBarManager)5 FocusEvent (org.eclipse.swt.events.FocusEvent)5 ActionManager (com.cubrid.common.ui.spi.action.ActionManager)4 IContributionItem (org.eclipse.jface.action.IContributionItem)4 Point (org.eclipse.swt.graphics.Point)4