Java 类com.intellij.ui.TreeExpandCollapse 实例源码

项目:intellij-ce-playground    文件:TreeUtilTest.java   
public void testRemoveSelected() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
  DefaultTreeModel model = new DefaultTreeModel(root);
  DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("1");
  model.insertNodeInto(child1, root, 0);
  DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("2");
  model.insertNodeInto(child2, root, 1);
  DefaultMutableTreeNode child11 = new DefaultMutableTreeNode("11");
  model.insertNodeInto(child11, child1, 0);
  JTree tree = new Tree(model);
  TreeExpandCollapse.expandAll(tree);
  tree.clearSelection();
  TreeUtil.removeSelected(tree);
  assertEquals(2, model.getChildCount(root));
  assertEquals(1, model.getChildCount(child1));
  tree.setSelectionPath(TreeUtil.getPathFromRoot(child11));
  TreeUtil.removeSelected(tree);
  assertSame(child1, tree.getSelectionPath().getLastPathComponent());
  TreeUtil.removeSelected(tree);
  assertSame(child2, tree.getSelectionPath().getLastPathComponent());
  tree.setSelectionPath(new TreePath(root));
  assertEquals(1, model.getChildCount(root));
  TreeUtil.removeSelected(tree);
  assertSame(root, model.getRoot());
  assertEquals(1, model.getChildCount(root));
}
项目:intellij-ce-playground    文件:TreeUtilTest.java   
public void testMultiLevelRemove() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
  DefaultTreeModel model = new DefaultTreeModel(root) {
      @Override
      public void removeNodeFromParent(MutableTreeNode mutableTreeNode) {
        super.removeNodeFromParent((MutableTreeNode) mutableTreeNode.getParent());
      }
    };
  DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("1");
  model.insertNodeInto(node1, root, 0);
  DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("2");
  model.insertNodeInto(node2, node1, 0);
  JTree tree = new Tree(model);
  TreeExpandCollapse.expandAll(tree);
  tree.setSelectionPath(TreeUtil.getPathFromRoot(node2));
  TreeUtil.removeSelected(tree);
  assertEquals(0, root.getChildCount());
  assertEquals(root, tree.getSelectionPath().getLastPathComponent());
}
项目:tools-idea    文件:TreeUtilTest.java   
public void testRemoveSelected() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
  DefaultTreeModel model = new DefaultTreeModel(root);
  DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("1");
  model.insertNodeInto(child1, root, 0);
  DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("2");
  model.insertNodeInto(child2, root, 1);
  DefaultMutableTreeNode child11 = new DefaultMutableTreeNode("11");
  model.insertNodeInto(child11, child1, 0);
  JTree tree = new Tree(model);
  TreeExpandCollapse.expandAll(tree);
  tree.clearSelection();
  TreeUtil.removeSelected(tree);
  assertEquals(2, model.getChildCount(root));
  assertEquals(1, model.getChildCount(child1));
  tree.setSelectionPath(TreeUtil.getPathFromRoot(child11));
  TreeUtil.removeSelected(tree);
  assertSame(child1, tree.getSelectionPath().getLastPathComponent());
  TreeUtil.removeSelected(tree);
  assertSame(child2, tree.getSelectionPath().getLastPathComponent());
  tree.setSelectionPath(new TreePath(root));
  assertEquals(1, model.getChildCount(root));
  TreeUtil.removeSelected(tree);
  assertSame(root, model.getRoot());
  assertEquals(1, model.getChildCount(root));
}
项目:tools-idea    文件:TreeUtilTest.java   
public void testMultiLevelRemove() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
  DefaultTreeModel model = new DefaultTreeModel(root) {
      @Override
      public void removeNodeFromParent(MutableTreeNode mutableTreeNode) {
        super.removeNodeFromParent((MutableTreeNode) mutableTreeNode.getParent());
      }
    };
  DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("1");
  model.insertNodeInto(node1, root, 0);
  DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("2");
  model.insertNodeInto(node2, node1, 0);
  JTree tree = new Tree(model);
  TreeExpandCollapse.expandAll(tree);
  tree.setSelectionPath(TreeUtil.getPathFromRoot(node2));
  TreeUtil.removeSelected(tree);
  assertEquals(0, root.getChildCount());
  assertEquals(root, tree.getSelectionPath().getLastPathComponent());
}
项目:consulo    文件:TreeUtilTest.java   
public void testRemoveSelected() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
  DefaultTreeModel model = new DefaultTreeModel(root);
  DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("1");
  model.insertNodeInto(child1, root, 0);
  DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("2");
  model.insertNodeInto(child2, root, 1);
  DefaultMutableTreeNode child11 = new DefaultMutableTreeNode("11");
  model.insertNodeInto(child11, child1, 0);
  JTree tree = new Tree(model);
  TreeExpandCollapse.expandAll(tree);
  tree.clearSelection();
  TreeUtil.removeSelected(tree);
  assertEquals(2, model.getChildCount(root));
  assertEquals(1, model.getChildCount(child1));
  tree.setSelectionPath(TreeUtil.getPathFromRoot(child11));
  TreeUtil.removeSelected(tree);
  assertSame(child1, tree.getSelectionPath().getLastPathComponent());
  TreeUtil.removeSelected(tree);
  assertSame(child2, tree.getSelectionPath().getLastPathComponent());
  tree.setSelectionPath(new TreePath(root));
  assertEquals(1, model.getChildCount(root));
  TreeUtil.removeSelected(tree);
  assertSame(root, model.getRoot());
  assertEquals(1, model.getChildCount(root));
}
项目:consulo    文件:TreeUtilTest.java   
public void testMultiLevelRemove() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
  DefaultTreeModel model = new DefaultTreeModel(root) {
      @Override
      public void removeNodeFromParent(MutableTreeNode mutableTreeNode) {
        super.removeNodeFromParent((MutableTreeNode) mutableTreeNode.getParent());
      }
    };
  DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("1");
  model.insertNodeInto(node1, root, 0);
  DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("2");
  model.insertNodeInto(node2, node1, 0);
  JTree tree = new Tree(model);
  TreeExpandCollapse.expandAll(tree);
  tree.setSelectionPath(TreeUtil.getPathFromRoot(node2));
  TreeUtil.removeSelected(tree);
  assertEquals(0, root.getChildCount());
  assertEquals(root, tree.getSelectionPath().getLastPathComponent());
}
项目:intellij-ce-playground    文件:ExpandTreeNodeAction.java   
protected void performOn(JTree tree) {
  TreeExpandCollapse.expand(tree);
}
项目:intellij-ce-playground    文件:CollapseTreeNodeAction.java   
protected void performOn(JTree tree) {
  TreeExpandCollapse.collapse(tree);
}
项目:intellij-ce-playground    文件:FullyExpandTreeNodeAction.java   
protected void performOn(JTree tree) {
  TreeExpandCollapse.expandAll(tree);
}
项目:tools-idea    文件:ExpandTreeNodeAction.java   
protected void performOn(JTree tree) {
  TreeExpandCollapse.expand(tree);
}
项目:tools-idea    文件:CollapseTreeNodeAction.java   
protected void performOn(JTree tree) {
  TreeExpandCollapse.collapse(tree);
}
项目:tools-idea    文件:FullyExpandTreeNodeAction.java   
protected void performOn(JTree tree) {
  TreeExpandCollapse.expandAll(tree);
}
项目:consulo    文件:ExpandTreeNodeAction.java   
@Override
protected void performOn(JTree tree) {
  TreeExpandCollapse.expand(tree);
}
项目:consulo    文件:CollapseTreeNodeAction.java   
protected void performOn(JTree tree) {
  TreeExpandCollapse.collapse(tree);
}
项目:consulo    文件:FullyExpandTreeNodeAction.java   
protected void performOn(JTree tree) {
  TreeExpandCollapse.expandAll(tree);
}