Search in sources :

Example 1 with AbstractTreeUi

use of com.intellij.ide.util.treeView.AbstractTreeUi in project intellij-community by JetBrains.

the class NodeProgressAnimator method repaintWithParents.

public void repaintWithParents(final SimpleNode element) {
    SimpleNode current = element;
    do {
        DefaultMutableTreeNode node = myTreeBuilder.getNodeForElement(current);
        if (node != null) {
            final AbstractTreeUi treeUi = myTreeBuilder.getUi();
            treeUi.addSubtreeToUpdate(node, false);
        }
        current = current.getParent();
    } while (current != null);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AbstractTreeUi(com.intellij.ide.util.treeView.AbstractTreeUi) SimpleNode(com.intellij.ui.treeStructure.SimpleNode)

Example 2 with AbstractTreeUi

use of com.intellij.ide.util.treeView.AbstractTreeUi in project android by JetBrains.

the class TreeBuilderSpeedSearch method findAndSelectElement.

@Override
public void findAndSelectElement(@NotNull String searchQuery) {
    String pattern = searchQuery.trim();
    clearSelection(myTree);
    if (searchQuery.isEmpty()) {
        return;
    }
    ActionCallback initialized = myTreeBuilder.getInitialized();
    initialized.doWhenDone(() -> {
        List<AbstractPsModelNode> nodes = Lists.newArrayList();
        myTreeBuilder.accept(AbstractPsModelNode.class, new TreeVisitor<AbstractPsModelNode>() {

            @Override
            public boolean visit(@NotNull AbstractPsModelNode node) {
                if (isMatchingElement(node, pattern)) {
                    nodes.add(node);
                }
                return false;
            }
        });
        Color foreground = nodes.isEmpty() ? JBColor.red : getToolTipForeground();
        if (mySearchPopup != null) {
            mySearchPopup.mySearchField.setForeground(foreground);
        }
        if (nodes.isEmpty()) {
            return;
        }
        Runnable onDone = () -> {
            myTreeBuilder.expandParents(nodes);
            myTreeBuilder.scrollToFirstSelectedRow();
        };
        myTreeBuilder.getUi().userSelect(nodes.toArray(), () -> {
            AbstractTreeUi ui = myTreeBuilder.getUi();
            if (ui != null) {
                ui.executeUserRunnable(onDone);
            } else {
                onDone.run();
            }
        }, false, false);
    });
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback) JBColor(com.intellij.ui.JBColor) AbstractTreeUi(com.intellij.ide.util.treeView.AbstractTreeUi)

Aggregations

AbstractTreeUi (com.intellij.ide.util.treeView.AbstractTreeUi)2 ActionCallback (com.intellij.openapi.util.ActionCallback)1 JBColor (com.intellij.ui.JBColor)1 SimpleNode (com.intellij.ui.treeStructure.SimpleNode)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1