Autopsy  4.21.0
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.Arrays;
23 import java.util.Collection;
24 import java.util.HashSet;
25 import java.util.List;
26 import javax.swing.Action;
27 import org.openide.util.NbBundle;
28 import org.openide.util.Utilities;
36 import org.sleuthkit.datamodel.AbstractFile;
37 import org.sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM;
38 import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
39 
44 public class SlackFileNode extends AbstractFsContentNode<AbstractFile> {
45 
51  public SlackFileNode(AbstractFile file) {
52  this(file, true);
53 
54  setIcon(file);
55  }
56 
57  public SlackFileNode(AbstractFile file, boolean directoryBrowseMode) {
58  super(file, directoryBrowseMode);
59 
60  setIcon(file);
61  }
62 
63  private void setIcon(AbstractFile file) {
64  // set name, display name, and icon
65  if (file.isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM.UNALLOC)) {
66  if (file.getType().equals(TSK_DB_FILES_TYPE_ENUM.CARVED)) {
67  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/carved-file-x-icon-16.png"); //NON-NLS
68  } else {
69  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon-deleted.png"); //NON-NLS
70  }
71  } else {
72  this.setIconBaseWithExtension(getIconForFileType(file));
73  }
74  }
75 
76  @Override
77  public Action[] getActions(boolean popup) {
78  List<Action> actionsList = new ArrayList<>();
79  if (!this.getDirectoryBrowseMode()) {
80  actionsList.add(new ViewContextAction(NbBundle.getMessage(this.getClass(), "SlackFileNode.getActions.viewFileInDir.text"), this.content));
81  actionsList.add(null); // creates a menu separator
82  }
83  actionsList.add(new NewWindowViewAction(
84  NbBundle.getMessage(this.getClass(), "SlackFileNode.getActions.viewInNewWin.text"), this));
85  actionsList.add(null); // creates a menu separator
86  actionsList.add(ExtractAction.getInstance());
87  actionsList.add(ExportCSVAction.getInstance());
88  actionsList.add(null); // creates a menu separator
89  actionsList.add(AddContentTagAction.getInstance());
90 
91  final Collection<AbstractFile> selectedFilesList =
92  new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
93  if(selectedFilesList.size() == 1) {
94  actionsList.add(DeleteFileContentTagAction.getInstance());
95  }
96 
97  actionsList.addAll(ContextMenuExtensionPoint.getActions());
98  actionsList.add(null);
99  actionsList.addAll(Arrays.asList(super.getActions(true)));
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-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.