Autopsy  4.9.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-2017 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;
34 import org.sleuthkit.datamodel.AbstractFile;
35 import org.sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM;
36 import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
37 
42 public class SlackFileNode extends AbstractFsContentNode<AbstractFile> {
43 
49  public SlackFileNode(AbstractFile file) {
50  this(file, true);
51 
52  setIcon(file);
53  }
54 
55  public SlackFileNode(AbstractFile file, boolean directoryBrowseMode) {
56  super(file, directoryBrowseMode);
57 
58  setIcon(file);
59  }
60 
61  private void setIcon(AbstractFile file) {
62  // set name, display name, and icon
63  if (file.isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM.UNALLOC)) {
64  if (file.getType().equals(TSK_DB_FILES_TYPE_ENUM.CARVED)) {
65  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/carved-file-icon-16.png"); //NON-NLS
66  } else {
67  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon-deleted.png"); //NON-NLS
68  }
69  } else {
70  this.setIconBaseWithExtension(getIconForFileType(file));
71  }
72  }
73 
74  @Override
75  public Action[] getActions(boolean popup) {
76  List<Action> actionsList = new ArrayList<>();
77  for (Action a : super.getActions(true)) {
78  actionsList.add(a);
79  }
80  if (!this.getDirectoryBrowseMode()) {
81  actionsList.add(new ViewContextAction(NbBundle.getMessage(this.getClass(), "SlackFileNode.viewFileInDir.text"), this.content));
82  actionsList.add(null); // creates a menu separator
83  }
84  actionsList.add(new NewWindowViewAction(
85  NbBundle.getMessage(this.getClass(), "SlackFileNode.getActions.viewInNewWin.text"), this));
86  actionsList.add(null); // creates a menu separator
87  actionsList.add(ExtractAction.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  return actionsList.toArray(new Action[actionsList.size()]);
99  }
100 
101  @Override
102  public <T> T accept(ContentNodeVisitor<T> visitor) {
103  return visitor.visit(this);
104  }
105 
106  @Override
107  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
108  return visitor.visit(this);
109  }
110 
111  // Given a file, returns the correct icon for said
112  // file based off it's extension
113  static String getIconForFileType(AbstractFile file) {
114 
115  return "org/sleuthkit/autopsy/images/file-icon.png"; //NON-NLS
116  }
117 
118  @Override
119  public boolean isLeafTypeNode() {
120  // This seems wrong, but it also seems that it is never called
121  // because the visitor to figure out if there are children or
122  // not will check if it has children using the Content API
123  return true;
124  }
125 
126  @Override
127  public String getItemType() {
128  return getClass().getName();
129  }
130 }
static synchronized ExtractAction getInstance()
SlackFileNode(AbstractFile file, boolean directoryBrowseMode)
static synchronized DeleteFileContentTagAction getInstance()
static synchronized AddContentTagAction getInstance()

Copyright © 2012-2018 Basis Technology. Generated on: Tue Dec 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.