mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 11:07:43 +00:00
move default file and dir node actions from actions decorator to the Node classes, so all nodes have them by default.
This commit is contained in:
parent
832b4467a6
commit
834c88882a
@ -18,7 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.datamodel;
|
package org.sleuthkit.autopsy.datamodel;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
|
import org.sleuthkit.autopsy.directorytree.ExtractAction;
|
||||||
|
import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
|
||||||
|
import org.sleuthkit.autopsy.directorytree.TagFileAction;
|
||||||
|
import org.sleuthkit.autopsy.directorytree.ViewContextAction;
|
||||||
import org.sleuthkit.datamodel.Directory;
|
import org.sleuthkit.datamodel.Directory;
|
||||||
import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
|
import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
|
||||||
|
|
||||||
@ -60,7 +66,17 @@ public class DirectoryNode extends AbstractFsContentNode<Directory> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Action[] getActions(boolean popup) {
|
public Action[] getActions(boolean popup) {
|
||||||
return new Action[]{};
|
List<Action> actions = new ArrayList<Action>();
|
||||||
|
if (!getDirectoryBrowseMode()) {
|
||||||
|
actions.add(new ViewContextAction("View File in Directory", this));
|
||||||
|
actions.add(null); // creates a menu separator
|
||||||
|
}
|
||||||
|
actions.add(new NewWindowViewAction("View in New Window", this));
|
||||||
|
actions.add(null); // creates a menu separator
|
||||||
|
actions.add(new ExtractAction("Extract Directory", this));
|
||||||
|
actions.add(null); // creates a menu separator
|
||||||
|
actions.add(new TagFileAction(this));
|
||||||
|
return actions.toArray(new Action[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,7 +18,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.datamodel;
|
package org.sleuthkit.autopsy.datamodel;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
|
import org.sleuthkit.autopsy.directorytree.ExternalViewerAction;
|
||||||
|
import org.sleuthkit.autopsy.directorytree.ExtractAction;
|
||||||
|
import org.sleuthkit.autopsy.directorytree.HashSearchAction;
|
||||||
|
import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
|
||||||
|
import org.sleuthkit.autopsy.directorytree.TagFileAction;
|
||||||
|
import org.sleuthkit.autopsy.directorytree.ViewContextAction;
|
||||||
import org.sleuthkit.datamodel.File;
|
import org.sleuthkit.datamodel.File;
|
||||||
import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
|
import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
|
||||||
|
|
||||||
@ -62,7 +70,19 @@ public class FileNode extends AbstractFsContentNode<File> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Action[] getActions(boolean popup) {
|
public Action[] getActions(boolean popup) {
|
||||||
return new Action[]{};
|
List<Action> actionsList = new ArrayList<Action>();
|
||||||
|
if (!this.getDirectoryBrowseMode()) {
|
||||||
|
actionsList.add(new ViewContextAction("View File in Directory", this));
|
||||||
|
actionsList.add(null); // creates a menu separator
|
||||||
|
}
|
||||||
|
actionsList.add(new NewWindowViewAction("View in New Window", this));
|
||||||
|
actionsList.add(new ExternalViewerAction("Open in External Viewer", this));
|
||||||
|
actionsList.add(null); // creates a menu separator
|
||||||
|
actionsList.add(new ExtractAction("Extract File", this));
|
||||||
|
actionsList.add(new HashSearchAction("Search for files with the same MD5 hash", this));
|
||||||
|
actionsList.add(null); // creates a menu separator
|
||||||
|
actionsList.add(new TagFileAction(this));
|
||||||
|
return actionsList.toArray(new Action[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -168,16 +168,12 @@ public class DataResultFilterNode extends FilterNode {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Action> visit(DirectoryNode dir) {
|
public List<Action> visit(DirectoryNode dir) {
|
||||||
|
//preserve the default node's actions
|
||||||
List<Action> actions = new ArrayList<Action>();
|
List<Action> actions = new ArrayList<Action>();
|
||||||
if (!dir.getDirectoryBrowseMode()) {
|
for (Action action : dir.getActions(true)) {
|
||||||
actions.add(new ViewContextAction("View File in Directory", dir));
|
actions.add(action);
|
||||||
actions.add(null); // creates a menu separator
|
|
||||||
}
|
}
|
||||||
actions.add(new NewWindowViewAction("View in New Window", dir));
|
|
||||||
actions.add(null); // creates a menu separator
|
|
||||||
actions.add(new ExtractAction("Extract Directory", dir));
|
|
||||||
actions.add(null); // creates a menu separator
|
|
||||||
actions.add(new TagFileAction(dir));
|
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,18 +200,12 @@ public class DataResultFilterNode extends FilterNode {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Action> visit(FileNode f) {
|
public List<Action> visit(FileNode f) {
|
||||||
|
//preserve the default node's actions
|
||||||
List<Action> actions = new ArrayList<Action>();
|
List<Action> actions = new ArrayList<Action>();
|
||||||
if (!f.getDirectoryBrowseMode()) {
|
for (Action action : f.getActions(true)) {
|
||||||
actions.add(new ViewContextAction("View File in Directory", f));
|
actions.add(action);
|
||||||
actions.add(null); // creates a menu separator
|
|
||||||
}
|
}
|
||||||
actions.add(new NewWindowViewAction("View in New Window", f));
|
|
||||||
actions.add(new ExternalViewerAction("Open in External Viewer", f));
|
|
||||||
actions.add(null); // creates a menu separator
|
|
||||||
actions.add(new ExtractAction("Extract File", f));
|
|
||||||
actions.add(new HashSearchAction("Search for files with the same MD5 hash", f));
|
|
||||||
actions.add(null); // creates a menu separator
|
|
||||||
actions.add(new TagFileAction(f));
|
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ import org.openide.explorer.view.TreeView;
|
|||||||
import org.openide.nodes.AbstractNode;
|
import org.openide.nodes.AbstractNode;
|
||||||
import org.openide.nodes.Children;
|
import org.openide.nodes.Children;
|
||||||
import org.openide.nodes.Node;
|
import org.openide.nodes.Node;
|
||||||
import org.openide.util.Exceptions;
|
|
||||||
import org.sleuthkit.autopsy.corecomponents.DataResultTopComponent;
|
import org.sleuthkit.autopsy.corecomponents.DataResultTopComponent;
|
||||||
import org.sleuthkit.autopsy.datamodel.AbstractFsContentNode;
|
import org.sleuthkit.autopsy.datamodel.AbstractFsContentNode;
|
||||||
import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode;
|
import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode;
|
||||||
@ -40,21 +39,14 @@ import org.sleuthkit.autopsy.datamodel.ImagesNode;
|
|||||||
import org.sleuthkit.autopsy.datamodel.RootContentChildren;
|
import org.sleuthkit.autopsy.datamodel.RootContentChildren;
|
||||||
import org.sleuthkit.datamodel.Content;
|
import org.sleuthkit.datamodel.Content;
|
||||||
import org.sleuthkit.datamodel.ContentVisitor;
|
import org.sleuthkit.datamodel.ContentVisitor;
|
||||||
import org.sleuthkit.datamodel.Directory;
|
|
||||||
import org.sleuthkit.datamodel.File;
|
|
||||||
import org.sleuthkit.datamodel.FileSystem;
|
import org.sleuthkit.datamodel.FileSystem;
|
||||||
import org.sleuthkit.datamodel.Image;
|
|
||||||
import org.sleuthkit.datamodel.VirtualDirectory;
|
|
||||||
import org.sleuthkit.datamodel.LayoutFile;
|
|
||||||
import org.sleuthkit.datamodel.TskCoreException;
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
import org.sleuthkit.datamodel.TskException;
|
|
||||||
import org.sleuthkit.datamodel.Volume;
|
|
||||||
import org.sleuthkit.datamodel.VolumeSystem;
|
import org.sleuthkit.datamodel.VolumeSystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View the directory content associated with the given Artifact
|
* View the directory content associated with the given Artifact
|
||||||
*/
|
*/
|
||||||
class ViewContextAction extends AbstractAction {
|
public class ViewContextAction extends AbstractAction {
|
||||||
|
|
||||||
private Content content;
|
private Content content;
|
||||||
private static final Logger logger = Logger.getLogger(ViewContextAction.class.getName());
|
private static final Logger logger = Logger.getLogger(ViewContextAction.class.getName());
|
||||||
@ -62,14 +54,14 @@ class ViewContextAction extends AbstractAction {
|
|||||||
public ViewContextAction(String title, BlackboardArtifactNode node) {
|
public ViewContextAction(String title, BlackboardArtifactNode node) {
|
||||||
super(title);
|
super(title);
|
||||||
this.content = node.getLookup().lookup(Content.class);
|
this.content = node.getLookup().lookup(Content.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewContextAction(String title, AbstractFsContentNode node) {
|
public ViewContextAction(String title, AbstractFsContentNode node) {
|
||||||
super(title);
|
super(title);
|
||||||
this.content = node.getLookup().lookup(Content.class);
|
this.content = node.getLookup().lookup(Content.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewContextAction(String title, Content content) {
|
public ViewContextAction(String title, Content content) {
|
||||||
super(title);
|
super(title);
|
||||||
this.content = content;
|
this.content = content;
|
||||||
@ -78,7 +70,6 @@ class ViewContextAction extends AbstractAction {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
EventQueue.invokeLater(new Runnable() {
|
EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// create a list of Content objects starting with content's
|
// create a list of Content objects starting with content's
|
||||||
@ -86,7 +77,7 @@ class ViewContextAction extends AbstractAction {
|
|||||||
ReverseHierarchyVisitor vtor = new ReverseHierarchyVisitor();
|
ReverseHierarchyVisitor vtor = new ReverseHierarchyVisitor();
|
||||||
List<Content> hierarchy = content.accept(vtor);
|
List<Content> hierarchy = content.accept(vtor);
|
||||||
Collections.reverse(hierarchy);
|
Collections.reverse(hierarchy);
|
||||||
|
|
||||||
Node generated = new DirectoryTreeFilterNode(new AbstractNode(new RootContentChildren(hierarchy)), true);
|
Node generated = new DirectoryTreeFilterNode(new AbstractNode(new RootContentChildren(hierarchy)), true);
|
||||||
Children genChilds = generated.getChildren();
|
Children genChilds = generated.getChildren();
|
||||||
|
|
||||||
@ -125,7 +116,6 @@ class ViewContextAction extends AbstractAction {
|
|||||||
|
|
||||||
// Another thread is needed because we have to wait for dataResult to populate
|
// Another thread is needed because we have to wait for dataResult to populate
|
||||||
EventQueue.invokeLater(new Runnable() {
|
EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
DataResultTopComponent dataResult = directoryTree.getDirectoryListing();
|
DataResultTopComponent dataResult = directoryTree.getDirectoryListing();
|
||||||
@ -150,15 +140,16 @@ class ViewContextAction extends AbstractAction {
|
|||||||
/**
|
/**
|
||||||
* The ReverseHierarchyVisitor class is designed to return a list of Content
|
* The ReverseHierarchyVisitor class is designed to return a list of Content
|
||||||
* objects starting with the one the user calls 'accept' with and ending at
|
* objects starting with the one the user calls 'accept' with and ending at
|
||||||
* the Image object. Please NOTE that Content objects in this hierarchy of
|
* the Image object. Please NOTE that Content objects in this hierarchy of
|
||||||
* type VolumeSystem and FileSystem are skipped. This seems to be necessary
|
* type VolumeSystem and FileSystem are skipped. This seems to be necessary
|
||||||
* because org.sleuthkit.autopsy.datamodel.AbstractContentChildren.CreateSleuthkitNodeVisitor
|
* because
|
||||||
|
* org.sleuthkit.autopsy.datamodel.AbstractContentChildren.CreateSleuthkitNodeVisitor
|
||||||
* does not support these types.
|
* does not support these types.
|
||||||
*/
|
*/
|
||||||
private class ReverseHierarchyVisitor extends ContentVisitor.Default<List<Content>> {
|
private class ReverseHierarchyVisitor extends ContentVisitor.Default<List<Content>> {
|
||||||
|
|
||||||
List<Content> ret = new ArrayList<Content>();
|
List<Content> ret = new ArrayList<Content>();
|
||||||
|
|
||||||
private List<Content> visitParentButDontAddMe(Content content) {
|
private List<Content> visitParentButDontAddMe(Content content) {
|
||||||
Content parent = null;
|
Content parent = null;
|
||||||
try {
|
try {
|
||||||
@ -180,12 +171,12 @@ class ViewContextAction extends AbstractAction {
|
|||||||
}
|
}
|
||||||
return parent == null ? ret : parent.accept(this);
|
return parent == null ? ret : parent.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Content> visit(FileSystem fs) {
|
public List<Content> visit(FileSystem fs) {
|
||||||
return visitParentButDontAddMe(fs);
|
return visitParentButDontAddMe(fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Content> visit(VolumeSystem vs) {
|
public List<Content> visit(VolumeSystem vs) {
|
||||||
return visitParentButDontAddMe(vs);
|
return visitParentButDontAddMe(vs);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user