Search in sources :

Example 46 with Navigatable

use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.

the class OccurenceNavigatorSupport method findNode.

public DefaultMutableTreeNode findNode(@NotNull JTree tree, TreeNode selectedNode, boolean forward, Counters counters) {
    boolean[] ready = { selectedNode == null };
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel().getRoot();
    Enumeration enumeration = root.preorderEnumeration();
    List<TreeNode> nodes = new ArrayList<>();
    while (enumeration.hasMoreElements()) {
        TreeNode node = (TreeNode) enumeration.nextElement();
        nodes.add(node);
    }
    DefaultMutableTreeNode result = null;
    if (forward) {
        for (TreeNode node : nodes) {
            DefaultMutableTreeNode nextNode = getNode(node, selectedNode, ready);
            if (nextNode != null) {
                result = nextNode;
                break;
            }
        }
    } else {
        for (int i = nodes.size() - 1; i >= 0; i--) {
            TreeNode node = nodes.get(i);
            DefaultMutableTreeNode nextNode = getNode(node, selectedNode, ready);
            if (nextNode != null) {
                result = nextNode;
                break;
            }
        }
    }
    if (result == null) {
        return null;
    }
    if (counters != null) {
        counters.myFoundOccurenceNumber = 0;
        counters.myOccurencesCount = 0;
        for (TreeNode node : nodes) {
            if (!(node instanceof DefaultMutableTreeNode))
                continue;
            Navigatable descriptor = createDescriptorForNode((DefaultMutableTreeNode) node);
            if (descriptor == null)
                continue;
            counters.myOccurencesCount++;
            if (result == node) {
                counters.myFoundOccurenceNumber = counters.myOccurencesCount;
            }
        }
    }
    return result;
}
Also used : Enumeration(java.util.Enumeration) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeNode(javax.swing.tree.TreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ArrayList(java.util.ArrayList) Navigatable(com.intellij.pom.Navigatable)

Example 47 with Navigatable

use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.

the class OccurenceNavigatorSupport method goPreviousOccurence.

@Override
public OccurenceInfo goPreviousOccurence() {
    Counters counters = new Counters();
    DefaultMutableTreeNode node = findNode(myTree, false, counters);
    if (node == null)
        return null;
    TreePath treePath = new TreePath(node.getPath());
    TreeUtil.selectPath(myTree, treePath);
    Navigatable editSourceDescriptor = createDescriptorForNode(node);
    if (editSourceDescriptor == null)
        return null;
    return new OccurenceInfo(editSourceDescriptor, counters.myFoundOccurenceNumber, counters.myOccurencesCount);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreePath(javax.swing.tree.TreePath) Navigatable(com.intellij.pom.Navigatable)

Example 48 with Navigatable

use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.

the class BaseNavigateToSourceAction method update.

public void update(AnActionEvent e) {
    boolean inPopup = ActionPlaces.isPopupPlace(e.getPlace());
    Navigatable target = findTargetForUpdate(e.getDataContext());
    boolean enabled = target != null;
    if (inPopup && !(this instanceof OpenModuleSettingsAction) && OpenModuleSettingsAction.isModuleInProjectViewPopup(e)) {
        e.getPresentation().setVisible(false);
        return;
    }
    //as myFocusEditor is always ignored - Main Menu|View always contains 2 actions with the same name and actually same behaviour
    e.getPresentation().setVisible((enabled || !inPopup) && (myFocusEditor || !(target instanceof NavigatableWithText)));
    e.getPresentation().setEnabled(enabled);
    String navigateActionText = myFocusEditor && target instanceof NavigatableWithText ? ((NavigatableWithText) target).getNavigateActionText(true) : null;
    e.getPresentation().setText(navigateActionText == null ? getTemplatePresentation().getText() : navigateActionText);
}
Also used : NavigatableWithText(com.intellij.pom.NavigatableWithText) Navigatable(com.intellij.pom.Navigatable)

Example 49 with Navigatable

use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.

the class SMTestRunnerResultsForm method createTestTreeView.

protected JComponent createTestTreeView() {
    myTreeView = new SMTRunnerTestTreeView();
    myTreeView.setLargeModel(true);
    myTreeView.attachToModel(this);
    myTreeView.setTestResultsViewer(this);
    final SMTRunnerTreeStructure structure = new SMTRunnerTreeStructure(myProject, myTestsRootNode);
    myTreeBuilder = new SMTRunnerTreeBuilder(myTreeView, structure);
    myTreeBuilder.setTestsComparator(myProperties);
    Disposer.register(this, myTreeBuilder);
    myAnimator = new TestsProgressAnimator(myTreeBuilder);
    TrackRunningTestUtil.installStopListeners(myTreeView, myProperties, new Pass<AbstractTestProxy>() {

        @Override
        public void pass(AbstractTestProxy testProxy) {
            if (testProxy == null)
                return;
            final AbstractTestProxy selectedProxy = testProxy;
            //drill to the first leaf
            while (!testProxy.isLeaf()) {
                final List<? extends AbstractTestProxy> children = testProxy.getChildren();
                if (!children.isEmpty()) {
                    final AbstractTestProxy firstChild = children.get(0);
                    if (firstChild != null) {
                        testProxy = firstChild;
                        continue;
                    }
                }
                break;
            }
            //pretend the selection on the first leaf
            //so if test would be run, tracking would be restarted 
            myLastSelected = testProxy;
            //ensure scroll to source on explicit selection only
            if (ScrollToTestSourceAction.isScrollEnabled(SMTestRunnerResultsForm.this)) {
                final Navigatable descriptor = TestsUIUtil.getOpenFileDescriptor(selectedProxy, SMTestRunnerResultsForm.this);
                if (descriptor != null) {
                    OpenSourceUtil.navigate(false, descriptor);
                }
            }
        }
    });
    //myTreeView.setRootVisible(false);
    return myTreeView;
}
Also used : TestsProgressAnimator(com.intellij.execution.testframework.ui.TestsProgressAnimator) List(java.util.List) Navigatable(com.intellij.pom.Navigatable)

Example 50 with Navigatable

use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.

the class NewErrorTreeViewPanel method navigateToSource.

private void navigateToSource(final boolean focusEditor) {
    NavigatableErrorTreeElement element = getSelectedNavigatableElement();
    if (element == null) {
        return;
    }
    final Navigatable navigatable = element.getNavigatable();
    if (navigatable.canNavigate()) {
        navigatable.navigate(focusEditor);
    }
}
Also used : Navigatable(com.intellij.pom.Navigatable)

Aggregations

Navigatable (com.intellij.pom.Navigatable)70 VirtualFile (com.intellij.openapi.vfs.VirtualFile)22 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)19 Project (com.intellij.openapi.project.Project)14 Nullable (org.jetbrains.annotations.Nullable)14 PsiElement (com.intellij.psi.PsiElement)11 ArrayList (java.util.ArrayList)9 PsiFile (com.intellij.psi.PsiFile)7 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)7 TreePath (javax.swing.tree.TreePath)7 NotNull (org.jetbrains.annotations.NotNull)6 Editor (com.intellij.openapi.editor.Editor)4 List (java.util.List)4 TextRange (com.intellij.openapi.util.TextRange)3 XmlTag (com.intellij.psi.xml.XmlTag)3 BlazeConsoleView (com.google.idea.blaze.base.console.BlazeConsoleView)2 IssueOutput (com.google.idea.blaze.base.scope.output.IssueOutput)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 Logger (com.intellij.openapi.diagnostic.Logger)2 Document (com.intellij.openapi.editor.Document)2