Java Code Examples for com.intellij.util.ui.tree.TreeUtil#promiseSelect()

The following examples show how to use com.intellij.util.ui.tree.TreeUtil#promiseSelect() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectViewImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void apply(final AbstractProjectViewPane viewPane) {
  if (viewPane == null) {
    return;
  }
  AbstractTreeBuilder treeBuilder = viewPane.getTreeBuilder();
  JTree tree = viewPane.myTree;
  if (treeBuilder != null) {
    DefaultTreeModel treeModel = (DefaultTreeModel)tree.getModel();
    List<TreePath> paths = new ArrayList<>(myElements.length);
    for (final Object element : myElements) {
      DefaultMutableTreeNode node = treeBuilder.getNodeForElement(element);
      if (node == null) {
        treeBuilder.buildNodeForElement(element);
        node = treeBuilder.getNodeForElement(element);
      }
      if (node != null) {
        paths.add(new TreePath(treeModel.getPathToRoot(node)));
      }
    }
    if (!paths.isEmpty()) {
      tree.setSelectionPaths(paths.toArray(new TreePath[0]));
    }
  }
  else {
    List<TreeVisitor> visitors = AbstractProjectViewPane.createVisitors(myElements);
    if (1 == visitors.size()) {
      TreeUtil.promiseSelect(tree, visitors.get(0));
    }
    else if (!visitors.isEmpty()) {
      TreeUtil.promiseSelect(tree, visitors.stream());
    }
  }
}
 
Example 2
Source File: TreeState.java    From consulo with Apache License 2.0 4 votes vote down vote up
private Promise<List<TreePath>> select(@Nonnull JTree tree) {
  return TreeUtil.promiseSelect(tree, mySelectedPaths.stream().map(elements -> new Visitor(elements)));
}