Example usage for com.intellij.openapi.actionSystem IdeActions GROUP_USAGE_VIEW_POPUP

List of usage examples for com.intellij.openapi.actionSystem IdeActions GROUP_USAGE_VIEW_POPUP

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem IdeActions GROUP_USAGE_VIEW_POPUP.

Prototype

String GROUP_USAGE_VIEW_POPUP

To view the source code for com.intellij.openapi.actionSystem IdeActions GROUP_USAGE_VIEW_POPUP.

Click Source Link

Usage

From source file:com.deepsky.findUsages.workarounds.UsageView2Impl.java

License:Apache License

private void initTree() {
    myTree.setRootVisible(false);/*  w  w  w . ja  v  a 2  s.  c  o  m*/
    myTree.setShowsRootHandles(true);
    SmartExpander.installOn(myTree);
    TreeUtil.installActions(myTree);
    EditSourceOnDoubleClickHandler.install(myTree);
    myTree.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (KeyEvent.VK_ENTER == e.getKeyCode()) {
                TreePath leadSelectionPath = myTree.getLeadSelectionPath();
                if (leadSelectionPath == null)
                    return;

                DefaultMutableTreeNode node = (DefaultMutableTreeNode) leadSelectionPath.getLastPathComponent();
                if (node instanceof UsageNode) {
                    final Usage usage = ((UsageNode) node).getUsage();
                    usage.navigate(false);
                    usage.highlightInEditor();
                } else if (node.isLeaf()) {
                    Navigatable navigatable = getNavigatableForNode(node);
                    if (navigatable != null && navigatable.canNavigate()) {
                        navigatable.navigate(false);
                    }
                }
            }
        }
    });

    TreeUtil.selectFirstNode(myTree);
    PopupHandler.installPopupHandler(myTree, IdeActions.GROUP_USAGE_VIEW_POPUP, ActionPlaces.USAGE_VIEW_POPUP);
    //TODO: install speed search. Not in openapi though. It makes sense to create a common TreeEnchancer service.
}

From source file:com.intellij.usages.impl.UsageViewImpl.java

License:Apache License

private void initTree() {
    myTree.setRootVisible(false);//from  ww w.  j a va2 s  .  com
    myTree.setShowsRootHandles(true);
    SmartExpander.installOn(myTree);
    TreeUtil.installActions(myTree);
    EditSourceOnDoubleClickHandler.install(myTree);
    myTree.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (KeyEvent.VK_ENTER == e.getKeyCode()) {
                TreePath leadSelectionPath = myTree.getLeadSelectionPath();
                if (leadSelectionPath == null)
                    return;

                DefaultMutableTreeNode node = (DefaultMutableTreeNode) leadSelectionPath.getLastPathComponent();
                if (node instanceof UsageNode) {
                    final Usage usage = ((UsageNode) node).getUsage();
                    usage.navigate(false);
                    usage.highlightInEditor();
                } else if (node.isLeaf()) {
                    Navigatable navigatable = getNavigatableForNode(node);
                    if (navigatable != null && navigatable.canNavigate()) {
                        navigatable.navigate(false);
                    }
                }
            }
        }
    });

    TreeUtil.selectFirstNode(myTree);
    PopupHandler.installPopupHandler(myTree, IdeActions.GROUP_USAGE_VIEW_POPUP, ActionPlaces.USAGE_VIEW_POPUP);

    myTree.addTreeExpansionListener(new TreeExpansionListener() {
        @Override
        public void treeExpanded(TreeExpansionEvent event) {
            TreePath path = event.getPath();
            Object component = path.getLastPathComponent();
            if (!(component instanceof Node))
                return;
            Node node = (Node) component;
            if (!expandingAll && node.needsUpdate()) {
                checkNodeValidity(node, path);
            }
        }

        @Override
        public void treeCollapsed(TreeExpansionEvent event) {
        }
    });

    TreeUIHelper.getInstance().installTreeSpeedSearch(myTree, new Convertor<TreePath, String>() {
        @Override
        public String convert(TreePath o) {
            Object value = o.getLastPathComponent();
            TreeCellRenderer renderer = myTree.getCellRenderer();
            if (renderer instanceof UsageViewTreeCellRenderer) {
                UsageViewTreeCellRenderer coloredRenderer = (UsageViewTreeCellRenderer) renderer;
                return coloredRenderer.getPlainTextForNode(value);
            }
            return value == null ? null : value.toString();
        }
    }, true);
}