mirror of
https://github.com/elisspace/autopsy.git
synced 2026-09-06 02:24:30 +00:00
add missing actions to dir tree for dir, files and derived files (tag, extract)
This commit is contained in:
@@ -23,6 +23,7 @@ import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -38,9 +39,10 @@ import javax.swing.table.DefaultTableModel;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.datamodel.Content;
|
||||
import org.sleuthkit.datamodel.ContentVisitor;
|
||||
import org.sleuthkit.datamodel.DerivedFile;
|
||||
import org.sleuthkit.datamodel.Directory;
|
||||
import org.sleuthkit.datamodel.FileSystem;
|
||||
import org.sleuthkit.datamodel.Image;
|
||||
import org.sleuthkit.datamodel.LayoutFile;
|
||||
import org.sleuthkit.datamodel.Volume;
|
||||
|
||||
class ExplorerNodeActionVisitor extends ContentVisitor.Default<List<? extends Action>> {
|
||||
@@ -77,6 +79,7 @@ class ExplorerNodeActionVisitor extends ContentVisitor.Default<List<? extends Ac
|
||||
public List<? extends Action> visit(final Image img) {
|
||||
List<Action> lst = new ArrayList<Action>();
|
||||
lst.add(new ImageDetails("Image Details", img));
|
||||
//TODO lst.add(new ExtractAction("Extract Image", img));
|
||||
lst.add(new ExtractUnallocAction("Extract Unallocated Space to Single Files", img));
|
||||
return lst;
|
||||
}
|
||||
@@ -94,9 +97,32 @@ class ExplorerNodeActionVisitor extends ContentVisitor.Default<List<? extends Ac
|
||||
return lst;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Action> visit(final Directory d) {
|
||||
List<Action> actions = new ArrayList<Action>();
|
||||
actions.add(new TagFileAction(d));
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Action> visit(final DerivedFile d) {
|
||||
List<Action> actions = new ArrayList<Action>();
|
||||
actions.add(new ExtractAction("Extract File", d));
|
||||
actions.add(new TagFileAction(d));
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Action> visit(final org.sleuthkit.datamodel.File d) {
|
||||
List<Action> actions = new ArrayList<Action>();
|
||||
actions.add(new ExtractAction("Extract File", d));
|
||||
actions.add(new TagFileAction(d));
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends Action> defaultVisit(Content di) {
|
||||
return new ArrayList<Action>();
|
||||
return Collections.<Action>emptyList();
|
||||
}
|
||||
|
||||
//Below here are classes regarding node-specific actions
|
||||
@@ -279,7 +305,7 @@ class ExplorerNodeActionVisitor extends ContentVisitor.Default<List<? extends Ac
|
||||
};
|
||||
|
||||
Object[][] rowValues = new Object[1][9];
|
||||
|
||||
|
||||
Content parent = null;
|
||||
try {
|
||||
parent = fs.getParent();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 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 not use this content except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
@@ -48,15 +48,22 @@ import org.sleuthkit.datamodel.Directory;
|
||||
public final class ExtractAction extends AbstractAction {
|
||||
|
||||
private static final InitializeContentVisitor initializeCV = new InitializeContentVisitor();
|
||||
private AbstractFile file;
|
||||
private AbstractFile content;
|
||||
private Logger logger = Logger.getLogger(ExtractAction.class.getName());
|
||||
|
||||
public ExtractAction(String title, Node contentNode) {
|
||||
super(title);
|
||||
Content tempContent = contentNode.getLookup().lookup(Content.class);
|
||||
|
||||
this.file = tempContent.accept(initializeCV);
|
||||
this.setEnabled(file != null);
|
||||
this.content = tempContent.accept(initializeCV);
|
||||
this.setEnabled(content != null);
|
||||
}
|
||||
|
||||
public ExtractAction(String title, Content content) {
|
||||
super(title);
|
||||
|
||||
this.content = content.accept(initializeCV);
|
||||
this.setEnabled(this.content != null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,16 +98,16 @@ public final class ExtractAction extends AbstractAction {
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks user to choose destination, then extracts file/directory to
|
||||
* Asks user to choose destination, then extracts content/directory to
|
||||
* destination (recursing on directories)
|
||||
* @param e the action event
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// Get file and check that it's okay to overwrite existing file
|
||||
// Get content and check that it's okay to overwrite existing content
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setCurrentDirectory(new File(Case.getCurrentCase().getCaseDirectory()));
|
||||
fc.setSelectedFile(new File(this.file.getName()));
|
||||
fc.setSelectedFile(new File(this.content.getName()));
|
||||
int returnValue = fc.showSaveDialog((Component) e.getSource());
|
||||
|
||||
if (returnValue == JFileChooser.APPROVE_OPTION) {
|
||||
@@ -127,7 +134,7 @@ public final class ExtractAction extends AbstractAction {
|
||||
|
||||
try {
|
||||
ExtractFileThread extract = new ExtractFileThread();
|
||||
extract.init(this.file, e, destination);
|
||||
extract.init(this.content, e, destination);
|
||||
extract.execute();
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, "Unable to start background thread.", ex);
|
||||
@@ -167,7 +174,7 @@ public final class ExtractAction extends AbstractAction {
|
||||
progress.start();
|
||||
progress.switchToIndeterminate();
|
||||
if(fsContent.isFile()) {
|
||||
// Max file size of 200GB
|
||||
// Max content size of 200GB
|
||||
//long filesize = fsContent.getSize();
|
||||
//int unit = (int) (filesize / 100);
|
||||
progress.switchToDeterminate(100);
|
||||
@@ -177,7 +184,7 @@ public final class ExtractAction extends AbstractAction {
|
||||
progress.switchToDeterminate(toProcess);
|
||||
}
|
||||
|
||||
// Start extracting the file/directory
|
||||
// Start extracting the content/directory
|
||||
ExtractFscContentVisitor.extract(fsContent, destination, progress, this);
|
||||
logger.log(Level.INFO, "Done background processing");
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user