diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/ExplorerNodeActionVisitor.java b/Core/src/org/sleuthkit/autopsy/directorytree/ExplorerNodeActionVisitor.java index b5d6342e94..dee3b68d3d 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/ExplorerNodeActionVisitor.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/ExplorerNodeActionVisitor.java @@ -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> { @@ -77,6 +79,7 @@ class ExplorerNodeActionVisitor extends ContentVisitor.Default visit(final Image img) { List lst = new ArrayList(); 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 visit(final Directory d) { + List actions = new ArrayList(); + actions.add(new TagFileAction(d)); + return actions; + } + + @Override + public List visit(final DerivedFile d) { + List actions = new ArrayList(); + actions.add(new ExtractAction("Extract File", d)); + actions.add(new TagFileAction(d)); + return actions; + } + + @Override + public List visit(final org.sleuthkit.datamodel.File d) { + List actions = new ArrayList(); + actions.add(new ExtractAction("Extract File", d)); + actions.add(new TagFileAction(d)); + return actions; + } + @Override protected List defaultVisit(Content di) { - return new ArrayList(); + return Collections.emptyList(); } //Below here are classes regarding node-specific actions @@ -279,7 +305,7 @@ class ExplorerNodeActionVisitor extends ContentVisitor.Default sleuthkit 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;