19 package org.sleuthkit.autopsy.directorytree;
21 import java.util.List;
22 import java.util.logging.Level;
24 import org.openide.nodes.Children;
26 import org.openide.nodes.FilterNode;
27 import org.openide.nodes.Node;
50 class DirectoryTreeFilterChildren
extends FilterNode.Children {
52 private final ShowItemVisitor showItemV =
new ShowItemVisitor();
53 private final IsLeafItemVisitor isLeafItemV =
new IsLeafItemVisitor();
54 private final static Logger logger = Logger.getLogger(DirectoryTreeFilterChildren.class.getName());
59 public DirectoryTreeFilterChildren(Node arg) {
64 protected Node copyNode(Node arg0) {
65 return new DirectoryTreeFilterNode(arg0,
true);
68 protected Node copyNode(Node arg0,
boolean createChildren) {
69 return new DirectoryTreeFilterNode(arg0, createChildren);
82 protected Node[] createNodes(Node origNode) {
83 if (origNode == null || !(origNode instanceof DisplayableItemNode)) {
88 final DisplayableItemNode diNode = (DisplayableItemNode) origNode;
89 if (diNode.accept(showItemV) ==
false) {
97 final boolean isLeaf = diNode.accept(isLeafItemV);
99 return new Node[]{this.copyNode(origNode, !isLeaf)};
109 private static boolean isLeafDirectory(DirectoryNode node) {
110 Directory dir = node.getLookup().lookup(Directory.class);
113 for (Content c : dir.getChildren()) {
114 if (c instanceof Directory && (!((Directory) c).getName().equals(
".")
115 && !((Directory) c).getName().equals(
".."))) {
118 }
else if (c.hasChildren()) {
124 }
catch (TskException ex) {
125 Logger.getLogger(DirectoryTreeFilterChildren.class.getName())
126 .log(Level.WARNING,
"Error getting directory children", ex);
132 private static boolean isLeafVolume(VolumeNode node) {
133 Volume vol = node.getLookup().lookup(Volume.class);
137 for (Content c : vol.getChildren()) {
138 if (!(c instanceof LayoutFile
139 || c instanceof VirtualDirectory
148 }
catch (TskException ex) {
149 Logger.getLogger(DirectoryTreeFilterChildren.class.getName())
150 .log(Level.WARNING,
"Error getting volume children", ex);
159 private static boolean isDotDirectory(DirectoryNode dir) {
160 String name = dir.getDisplayName();
161 return name.equals(DirectoryNode.DOTDIR) || name.equals(DirectoryNode.DOTDOTDIR);
172 public static Children createInstance(Node arg,
boolean createChildren) {
173 if (createChildren) {
174 return new DirectoryTreeFilterChildren(arg);
176 return Children.LEAF;
189 return isLeafDirectory(dn);
200 for (
Content childContent : derivedChildren) {
210 logger.log(Level.SEVERE,
"Error checking if file node is leaf.", e);
236 return isLeafVolume(vn);
255 if (isDotDirectory(dn)) {
263 return fn.hasContentChildren();
268 return lfn.hasContentChildren();
273 return ln.hasContentChildren();
Boolean visit(FileNode fn)
Boolean visit(VirtualDirectoryNode vdn)
Boolean visit(LocalFileNode lfn)
Boolean visit(VirtualDirectoryNode vdn)
abstract boolean isLeafTypeNode()
List< Content > getContentChildren()
Boolean visit(LayoutFileNode fn)
Boolean visit(LocalFileNode lfn)
Boolean defaultVisit(DisplayableItemNode c)
Boolean visit(VolumeNode vn)
boolean hasContentChildren()
Boolean visitDeep(AbstractAbstractFileNode<?extends AbstractFile > node)
Boolean defaultVisit(DisplayableItemNode c)
Boolean visit(DirectoryNode dn)
Boolean visit(DirectoryNode dn)
Boolean visit(FileNode fn)
Boolean visit(LayoutFileNode ln)