/** * Removes all files from <code>deselected</code> that are ancestors * of <code>file</code or vice versa. */ private void removeFromPath(File file) { // remove all children, file itself is removed here too for (Iterator<File> i = deselected.iterator(); i.hasNext(); ) { File f = i.next(); if (FileUtils.isAncestor(file, f)) { i.remove(); } } while (file != null && !roots.contains(file)) { // mark other children of parent as excluded File parent = file.getParentFile(); if (ancestorIsExcluded(parent)) { deselected.remove(parent); int childCount = directoryTreeModel.getChildCount(parent); for (int j = 0; j < childCount; j++) { File sibling = (File) directoryTreeModel.getChild(parent, j); if (sibling != null && !sibling.equals(file)) { deselected.add(sibling); } } } file = parent; } }