Search in sources :

Example 1 with NodeFilterAction

use of com.cubrid.common.ui.common.action.NodeFilterAction 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

CollapseAllAction (com.cubrid.common.ui.common.action.CollapseAllAction)1 FilterSettingAction (com.cubrid.common.ui.common.action.FilterSettingAction)1 GroupSettingAction (com.cubrid.common.ui.common.action.GroupSettingAction)1 NodeFilterAction (com.cubrid.common.ui.common.action.NodeFilterAction)1 ShowToolTipAction (com.cubrid.common.ui.common.action.ShowToolTipAction)1 TopGroupAction (com.cubrid.common.ui.common.action.TopGroupAction)1 TopGroupItemAction (com.cubrid.common.ui.common.action.TopGroupItemAction)1 ActionManager (com.cubrid.common.ui.spi.action.ActionManager)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IAction (org.eclipse.jface.action.IAction)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 Separator (org.eclipse.jface.action.Separator)1 Point (org.eclipse.swt.graphics.Point)1