private void removeDescendants(TreePath ancestor) {
   for (Iterator<TreePath> i = checkedPaths.iterator(); i.hasNext(); ) {
     TreePath path = i.next();
     if (ancestor.isDescendant(path)) {
       i.remove();
     }
   }
 }
Exemple #2
0
 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);
       }
     }
   }
 }
Exemple #3
0
 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;
 }