19 package org.sleuthkit.autopsy.datamodel;
21 import java.util.ArrayList;
22 import java.util.List;
23 import javax.swing.Action;
24 import org.apache.commons.lang3.StringUtils;
25 import org.openide.util.NbBundle;
36 import org.
sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM;
37 import org.
sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
57 super(file, directoryBrowseMode);
64 if (file.isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM.UNALLOC)) {
65 if (file.getType().equals(TSK_DB_FILES_TYPE_ENUM.CARVED)) {
66 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/carved-file-icon-16.png");
68 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/file-icon-deleted.png");
71 this.setIconBaseWithExtension(getIconForFileType(file));
77 "FileNode.getActions.viewFileInDir.text=View File in Directory",
78 "FileNode.getActions.viewInNewWin.text=View in New Window",
79 "FileNode.getActions.openInExtViewer.text=Open in External Viewer",
80 "FileNode.getActions.searchFilesSameMD5.text=Search for files with the same MD5 hash"})
82 List<Action> actionsList =
new ArrayList<>();
83 for (Action a : super.getActions(
true)) {
87 actionsList.add(
new ViewContextAction(Bundle.FileNode_getActions_viewFileInDir_text(),
this));
88 actionsList.add(null);
90 actionsList.add(
new NewWindowViewAction(Bundle.FileNode_getActions_viewInNewWin_text(),
this));
91 actionsList.add(
new ExternalViewerAction(Bundle.FileNode_getActions_openInExtViewer_text(),
this));
94 actionsList.add(null);
96 actionsList.add(
new HashSearchAction(Bundle.FileNode_getActions_searchFilesSameMD5_text(),
this));
97 actionsList.add(null);
100 return actionsList.toArray(
new Action[actionsList.size()]);
104 public <T> T accept(ContentNodeVisitor<T> v) {
105 return v.visit(
this);
109 public <T> T accept(DisplayableItemNodeVisitor<T> v) {
110 return v.visit(
this);
115 static String getIconForFileType(AbstractFile file) {
117 String ext = file.getNameExtension();
119 if (StringUtils.isBlank(ext)) {
120 return "org/sleuthkit/autopsy/images/file-icon.png";
125 if (ImageUtils.isImageThumbnailSupported(file)
126 || FileTypeExtensions.getImageExtensions().contains(ext)) {
127 return "org/sleuthkit/autopsy/images/image-file.png";
130 if (FileTypeExtensions.getVideoExtensions().contains(ext)) {
131 return "org/sleuthkit/autopsy/images/video-file.png";
134 if (FileTypeExtensions.getAudioExtensions().contains(ext)) {
135 return "org/sleuthkit/autopsy/images/audio-file.png";
138 if (FileTypeExtensions.getDocumentExtensions().contains(ext)) {
139 return "org/sleuthkit/autopsy/images/doc-file.png";
142 if (FileTypeExtensions.getExecutableExtensions().contains(ext)) {
143 return "org/sleuthkit/autopsy/images/exe-file.png";
146 if (FileTypeExtensions.getTextExtensions().contains(ext)) {
147 return "org/sleuthkit/autopsy/images/text-file.png";
150 if (FileTypeExtensions.getWebExtensions().contains(ext)) {
151 return "org/sleuthkit/autopsy/images/web-file.png";
154 if (FileTypeExtensions.getPDFExtensions().contains(ext)) {
155 return "org/sleuthkit/autopsy/images/pdf-file.png";
158 if (FileTypeExtensions.getArchiveExtensions().contains(ext)) {
159 return "org/sleuthkit/autopsy/images/archive-file.png";
162 return "org/sleuthkit/autopsy/images/file-icon.png";
Action[] getActions(boolean popup)
boolean directoryBrowseMode
void setIcon(AbstractFile file)
FileNode(AbstractFile file, boolean directoryBrowseMode)
static ViewFileInTimelineAction createViewFileAction(AbstractFile file)
FileNode(AbstractFile file)
static synchronized AddContentTagAction getInstance()
boolean getDirectoryBrowseMode()