예제 #1
0
파일: TreeUtil.java 프로젝트: jexp/idea2
 public static List<TreePath> collectExpandedPaths(final JTree tree, TreePath path) {
   final ArrayList<TreePath> result = new ArrayList<TreePath>();
   if (!tree.isExpanded(path)) return result;
   final Object lastPathComponent = path.getLastPathComponent();
   final TreeModel model = tree.getModel();
   if (model.isLeaf(lastPathComponent)) {
     result.add(path);
   } else {
     boolean pathWasAdded = false;
     for (int i = model.getChildCount(lastPathComponent) - 1; i >= 0; i--) {
       final TreePath childPath = path.pathByAddingChild(model.getChild(lastPathComponent, i));
       if (model.isLeaf(lastPathComponent)) {
         if (!pathWasAdded) {
           result.add(path);
           pathWasAdded = true;
         }
       } else if (tree.isExpanded(childPath)) {
         result.addAll(collectExpandedPaths(tree, childPath));
       } else {
         if (!pathWasAdded) {
           result.add(path);
           pathWasAdded = true;
         }
       }
     }
   }
   return result;
 }
예제 #2
0
파일: TreeUtil.java 프로젝트: jexp/idea2
  /**
   * @param tree JTree to collect expanded paths from.
   * @param paths output parameter.
   */
  public static void collectExpandedPaths(
      @NotNull final JTree tree, @NotNull final List<TreePath> paths) {
    final TreeModel model = tree.getModel();
    final Object root = model.getRoot();
    LOG.assertTrue(root != null);

    collectExpandedPathsImpl(tree, paths, new TreePath(root));
  }
예제 #3
0
파일: TreeUtil.java 프로젝트: jexp/idea2
 public static ActionCallback selectFirstNode(final JTree tree) {
   final TreeModel model = tree.getModel();
   final Object root = model.getRoot();
   TreePath selectionPath = new TreePath(root);
   if (!tree.isRootVisible() && model.getChildCount(root) > 0)
     selectionPath = selectionPath.pathByAddingChild(model.getChild(root, 0));
   return selectPath(tree, selectionPath);
 }
 @Override
 public boolean isModified(CodeStyleSettings settings) {
   TreeModel treeModel = myTreeTable.getTree().getModel();
   TreeNode root = (TreeNode) treeModel.getRoot();
   if (isModified(root, settings)) {
     return true;
   }
   return false;
 }
예제 #5
0
파일: TreeUtil.java 프로젝트: jexp/idea2
 @Nullable
 public static TreeNode findNodeWithObject(
     final Object object, final TreeModel model, final Object parent) {
   for (int i = 0; i < model.getChildCount(parent); i++) {
     final DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) model.getChild(parent, i);
     if (childNode.getUserObject().equals(object)) return childNode;
   }
   return null;
 }
  @Nullable
  private static TreePath findNodePath(MavenArchetype object, TreeModel model, Object parent) {
    for (int i = 0; i < model.getChildCount(parent); i++) {
      DefaultMutableTreeNode each = (DefaultMutableTreeNode) model.getChild(parent, i);
      if (each.getUserObject().equals(object)) return new TreePath(each.getPath());

      TreePath result = findNodePath(object, model, each);
      if (result != null) return result;
    }
    return null;
  }
  public double setNodeHeights(TreeModel tree, Likelihood likelihood, Prior prior) {
    double prob = 0.0;
    NodeRef node = tree.getRoot();
    Clade currentClade = getClade(tree, node);

    int childcount = tree.getChildCount(node);
    for (int i = 0; i < childcount; i++) {
      NodeRef child = tree.getChild(node, i);
      if (!tree.isExternal(child)) {
        //				prob += setNodeHeights(tree, child, currentClade, likelihood,
        //						prior);
      }
    }

    return prob;
  }
예제 #8
0
파일: TreeUtil.java 프로젝트: jexp/idea2
  private static boolean collectExpandedPathsImpl(
      final JTree tree, final Collection<TreePath> paths, final TreePath path) {
    final TreeModel model = tree.getModel();
    final Object lastPathComponent = path.getLastPathComponent();
    if (model.isLeaf(lastPathComponent)) {
      return false;
    }

    boolean hasExpandedChildren = false;

    for (int i = model.getChildCount(lastPathComponent) - 1; i >= 0; i--) {
      hasExpandedChildren |=
          collectExpandedPathsImpl(
              tree, paths, path.pathByAddingChild(model.getChild(lastPathComponent, i)));
    }

    if (!hasExpandedChildren) {
      paths.add(path);
      return true;
    } else {
      return false;
    }
  }
예제 #9
0
파일: TreeUtil.java 프로젝트: jexp/idea2
  @Nullable
  public static Range<Integer> getExpandControlRange(final JTree aTree, final TreePath path) {
    TreeModel treeModel = aTree.getModel();

    final BasicTreeUI basicTreeUI = (BasicTreeUI) aTree.getUI();
    Icon expandedIcon = basicTreeUI.getExpandedIcon();

    Range<Integer> box = null;
    if (path != null && !treeModel.isLeaf(path.getLastPathComponent())) {
      int boxWidth;
      Insets i = aTree.getInsets();

      if (expandedIcon != null) {
        boxWidth = expandedIcon.getIconWidth();
      } else {
        boxWidth = 8;
      }

      int boxLeftX = i != null ? i.left : 0;

      boolean leftToRight = aTree.getComponentOrientation().isLeftToRight();
      int depthOffset = getDepthOffset(aTree);
      int totalChildIndent = basicTreeUI.getLeftChildIndent() + basicTreeUI.getRightChildIndent();

      if (leftToRight) {
        boxLeftX +=
            ((path.getPathCount() + depthOffset - 2) * totalChildIndent
                    + basicTreeUI.getLeftChildIndent())
                - boxWidth / 2;
      }
      int boxRightX = boxLeftX + boxWidth;

      box = new Range<Integer>(boxLeftX, boxRightX);
    }
    return box;
  }
 @Override
 protected void resetImpl(final CodeStyleSettings settings) {
   TreeModel treeModel = myTreeTable.getTree().getModel();
   TreeNode root = (TreeNode) treeModel.getRoot();
   resetNode(root, settings);
 }
 @Override
 public void apply(CodeStyleSettings settings) {
   TreeModel treeModel = myTreeTable.getTree().getModel();
   TreeNode root = (TreeNode) treeModel.getRoot();
   applyNode(root, settings);
 }