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;
52 class DirectoryTreeFilterChildren
extends FilterNode.Children {
54 private final ShowItemVisitor showItemV =
new ShowItemVisitor();
55 private final IsLeafItemVisitor isLeafItemV =
new IsLeafItemVisitor();
56 private final static Logger logger = Logger.getLogger(DirectoryTreeFilterChildren.class.getName());
61 public DirectoryTreeFilterChildren(Node arg) {
66 protected Node copyNode(Node arg0) {
67 return new DirectoryTreeFilterNode(arg0,
true);
70 protected Node copyNode(Node arg0,
boolean createChildren) {
71 return new DirectoryTreeFilterNode(arg0, createChildren);
83 protected Node[] createNodes(Node origNode) {
84 if (origNode == null || !(origNode instanceof DisplayableItemNode)) {
89 final DisplayableItemNode diNode = (DisplayableItemNode) origNode;
90 if (diNode.accept(showItemV) ==
false) {
98 final boolean isLeaf = diNode.accept(isLeafItemV);
100 return new Node[]{this.copyNode(origNode, !isLeaf)};
111 private static boolean isLeafDirectory(DirectoryNode node) {
112 Directory dir = node.getLookup().lookup(Directory.class);
115 for (Content c : dir.getChildren()) {
116 if (c instanceof Directory && (!((Directory) c).getName().equals(
".")
117 && !((Directory) c).getName().equals(
".."))) {
120 }
else if (c.hasChildren()) {
126 }
catch (TskException ex) {
127 Logger.getLogger(DirectoryTreeFilterChildren.class.getName())
128 .log(Level.WARNING,
"Error getting directory children", ex);
134 private static boolean isLeafVolume(VolumeNode node) {
135 Volume vol = node.getLookup().lookup(Volume.class);
139 for (Content c : vol.getChildren()) {
140 if (!(c instanceof LayoutFile
141 || c instanceof VirtualDirectory)) {
147 }
catch (TskException ex) {
148 Logger.getLogger(DirectoryTreeFilterChildren.class.getName())
149 .log(Level.WARNING,
"Error getting volume children", ex);
158 private static boolean isDotDirectory(DirectoryNode dir) {
159 String name = dir.getDisplayName();
160 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) {
201 if (((AbstractFile) childContent).isDir()) {
205 if (childContent.hasChildren()) {
208 }
catch (TskCoreException e) {
209 logger.log(Level.SEVERE,
"Error checking if file node is leaf.", e);
238 return isLeafVolume(vn);
263 if (isDotDirectory(dn)) {
271 return fn.hasContentChildren();
276 return lfn.hasContentChildren();
281 return ln.hasContentChildren();
286 return sfn.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(FileTypesNode fileTypes)
Boolean visit(LocalFileNode lfn)
Boolean visit(SlackFileNode sfn)
Boolean visit(SlackFileNode sfn)
Boolean defaultVisit(DisplayableItemNode c)
Boolean visit(VolumeNode vn)
boolean hasContentChildren()
Boolean visit(FileTypesNode ft)
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)