support for opening parents of derived files in datamodel / nodes

This commit is contained in:
adam-m
2013-01-31 13:25:06 -05:00
parent 6c28e7a2e3
commit 0760f598ec
4 changed files with 48 additions and 35 deletions
@@ -23,6 +23,7 @@ import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children.Keys;
import org.openide.nodes.Node;
import org.sleuthkit.autopsy.datamodel.KeywordHits.KeywordHitsRootNode;
import org.sleuthkit.datamodel.DerivedFile;
import org.sleuthkit.datamodel.Directory;
import org.sleuthkit.datamodel.File;
import org.sleuthkit.datamodel.Image;
@@ -91,6 +92,11 @@ abstract class AbstractContentChildren<T> extends Keys<T> {
return new LayoutFileNode(lf);
}
@Override
public AbstractContentNode visit(DerivedFile df) {
return new DerivedFileNode(df);
}
@Override
public AbstractContentNode visit(VirtualDirectory ld) {
return new VirtualDirectoryNode(ld);
@@ -67,7 +67,7 @@ public class DirectoryNode extends AbstractFsContentNode<Directory> {
return v.visit(this);
}
@Override
@Override
public TYPE getDisplayableItemNodeType() {
return TYPE.CONTENT;
}
@@ -26,7 +26,6 @@ import org.openide.nodes.Node;
* This class is used for the creation of all the children for the
* DataResultFilterNode that created in the DataResultFilterNode.java.
*
* @author jantonius
*/
public class DataResultFilterChildren extends FilterNode.Children {
@@ -18,7 +18,6 @@
*/
package org.sleuthkit.autopsy.directorytree;
import com.google.common.collect.Lists;
import java.awt.event.ActionEvent;
import java.beans.PropertyVetoException;
import java.util.ArrayList;
@@ -38,6 +37,7 @@ import org.sleuthkit.autopsy.datamodel.AbstractFsContentNode;
import org.sleuthkit.autopsy.datamodel.AbstractFsContentNode.FsContentPropertyType;
import org.sleuthkit.autopsy.datamodel.ArtifactTypeNode;
import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode;
import org.sleuthkit.autopsy.datamodel.DerivedFileNode;
import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor;
import org.sleuthkit.autopsy.datamodel.EmailExtracted.EmailExtractedAccountNode;
@@ -180,11 +180,11 @@ public class DataResultFilterNode extends FilterNode {
actions.add(new TagFileAction(dir));
return actions;
}
@Override
public List<Action> visit(LayoutFileNode lf) {
List<Action> actions = new ArrayList<Action>();
actions.add(new NewWindowViewAction("View in New Window", lf));
actions.add(new ExternalViewerAction("Open in External Viewer", lf));
actions.add(null); // creates a menu separator
@@ -193,11 +193,11 @@ public class DataResultFilterNode extends FilterNode {
actions.add(new TagFileAction(lf));
return actions;
}
@Override
public List<Action> visit(VirtualDirectoryNode ld) {
List<Action> actions = new ArrayList<Action>();
actions.add(new TagFileAction(ld));
return actions;
}
@@ -222,7 +222,7 @@ public class DataResultFilterNode extends FilterNode {
@Override
public List<Action> visit(BlackboardArtifactNode ban) {
List<Action> actions = new ArrayList<Action>();
//merge predefined specific node actions if bban sublcasses have their own
for (Action a : ban.getActions(true)) {
actions.add(a);
@@ -250,53 +250,49 @@ public class DataResultFilterNode extends FilterNode {
actions.add(null); // creates a menu separator
actions.add(new ExtractAction("Extract File", new FileNode(f)));
actions.add(new HashSearchAction("Search for files with the same MD5 hash", new FileNode(f)));
//add file/result tag if itself is not a tag
if (artifactTypeID != BlackboardArtifact.ARTIFACT_TYPE.TSK_TAG_FILE.getTypeID()
&& artifactTypeID != BlackboardArtifact.ARTIFACT_TYPE.TSK_TAG_ARTIFACT.getTypeID()
) {
&& artifactTypeID != BlackboardArtifact.ARTIFACT_TYPE.TSK_TAG_ARTIFACT.getTypeID()) {
actions.add(null); // creates a menu separator
actions.add(new TagFileAction(f));
actions.add(new TagResultAction(ba));
}
}
if (( d = ban.getLookup().lookup(Directory.class)) != null) {
if ((d = ban.getLookup().lookup(Directory.class)) != null) {
actions.add(null); // creates a menu separator
actions.add(new NewWindowViewAction("View in New Window", new DirectoryNode(d)));
actions.add(new ExternalViewerAction("Open in External Viewer", new DirectoryNode(d)));
actions.add(null); // creates a menu separator
actions.add(new ExtractAction("Extract Directory", new DirectoryNode(d)));
//add file/result tag if itself is not a tag
if (artifactTypeID != BlackboardArtifact.ARTIFACT_TYPE.TSK_TAG_FILE.getTypeID()
&& artifactTypeID != BlackboardArtifact.ARTIFACT_TYPE.TSK_TAG_ARTIFACT.getTypeID()
) {
&& artifactTypeID != BlackboardArtifact.ARTIFACT_TYPE.TSK_TAG_ARTIFACT.getTypeID()) {
actions.add(null); // creates a menu separator
actions.add(new TagFileAction( d));
actions.add(new TagFileAction(d));
actions.add(new TagResultAction(ba));
}
}
else if ( ( lf = ban.getLookup().lookup(LayoutFile.class)) != null) {
} else if ((lf = ban.getLookup().lookup(LayoutFile.class)) != null) {
actions.add(null); // creates a menu separator
actions.add(new NewWindowViewAction("View in New Window", new LayoutFileNode(lf)));
actions.add(new ExternalViewerAction("Open in External Viewer", new LayoutFileNode(lf)));
actions.add(null); // creates a menu separator
actions.add(new ExtractAction("Extract File", new LayoutFileNode(lf)));
//add tag if itself is not a tag
if (artifactTypeID != BlackboardArtifact.ARTIFACT_TYPE.TSK_TAG_FILE.getTypeID()
&& artifactTypeID != BlackboardArtifact.ARTIFACT_TYPE.TSK_TAG_ARTIFACT.getTypeID()
) {
&& artifactTypeID != BlackboardArtifact.ARTIFACT_TYPE.TSK_TAG_ARTIFACT.getTypeID()) {
actions.add(null); // creates a menu separator
actions.add(new TagFileAction(lf));
actions.add(new TagFileAction(lf));
actions.add(new TagResultAction(ba));
}
}
//if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
//actions.add(null); // creates a menu separator
//actions.add(new ResultDeleteAction("Delete Result", ba));
//actions.add(null); // creates a menu separator
//actions.add(new ResultDeleteAction("Delete Result", ba));
//}
return actions;
}
@@ -422,18 +418,11 @@ public class DataResultFilterNode extends FilterNode {
public AbstractAction visit(TagNodeRoot tnr) {
return openChild(tnr);
}
@Override
public AbstractAction visit(TagsNodeRoot tnr) {
return openChild(tnr);
}
@Override
public AbstractAction visit(DirectoryNode dn) {
@@ -445,12 +434,30 @@ public class DataResultFilterNode extends FilterNode {
return null;
}
}
@Override
public AbstractAction visit(VirtualDirectoryNode ldn) {
return openChild(ldn);
}
@Override
public AbstractAction visit(FileNode fn) {
if (fn.hasContentChildren()) {
return openChild(fn);
} else {
return null;
}
}
@Override
public AbstractAction visit(DerivedFileNode dfn) {
if (dfn.hasContentChildren()) {
return openChild(dfn);
} else {
return null;
}
}
@Override
public AbstractAction visit(FileSearchFilterNode fsfn) {
return openChild(fsfn);
@@ -490,7 +497,8 @@ public class DataResultFilterNode extends FilterNode {
@Override
public void actionPerformed(ActionEvent e) {
if (parentContext != null) {
for (int i = 0; i < parentContext.getChildren().getNodesCount(); i++) {
final int childrenNodesCount = parentContext.getChildren().getNodesCount();
for (int i = 0; i < childrenNodesCount; i++) {
Node selectedNode = parentContext.getChildren().getNodeAt(i);
if (selectedNode != null && selectedNode.getName().equals(original.getName())) {
try {