mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 07:56:16 +00:00
Make file content viewable from blackboard entry
This commit is contained in:
parent
a0cc243171
commit
81c9b92f27
@ -26,6 +26,7 @@ import java.util.logging.Logger;
|
|||||||
import org.openide.nodes.AbstractNode;
|
import org.openide.nodes.AbstractNode;
|
||||||
import org.openide.nodes.Children;
|
import org.openide.nodes.Children;
|
||||||
import org.openide.nodes.Sheet;
|
import org.openide.nodes.Sheet;
|
||||||
|
import org.openide.util.Lookup;
|
||||||
import org.openide.util.lookup.Lookups;
|
import org.openide.util.lookup.Lookups;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||||
@ -44,7 +45,8 @@ public class BlackboardArtifactNode extends AbstractNode implements DisplayableI
|
|||||||
static final Logger logger = Logger.getLogger(BlackboardArtifactNode.class.getName());
|
static final Logger logger = Logger.getLogger(BlackboardArtifactNode.class.getName());
|
||||||
|
|
||||||
public BlackboardArtifactNode(BlackboardArtifact artifact) {
|
public BlackboardArtifactNode(BlackboardArtifact artifact) {
|
||||||
super(Children.LEAF, Lookups.singleton(new ArtifactStringContent(artifact)));
|
super(Children.LEAF, Lookups.singleton(getAssociatedFile(artifact)));
|
||||||
|
//super(Children.LEAF, Lookups.singleton(new ArtifactStringContent(artifact)));
|
||||||
this.artifact = artifact;
|
this.artifact = artifact;
|
||||||
this.setName(Long.toString(artifact.getArtifactID()));
|
this.setName(Long.toString(artifact.getArtifactID()));
|
||||||
this.setDisplayName(artifact.getDisplayName());
|
this.setDisplayName(artifact.getDisplayName());
|
||||||
@ -129,6 +131,17 @@ public class BlackboardArtifactNode extends AbstractNode implements DisplayableI
|
|||||||
throw new IllegalArgumentException("Couldn't get file from database");
|
throw new IllegalArgumentException("Couldn't get file from database");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static File getAssociatedFile(BlackboardArtifact artifact){
|
||||||
|
try {
|
||||||
|
return artifact.getSleuthkitCase().getFileById(artifact.getObjectID());
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
logger.log(Level.WARNING, "SQL query threw exception", ex);
|
||||||
|
} catch (TskException ex) {
|
||||||
|
logger.log(Level.WARNING, "Getting file failed", ex);
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Couldn't get file from database");
|
||||||
|
}
|
||||||
|
|
||||||
public Directory getParentDirectory(){
|
public Directory getParentDirectory(){
|
||||||
try{
|
try{
|
||||||
return getAssociatedFile().getParentDirectory();
|
return getAssociatedFile().getParentDirectory();
|
||||||
|
@ -69,10 +69,11 @@ class ViewContextAction extends AbstractAction {
|
|||||||
ReverseHierarchyVisitor vtor = new ReverseHierarchyVisitor();
|
ReverseHierarchyVisitor vtor = new ReverseHierarchyVisitor();
|
||||||
List<Content> hierarchy = node.getAssociatedFile().accept(vtor);
|
List<Content> hierarchy = node.getAssociatedFile().accept(vtor);
|
||||||
Collections.reverse(hierarchy);
|
Collections.reverse(hierarchy);
|
||||||
Node generated = new AbstractNode(new RootContentChildren(hierarchy));
|
Node generated = new DirectoryTreeFilterNode(new AbstractNode(new RootContentChildren(hierarchy)));
|
||||||
Children genChilds = generated.getChildren();
|
Children genChilds = generated.getChildren();
|
||||||
|
|
||||||
final DirectoryTreeTopComponent directoryTree = DirectoryTreeTopComponent.findInstance();
|
final DirectoryTreeTopComponent directoryTree = DirectoryTreeTopComponent.findInstance();
|
||||||
|
TreeView tree = directoryTree.getTree();
|
||||||
ExplorerManager man = directoryTree.getExplorerManager();
|
ExplorerManager man = directoryTree.getExplorerManager();
|
||||||
Node dirRoot = man.getRootContext();
|
Node dirRoot = man.getRootContext();
|
||||||
Children dirChilds = dirRoot.getChildren();
|
Children dirChilds = dirRoot.getChildren();
|
||||||
@ -85,6 +86,7 @@ class ViewContextAction extends AbstractAction {
|
|||||||
Node currentDirectoryTreeNode = dirChilds.getNodeAt(j);
|
Node currentDirectoryTreeNode = dirChilds.getNodeAt(j);
|
||||||
if (currentGeneratedNode.getDisplayName().equals(currentDirectoryTreeNode.getDisplayName())) {
|
if (currentGeneratedNode.getDisplayName().equals(currentDirectoryTreeNode.getDisplayName())) {
|
||||||
dirExplored = currentDirectoryTreeNode;
|
dirExplored = currentDirectoryTreeNode;
|
||||||
|
tree.expandNode(dirExplored);
|
||||||
dirChilds = currentDirectoryTreeNode.getChildren();
|
dirChilds = currentDirectoryTreeNode.getChildren();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -93,7 +95,6 @@ class ViewContextAction extends AbstractAction {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (dirExplored != null) {
|
if (dirExplored != null) {
|
||||||
TreeView tree = directoryTree.getTree();
|
|
||||||
tree.expandNode(dirExplored);
|
tree.expandNode(dirExplored);
|
||||||
man.setExploredContextAndSelection(dirExplored, new Node[]{dirExplored});
|
man.setExploredContextAndSelection(dirExplored, new Node[]{dirExplored});
|
||||||
}
|
}
|
||||||
@ -114,6 +115,7 @@ class ViewContextAction extends AbstractAction {
|
|||||||
for (int i = 0; i < resultChilds.getNodesCount(); i++) {
|
for (int i = 0; i < resultChilds.getNodesCount(); i++) {
|
||||||
Node current = resultChilds.getNodeAt(i);
|
Node current = resultChilds.getNodeAt(i);
|
||||||
if (generated.getName().equals(current.getName())) {
|
if (generated.getName().equals(current.getName())) {
|
||||||
|
dataResult.requestActive();
|
||||||
dataResult.setSelectedNodes(new Node[]{current});
|
dataResult.setSelectedNodes(new Node[]{current});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user