diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageAction.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageAction.java
index 8b4ef96f1d..cdfb561ae0 100644
--- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageAction.java
+++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageAction.java
@@ -109,7 +109,7 @@ public final class AddImageAction extends CallableSystemAction implements Presen
Logger.noteAction(AddImageAction.class);
final IngestConfigurator ingestConfig = Lookup.getDefault().lookup(IngestConfigurator.class);
- if (ingestConfig.isIngestRunning()) {
+ if (null != ingestConfig && ingestConfig.isIngestRunning()) {
final String msg = "Ingest is ongoing on another data source. Adding a new source now might slow down the current ingest.
Do you want to proceed and add a new data source now?";
if (JOptionPane.showConfirmDialog(null, msg, "Ingest in progress", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
return;
@@ -128,7 +128,6 @@ public final class AddImageAction extends CallableSystemAction implements Presen
dialog.setVisible(true);
dialog.toFront();
-
// Do any cleanup that needs to happen (potentially: stopping the
//add-image process, reverting an image)
runCleanupTasks();
diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/GeneralIngestConfigurator.java b/Core/src/org/sleuthkit/autopsy/casemodule/GeneralIngestConfigurator.java
new file mode 100644
index 0000000000..3ce1571150
--- /dev/null
+++ b/Core/src/org/sleuthkit/autopsy/casemodule/GeneralIngestConfigurator.java
@@ -0,0 +1,151 @@
+/*
+ * Autopsy Forensic Browser
+ *
+ * Copyright 2013 Basis Technology Corp.
+ * Contact: carrier 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 obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.sleuthkit.autopsy.casemodule;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.swing.JPanel;
+import org.openide.util.lookup.ServiceProvider;
+import org.sleuthkit.autopsy.coreutils.ModuleSettings;
+import org.sleuthkit.autopsy.ingest.IngestDialogPanel;
+import static org.sleuthkit.autopsy.ingest.IngestDialogPanel.DISABLED_MOD;
+import static org.sleuthkit.autopsy.ingest.IngestDialogPanel.PARSE_UNALLOC;
+import org.sleuthkit.autopsy.ingest.IngestManager;
+import org.sleuthkit.autopsy.ingest.IngestModuleAbstract;
+import org.sleuthkit.datamodel.Content;
+
+@ServiceProvider(service = IngestConfigurator.class)
+public class GeneralIngestConfigurator implements IngestConfigurator {
+ private List contentToIngest;
+ private IngestManager manager;
+ private IngestDialogPanel ingestDialogPanel;
+ private String moduleContext;
+
+ public GeneralIngestConfigurator() {
+ this.moduleContext = IngestManager.MODULE_PROPERTIES; // Hard-code this for now.
+ ingestDialogPanel = new IngestDialogPanel();
+ manager = IngestManager.getDefault();
+ loadSettings();
+ }
+
+ @Override
+ public JPanel getIngestConfigPanel() {
+ return ingestDialogPanel;
+ }
+
+ @Override
+ public void setContent(List inputContent) {
+ this.contentToIngest = inputContent;
+ }
+
+ @Override
+ public void start() {
+ // Get the list of ingest modules selected by the user.
+ List modulesToStart = ingestDialogPanel.getModulesToStart();
+
+ // Get the user's selection of whether or not to process unallocated space.
+ manager.setProcessUnallocSpace(ingestDialogPanel.processUnallocSpaceEnabled());
+
+ // Start the ingest.
+ if (!modulesToStart.isEmpty()) {
+ manager.execute(modulesToStart, contentToIngest);
+ }
+ }
+
+ @Override
+ public void save() {
+ // Save the user's configuration of the currently selected module.
+ IngestModuleAbstract currentModule = ingestDialogPanel.getCurrentIngestModule();
+ if (currentModule != null && currentModule.hasSimpleConfiguration()) {
+ currentModule.saveSimpleConfiguration();
+ }
+
+ // Create a list of the modules the user wants to be disabled.
+ List disabledModules = IngestManager.getDefault().enumerateAllModules();
+ disabledModules.removeAll(ingestDialogPanel.getModulesToStart());
+ String disabledModulesCsv = moduleListToCsv(disabledModules);
+
+ // Save the user's general ingest configuration.
+ ModuleSettings.setConfigSetting(moduleContext, DISABLED_MOD, disabledModulesCsv);
+ String processUnalloc = Boolean.toString(ingestDialogPanel.processUnallocSpaceEnabled());
+ ModuleSettings.setConfigSetting(moduleContext, PARSE_UNALLOC, processUnalloc);
+ }
+
+ @Override
+ public void reload() {
+ loadSettings();
+ }
+
+ @Override
+ public boolean isIngestRunning() {
+ return manager.isIngestRunning();
+ }
+
+ private static String moduleListToCsv(List lst) {
+ if (lst == null || lst.isEmpty()) {
+ return "";
+ }
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < lst.size() - 1; ++i) {
+ sb.append(lst.get(i).getName()).append(", ");
+ }
+
+ // and the last one
+ sb.append(lst.get(lst.size() - 1).getName());
+
+ return sb.toString();
+ }
+
+ private static List csvToModuleList(String csv) {
+ List modules = new ArrayList<>();
+
+ if (csv == null || csv.isEmpty()) {
+ return modules;
+ }
+
+ String[] moduleNames = csv.split(", ");
+ List allModules = IngestManager.getDefault().enumerateAllModules();
+ for (String moduleName : moduleNames) {
+ for (IngestModuleAbstract module : allModules) {
+ if (moduleName.equals(module.getName())) {
+ modules.add(module);
+ break;
+ }
+ }
+ }
+
+ return modules;
+ }
+
+ private void loadSettings() {
+ // get the csv list of disabled modules
+ String disabledModulesCsv = ModuleSettings.getConfigSetting(moduleContext, DISABLED_MOD);
+
+ // create a list of modules from it
+ List disabledModules = csvToModuleList(disabledModulesCsv);
+
+ // tell the ingestDialogPanel to unselect these modules
+ ingestDialogPanel.setDisabledModules(disabledModules);
+
+ boolean processUnalloc = Boolean.parseBoolean(ModuleSettings.getConfigSetting(moduleContext, PARSE_UNALLOC));
+ ingestDialogPanel.setProcessUnallocSpaceEnabled(processUnalloc);
+ }
+}
diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/IngestConfigurator.java b/Core/src/org/sleuthkit/autopsy/casemodule/IngestConfigurator.java
index cca3e2d064..45f6a8e80d 100644
--- a/Core/src/org/sleuthkit/autopsy/casemodule/IngestConfigurator.java
+++ b/Core/src/org/sleuthkit/autopsy/casemodule/IngestConfigurator.java
@@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
- * Copyright 2011 Basis Technology Corp.
+ * Copyright 2013 Basis Technology Corp.
* Contact: carrier sleuthkit org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -59,5 +59,5 @@ public interface IngestConfigurator {
* @return true if ingest process is running, false otherwise
*/
boolean isIngestRunning();
-
+
}
diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/AbstractDataResultViewer.java b/Core/src/org/sleuthkit/autopsy/corecomponents/AbstractDataResultViewer.java
index 3387065d1d..942bbbd242 100644
--- a/Core/src/org/sleuthkit/autopsy/corecomponents/AbstractDataResultViewer.java
+++ b/Core/src/org/sleuthkit/autopsy/corecomponents/AbstractDataResultViewer.java
@@ -81,21 +81,17 @@ public abstract class AbstractDataResultViewer extends JPanel implements
// change the cursor to "waiting cursor" for this operation
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
- Node selectedNode = getSelectedNode();
-
- nodeSelected(selectedNode);
-
-
-
- if (selectedNode != null) {
+ Node[] selectedNodes = getExplorerManager().getSelectedNodes();
+ if (selectedNodes.length == 1) {
+ nodeSelected(selectedNodes[0]);
+
// there's a new/changed node to display
- Node newSelectedNode = selectedNode; // get the selected Node on the table
// push the node to default "DataContent"
//TODO only the active viewer should be calling setNode
//not all of them, otherwise it results in multiple setNode() invocations
//alternative is to use a single instance of the event listener
//, per top component and not the tab perhaps
- contentViewer.setNode(newSelectedNode);
+ contentViewer.setNode(selectedNodes[0]);
} else {
// clear the node viewer
contentViewer.setNode(null);
@@ -131,6 +127,7 @@ public abstract class AbstractDataResultViewer extends JPanel implements
}
}
+ @Deprecated
public Node getSelectedNode() {
Node result = null;
Node[] selectedNodes = this.getExplorerManager().getSelectedNodes();
diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java
index ecdf121466..dc4fbb6d8f 100644
--- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java
+++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java
@@ -23,6 +23,7 @@ import java.util.Collections;
import java.util.List;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataResult;
import java.util.logging.Level;
+import org.openide.explorer.ExplorerUtils;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
import org.openide.nodes.Node;
@@ -96,9 +97,9 @@ public class DataResultTopComponent extends TopComponent implements DataResult {
initComponents();
customizeComponent(isMain, name);;
-
+
}
-
+
private void customizeComponent(boolean isMain, String title) {
this.isMain = isMain;
this.customModeName = null;
@@ -260,6 +261,14 @@ public class DataResultTopComponent extends TopComponent implements DataResult {
super.componentOpened();
this.dataResultPanel.open();
+
+ List resultViewers = this.dataResultPanel.getViewers();
+ for (DataResultViewer viewer : resultViewers) {
+ if (viewer instanceof DataResultViewerTable) {
+ associateLookup(ExplorerUtils.createLookup(((DataResultViewerTable)viewer).getExplorerManager(), getActionMap()));
+ break;
+ }
+ }
}
diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java
index 9ab0d40dea..6f5368578b 100644
--- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java
+++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java
@@ -62,7 +62,7 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
ov.setAllowedDropActions(DnDConstants.ACTION_NONE);
// only allow one item to be selected at a time
- ov.getOutline().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ ov.getOutline().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
// don't show the root node
ov.getOutline().setRootVisible(false);
diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java b/Core/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java
index 117c5eb4ab..4eff288380 100644
--- a/Core/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java
+++ b/Core/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java
@@ -19,12 +19,17 @@
package org.sleuthkit.autopsy.coreutils;
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
+
/**
* This class contains the framework to read, add, update, and remove
* from the property files located at %USERDIR%/Config/x.properties
@@ -33,15 +38,11 @@ public class ModuleSettings {
// The directory where the properties file is lcoated
private final static String moduleDirPath = PlatformUtil.getUserConfigDirectory();
- public static final String MAIN_SETTINGS="Case";
+ public static final String MAIN_SETTINGS = "Case";
-
/** the constructor */
- private ModuleSettings() {
-
- }
-
-
+ private ModuleSettings() {}
+
/**
* Makes a new config file of the specified name. Do not include the extension.
* @param moduleName - The name of the config file to make
@@ -161,9 +162,7 @@ public class ModuleSettings {
return null;
}
}
-
-
-
+
/**
* Sets the given properties file to the given setting map.
* @param moduleName - The name of the module to be written to.
@@ -215,14 +214,12 @@ public class ModuleSettings {
Logger.getLogger(ModuleSettings.class.getName()).log(Level.WARNING, "Property file exists for [" + moduleName + "] at [" + getPropertyPath(moduleName) + "] but could not be loaded.", e);
}
}
-
/**
* Removes the given key from the given properties file.
* @param moduleName - The name of the properties file to be modified.
* @param key - the name of the key to remove.
*/
-
public static synchronized void removeProperty(String moduleName, String key){
try{
if(getConfigSetting(moduleName, key) != null){
@@ -268,5 +265,4 @@ public class ModuleSettings {
return new File(getPropertyPath(moduleName));
}
}
-
}
diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/DirectoryNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/DirectoryNode.java
old mode 100644
new mode 100755
index a364071ac7..3c4d33c253
--- a/Core/src/org/sleuthkit/autopsy/datamodel/DirectoryNode.java
+++ b/Core/src/org/sleuthkit/autopsy/datamodel/DirectoryNode.java
@@ -1,97 +1,97 @@
-/*
- * Autopsy Forensic Browser
- *
- * Copyright 2011 Basis Technology Corp.
- * Contact: carrier 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 obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.sleuthkit.autopsy.datamodel;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.swing.Action;
-import org.sleuthkit.autopsy.directorytree.ExtractAction;
-import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
-import org.sleuthkit.autopsy.directorytree.TagAction;
-import org.sleuthkit.autopsy.directorytree.ViewContextAction;
-import org.sleuthkit.datamodel.AbstractFile;
-import org.sleuthkit.datamodel.Directory;
-import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
-
-/**
- * This class is used to represent the "Node" for the directory. Its children
- * are more directories.
- */
-public class DirectoryNode extends AbstractFsContentNode {
-
- public static final String DOTDOTDIR = "[parent folder]";
- public static final String DOTDIR = "[current folder]";
-
- public DirectoryNode(Directory dir) {
- this(dir, true);
-
- setIcon(dir);
- }
-
- public DirectoryNode(AbstractFile dir, boolean directoryBrowseMode) {
- super(dir, directoryBrowseMode);
-
- setIcon(dir);
- }
-
- private void setIcon(AbstractFile dir) {
- // set name, display name, and icon
- if (dir.isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM.UNALLOC)) {
- this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/folder-icon-deleted.png");
- } else {
- this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png");
- }
- }
-
- /**
- * Right click action for this node
- *
- * @param popup
- * @return
- */
- @Override
- public Action[] getActions(boolean popup) {
- List actions = new ArrayList();
- 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 TagAction(this));
- return actions.toArray(new Action[0]);
- }
-
- @Override
- public T accept(ContentNodeVisitor v) {
- return v.visit(this);
- }
-
- @Override
- public T accept(DisplayableItemNodeVisitor v) {
- return v.visit(this);
- }
-
- @Override
- public TYPE getDisplayableItemNodeType() {
- return TYPE.CONTENT;
- }
-}
+/*
+ * Autopsy Forensic Browser
+ *
+ * Copyright 2011 Basis Technology Corp.
+ * Contact: carrier 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 obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.sleuthkit.autopsy.datamodel;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.swing.Action;
+import org.sleuthkit.autopsy.directorytree.ExtractAction;
+import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
+import org.sleuthkit.autopsy.directorytree.TagAbstractFileAction;
+import org.sleuthkit.autopsy.directorytree.ViewContextAction;
+import org.sleuthkit.datamodel.AbstractFile;
+import org.sleuthkit.datamodel.Directory;
+import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
+
+/**
+ * This class is used to represent the "Node" for the directory. Its children
+ * are more directories.
+ */
+public class DirectoryNode extends AbstractFsContentNode {
+
+ public static final String DOTDOTDIR = "[parent folder]";
+ public static final String DOTDIR = "[current folder]";
+
+ public DirectoryNode(Directory dir) {
+ this(dir, true);
+
+ setIcon(dir);
+ }
+
+ public DirectoryNode(AbstractFile dir, boolean directoryBrowseMode) {
+ super(dir, directoryBrowseMode);
+
+ setIcon(dir);
+ }
+
+ private void setIcon(AbstractFile dir) {
+ // set name, display name, and icon
+ if (dir.isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM.UNALLOC)) {
+ this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/folder-icon-deleted.png");
+ } else {
+ this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png");
+ }
+ }
+
+ /**
+ * Right click action for this node
+ *
+ * @param popup
+ * @return
+ */
+ @Override
+ public Action[] getActions(boolean popup) {
+ List actions = new ArrayList<>();
+ 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(ExtractAction.getInstance());
+ actions.add(null); // creates a menu separator
+ actions.add(TagAbstractFileAction.getInstance());
+ return actions.toArray(new Action[0]);
+ }
+
+ @Override
+ public T accept(ContentNodeVisitor v) {
+ return v.visit(this);
+ }
+
+ @Override
+ public T accept(DisplayableItemNodeVisitor v) {
+ return v.visit(this);
+ }
+
+ @Override
+ public TYPE getDisplayableItemNodeType() {
+ return TYPE.CONTENT;
+ }
+}
diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/FileNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/FileNode.java
old mode 100644
new mode 100755
index 6c3f739624..9ca87fd8a7
--- a/Core/src/org/sleuthkit/autopsy/datamodel/FileNode.java
+++ b/Core/src/org/sleuthkit/autopsy/datamodel/FileNode.java
@@ -1,181 +1,180 @@
-/*
- * Autopsy Forensic Browser
- *
- * Copyright 2011 Basis Technology Corp.
- * Contact: carrier 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 obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.sleuthkit.autopsy.datamodel;
-
-import java.util.ArrayList;
-import java.util.List;
-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.TagAction;
-import org.sleuthkit.autopsy.directorytree.ViewContextAction;
-import org.sleuthkit.datamodel.AbstractFile;
-import org.sleuthkit.datamodel.FsContent;
-import org.sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM;
-import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
-
-/**
- * This class is used to represent the "Node" for the file. It may have derived
- * files children.
- */
-public class FileNode extends AbstractFsContentNode {
-
- /**
- * @param file underlying Content
- */
- public FileNode(AbstractFile file) {
- this(file, true);
-
- setIcon(file);
- }
-
- public FileNode(AbstractFile file, boolean directoryBrowseMode) {
- super(file, directoryBrowseMode);
-
- setIcon(file);
- }
-
- private void setIcon(AbstractFile file) {
- // set name, display name, and icon
- if (file.isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM.UNALLOC)) {
- if (file.getType().equals(TSK_DB_FILES_TYPE_ENUM.CARVED)) {
- this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/carved-file-icon-16.png");
- } else {
- this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon-deleted.png");
- }
- } else {
- this.setIconBaseWithExtension(getIconForFileType(file));
- }
- }
-
- /**
- * Right click action for this node
- *
- * @param popup
- * @return
- */
- @Override
- public Action[] getActions(boolean popup) {
- List actionsList = new ArrayList();
- 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 TagAction(this));
- return actionsList.toArray(new Action[0]);
- }
-
- @Override
- public T accept(ContentNodeVisitor< T> v) {
- return v.visit(this);
- }
-
- @Override
- public T accept(DisplayableItemNodeVisitor< T> v) {
- return v.visit(this);
- }
-
- // Given a file, returns the correct icon for said
- // file based off it's extension
- static String getIconForFileType(AbstractFile file) {
- // Get the name, extension
- String name = file.getName();
- int dotIndex = name.lastIndexOf(".");
- if (dotIndex == -1) {
- return "org/sleuthkit/autopsy/images/file-icon.png";
- }
- String ext = name.substring(dotIndex).toLowerCase();
-
- // Images
- for (String s : FileTypeExtensions.getImageExtensions()) {
- if (ext.equals(s)) {
- return "org/sleuthkit/autopsy/images/image-file.png";
- }
- }
- // Videos
- for (String s : FileTypeExtensions.getVideoExtensions()) {
- if (ext.equals(s)) {
- return "org/sleuthkit/autopsy/images/video-file.png";
- }
- }
- // Audio Files
- for (String s : FileTypeExtensions.getAudioExtensions()) {
- if (ext.equals(s)) {
- return "org/sleuthkit/autopsy/images/audio-file.png";
- }
- }
- // Documents
- for (String s : FileTypeExtensions.getDocumentExtensions()) {
- if (ext.equals(s)) {
- return "org/sleuthkit/autopsy/images/doc-file.png";
- }
- }
- // Executables / System Files
- for (String s : FileTypeExtensions.getExecutableExtensions()) {
- if (ext.equals(s)) {
- return "org/sleuthkit/autopsy/images/exe-file.png";
- }
- }
- // Text Files
- for (String s : FileTypeExtensions.getTextExtensions()) {
- if (ext.equals(s)) {
- return "org/sleuthkit/autopsy/images/text-file.png";
- }
- }
- // Web Files
- for (String s : FileTypeExtensions.getWebExtensions()) {
- if (ext.equals(s)) {
- return "org/sleuthkit/autopsy/images/web-file.png";
- }
- }
- // PDFs
- for (String s : FileTypeExtensions.getPDFExtensions()) {
- if (ext.equals(s)) {
- return "org/sleuthkit/autopsy/images/pdf-file.png";
- }
- }
- // Archives
- for (String s : FileTypeExtensions.getArchiveExtensions()) {
- if (ext.equals(s)) {
- return "org/sleuthkit/autopsy/images/archive-file.png";
- }
- }
- // Else return the default
- return "org/sleuthkit/autopsy/images/file-icon.png";
-
- }
-
- @Override
- public TYPE getDisplayableItemNodeType() {
- return TYPE.CONTENT;
- }
-
- @Override
- public boolean isLeafTypeNode() {
- return true; //false;
- }
-}
+/*
+ * Autopsy Forensic Browser
+ *
+ * Copyright 2011 Basis Technology Corp.
+ * Contact: carrier 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 obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.sleuthkit.autopsy.datamodel;
+
+import java.util.ArrayList;
+import java.util.List;
+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.TagAbstractFileAction;
+import org.sleuthkit.autopsy.directorytree.ViewContextAction;
+import org.sleuthkit.datamodel.AbstractFile;
+import org.sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM;
+import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
+
+/**
+ * This class is used to represent the "Node" for the file. It may have derived
+ * files children.
+ */
+public class FileNode extends AbstractFsContentNode {
+
+ /**
+ * @param file underlying Content
+ */
+ public FileNode(AbstractFile file) {
+ this(file, true);
+
+ setIcon(file);
+ }
+
+ public FileNode(AbstractFile file, boolean directoryBrowseMode) {
+ super(file, directoryBrowseMode);
+
+ setIcon(file);
+ }
+
+ private void setIcon(AbstractFile file) {
+ // set name, display name, and icon
+ if (file.isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM.UNALLOC)) {
+ if (file.getType().equals(TSK_DB_FILES_TYPE_ENUM.CARVED)) {
+ this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/carved-file-icon-16.png");
+ } else {
+ this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon-deleted.png");
+ }
+ } else {
+ this.setIconBaseWithExtension(getIconForFileType(file));
+ }
+ }
+
+ /**
+ * Right click action for this node
+ *
+ * @param popup
+ * @return
+ */
+ @Override
+ public Action[] getActions(boolean popup) {
+ List actionsList = new ArrayList<>();
+ 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(ExtractAction.getInstance());
+ actionsList.add(new HashSearchAction("Search for files with the same MD5 hash", this));
+ actionsList.add(null); // creates a menu separator
+ actionsList.add(TagAbstractFileAction.getInstance());
+ return actionsList.toArray(new Action[0]);
+ }
+
+ @Override
+ public T accept(ContentNodeVisitor< T> v) {
+ return v.visit(this);
+ }
+
+ @Override
+ public T accept(DisplayableItemNodeVisitor< T> v) {
+ return v.visit(this);
+ }
+
+ // Given a file, returns the correct icon for said
+ // file based off it's extension
+ static String getIconForFileType(AbstractFile file) {
+ // Get the name, extension
+ String name = file.getName();
+ int dotIndex = name.lastIndexOf(".");
+ if (dotIndex == -1) {
+ return "org/sleuthkit/autopsy/images/file-icon.png";
+ }
+ String ext = name.substring(dotIndex).toLowerCase();
+
+ // Images
+ for (String s : FileTypeExtensions.getImageExtensions()) {
+ if (ext.equals(s)) {
+ return "org/sleuthkit/autopsy/images/image-file.png";
+ }
+ }
+ // Videos
+ for (String s : FileTypeExtensions.getVideoExtensions()) {
+ if (ext.equals(s)) {
+ return "org/sleuthkit/autopsy/images/video-file.png";
+ }
+ }
+ // Audio Files
+ for (String s : FileTypeExtensions.getAudioExtensions()) {
+ if (ext.equals(s)) {
+ return "org/sleuthkit/autopsy/images/audio-file.png";
+ }
+ }
+ // Documents
+ for (String s : FileTypeExtensions.getDocumentExtensions()) {
+ if (ext.equals(s)) {
+ return "org/sleuthkit/autopsy/images/doc-file.png";
+ }
+ }
+ // Executables / System Files
+ for (String s : FileTypeExtensions.getExecutableExtensions()) {
+ if (ext.equals(s)) {
+ return "org/sleuthkit/autopsy/images/exe-file.png";
+ }
+ }
+ // Text Files
+ for (String s : FileTypeExtensions.getTextExtensions()) {
+ if (ext.equals(s)) {
+ return "org/sleuthkit/autopsy/images/text-file.png";
+ }
+ }
+ // Web Files
+ for (String s : FileTypeExtensions.getWebExtensions()) {
+ if (ext.equals(s)) {
+ return "org/sleuthkit/autopsy/images/web-file.png";
+ }
+ }
+ // PDFs
+ for (String s : FileTypeExtensions.getPDFExtensions()) {
+ if (ext.equals(s)) {
+ return "org/sleuthkit/autopsy/images/pdf-file.png";
+ }
+ }
+ // Archives
+ for (String s : FileTypeExtensions.getArchiveExtensions()) {
+ if (ext.equals(s)) {
+ return "org/sleuthkit/autopsy/images/archive-file.png";
+ }
+ }
+ // Else return the default
+ return "org/sleuthkit/autopsy/images/file-icon.png";
+
+ }
+
+ @Override
+ public TYPE getDisplayableItemNodeType() {
+ return TYPE.CONTENT;
+ }
+
+ @Override
+ public boolean isLeafTypeNode() {
+ return true; //false;
+ }
+}
diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/LayoutFileNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/LayoutFileNode.java
index 36f2fc8c02..9224131ad6 100644
--- a/Core/src/org/sleuthkit/autopsy/datamodel/LayoutFileNode.java
+++ b/Core/src/org/sleuthkit/autopsy/datamodel/LayoutFileNode.java
@@ -24,11 +24,10 @@ import java.util.List;
import java.util.Map;
import javax.swing.Action;
import org.openide.nodes.Sheet;
-import org.sleuthkit.autopsy.directorytree.ExplorerNodeActionVisitor;
import org.sleuthkit.autopsy.directorytree.ExternalViewerAction;
import org.sleuthkit.autopsy.directorytree.ExtractAction;
import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
-import org.sleuthkit.autopsy.directorytree.TagAction;
+import org.sleuthkit.autopsy.directorytree.TagAbstractFileAction;
import org.sleuthkit.datamodel.LayoutFile;
import org.sleuthkit.datamodel.TskData;
@@ -104,14 +103,12 @@ public class LayoutFileNode extends AbstractAbstractFileNode {
@Override
public Action[] getActions(boolean context) {
List actionsList = new ArrayList();
-
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", content));
+ actionsList.add(ExtractAction.getInstance());
actionsList.add(null); // creates a menu separator
- actionsList.add(new TagAction(content));
-
+ actionsList.add(TagAbstractFileAction.getInstance());
return actionsList.toArray(new Action[0]);
}
diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/LocalFileNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/LocalFileNode.java
index f2dc17d9a0..78711736b9 100644
--- a/Core/src/org/sleuthkit/autopsy/datamodel/LocalFileNode.java
+++ b/Core/src/org/sleuthkit/autopsy/datamodel/LocalFileNode.java
@@ -30,9 +30,8 @@ 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.TagAction;
+import org.sleuthkit.autopsy.directorytree.TagAbstractFileAction;
import org.sleuthkit.datamodel.AbstractFile;
-import org.sleuthkit.datamodel.LocalFile;
/**
* A Node for a LocalFile or DerivedFile content object.
@@ -86,16 +85,14 @@ public class LocalFileNode extends AbstractAbstractFileNode {
@Override
public Action[] getActions(boolean context) {
- List actionsList = new ArrayList();
-
+ List actionsList = new ArrayList<>();
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", content)); //might not need this actions - already local file
+ actionsList.add(ExtractAction.getInstance());
actionsList.add(new HashSearchAction("Search for files with the same MD5 hash", this));
actionsList.add(null); // creates a menu separator
- actionsList.add(new TagAction(content));
-
+ actionsList.add(TagAbstractFileAction.getInstance());
return actionsList.toArray(new Action[0]);
}
diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/Tags.java b/Core/src/org/sleuthkit/autopsy/datamodel/Tags.java
index 319d36e737..064f953660 100644
--- a/Core/src/org/sleuthkit/autopsy/datamodel/Tags.java
+++ b/Core/src/org/sleuthkit/autopsy/datamodel/Tags.java
@@ -22,7 +22,6 @@ import java.awt.event.ActionEvent;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
@@ -656,36 +655,4 @@ public class Tags implements AutopsyVisitableItem {
return tagNames;
}
-
- public interface Taggable {
- void createTag(String name, String comment);
- }
-
- public static class TaggableFile implements Taggable {
-
- private AbstractFile file;
-
- public TaggableFile(AbstractFile file) {
- this.file = file;
- }
-
- @Override
- public void createTag(String name, String comment) {
- Tags.createTag(file, name, comment);
- }
- }
-
- public static class TaggableBlackboardArtifact implements Taggable {
-
- private BlackboardArtifact bba;
-
- public TaggableBlackboardArtifact(BlackboardArtifact bba) {
- this.bba = bba;
- }
-
- @Override
- public void createTag(String name, String comment) {
- Tags.createTag(bba, name, comment);
- }
- }
}
diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/VirtualDirectoryNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/VirtualDirectoryNode.java
index 59e523ff81..756a376d11 100644
--- a/Core/src/org/sleuthkit/autopsy/datamodel/VirtualDirectoryNode.java
+++ b/Core/src/org/sleuthkit/autopsy/datamodel/VirtualDirectoryNode.java
@@ -27,7 +27,7 @@ import org.openide.nodes.Sheet;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.directorytree.ExtractAction;
import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
-import org.sleuthkit.autopsy.directorytree.TagAction;
+import org.sleuthkit.autopsy.directorytree.TagAbstractFileAction;
import org.sleuthkit.datamodel.VirtualDirectory;
import org.sleuthkit.datamodel.TskData;
@@ -76,16 +76,15 @@ public class VirtualDirectoryNode extends AbstractAbstractFileNode actions = new ArrayList();
-
+ List actions = new ArrayList<>();
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(ExtractAction.getInstance());
actions.add(null); // creates a menu separator
- actions.add(new TagAction(this));
+ actions.add(TagAbstractFileAction.getInstance());
return actions.toArray(new Action[0]);
}
-
+
@Override
protected Sheet createSheet() {
Sheet s = super.createSheet();
diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java b/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java
old mode 100644
new mode 100755
index a439a066bf..e30e9b56b1
--- a/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java
+++ b/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java
@@ -1,520 +1,520 @@
-/*
- * Autopsy Forensic Browser
- *
- * Copyright 2011 Basis Technology Corp.
- * Contact: carrier 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 obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.sleuthkit.autopsy.directorytree;
-
-import java.awt.event.ActionEvent;
-import java.beans.PropertyVetoException;
-import java.util.ArrayList;
-import java.util.List;
-import org.sleuthkit.autopsy.datamodel.VolumeNode;
-import org.sleuthkit.autopsy.datamodel.DirectoryNode;
-import java.util.logging.Level;
-import org.sleuthkit.autopsy.coreutils.Logger;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import org.openide.explorer.ExplorerManager;
-import org.openide.nodes.AbstractNode;
-import org.openide.nodes.FilterNode;
-import org.openide.nodes.Node;
-import org.openide.nodes.Sheet;
-import org.sleuthkit.autopsy.datamodel.AbstractAbstractFileNode.AbstractFilePropertyType;
-import org.sleuthkit.autopsy.datamodel.AbstractFsContentNode;
-import org.sleuthkit.autopsy.datamodel.ArtifactTypeNode;
-import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode;
-import org.sleuthkit.autopsy.datamodel.LocalFileNode;
-import org.sleuthkit.autopsy.datamodel.DeletedContent.DeletedContentsChildren.DeletedContentNode;
-import org.sleuthkit.autopsy.datamodel.DeletedContent.DeletedContentsNode;
-import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
-import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor;
-import org.sleuthkit.autopsy.datamodel.EmailExtracted.EmailExtractedAccountNode;
-import org.sleuthkit.autopsy.datamodel.EmailExtracted.EmailExtractedFolderNode;
-import org.sleuthkit.autopsy.datamodel.EmailExtracted.EmailExtractedRootNode;
-import org.sleuthkit.autopsy.datamodel.ExtractedContentNode;
-import org.sleuthkit.autopsy.datamodel.FileNode;
-import org.sleuthkit.autopsy.datamodel.FileSearchFilterNode;
-import org.sleuthkit.autopsy.datamodel.FileSize.FileSizeRootChildren.FileSizeNode;
-import org.sleuthkit.autopsy.datamodel.FileSize.FileSizeRootNode;
-import org.sleuthkit.autopsy.datamodel.HashsetHits.HashsetHitsRootNode;
-import org.sleuthkit.autopsy.datamodel.HashsetHits.HashsetHitsSetNode;
-import org.sleuthkit.autopsy.datamodel.ImageNode;
-import org.sleuthkit.autopsy.datamodel.KeywordHits.KeywordHitsKeywordNode;
-import org.sleuthkit.autopsy.datamodel.KeywordHits.KeywordHitsListNode;
-import org.sleuthkit.autopsy.datamodel.KeywordHits.KeywordHitsRootNode;
-import org.sleuthkit.autopsy.datamodel.VirtualDirectoryNode;
-import org.sleuthkit.autopsy.datamodel.LayoutFileNode;
-import org.sleuthkit.autopsy.datamodel.RecentFilesFilterNode;
-import org.sleuthkit.autopsy.datamodel.RecentFilesNode;
-import org.sleuthkit.autopsy.datamodel.SearchFiltersNode;
-import org.sleuthkit.autopsy.datamodel.Tags.TagNodeRoot;
-import org.sleuthkit.autopsy.datamodel.Tags.TagsNodeRoot;
-import org.sleuthkit.datamodel.AbstractFile;
-import org.sleuthkit.datamodel.BlackboardArtifact;
-import org.sleuthkit.datamodel.BlackboardAttribute;
-import org.sleuthkit.datamodel.Content;
-import org.sleuthkit.datamodel.DerivedFile;
-import org.sleuthkit.datamodel.Directory;
-import org.sleuthkit.datamodel.File;
-import org.sleuthkit.datamodel.LayoutFile;
-import org.sleuthkit.datamodel.LocalFile;
-import org.sleuthkit.datamodel.TskException;
-import org.sleuthkit.datamodel.VirtualDirectory;
-
-/**
- * This class wraps nodes as they are passed to the DataResult viewers. It
- * defines the actions that the node should have.
- */
-public class DataResultFilterNode extends FilterNode {
-
- private ExplorerManager sourceEm;
- private final DisplayableItemNodeVisitor> getActionsDIV;
- private final DisplayableItemNodeVisitor getPreferredActionsDIV;
-
- /**
- * the constructor
- */
- public DataResultFilterNode(Node node, ExplorerManager em) {
- super(node, new DataResultFilterChildren(node, em));
- this.sourceEm = em;
- getActionsDIV = new GetPopupActionsDisplayableItemNodeVisitor();
- getPreferredActionsDIV = new GetPreferredActionsDisplayableItemNodeVisitor();
- }
-
- /**
- * Right click action for the nodes that we want to pass to the directory
- * table and the output view.
- *
- * @param popup
- * @return actions
- */
- @Override
- public Action[] getActions(boolean popup) {
-
- List actions = new ArrayList();
-
- final DisplayableItemNode originalNode = (DisplayableItemNode) this.getOriginal();
- actions.addAll(originalNode.accept(getActionsDIV));
-
- //actions.add(new IndexContentFilesAction(nodeContent, "Index"));
-
- return actions.toArray(new Action[actions.size()]);
- }
-
- /**
- * Double click action for the nodes that we want to pass to the directory
- * table and the output view.
- *
- * @return action
- */
- @Override
- public Action getPreferredAction() {
- // double click action(s) for volume node or directory node
-
- final DisplayableItemNode originalNode;
- originalNode = (DisplayableItemNode) this.getOriginal();
-
- return originalNode.accept(getPreferredActionsDIV);
- }
-
- @Override
- public Node.PropertySet[] getPropertySets() {
- Node.PropertySet[] propertySets = super.getPropertySets();
-
- for (int i = 0; i < propertySets.length; i++) {
- Node.PropertySet ps = propertySets[i];
-
- if (ps.getName().equals(Sheet.PROPERTIES)) {
- Sheet.Set newPs = new Sheet.Set();
- newPs.setName(ps.getName());
- newPs.setDisplayName(ps.getDisplayName());
- newPs.setShortDescription(ps.getShortDescription());
-
- newPs.put(ps.getProperties());
- if (newPs.remove(AbstractFsContentNode.HIDE_PARENT) != null) {
- newPs.remove(AbstractFilePropertyType.LOCATION.toString());
- }
- propertySets[i] = newPs;
- }
- }
-
- return propertySets;
- }
-
- /**
- * Uses the default nodes actions per node, adds some custom ones and
- * returns them per visited node type
- */
- private static class GetPopupActionsDisplayableItemNodeVisitor extends DisplayableItemNodeVisitor.Default> {
-
- @Override
- public List visit(BlackboardArtifactNode ban) {
- //set up actions for artifact node based on its Content object
- //TODO all actions need to be consolidated in single place!
- //they should be set in individual Node subclass and using a utility to get Actions per Content sub-type
-
- List actions = new ArrayList();
-
- //merge predefined specific node actions if bban subclasses have their own
- for (Action a : ban.getActions(true)) {
- actions.add(a);
- }
- BlackboardArtifact ba = ban.getLookup().lookup(BlackboardArtifact.class);
- final int artifactTypeID = ba.getArtifactTypeID();
-
- if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()
- || artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
- actions.add(new ViewContextAction("View File in Directory", ban));
- } else {
- Content c = findLinked(ban);
- if (c != null) {
- actions.add(new ViewContextAction("View File in Directory", c));
- }
- actions.add(new ViewContextAction("View Source File in Directory", ban));
- }
- File f = ban.getLookup().lookup(File.class);
- LayoutFile lf = null;
- AbstractFile locF = null;
- Directory d = null;
- VirtualDirectory vd = null;
- if (f != null) {
- final FileNode fn = new FileNode(f);
- actions.add(null); // creates a menu separator
- actions.add(new NewWindowViewAction("View in New Window", fn));
- actions.add(new ExternalViewerAction("Open in External Viewer", fn));
- 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", fn));
-
- //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()) {
- actions.add(null); // creates a menu separator
- actions.add(new TagAction(f));
- actions.add(new TagAction(ba));
- }
- }
- if ((d = ban.getLookup().lookup(Directory.class)) != null) {
- DirectoryNode dn = new DirectoryNode(d);
- actions.add(null); // creates a menu separator
- actions.add(new NewWindowViewAction("View in New Window", dn));
- actions.add(new ExternalViewerAction("Open in External Viewer", dn));
- actions.add(null); // creates a menu separator
- actions.add(new ExtractAction("Extract Directory", dn));
-
- //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()) {
- actions.add(null); // creates a menu separator
- actions.add(new TagAction(d));
- actions.add(new TagAction(ba));
- }
- }
- if ((vd = ban.getLookup().lookup(VirtualDirectory.class)) != null) {
- VirtualDirectoryNode dn = new VirtualDirectoryNode(vd);
- actions.add(null); // creates a menu separator
- actions.add(new NewWindowViewAction("View in New Window", dn));
- actions.add(new ExternalViewerAction("Open in External Viewer", dn));
- actions.add(null); // creates a menu separator
- actions.add(new ExtractAction("Extract Directory", dn));
-
- //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()) {
- actions.add(null); // creates a menu separator
- actions.add(new TagAction(d));
- actions.add(new TagAction(ba));
- }
- } else if ((lf = ban.getLookup().lookup(LayoutFile.class)) != null) {
- LayoutFileNode lfn = new LayoutFileNode(lf);
- actions.add(null); // creates a menu separator
- actions.add(new NewWindowViewAction("View in New Window", lfn));
- actions.add(new ExternalViewerAction("Open in External Viewer", lfn));
- actions.add(null); // creates a menu separator
- actions.add(new ExtractAction("Extract File", lfn));
-
- //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()) {
- actions.add(null); // creates a menu separator
- actions.add(new TagAction(lf));
- actions.add(new TagAction(ba));
- }
- } else if ((locF = ban.getLookup().lookup(LocalFile.class)) != null
- || (locF = ban.getLookup().lookup(DerivedFile.class)) != null) {
- final LocalFileNode locfn = new LocalFileNode(locF);
- actions.add(null); // creates a menu separator
- actions.add(new NewWindowViewAction("View in New Window", locfn));
- actions.add(new ExternalViewerAction("Open in External Viewer", locfn));
- actions.add(null); // creates a menu separator
- actions.add(new ExtractAction("Extract File", locfn));
-
- //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()) {
- actions.add(null); // creates a menu separator
- actions.add(new TagAction(lf));
- actions.add(new TagAction(ba));
- }
- }
-
- return actions;
- }
-
- @Override
- protected List defaultVisit(DisplayableItemNode ditem) {
- //preserve the default node's actions
- List actions = new ArrayList();
-
- for (Action action : ditem.getActions(true)) {
- actions.add(action);
- }
-
- return actions;
- }
-
- private Content findLinked(BlackboardArtifactNode ba) {
- BlackboardArtifact art = ba.getLookup().lookup(BlackboardArtifact.class);
- Content c = null;
- try {
- for (BlackboardAttribute attr : art.getAttributes()) {
- if (attr.getAttributeTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) {
- switch (attr.getValueType()) {
- case INTEGER:
- int i = attr.getValueInt();
- if (i != -1) {
- c = art.getSleuthkitCase().getContentById(i);
- }
- break;
- case LONG:
- long l = attr.getValueLong();
- if (l != -1) {
- c = art.getSleuthkitCase().getContentById(l);
- }
- break;
- }
- }
- }
- } catch (TskException ex) {
- Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Error getting linked file", ex);
- }
- return c;
- }
- }
-
- private class GetPreferredActionsDisplayableItemNodeVisitor extends DisplayableItemNodeVisitor.Default {
-
- @Override
- public AbstractAction visit(ImageNode in) {
- return openChild(in);
- }
-
- @Override
- public AbstractAction visit(VolumeNode vn) {
- return openChild(vn);
- }
-
- @Override
- public AbstractAction visit(ExtractedContentNode ecn) {
- return openChild(ecn);
- }
-
- @Override
- public AbstractAction visit(KeywordHitsRootNode khrn) {
- return openChild(khrn);
- }
-
- @Override
- public AbstractAction visit(HashsetHitsRootNode hhrn) {
- return openChild(hhrn);
- }
-
- @Override
- public AbstractAction visit(HashsetHitsSetNode hhsn) {
- return openChild(hhsn);
- }
-
- @Override
- public AbstractAction visit(EmailExtractedRootNode eern) {
- return openChild(eern);
- }
-
- @Override
- public AbstractAction visit(EmailExtractedAccountNode eean) {
- return openChild(eean);
- }
-
- @Override
- public AbstractAction visit(EmailExtractedFolderNode eefn) {
- return openChild(eefn);
- }
-
- @Override
- public AbstractAction visit(RecentFilesNode rfn) {
- return openChild(rfn);
- }
-
- @Override
- public AbstractAction visit(DeletedContentsNode dcn) {
- return openChild(dcn);
- }
-
- @Override
- public AbstractAction visit(DeletedContentNode dcn) {
- return openChild(dcn);
- }
-
- @Override
- public AbstractAction visit(FileSizeRootNode fsrn) {
- return openChild(fsrn);
- }
-
- @Override
- public AbstractAction visit(FileSizeNode fsn) {
- return openChild(fsn);
- }
-
- @Override
- public AbstractAction visit(BlackboardArtifactNode ban) {
- return new ViewContextAction("View in Directory", ban);
- }
-
- @Override
- public AbstractAction visit(ArtifactTypeNode atn) {
- return openChild(atn);
- }
-
- @Override
- public AbstractAction visit(TagNodeRoot tnr) {
- return openChild(tnr);
- }
-
- @Override
- public AbstractAction visit(TagsNodeRoot tnr) {
- return openChild(tnr);
- }
-
- @Override
- public AbstractAction visit(DirectoryNode dn) {
- if (dn.getDisplayName().equals(DirectoryNode.DOTDOTDIR)) {
- return openParent(dn);
- } else if (!dn.getDisplayName().equals(DirectoryNode.DOTDIR)) {
- return openChild(dn);
- } else {
- 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(LocalFileNode dfn) {
- if (dfn.hasContentChildren()) {
- return openChild(dfn);
- } else {
- return null;
- }
- }
-
- @Override
- public AbstractAction visit(FileSearchFilterNode fsfn) {
- return openChild(fsfn);
- }
-
- @Override
- public AbstractAction visit(SearchFiltersNode sfn) {
- return openChild(sfn);
- }
-
- @Override
- public AbstractAction visit(RecentFilesFilterNode rffn) {
- return openChild(rffn);
- }
-
- @Override
- public AbstractAction visit(KeywordHitsListNode khsn) {
- return openChild(khsn);
- }
-
- @Override
- public AbstractAction visit(KeywordHitsKeywordNode khmln) {
- return openChild(khmln);
- }
-
- @Override
- protected AbstractAction defaultVisit(DisplayableItemNode c) {
- return null;
- }
-
- private AbstractAction openChild(AbstractNode node) {
- final Node[] parentNode = sourceEm.getSelectedNodes();
- final Node parentContext = parentNode[0];
- final Node original = node;
-
- return new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (parentContext != null) {
- 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 {
- sourceEm.setExploredContextAndSelection(selectedNode, new Node[]{selectedNode});
- } catch (PropertyVetoException ex) {
- // throw an error here
- Logger logger = Logger.getLogger(DataResultFilterNode.class.getName());
- logger.log(Level.WARNING, "Error: can't open the selected directory.", ex);
- }
- }
- }
- }
- }
- };
- }
-
- private AbstractAction openParent(AbstractNode node) {
- Node[] selectedNode = sourceEm.getSelectedNodes();
- Node selectedContext = selectedNode[0];
- final Node parentNode = selectedContext.getParentNode();
-
- return new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- try {
- sourceEm.setSelectedNodes(new Node[]{parentNode});
- } catch (PropertyVetoException ex) {
- Logger logger = Logger.getLogger(DataResultFilterNode.class.getName());
- logger.log(Level.WARNING, "Error: can't open the parent directory.", ex);
- }
- }
- };
- }
- }
+/*
+ * Autopsy Forensic Browser
+ *
+ * Copyright 2011 Basis Technology Corp.
+ * Contact: carrier 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 obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.sleuthkit.autopsy.directorytree;
+
+import java.awt.event.ActionEvent;
+import java.beans.PropertyVetoException;
+import java.util.ArrayList;
+import java.util.List;
+import org.sleuthkit.autopsy.datamodel.VolumeNode;
+import org.sleuthkit.autopsy.datamodel.DirectoryNode;
+import java.util.logging.Level;
+import org.sleuthkit.autopsy.coreutils.Logger;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import org.openide.explorer.ExplorerManager;
+import org.openide.nodes.AbstractNode;
+import org.openide.nodes.FilterNode;
+import org.openide.nodes.Node;
+import org.openide.nodes.Sheet;
+import org.sleuthkit.autopsy.datamodel.AbstractAbstractFileNode.AbstractFilePropertyType;
+import org.sleuthkit.autopsy.datamodel.AbstractFsContentNode;
+import org.sleuthkit.autopsy.datamodel.ArtifactTypeNode;
+import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode;
+import org.sleuthkit.autopsy.datamodel.LocalFileNode;
+import org.sleuthkit.autopsy.datamodel.DeletedContent.DeletedContentsChildren.DeletedContentNode;
+import org.sleuthkit.autopsy.datamodel.DeletedContent.DeletedContentsNode;
+import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
+import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor;
+import org.sleuthkit.autopsy.datamodel.EmailExtracted.EmailExtractedAccountNode;
+import org.sleuthkit.autopsy.datamodel.EmailExtracted.EmailExtractedFolderNode;
+import org.sleuthkit.autopsy.datamodel.EmailExtracted.EmailExtractedRootNode;
+import org.sleuthkit.autopsy.datamodel.ExtractedContentNode;
+import org.sleuthkit.autopsy.datamodel.FileNode;
+import org.sleuthkit.autopsy.datamodel.FileSearchFilterNode;
+import org.sleuthkit.autopsy.datamodel.FileSize.FileSizeRootChildren.FileSizeNode;
+import org.sleuthkit.autopsy.datamodel.FileSize.FileSizeRootNode;
+import org.sleuthkit.autopsy.datamodel.HashsetHits.HashsetHitsRootNode;
+import org.sleuthkit.autopsy.datamodel.HashsetHits.HashsetHitsSetNode;
+import org.sleuthkit.autopsy.datamodel.ImageNode;
+import org.sleuthkit.autopsy.datamodel.KeywordHits.KeywordHitsKeywordNode;
+import org.sleuthkit.autopsy.datamodel.KeywordHits.KeywordHitsListNode;
+import org.sleuthkit.autopsy.datamodel.KeywordHits.KeywordHitsRootNode;
+import org.sleuthkit.autopsy.datamodel.VirtualDirectoryNode;
+import org.sleuthkit.autopsy.datamodel.LayoutFileNode;
+import org.sleuthkit.autopsy.datamodel.RecentFilesFilterNode;
+import org.sleuthkit.autopsy.datamodel.RecentFilesNode;
+import org.sleuthkit.autopsy.datamodel.SearchFiltersNode;
+import org.sleuthkit.autopsy.datamodel.Tags.TagNodeRoot;
+import org.sleuthkit.autopsy.datamodel.Tags.TagsNodeRoot;
+import org.sleuthkit.datamodel.AbstractFile;
+import org.sleuthkit.datamodel.BlackboardArtifact;
+import org.sleuthkit.datamodel.BlackboardAttribute;
+import org.sleuthkit.datamodel.Content;
+import org.sleuthkit.datamodel.DerivedFile;
+import org.sleuthkit.datamodel.Directory;
+import org.sleuthkit.datamodel.File;
+import org.sleuthkit.datamodel.LayoutFile;
+import org.sleuthkit.datamodel.LocalFile;
+import org.sleuthkit.datamodel.TskException;
+import org.sleuthkit.datamodel.VirtualDirectory;
+
+/**
+ * This class wraps nodes as they are passed to the DataResult viewers. It
+ * defines the actions that the node should have.
+ */
+public class DataResultFilterNode extends FilterNode {
+
+ private ExplorerManager sourceEm;
+ private final DisplayableItemNodeVisitor> getActionsDIV;
+ private final DisplayableItemNodeVisitor getPreferredActionsDIV;
+
+ /**
+ * the constructor
+ */
+ public DataResultFilterNode(Node node, ExplorerManager em) {
+ super(node, new DataResultFilterChildren(node, em));
+ this.sourceEm = em;
+ getActionsDIV = new GetPopupActionsDisplayableItemNodeVisitor();
+ getPreferredActionsDIV = new GetPreferredActionsDisplayableItemNodeVisitor();
+ }
+
+ /**
+ * Right click action for the nodes that we want to pass to the directory
+ * table and the output view.
+ *
+ * @param popup
+ * @return actions
+ */
+ @Override
+ public Action[] getActions(boolean popup) {
+
+ List actions = new ArrayList<>();
+
+ final DisplayableItemNode originalNode = (DisplayableItemNode) this.getOriginal();
+ actions.addAll(originalNode.accept(getActionsDIV));
+
+ //actions.add(new IndexContentFilesAction(nodeContent, "Index"));
+
+ return actions.toArray(new Action[actions.size()]);
+ }
+
+ /**
+ * Double click action for the nodes that we want to pass to the directory
+ * table and the output view.
+ *
+ * @return action
+ */
+ @Override
+ public Action getPreferredAction() {
+ // double click action(s) for volume node or directory node
+
+ final DisplayableItemNode originalNode;
+ originalNode = (DisplayableItemNode) this.getOriginal();
+
+ return originalNode.accept(getPreferredActionsDIV);
+ }
+
+ @Override
+ public Node.PropertySet[] getPropertySets() {
+ Node.PropertySet[] propertySets = super.getPropertySets();
+
+ for (int i = 0; i < propertySets.length; i++) {
+ Node.PropertySet ps = propertySets[i];
+
+ if (ps.getName().equals(Sheet.PROPERTIES)) {
+ Sheet.Set newPs = new Sheet.Set();
+ newPs.setName(ps.getName());
+ newPs.setDisplayName(ps.getDisplayName());
+ newPs.setShortDescription(ps.getShortDescription());
+
+ newPs.put(ps.getProperties());
+ if (newPs.remove(AbstractFsContentNode.HIDE_PARENT) != null) {
+ newPs.remove(AbstractFilePropertyType.LOCATION.toString());
+ }
+ propertySets[i] = newPs;
+ }
+ }
+
+ return propertySets;
+ }
+
+ /**
+ * Uses the default nodes actions per node, adds some custom ones and
+ * returns them per visited node type
+ */
+ private static class GetPopupActionsDisplayableItemNodeVisitor extends DisplayableItemNodeVisitor.Default> {
+
+ @Override
+ public List visit(BlackboardArtifactNode ban) {
+ //set up actions for artifact node based on its Content object
+ //TODO all actions need to be consolidated in single place!
+ //they should be set in individual Node subclass and using a utility to get Actions per Content sub-type
+
+ List actions = new ArrayList<>();
+
+ //merge predefined specific node actions if bban subclasses have their own
+ for (Action a : ban.getActions(true)) {
+ actions.add(a);
+ }
+ BlackboardArtifact ba = ban.getLookup().lookup(BlackboardArtifact.class);
+ final int artifactTypeID = ba.getArtifactTypeID();
+
+ if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()
+ || artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
+ actions.add(new ViewContextAction("View File in Directory", ban));
+ } else {
+ Content c = findLinked(ban);
+ if (c != null) {
+ actions.add(new ViewContextAction("View File in Directory", c));
+ }
+ actions.add(new ViewContextAction("View Source File in Directory", ban));
+ }
+ File f = ban.getLookup().lookup(File.class);
+ LayoutFile lf = null;
+ AbstractFile locF = null;
+ Directory d = null;
+ VirtualDirectory vd = null;
+ if (f != null) {
+ final FileNode fn = new FileNode(f);
+ actions.add(null); // creates a menu separator
+ actions.add(new NewWindowViewAction("View in New Window", fn));
+ actions.add(new ExternalViewerAction("Open in External Viewer", fn));
+ actions.add(null); // creates a menu separator
+ actions.add(ExtractAction.getInstance());
+ actions.add(new HashSearchAction("Search for files with the same MD5 hash", fn));
+
+ //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()) {
+ actions.add(null); // creates a menu separator
+ actions.add(TagAbstractFileAction.getInstance());
+ actions.add(TagBlackboardArtifactAction.getInstance());
+ }
+ }
+ if ((d = ban.getLookup().lookup(Directory.class)) != null) {
+ DirectoryNode dn = new DirectoryNode(d);
+ actions.add(null); // creates a menu separator
+ actions.add(new NewWindowViewAction("View in New Window", dn));
+ actions.add(new ExternalViewerAction("Open in External Viewer", dn));
+ actions.add(null); // creates a menu separator
+ actions.add(ExtractAction.getInstance());
+
+ //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()) {
+ actions.add(null); // creates a menu separator
+ actions.add(TagAbstractFileAction.getInstance());
+ actions.add(TagBlackboardArtifactAction.getInstance());
+ }
+ }
+ if ((vd = ban.getLookup().lookup(VirtualDirectory.class)) != null) {
+ VirtualDirectoryNode dn = new VirtualDirectoryNode(vd);
+ actions.add(null); // creates a menu separator
+ actions.add(new NewWindowViewAction("View in New Window", dn));
+ actions.add(new ExternalViewerAction("Open in External Viewer", dn));
+ actions.add(null); // creates a menu separator
+ actions.add(ExtractAction.getInstance());
+
+ //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()) {
+ actions.add(null); // creates a menu separator
+ actions.add(TagAbstractFileAction.getInstance());
+ actions.add(TagBlackboardArtifactAction.getInstance());
+ }
+ } else if ((lf = ban.getLookup().lookup(LayoutFile.class)) != null) {
+ LayoutFileNode lfn = new LayoutFileNode(lf);
+ actions.add(null); // creates a menu separator
+ actions.add(new NewWindowViewAction("View in New Window", lfn));
+ actions.add(new ExternalViewerAction("Open in External Viewer", lfn));
+ actions.add(null); // creates a menu separator
+ actions.add(ExtractAction.getInstance());
+
+ //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()) {
+ actions.add(null); // creates a menu separator
+ actions.add(TagAbstractFileAction.getInstance());
+ actions.add(TagBlackboardArtifactAction.getInstance());
+ }
+ } else if ((locF = ban.getLookup().lookup(LocalFile.class)) != null
+ || (locF = ban.getLookup().lookup(DerivedFile.class)) != null) {
+ final LocalFileNode locfn = new LocalFileNode(locF);
+ actions.add(null); // creates a menu separator
+ actions.add(new NewWindowViewAction("View in New Window", locfn));
+ actions.add(new ExternalViewerAction("Open in External Viewer", locfn));
+ actions.add(null); // creates a menu separator
+ actions.add(ExtractAction.getInstance());
+
+ //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()) {
+ actions.add(null); // creates a menu separator
+ actions.add(TagAbstractFileAction.getInstance());
+ actions.add(TagBlackboardArtifactAction.getInstance());
+ }
+ }
+
+ return actions;
+ }
+
+ @Override
+ protected List defaultVisit(DisplayableItemNode ditem) {
+ //preserve the default node's actions
+ List actions = new ArrayList<>();
+
+ for (Action action : ditem.getActions(true)) {
+ actions.add(action);
+ }
+
+ return actions;
+ }
+
+ private Content findLinked(BlackboardArtifactNode ba) {
+ BlackboardArtifact art = ba.getLookup().lookup(BlackboardArtifact.class);
+ Content c = null;
+ try {
+ for (BlackboardAttribute attr : art.getAttributes()) {
+ if (attr.getAttributeTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) {
+ switch (attr.getValueType()) {
+ case INTEGER:
+ int i = attr.getValueInt();
+ if (i != -1) {
+ c = art.getSleuthkitCase().getContentById(i);
+ }
+ break;
+ case LONG:
+ long l = attr.getValueLong();
+ if (l != -1) {
+ c = art.getSleuthkitCase().getContentById(l);
+ }
+ break;
+ }
+ }
+ }
+ } catch (TskException ex) {
+ Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Error getting linked file", ex);
+ }
+ return c;
+ }
+ }
+
+ private class GetPreferredActionsDisplayableItemNodeVisitor extends DisplayableItemNodeVisitor.Default {
+
+ @Override
+ public AbstractAction visit(ImageNode in) {
+ return openChild(in);
+ }
+
+ @Override
+ public AbstractAction visit(VolumeNode vn) {
+ return openChild(vn);
+ }
+
+ @Override
+ public AbstractAction visit(ExtractedContentNode ecn) {
+ return openChild(ecn);
+ }
+
+ @Override
+ public AbstractAction visit(KeywordHitsRootNode khrn) {
+ return openChild(khrn);
+ }
+
+ @Override
+ public AbstractAction visit(HashsetHitsRootNode hhrn) {
+ return openChild(hhrn);
+ }
+
+ @Override
+ public AbstractAction visit(HashsetHitsSetNode hhsn) {
+ return openChild(hhsn);
+ }
+
+ @Override
+ public AbstractAction visit(EmailExtractedRootNode eern) {
+ return openChild(eern);
+ }
+
+ @Override
+ public AbstractAction visit(EmailExtractedAccountNode eean) {
+ return openChild(eean);
+ }
+
+ @Override
+ public AbstractAction visit(EmailExtractedFolderNode eefn) {
+ return openChild(eefn);
+ }
+
+ @Override
+ public AbstractAction visit(RecentFilesNode rfn) {
+ return openChild(rfn);
+ }
+
+ @Override
+ public AbstractAction visit(DeletedContentsNode dcn) {
+ return openChild(dcn);
+ }
+
+ @Override
+ public AbstractAction visit(DeletedContentNode dcn) {
+ return openChild(dcn);
+ }
+
+ @Override
+ public AbstractAction visit(FileSizeRootNode fsrn) {
+ return openChild(fsrn);
+ }
+
+ @Override
+ public AbstractAction visit(FileSizeNode fsn) {
+ return openChild(fsn);
+ }
+
+ @Override
+ public AbstractAction visit(BlackboardArtifactNode ban) {
+ return new ViewContextAction("View in Directory", ban);
+ }
+
+ @Override
+ public AbstractAction visit(ArtifactTypeNode atn) {
+ return openChild(atn);
+ }
+
+ @Override
+ public AbstractAction visit(TagNodeRoot tnr) {
+ return openChild(tnr);
+ }
+
+ @Override
+ public AbstractAction visit(TagsNodeRoot tnr) {
+ return openChild(tnr);
+ }
+
+ @Override
+ public AbstractAction visit(DirectoryNode dn) {
+ if (dn.getDisplayName().equals(DirectoryNode.DOTDOTDIR)) {
+ return openParent(dn);
+ } else if (!dn.getDisplayName().equals(DirectoryNode.DOTDIR)) {
+ return openChild(dn);
+ } else {
+ 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(LocalFileNode dfn) {
+ if (dfn.hasContentChildren()) {
+ return openChild(dfn);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public AbstractAction visit(FileSearchFilterNode fsfn) {
+ return openChild(fsfn);
+ }
+
+ @Override
+ public AbstractAction visit(SearchFiltersNode sfn) {
+ return openChild(sfn);
+ }
+
+ @Override
+ public AbstractAction visit(RecentFilesFilterNode rffn) {
+ return openChild(rffn);
+ }
+
+ @Override
+ public AbstractAction visit(KeywordHitsListNode khsn) {
+ return openChild(khsn);
+ }
+
+ @Override
+ public AbstractAction visit(KeywordHitsKeywordNode khmln) {
+ return openChild(khmln);
+ }
+
+ @Override
+ protected AbstractAction defaultVisit(DisplayableItemNode c) {
+ return null;
+ }
+
+ private AbstractAction openChild(AbstractNode node) {
+ final Node[] parentNode = sourceEm.getSelectedNodes();
+ final Node parentContext = parentNode[0];
+ final Node original = node;
+
+ return new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (parentContext != null) {
+ 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 {
+ sourceEm.setExploredContextAndSelection(selectedNode, new Node[]{selectedNode});
+ } catch (PropertyVetoException ex) {
+ // throw an error here
+ Logger logger = Logger.getLogger(DataResultFilterNode.class.getName());
+ logger.log(Level.WARNING, "Error: can't open the selected directory.", ex);
+ }
+ }
+ }
+ }
+ }
+ };
+ }
+
+ private AbstractAction openParent(AbstractNode node) {
+ Node[] selectedNode = sourceEm.getSelectedNodes();
+ Node selectedContext = selectedNode[0];
+ final Node parentNode = selectedContext.getParentNode();
+
+ return new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ try {
+ sourceEm.setSelectedNodes(new Node[]{parentNode});
+ } catch (PropertyVetoException ex) {
+ Logger logger = Logger.getLogger(DataResultFilterNode.class.getName());
+ logger.log(Level.WARNING, "Error: can't open the parent directory.", ex);
+ }
+ }
+ };
+ }
+ }
}
\ No newline at end of file
diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeFilterNode.java b/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeFilterNode.java
old mode 100644
new mode 100755
index 018679ae2c..d71ea25216
--- a/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeFilterNode.java
+++ b/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeFilterNode.java
@@ -1,160 +1,159 @@
-/*
- * Autopsy Forensic Browser
- *
- * Copyright 2011 Basis Technology Corp.
- * Contact: carrier 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 obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.sleuthkit.autopsy.directorytree;
-
-import java.awt.event.ActionEvent;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.logging.Level;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import org.openide.nodes.FilterNode;
-import org.openide.nodes.Node;
-import org.openide.util.lookup.Lookups;
-import org.openide.util.lookup.ProxyLookup;
-import org.sleuthkit.autopsy.coreutils.Logger;
-import org.sleuthkit.autopsy.datamodel.AbstractContentNode;
-import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
-import org.sleuthkit.autopsy.ingest.IngestDialog;
-import org.sleuthkit.datamodel.AbstractFile;
-import org.sleuthkit.datamodel.Content;
-import org.sleuthkit.datamodel.Directory;
-import org.sleuthkit.datamodel.Image;
-import org.sleuthkit.datamodel.TskCoreException;
-
-/**
- * This class sets the actions for the nodes in the directory tree and creates
- * the children filter so that files and such are hidden from the tree.
- *
- */
-class DirectoryTreeFilterNode extends FilterNode {
-
- private static final Action collapseAll = new CollapseAction("Collapse All");
- private static final Logger logger = Logger.getLogger(DirectoryTreeFilterNode.class.getName());
-
- /**
- * the constructor
- */
- DirectoryTreeFilterNode(Node arg, boolean createChildren) {
- super(arg, DirectoryTreeFilterChildren.createInstance(arg, createChildren),
- new ProxyLookup(Lookups.singleton(new OriginalNode(arg)),
- arg.getLookup()));
- }
-
- @Override
- public String getDisplayName() {
- final Node orig = getOriginal();
-
- String name = orig.getDisplayName();
-
- //do not show children counts for non content nodes
- if (orig instanceof AbstractContentNode) {
- //show only for file content nodes
- AbstractFile file = getLookup().lookup(AbstractFile.class);
- if (file != null) {
- try {
- final int numChildren = file.getChildrenCount();
- name = name + " (" + numChildren + ")";
- } catch (TskCoreException ex) {
- logger.log(Level.SEVERE, "Error getting children count to display for file: " + file, ex);
- }
-
- }
- }
-
- return name;
- }
-
- /**
- * Right click action for the nodes in the directory tree.
- *
- * @param popup
- * @return
- */
- @Override
- public Action[] getActions(boolean popup) {
- List actions = new ArrayList();
-
- final Content content = this.getLookup().lookup(Content.class);
- if (content != null) {
- actions.addAll(DirectoryTreeFilterNode.getDetailActions(content));
-
- //extract dir action
- Directory dir = this.getLookup().lookup(Directory.class);
- if (dir != null) {
- actions.add(new ExtractAction("Extract Directory",
- getOriginal()));
- }
-
- // file search action
- final Image img = this.getLookup().lookup(Image.class);
- if (img != null) {
- actions.add(new FileSearchAction("Open File Search by Attributes"));
- }
-
- //ingest action
- actions.add(new AbstractAction("Run Ingest Modules") {
- @Override
- public void actionPerformed(ActionEvent e) {
- final IngestDialog ingestDialog = new IngestDialog();
- ingestDialog.setContent(Collections.singletonList(content));
- ingestDialog.display();
- }
- });
- }
-
- //check if delete actions should be added
- final Node orig = getOriginal();
- //TODO add a mechanism to determine if DisplayableItemNode
- if (orig instanceof DisplayableItemNode) {
- actions.addAll(getDeleteActions((DisplayableItemNode) orig));
- }
-
- actions.add(collapseAll);
- return actions.toArray(new Action[actions.size()]);
- }
-
- private static List getDeleteActions(DisplayableItemNode original) {
- List actions = new ArrayList();
- //actions.addAll(original.accept(getDeleteActionVisitor));
- return actions;
- }
-
- private static List getDetailActions(Content c) {
- List actions = new ArrayList();
-
- actions.addAll(ExplorerNodeActionVisitor.getActions(c));
-
- return actions;
- }
-}
-
-class OriginalNode {
-
- private Node original;
-
- OriginalNode(Node original) {
- this.original = original;
- }
-
- Node getNode() {
- return original;
- }
+/*
+ * Autopsy Forensic Browser
+ *
+ * Copyright 2011 Basis Technology Corp.
+ * Contact: carrier 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 obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.sleuthkit.autopsy.directorytree;
+
+import java.awt.event.ActionEvent;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Level;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import org.openide.nodes.FilterNode;
+import org.openide.nodes.Node;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+import org.sleuthkit.autopsy.coreutils.Logger;
+import org.sleuthkit.autopsy.datamodel.AbstractContentNode;
+import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
+import org.sleuthkit.autopsy.ingest.IngestDialog;
+import org.sleuthkit.datamodel.AbstractFile;
+import org.sleuthkit.datamodel.Content;
+import org.sleuthkit.datamodel.Directory;
+import org.sleuthkit.datamodel.Image;
+import org.sleuthkit.datamodel.TskCoreException;
+
+/**
+ * This class sets the actions for the nodes in the directory tree and creates
+ * the children filter so that files and such are hidden from the tree.
+ *
+ */
+class DirectoryTreeFilterNode extends FilterNode {
+
+ private static final Action collapseAll = new CollapseAction("Collapse All");
+ private static final Logger logger = Logger.getLogger(DirectoryTreeFilterNode.class.getName());
+
+ /**
+ * the constructor
+ */
+ DirectoryTreeFilterNode(Node arg, boolean createChildren) {
+ super(arg, DirectoryTreeFilterChildren.createInstance(arg, createChildren),
+ new ProxyLookup(Lookups.singleton(new OriginalNode(arg)),
+ arg.getLookup()));
+ }
+
+ @Override
+ public String getDisplayName() {
+ final Node orig = getOriginal();
+
+ String name = orig.getDisplayName();
+
+ //do not show children counts for non content nodes
+ if (orig instanceof AbstractContentNode) {
+ //show only for file content nodes
+ AbstractFile file = getLookup().lookup(AbstractFile.class);
+ if (file != null) {
+ try {
+ final int numChildren = file.getChildrenCount();
+ name = name + " (" + numChildren + ")";
+ } catch (TskCoreException ex) {
+ logger.log(Level.SEVERE, "Error getting children count to display for file: " + file, ex);
+ }
+
+ }
+ }
+
+ return name;
+ }
+
+ /**
+ * Right click action for the nodes in the directory tree.
+ *
+ * @param popup
+ * @return
+ */
+ @Override
+ public Action[] getActions(boolean popup) {
+ List actions = new ArrayList();
+
+ final Content content = this.getLookup().lookup(Content.class);
+ if (content != null) {
+ actions.addAll(DirectoryTreeFilterNode.getDetailActions(content));
+
+ //extract dir action
+ Directory dir = this.getLookup().lookup(Directory.class);
+ if (dir != null) {
+ actions.add(ExtractAction.getInstance());
+ }
+
+ // file search action
+ final Image img = this.getLookup().lookup(Image.class);
+ if (img != null) {
+ actions.add(new FileSearchAction("Open File Search by Attributes"));
+ }
+
+ //ingest action
+ actions.add(new AbstractAction("Run Ingest Modules") {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ final IngestDialog ingestDialog = new IngestDialog();
+ ingestDialog.setContent(Collections.singletonList(content));
+ ingestDialog.display();
+ }
+ });
+ }
+
+ //check if delete actions should be added
+ final Node orig = getOriginal();
+ //TODO add a mechanism to determine if DisplayableItemNode
+ if (orig instanceof DisplayableItemNode) {
+ actions.addAll(getDeleteActions((DisplayableItemNode) orig));
+ }
+
+ actions.add(collapseAll);
+ return actions.toArray(new Action[actions.size()]);
+ }
+
+ private static List getDeleteActions(DisplayableItemNode original) {
+ List actions = new ArrayList();
+ //actions.addAll(original.accept(getDeleteActionVisitor));
+ return actions;
+ }
+
+ private static List getDetailActions(Content c) {
+ List actions = new ArrayList();
+
+ actions.addAll(ExplorerNodeActionVisitor.getActions(c));
+
+ return actions;
+ }
+}
+
+class OriginalNode {
+
+ private Node original;
+
+ OriginalNode(Node original) {
+ this.original = original;
+ }
+
+ Node getNode() {
+ return original;
+ }
}
\ No newline at end of file
diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/ExplorerNodeActionVisitor.java b/Core/src/org/sleuthkit/autopsy/directorytree/ExplorerNodeActionVisitor.java
old mode 100644
new mode 100755
index 28479e83c3..90c1eded2e
--- a/Core/src/org/sleuthkit/autopsy/directorytree/ExplorerNodeActionVisitor.java
+++ b/Core/src/org/sleuthkit/autopsy/directorytree/ExplorerNodeActionVisitor.java
@@ -1,383 +1,383 @@
-/*
- * Autopsy Forensic Browser
- *
- * Copyright 2011 Basis Technology Corp.
- * Contact: carrier 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 obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.sleuthkit.autopsy.directorytree;
-
-import java.awt.Toolkit;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.logging.Level;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JTable;
-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.LocalFile;
-import org.sleuthkit.datamodel.VirtualDirectory;
-import org.sleuthkit.datamodel.Volume;
-
-public class ExplorerNodeActionVisitor extends ContentVisitor.Default> {
-
- private static ExplorerNodeActionVisitor instance = new ExplorerNodeActionVisitor();
-
- public static List getActions(Content c) {
- List actions = new ArrayList();
-
- actions.addAll(c.accept(instance));
- //TODO: fix this
- /*
- while (c.isOnto()) {
- try {
- List extends Content> children = c.getChildren();
- if (!children.isEmpty()) {
- c = c.getChildren().get(0);
- } else {
- return actions;
- }
- } catch (TskException ex) {
- Log.get(ExplorerNodeActionVisitor.class).log(Level.WARNING, "Error getting show detail actions.", ex);
- return actions;
- }
- actions.addAll(c.accept(instance));
- }*/
- return actions;
- }
-
- ExplorerNodeActionVisitor() {
- }
-
- @Override
- public List extends Action> 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;
- }
-
- @Override
- public List extends Action> visit(final FileSystem fs) {
- return Collections.singletonList(new FileSystemDetails("File System Details", fs));
- }
-
- @Override
- public List extends Action> visit(final Volume vol) {
- List lst = new ArrayList();
- lst.add(new VolumeDetails("Volume Details", vol));
- lst.add(new ExtractUnallocAction("Extract Unallocated Space to Single File", vol));
- return lst;
- }
-
- @Override
- public List extends Action> visit(final Directory d) {
- List actions = new ArrayList();
- actions.add(new TagAction(d));
- return actions;
- }
-
- @Override
- public List extends Action> visit(final VirtualDirectory d) {
- List actions = new ArrayList();
- actions.add(new TagAction(d));
- actions.add(new ExtractAction("Extract Directory", d));
- return actions;
- }
-
- @Override
- public List extends Action> visit(final DerivedFile d) {
- List actions = new ArrayList();
- actions.add(new ExtractAction("Extract File", d));
- actions.add(new TagAction(d));
- return actions;
- }
-
- @Override
- public List extends Action> visit(final LocalFile d) {
- List actions = new ArrayList();
- actions.add(new ExtractAction("Extract File", d));
- actions.add(new TagAction(d));
- return actions;
- }
-
- @Override
- public List extends Action> visit(final org.sleuthkit.datamodel.File d) {
- List actions = new ArrayList();
- actions.add(new ExtractAction("Extract File", d));
- actions.add(new TagAction(d));
- return actions;
- }
-
- @Override
- protected List extends Action> defaultVisit(Content di) {
- return Collections.emptyList();
- }
-
- //Below here are classes regarding node-specific actions
- /**
- * VolumeDetails class
- */
- private class VolumeDetails extends AbstractAction {
-
- private final String title;
- private final Volume vol;
-
- VolumeDetails(String title, Volume vol) {
- super(title);
- this.title = title;
- this.vol = vol;
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- Logger.noteAction(ExplorerNodeActionVisitor.class);
-
- final JFrame frame = new JFrame(title);
- final JDialog popUpWindow = new JDialog(frame, title, true); // to make the popUp Window to be modal
-
-
- Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
-
- // set the popUp window / JFrame
- popUpWindow.setSize(800, 400);
-
- int w = popUpWindow.getSize().width;
- int h = popUpWindow.getSize().height;
-
- // set the location of the popUp Window on the center of the screen
- popUpWindow.setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2);
-
- VolumeDetailsPanel volumeDetailPanel = new VolumeDetailsPanel();
- Boolean counter = false;
-
- volumeDetailPanel.setVolumeIDValue(Long.toString(vol.getAddr()));
- volumeDetailPanel.setStartValue(Long.toString(vol.getStart()));
- volumeDetailPanel.setLengthValue(Long.toString(vol.getLength()));
- volumeDetailPanel.setDescValue(vol.getDescription());
- volumeDetailPanel.setFlagsValue(vol.getFlagsAsString());
- counter = true;
-
- if (counter) {
- // add the volume detail panel to the popUp window
- popUpWindow.add(volumeDetailPanel);
- } else {
- // error handler if no volume matches
- JLabel error = new JLabel("Error: No Volume Matches.");
- error.setFont(new Font("Arial", Font.BOLD, 24));
- popUpWindow.add(error);
- }
-
- // add the command to close the window to the button on the Volume Detail Panel
- volumeDetailPanel.setOKButtonActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- popUpWindow.dispose();
- }
- });
- popUpWindow.pack();
- popUpWindow.setResizable(false);
- popUpWindow.setVisible(true);
-
- }
- }
-
- /**
- * ImageDetails panel class
- */
- private class ImageDetails extends AbstractAction {
-
- final String title;
- final Image img;
-
- ImageDetails(String title, Image img) {
- super(title);
- this.title = title;
- this.img = img;
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- Logger.noteAction(ExplorerNodeActionVisitor.class);
-
- final JFrame frame = new JFrame(title);
- final JDialog popUpWindow = new JDialog(frame, title, true); // to make the popUp Window to be modal
- // if we select the Image Details menu
-
- Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
-
- // set the popUp window / JFrame
- popUpWindow.setSize(750, 400);
-
- int w = popUpWindow.getSize().width;
- int h = popUpWindow.getSize().height;
-
- // set the location of the popUp Window on the center of the screen
- popUpWindow.setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2);
-
- ImageDetailsPanel imgDetailPanel = new ImageDetailsPanel();
- Boolean counter = false;
-
- imgDetailPanel.setImgNameValue(img.getName());
- imgDetailPanel.setImgTypeValue(Image.imageTypeToString(img.getType()));
- imgDetailPanel.setImgSectorSizeValue(Long.toString(img.getSsize()));
- counter = true;
-
- if (counter) {
- // add the volume detail panel to the popUp window
- popUpWindow.add(imgDetailPanel);
- } else {
- // error handler if no volume matches
- JLabel error = new JLabel("Error: No Volume Matches.");
- error.setFont(new Font("Arial", Font.BOLD, 24));
- popUpWindow.add(error);
- }
-
- // add the command to close the window to the button on the Volume Detail Panel
- imgDetailPanel.setOKButtonActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- popUpWindow.dispose();
- }
- });
-
-
- popUpWindow.pack();
- popUpWindow.setResizable(false);
- popUpWindow.setVisible(true);
- }
- }
-
- /**
- * FileSystemDetails class
- */
- private class FileSystemDetails extends AbstractAction {
-
- private final FileSystem fs;
- private final String title;
-
- FileSystemDetails(String title, FileSystem fs) {
- super(title);
- this.title = title;
- this.fs = fs;
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
-
- Logger.noteAction(ExplorerNodeActionVisitor.class);
-
- final JFrame frame = new JFrame(title);
- final JDialog popUpWindow = new JDialog(frame, title, true); // to make the popUp Window to be modal
-
- // set the popUp window / JFrame
-
- popUpWindow.setSize(1000, 500);
-
- int w = popUpWindow.getSize().width;
- int h = popUpWindow.getSize().height;
-
- // set the location of the popUp Window on the center of the screen
- popUpWindow.setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2);
-
- String[] columnNames = new String[]{
- "fs_id",
- "img_offset",
- "par_id",
- "fs_type",
- "block_size",
- "block_count",
- "root_inum",
- "first_inum",
- "last_inum"
- };
-
- Object[][] rowValues = new Object[1][9];
-
- Content parent = null;
- try {
- parent = fs.getParent();
- } catch (Exception ex) {
- throw new RuntimeException("Problem getting parent from " + FileSystem.class.getName() + ": " + fs, ex);
- }
- long id = -1;
- if (parent != null) {
- id = parent.getId();
- }
-
- Arrays.fill(rowValues, 0, 1, new Object[]{
- fs.getId(),
- fs.getImageOffset(),
- id,
- fs.getFsType(),
- fs.getBlock_size(),
- fs.getBlock_count(),
- fs.getRoot_inum(),
- fs.getFirst_inum(),
- fs.getLastInum()
- });
-
-
- JTable table = new JTable(new DefaultTableModel(rowValues, columnNames));
-
- FileSystemDetailsPanel fsdPanel = new FileSystemDetailsPanel();
-
- // add the command to close the window to the button on the Volume Detail Panel
- fsdPanel.setOKButtonActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- popUpWindow.dispose();
- }
- });
-
- try {
- fsdPanel.setFileSystemTypeValue(table.getValueAt(0, 3).toString());
- fsdPanel.setImageOffsetValue(table.getValueAt(0, 1).toString());
- fsdPanel.setVolumeIDValue(table.getValueAt(0, 2).toString()); //TODO: fix this to parent id, not vol id
- fsdPanel.setBlockSizeValue(table.getValueAt(0, 4).toString());
- fsdPanel.setBlockCountValue(table.getValueAt(0, 5).toString());
- fsdPanel.setRootInumValue(table.getValueAt(0, 6).toString());
- fsdPanel.setFirstInumValue(table.getValueAt(0, 7).toString());
- fsdPanel.setLastInumValue(table.getValueAt(0, 8).toString());
-
- popUpWindow.add(fsdPanel);
- } catch (Exception ex) {
- Logger.getLogger(ExplorerNodeActionVisitor.class.getName()).log(Level.WARNING, "Error setting up File System Details panel.", ex);
- }
-
- popUpWindow.pack();
- popUpWindow.setResizable(false);
- popUpWindow.setVisible(true);
-
- }
- }
+/*
+ * Autopsy Forensic Browser
+ *
+ * Copyright 2011 Basis Technology Corp.
+ * Contact: carrier 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 obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.sleuthkit.autopsy.directorytree;
+
+import java.awt.Toolkit;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Level;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JTable;
+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.LocalFile;
+import org.sleuthkit.datamodel.VirtualDirectory;
+import org.sleuthkit.datamodel.Volume;
+
+public class ExplorerNodeActionVisitor extends ContentVisitor.Default> {
+
+ private static ExplorerNodeActionVisitor instance = new ExplorerNodeActionVisitor();
+
+ public static List getActions(Content c) {
+ List actions = new ArrayList();
+
+ actions.addAll(c.accept(instance));
+ //TODO: fix this
+ /*
+ while (c.isOnto()) {
+ try {
+ List extends Content> children = c.getChildren();
+ if (!children.isEmpty()) {
+ c = c.getChildren().get(0);
+ } else {
+ return actions;
+ }
+ } catch (TskException ex) {
+ Log.get(ExplorerNodeActionVisitor.class).log(Level.WARNING, "Error getting show detail actions.", ex);
+ return actions;
+ }
+ actions.addAll(c.accept(instance));
+ }*/
+ return actions;
+ }
+
+ ExplorerNodeActionVisitor() {
+ }
+
+ @Override
+ public List extends Action> 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;
+ }
+
+ @Override
+ public List extends Action> visit(final FileSystem fs) {
+ return Collections.singletonList(new FileSystemDetails("File System Details", fs));
+ }
+
+ @Override
+ public List extends Action> visit(final Volume vol) {
+ List lst = new ArrayList();
+ lst.add(new VolumeDetails("Volume Details", vol));
+ lst.add(new ExtractUnallocAction("Extract Unallocated Space to Single File", vol));
+ return lst;
+ }
+
+ @Override
+ public List extends Action> visit(final Directory d) {
+ List actions = new ArrayList();
+ actions.add(TagAbstractFileAction.getInstance());
+ return actions;
+ }
+
+ @Override
+ public List extends Action> visit(final VirtualDirectory d) {
+ List actions = new ArrayList();
+ actions.add(ExtractAction.getInstance());
+ actions.add(TagAbstractFileAction.getInstance());
+ return actions;
+ }
+
+ @Override
+ public List extends Action> visit(final DerivedFile d) {
+ List actions = new ArrayList();
+ actions.add(ExtractAction.getInstance());
+ actions.add(TagAbstractFileAction.getInstance());
+ return actions;
+ }
+
+ @Override
+ public List extends Action> visit(final LocalFile d) {
+ List actions = new ArrayList();
+ actions.add(ExtractAction.getInstance());
+ actions.add(TagAbstractFileAction.getInstance());
+ return actions;
+ }
+
+ @Override
+ public List extends Action> visit(final org.sleuthkit.datamodel.File d) {
+ List actions = new ArrayList();
+ actions.add(ExtractAction.getInstance());
+ actions.add(TagAbstractFileAction.getInstance());
+ return actions;
+ }
+
+ @Override
+ protected List extends Action> defaultVisit(Content di) {
+ return Collections.emptyList();
+ }
+
+ //Below here are classes regarding node-specific actions
+ /**
+ * VolumeDetails class
+ */
+ private class VolumeDetails extends AbstractAction {
+
+ private final String title;
+ private final Volume vol;
+
+ VolumeDetails(String title, Volume vol) {
+ super(title);
+ this.title = title;
+ this.vol = vol;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Logger.noteAction(ExplorerNodeActionVisitor.class);
+
+ final JFrame frame = new JFrame(title);
+ final JDialog popUpWindow = new JDialog(frame, title, true); // to make the popUp Window to be modal
+
+
+ Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
+
+ // set the popUp window / JFrame
+ popUpWindow.setSize(800, 400);
+
+ int w = popUpWindow.getSize().width;
+ int h = popUpWindow.getSize().height;
+
+ // set the location of the popUp Window on the center of the screen
+ popUpWindow.setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2);
+
+ VolumeDetailsPanel volumeDetailPanel = new VolumeDetailsPanel();
+ Boolean counter = false;
+
+ volumeDetailPanel.setVolumeIDValue(Long.toString(vol.getAddr()));
+ volumeDetailPanel.setStartValue(Long.toString(vol.getStart()));
+ volumeDetailPanel.setLengthValue(Long.toString(vol.getLength()));
+ volumeDetailPanel.setDescValue(vol.getDescription());
+ volumeDetailPanel.setFlagsValue(vol.getFlagsAsString());
+ counter = true;
+
+ if (counter) {
+ // add the volume detail panel to the popUp window
+ popUpWindow.add(volumeDetailPanel);
+ } else {
+ // error handler if no volume matches
+ JLabel error = new JLabel("Error: No Volume Matches.");
+ error.setFont(new Font("Arial", Font.BOLD, 24));
+ popUpWindow.add(error);
+ }
+
+ // add the command to close the window to the button on the Volume Detail Panel
+ volumeDetailPanel.setOKButtonActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ popUpWindow.dispose();
+ }
+ });
+ popUpWindow.pack();
+ popUpWindow.setResizable(false);
+ popUpWindow.setVisible(true);
+
+ }
+ }
+
+ /**
+ * ImageDetails panel class
+ */
+ private class ImageDetails extends AbstractAction {
+
+ final String title;
+ final Image img;
+
+ ImageDetails(String title, Image img) {
+ super(title);
+ this.title = title;
+ this.img = img;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Logger.noteAction(ExplorerNodeActionVisitor.class);
+
+ final JFrame frame = new JFrame(title);
+ final JDialog popUpWindow = new JDialog(frame, title, true); // to make the popUp Window to be modal
+ // if we select the Image Details menu
+
+ Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
+
+ // set the popUp window / JFrame
+ popUpWindow.setSize(750, 400);
+
+ int w = popUpWindow.getSize().width;
+ int h = popUpWindow.getSize().height;
+
+ // set the location of the popUp Window on the center of the screen
+ popUpWindow.setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2);
+
+ ImageDetailsPanel imgDetailPanel = new ImageDetailsPanel();
+ Boolean counter = false;
+
+ imgDetailPanel.setImgNameValue(img.getName());
+ imgDetailPanel.setImgTypeValue(Image.imageTypeToString(img.getType()));
+ imgDetailPanel.setImgSectorSizeValue(Long.toString(img.getSsize()));
+ counter = true;
+
+ if (counter) {
+ // add the volume detail panel to the popUp window
+ popUpWindow.add(imgDetailPanel);
+ } else {
+ // error handler if no volume matches
+ JLabel error = new JLabel("Error: No Volume Matches.");
+ error.setFont(new Font("Arial", Font.BOLD, 24));
+ popUpWindow.add(error);
+ }
+
+ // add the command to close the window to the button on the Volume Detail Panel
+ imgDetailPanel.setOKButtonActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ popUpWindow.dispose();
+ }
+ });
+
+
+ popUpWindow.pack();
+ popUpWindow.setResizable(false);
+ popUpWindow.setVisible(true);
+ }
+ }
+
+ /**
+ * FileSystemDetails class
+ */
+ private class FileSystemDetails extends AbstractAction {
+
+ private final FileSystem fs;
+ private final String title;
+
+ FileSystemDetails(String title, FileSystem fs) {
+ super(title);
+ this.title = title;
+ this.fs = fs;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
+
+ Logger.noteAction(ExplorerNodeActionVisitor.class);
+
+ final JFrame frame = new JFrame(title);
+ final JDialog popUpWindow = new JDialog(frame, title, true); // to make the popUp Window to be modal
+
+ // set the popUp window / JFrame
+
+ popUpWindow.setSize(1000, 500);
+
+ int w = popUpWindow.getSize().width;
+ int h = popUpWindow.getSize().height;
+
+ // set the location of the popUp Window on the center of the screen
+ popUpWindow.setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2);
+
+ String[] columnNames = new String[]{
+ "fs_id",
+ "img_offset",
+ "par_id",
+ "fs_type",
+ "block_size",
+ "block_count",
+ "root_inum",
+ "first_inum",
+ "last_inum"
+ };
+
+ Object[][] rowValues = new Object[1][9];
+
+ Content parent = null;
+ try {
+ parent = fs.getParent();
+ } catch (Exception ex) {
+ throw new RuntimeException("Problem getting parent from " + FileSystem.class.getName() + ": " + fs, ex);
+ }
+ long id = -1;
+ if (parent != null) {
+ id = parent.getId();
+ }
+
+ Arrays.fill(rowValues, 0, 1, new Object[]{
+ fs.getId(),
+ fs.getImageOffset(),
+ id,
+ fs.getFsType(),
+ fs.getBlock_size(),
+ fs.getBlock_count(),
+ fs.getRoot_inum(),
+ fs.getFirst_inum(),
+ fs.getLastInum()
+ });
+
+
+ JTable table = new JTable(new DefaultTableModel(rowValues, columnNames));
+
+ FileSystemDetailsPanel fsdPanel = new FileSystemDetailsPanel();
+
+ // add the command to close the window to the button on the Volume Detail Panel
+ fsdPanel.setOKButtonActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ popUpWindow.dispose();
+ }
+ });
+
+ try {
+ fsdPanel.setFileSystemTypeValue(table.getValueAt(0, 3).toString());
+ fsdPanel.setImageOffsetValue(table.getValueAt(0, 1).toString());
+ fsdPanel.setVolumeIDValue(table.getValueAt(0, 2).toString()); //TODO: fix this to parent id, not vol id
+ fsdPanel.setBlockSizeValue(table.getValueAt(0, 4).toString());
+ fsdPanel.setBlockCountValue(table.getValueAt(0, 5).toString());
+ fsdPanel.setRootInumValue(table.getValueAt(0, 6).toString());
+ fsdPanel.setFirstInumValue(table.getValueAt(0, 7).toString());
+ fsdPanel.setLastInumValue(table.getValueAt(0, 8).toString());
+
+ popUpWindow.add(fsdPanel);
+ } catch (Exception ex) {
+ Logger.getLogger(ExplorerNodeActionVisitor.class.getName()).log(Level.WARNING, "Error setting up File System Details panel.", ex);
+ }
+
+ popUpWindow.pack();
+ popUpWindow.setResizable(false);
+ popUpWindow.setVisible(true);
+
+ }
+ }
}
\ No newline at end of file
diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/ExtractAction.java b/Core/src/org/sleuthkit/autopsy/directorytree/ExtractAction.java
index 6b183644f1..1442cb57cd 100644
--- a/Core/src/org/sleuthkit/autopsy/directorytree/ExtractAction.java
+++ b/Core/src/org/sleuthkit/autopsy/directorytree/ExtractAction.java
@@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
- * Copyright 2011 Basis Technology Corp.
+ * Copyright 2013 Basis Technology Corp.
* Contact: carrier sleuthkit org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +21,7 @@ package org.sleuthkit.autopsy.directorytree;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.io.File;
+import java.util.Collection;
import java.util.concurrent.CancellationException;
import java.util.logging.Level;
import org.sleuthkit.autopsy.coreutils.Logger;
@@ -30,83 +31,37 @@ import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
-import org.openide.nodes.Node;
import org.openide.util.Cancellable;
+import org.openide.util.Utilities;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.FileUtil;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
-import org.sleuthkit.autopsy.datamodel.ContentUtils;
import org.sleuthkit.autopsy.datamodel.ContentUtils.ExtractFscContentVisitor;
import org.sleuthkit.datamodel.AbstractFile;
-import org.sleuthkit.datamodel.Content;
-import org.sleuthkit.datamodel.ContentVisitor;
-import org.sleuthkit.datamodel.Directory;
/**
* Exports files and folders
*/
public final class ExtractAction extends AbstractAction {
-
- private static final InitializeContentVisitor initializeCV = new InitializeContentVisitor();
- 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 class is a singleton to support multi-selection of nodes, since
+ // org.openide.nodes.NodeOp.findActions(Node[] nodes) will only pick up an Action if every
+ // node in the array returns a reference to the same action object from Node.getActions(boolean).
+ private static ExtractAction instance;
- this.content = tempContent.accept(initializeCV);
- this.setEnabled(content != null);
- }
-
- public ExtractAction(String title, Content content) {
- super(title);
+ public static synchronized ExtractAction getInstance() {
+ if (null == instance) {
+ instance = new ExtractAction();
+ }
- this.content = content.accept(initializeCV);
- this.setEnabled(this.content != null);
+ return instance;
}
- /**
- * Returns the FsContent if it is supported, otherwise null
- */
- private static class InitializeContentVisitor extends ContentVisitor.Default {
-
- @Override
- public AbstractFile visit(org.sleuthkit.datamodel.File f) {
- return f;
- }
-
- @Override
- public AbstractFile visit(org.sleuthkit.datamodel.LayoutFile lf) {
- return lf;
- }
-
- @Override
- public AbstractFile visit(org.sleuthkit.datamodel.DerivedFile df) {
- return df;
- }
-
- @Override
- public AbstractFile visit(org.sleuthkit.datamodel.LocalFile lf) {
- return lf;
- }
-
- @Override
- public AbstractFile visit(org.sleuthkit.datamodel.VirtualDirectory vd) {
- return vd;
- }
-
- @Override
- public AbstractFile visit(Directory dir) {
- return ContentUtils.isDotDirectory(dir) ? null : dir;
- }
-
- @Override
- protected AbstractFile defaultVisit(Content cntnt) {
- return null;
- }
+ private ExtractAction() {
+ super("Extract");
}
-
+
/**
* Asks user to choose destination, then extracts content/directory to
* destination (recursing on directories)
@@ -114,10 +69,17 @@ public final class ExtractAction extends AbstractAction {
*/
@Override
public void actionPerformed(ActionEvent e) {
+ Collection extends AbstractFile> selectedFiles = Utilities.actionsGlobalContext().lookupAll(AbstractFile.class);
+ for (AbstractFile file : selectedFiles) {
+ extractFile(e, file);
+ }
+ }
+
+ private void extractFile(ActionEvent e, AbstractFile 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.content.getName()));
+ fc.setSelectedFile(new File(file.getName()));
int returnValue = fc.showSaveDialog((Component) e.getSource());
if (returnValue == JFileChooser.APPROVE_OPTION) {
@@ -144,12 +106,12 @@ public final class ExtractAction extends AbstractAction {
try {
ExtractFileThread extract = new ExtractFileThread();
- extract.init(this.content, e, destination);
+ extract.init(file, e, destination);
extract.execute();
} catch (Exception ex) {
logger.log(Level.WARNING, "Unable to start background thread.", ex);
}
- }
+ }
}
private class ExtractFileThread extends SwingWorker