예제 #1
0
파일: TreeUtil.java 프로젝트: jexp/idea2
 private static void expand(JTree tree, TreePath path, int levels) {
   if (levels == 0) return;
   tree.expandPath(path);
   TreeNode node = (TreeNode) path.getLastPathComponent();
   Enumeration children = node.children();
   while (children.hasMoreElements()) {
     expand(tree, path.pathByAddingChild(children.nextElement()), levels - 1);
   }
 }
예제 #2
0
파일: TreeUtil.java 프로젝트: jexp/idea2
  public static ActionCallback selectInTree(
      DefaultMutableTreeNode node, boolean requestFocus, JTree tree, boolean center) {
    if (node == null) return new ActionCallback.Done();

    final TreePath treePath = new TreePath(node.getPath());
    tree.expandPath(treePath);
    if (requestFocus) {
      tree.requestFocus();
    }
    return selectPath(tree, treePath, center);
  }
예제 #3
0
파일: TreeUtil.java 프로젝트: jexp/idea2
 public static void expandAll(final JTree tree) {
   tree.expandPath(new TreePath(tree.getModel().getRoot()));
   int oldRowCount = 0;
   do {
     int rowCount = tree.getRowCount();
     if (rowCount == oldRowCount) break;
     oldRowCount = rowCount;
     for (int i = 0; i < rowCount; i++) {
       tree.expandRow(i);
     }
   } while (true);
 }
 private void restoreUsageExpandState(final Collection<UsageState> states) {
   // always expand the last level group
   final DefaultMutableTreeNode root = (DefaultMutableTreeNode) myTree.getModel().getRoot();
   for (int i = root.getChildCount() - 1; i >= 0; i--) {
     final DefaultMutableTreeNode child = (DefaultMutableTreeNode) root.getChildAt(i);
     if (child instanceof GroupNode) {
       final TreePath treePath = new TreePath(child.getPath());
       myTree.expandPath(treePath);
     }
   }
   myTree.getSelectionModel().clearSelection();
   for (final UsageState usageState : states) {
     usageState.restore();
   }
 }
예제 #5
0
파일: TreeUtil.java 프로젝트: jexp/idea2
  public static ActionCallback selectInTree(
      Project project,
      DefaultMutableTreeNode node,
      boolean requestFocus,
      JTree tree,
      boolean center) {
    if (node == null) return new ActionCallback.Done();

    final TreePath treePath = new TreePath(node.getPath());
    tree.expandPath(treePath);
    if (requestFocus) {
      ActionCallback result = new ActionCallback(2);
      IdeFocusManager.getInstance(project).requestFocus(tree, true).notifyWhenDone(result);
      selectPath(tree, treePath, center).notifyWhenDone(result);
      return result;
    }
    return selectPath(tree, treePath, center);
  }
예제 #6
0
파일: TreeUtil.java 프로젝트: jexp/idea2
 public static void collapseAll(final JTree tree, final int keepSelectionLevel) {
   final TreePath leadSelectionPath = tree.getLeadSelectionPath();
   // Collapse all
   int row = tree.getRowCount() - 1;
   while (row >= 0) {
     tree.collapseRow(row);
     row--;
   }
   final DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel().getRoot();
   tree.expandPath(new TreePath(root));
   if (leadSelectionPath != null) {
     final Object[] path = leadSelectionPath.getPath();
     final Object[] pathToSelect =
         new Object
             [path.length > keepSelectionLevel && keepSelectionLevel >= 0
                 ? keepSelectionLevel
                 : path.length];
     System.arraycopy(path, 0, pathToSelect, 0, pathToSelect.length);
     if (pathToSelect.length == 0) return;
     selectPath(tree, new TreePath(pathToSelect));
   }
 }
 private void restorePathsAfterTreeOptimization(final List<TreePath> treePaths) {
   for (final TreePath treePath : treePaths) {
     myActionsTree.expandPath(CustomizationUtil.getPathByUserObjects(myActionsTree, treePath));
   }
 }
예제 #8
0
 public void install() {
   for (TreePath path : expandedPaths) {
     tree.expandPath(path);
   }
   tree.addTreeExpansionListener(this);
 }
예제 #9
0
파일: TreeUtil.java 프로젝트: jexp/idea2
 /**
  * Expands specified paths.
  *
  * @param tree JTree to apply expansion status to
  * @param paths to expand. See {@link #collectExpandedPaths(javax.swing.JTree, java.util.List)}
  */
 public static void restoreExpandedPaths(
     @NotNull final JTree tree, @NotNull final List<TreePath> paths) {
   for (int i = paths.size() - 1; i >= 0; i--) {
     tree.expandPath(paths.get(i));
   }
 }