Search in sources :

Example 1 with OccurenceNavigatorSupport

use of com.intellij.ide.OccurenceNavigatorSupport in project intellij-community by JetBrains.

the class TreeView method createPanel.

private JPanel createPanel() {
    createModel();
    myTree = new MyTree();
    myTree.setLineStyleAngled();
    myTree.setRootVisible(false);
    myTree.setShowsRootHandles(true);
    myTree.updateUI();
    myTree.setLargeModel(true);
    myTree.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false);
            }
        }
    });
    myTree.addMouseListener(new PopupHandler() {

        public void invokePopup(Component comp, int x, int y) {
            popupInvoked(comp, x, y);
        }
    });
    EditSourceOnDoubleClickHandler.install(myTree);
    myAutoScrollToSourceHandler.install(myTree);
    myOccurenceNavigatorSupport = new OccurenceNavigatorSupport(myTree) {

        protected Navigatable createDescriptorForNode(DefaultMutableTreeNode node) {
            if (!(node instanceof MessageNode)) {
                return null;
            }
            MessageNode messageNode = (MessageNode) node;
            AntBuildMessageView.MessageType type = messageNode.getType();
            if (type != AntBuildMessageView.MessageType.MESSAGE && type != AntBuildMessageView.MessageType.ERROR) {
                return null;
            }
            if (!isValid(messageNode.getFile())) {
                return null;
            }
            return new OpenFileDescriptor(myProject, messageNode.getFile(), messageNode.getOffset());
        }

        @Nullable
        public String getNextOccurenceActionName() {
            return AntBundle.message("ant.execution.next.error.warning.action.name");
        }

        @Nullable
        public String getPreviousOccurenceActionName() {
            return AntBundle.message("ant.execution.previous.error.warning.action.name");
        }
    };
    return JBUI.Panels.simplePanel(MessageTreeRenderer.install(myTree));
}
Also used : PopupHandler(com.intellij.ui.PopupHandler) KeyAdapter(java.awt.event.KeyAdapter) Navigatable(com.intellij.pom.Navigatable) KeyEvent(java.awt.event.KeyEvent) OccurenceNavigatorSupport(com.intellij.ide.OccurenceNavigatorSupport) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

OccurenceNavigatorSupport (com.intellij.ide.OccurenceNavigatorSupport)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 Navigatable (com.intellij.pom.Navigatable)1 PopupHandler (com.intellij.ui.PopupHandler)1 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1 Nullable (org.jetbrains.annotations.Nullable)1