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

The following examples show how to use com.intellij.util.ui.tree.TreeUtil#getPathFromRoot() . 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: PushLog.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void setChildren(@Nonnull DefaultMutableTreeNode parentNode,
                        @Nonnull Collection<? extends DefaultMutableTreeNode> childrenNodes) {
  parentNode.removeAllChildren();
  for (DefaultMutableTreeNode child : childrenNodes) {
    parentNode.add(child);
  }
  if (!myTree.isEditing()) {
    refreshNode(parentNode);
    TreePath path = TreeUtil.getPathFromRoot(parentNode);
    if (myTree.getSelectionModel().isPathSelected(path)) {
      updateChangesView();
    }
  }
  else {
    myShouldRepaint = true;
  }
}
 
Example 2
Source File: TreeExpandCollapseTest.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();
  myTreeModel.insertNodeInto(myChildA, myRoot, 0);
  myTreeModel.insertNodeInto(myChildB, myRoot, 1);
  myTreeModel.insertNodeInto(myChild2, myChildA, 0);
  myTreeModel.insertNodeInto(new DefaultMutableTreeNode(), myChild2, 0);
  myTreeModel.insertNodeInto(new DefaultMutableTreeNode(), myChildB, 0);
  myChildAPath = TreeUtil.getPathFromRoot(myChildA);
  myChild2Path = TreeUtil.getPathFromRoot(myChild2);
  myChildBPath = TreeUtil.getPathFromRoot(myChildB);
}
 
Example 3
Source File: SimpleTree.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public TreePath getPathFor(SimpleNode node) {
  final TreeNode nodeWithObject = TreeUtil.findNodeWithObject((DefaultMutableTreeNode)getModel().getRoot(), node);
  if (nodeWithObject != null) {
    return TreeUtil.getPathFromRoot(nodeWithObject);
  }
  return null;
}
 
Example 4
Source File: NotificationsConfigurablePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private TreePath removeNode(DefaultMutableTreeNode node) {
  DefaultMutableTreeNode parent = (DefaultMutableTreeNode)node.getParent();
  if (parent != null) {
    IndexTreePathState state = new IndexTreePathState(TreeUtil.getPathFromRoot(node));
    removeNodeFromParent(node);
    if (parent.isLeaf()) {
      return removeNode(parent);
    }
    return state.getRestoredPath();
  }
  return null;
}
 
Example 5
Source File: ChangesViewManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void selectChange(@Nonnull Change change) {
  DefaultMutableTreeNode root = (DefaultMutableTreeNode)myView.getModel().getRoot();
  DefaultMutableTreeNode node = TreeUtil.findNodeWithObject(root, change);
  if (node != null) {
    TreePath path = TreeUtil.getPathFromRoot(node);
    TreeUtil.selectPath(myView, path, false);
  }
}