/*
 * Autopsy Forensic Browser
 *
 * Copyright 2011 Basis Technology Corp.
 * Contact: carrier <at> sleuthkit <dot> org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.sleuthkit.autopsy.directorytree;

import org.openide.nodes.Children;
import org.sleuthkit.autopsy.datamodel.ImageNode;
import org.sleuthkit.autopsy.datamodel.VolumeNode;
import org.sleuthkit.autopsy.datamodel.DirectoryNode;
import org.openide.nodes.FilterNode;
import org.openide.nodes.Node;
import org.sleuthkit.autopsy.datamodel.ArtifactTypeNode;
import org.sleuthkit.autopsy.datamodel.ExtractedContentNode;
import org.sleuthkit.datamodel.Directory;

/**
 * This class wraps around nodes that are displayed in the directory tree and 
 * hides files, '..', and other children that should not be displayed. 
 * 
 * @author jantonius
 */
class DirectoryTreeFilterChildren extends FilterNode.Children {

    /** the constructor */
    public DirectoryTreeFilterChildren(Node arg) {
        super(arg);
    }

    @Override
    protected Node copyNode(Node arg0) {
        return new DirectoryTreeFilterNode(arg0);
    }

    @Override
    protected Node[] createNodes(Node arg0) {
        
        //TODO: ContentNode fix - replace with ContentVisitor
        
        // filter out the FileNode and the "." and ".." directories
        if (arg0 != null && (arg0 instanceof ImageNode
                || arg0 instanceof ExtractedContentNode
                || arg0 instanceof ArtifactTypeNode
                || arg0 instanceof VolumeNode || (arg0 instanceof DirectoryNode
                && !((DirectoryNode) arg0).getDisplayName().equals("."))
                && !((DirectoryNode) arg0).getDisplayName().equals(".."))) {
            return new Node[]{this.copyNode(arg0)};
        } else {
            return new Node[]{};
        }
    }

    /**
     * Return the children based on the current node given. If the node doesn't
     * have any directory or volume or image node inside it, it just returns leaf.
     * 
     * @param arg        the node
     * @return children  the children
     */
    public static Children createInstance(Node arg) {
        return new DirectoryTreeFilterChildren(arg);
    }
}

@@ -1093,24 +1093,75 @@
 ontentNode;%0A
+import org.sleuthkit.datamodel.BlackboardArtifact;%0A
 import org.s
@@ -1893,16 +1893,33 @@
 null && 
+%0A                
 (arg0 in
@@ -1932,24 +1932,27 @@
 of ImageNode
+ %7C%7C
 %0A           
@@ -1948,34 +1948,32 @@
                 
-%7C%7C
  arg0 instanceof
@@ -1973,36 +1973,30 @@
 tanceof 
-ExtractedContentNode
+VolumeNode %7C%7C 
 %0A       
@@ -1996,35 +1996,33 @@
                 
-%7C%7C 
+(
 arg0 instanceof 
@@ -2025,105 +2025,110 @@
 eof 
-ArtifactTypeNode%0A                %7C%7C arg0 instanceof VolumeNode %7C%7C (arg0 instanceof DirectoryNode%0A
+DirectoryNode%0A                        && !((DirectoryNode) arg0).getDisplayName().equals(%22.%22)%0A        
     
@@ -2192,19 +2192,23 @@
 quals(%22.
+.
 %22))
+ %7C%7C
 %0A       
@@ -2212,39 +2212,100 @@
             
-&& !((Directory
+(arg0 instanceof ArtifactTypeNode%0A                        && !((ArtifactType
 Node) arg0).
@@ -2299,39 +2299,32 @@
 eNode) arg0).get
-Display
 Name().equals(%22.
@@ -2321,20 +2321,125 @@
 .equals(
-%22..%22
+BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO.name()) %7C%7C%0A                arg0 instanceof ExtractedContentNode
 ))) %7B%0A  

Remove "General Info" from Directory Tree