private void removeDescendants(TreePath ancestor) {
   for (Iterator<TreePath> i = checkedPaths.iterator(); i.hasNext(); ) {
     TreePath path = i.next();
     if (ancestor.isDescendant(path)) {
       i.remove();
     }
   }
 }
示例#2
0
文件: TreeUtil.java 项目: jexp/idea2
 public static void unselect(JTree tree, final DefaultMutableTreeNode node) {
   final TreePath rootPath = new TreePath(node.getPath());
   final TreePath[] selectionPaths = tree.getSelectionPaths();
   if (selectionPaths != null) {
     for (TreePath selectionPath : selectionPaths) {
       if (selectionPath.getPathCount() > rootPath.getPathCount()
           && rootPath.isDescendant(selectionPath)) {
         tree.removeSelectionPath(selectionPath);
       }
     }
   }
 }
示例#3
0
文件: TreeUtil.java 项目: jexp/idea2
 public static List<TreePath> collectSelectedPaths(final JTree tree, final TreePath treePath) {
   final ArrayList<TreePath> result = new ArrayList<TreePath>();
   final TreePath[] selections = tree.getSelectionPaths();
   if (selections != null) {
     for (TreePath selection : selections) {
       if (treePath.isDescendant(selection)) {
         result.add(selection);
       }
     }
   }
   return result;
 }