Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
SlackFileNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2019 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.datamodel;
20 
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.HashSet;
24 import java.util.List;
25 import javax.swing.Action;
26 import org.openide.util.NbBundle;
27 import org.openide.util.Utilities;
35 import org.sleuthkit.datamodel.AbstractFile;
36 import org.sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM;
37 import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
38 
43 public class SlackFileNode extends AbstractFsContentNode<AbstractFile> {
44 
50  public SlackFileNode(AbstractFile file) {
51  this(file, true);
52 
53  setIcon(file);
54  }
55 
56  public SlackFileNode(AbstractFile file, boolean directoryBrowseMode) {
57  super(file, directoryBrowseMode);
58 
59  setIcon(file);
60  }
61 
62  private void setIcon(AbstractFile file) {
63  // set name, display name, and icon
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-x-icon-16.png"); //NON-NLS
67  } else {
68  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon-deleted.png"); //NON-NLS
69  }
70  } else {
71  this.setIconBaseWithExtension(getIconForFileType(file));
72  }
73  }
74 
75  @Override
76  public Action[] getActions(boolean popup) {
77  List<Action> actionsList = new ArrayList<>();
78  for (Action a : super.getActions(true)) {
79  actionsList.add(a);
80  }
81  if (!this.getDirectoryBrowseMode()) {
82  actionsList.add(new ViewContextAction(NbBundle.getMessage(this.getClass(), "SlackFileNode.getActions.viewFileInDir.text"), this.content));
83  actionsList.add(null); // creates a menu separator
84  }
85  actionsList.add(new NewWindowViewAction(
86  NbBundle.getMessage(this.getClass(), "SlackFileNode.getActions.viewInNewWin.text"), this));
87  actionsList.add(null); // creates a menu separator
88  actionsList.add(ExtractAction.getInstance());
89  actionsList.add(ExportCSVAction.getInstance());
90  actionsList.add(null); // creates a menu separator
91  actionsList.add(AddContentTagAction.getInstance());
92 
93  final Collection<AbstractFile> selectedFilesList =
94  new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
95  if(selectedFilesList.size() == 1) {
96  actionsList.add(DeleteFileContentTagAction.getInstance());
97  }
98 
99  actionsList.addAll(ContextMenuExtensionPoint.getActions());
100  return actionsList.toArray(new Action[actionsList.size()]);
101  }
102 
103  @Override
104  public <T> T accept(ContentNodeVisitor<T> visitor) {
105  return visitor.visit(this);
106  }
107 
108  @Override
109  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
110  return visitor.visit(this);
111  }
112 
113  // Given a file, returns the correct icon for said
114  // file based off it's extension
115  static String getIconForFileType(AbstractFile file) {
116 
117  return "org/sleuthkit/autopsy/images/file-icon.png"; //NON-NLS
118  }
119 
120  @Override
121  public boolean isLeafTypeNode() {
122  // This seems wrong, but it also seems that it is never called
123  // because the visitor to figure out if there are children or
124  // not will check if it has children using the Content API
125  return true;
126  }
127 
128  @Override
129  public String getItemType() {
130  return getClass().getName();
131  }
132 }
static synchronized ExportCSVAction getInstance()
static synchronized ExtractAction getInstance()
SlackFileNode(AbstractFile file, boolean directoryBrowseMode)
static synchronized DeleteFileContentTagAction getInstance()
static synchronized AddContentTagAction getInstance()

Copyright © 2012-2021 Basis Technology. Generated on: Thu Sep 30 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.