Autopsy  4.4
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 
81  if (!this.getDirectoryBrowseMode()) {
82  actionsList.add(new ViewContextAction(NbBundle.getMessage(this.getClass(), "SlackFileNode.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(null); // creates a menu separator
90  actionsList.add(AddContentTagAction.getInstance());
91 
92  final Collection<AbstractFile> selectedFilesList =
93  new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
94  if(selectedFilesList.size() == 1) {
95  actionsList.add(DeleteFileContentTagAction.getInstance());
96  }
97 
98  actionsList.addAll(ContextMenuExtensionPoint.getActions());
99  return actionsList.toArray(new Action[actionsList.size()]);
100  }
101 
102  @Override
103  public <T> T accept(ContentNodeVisitor<T> v) {
104  return v.visit(this);
105  }
106 
107  @Override
108  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
109  return v.visit(this);
110  }
111 
112  // Given a file, returns the correct icon for said
113  // file based off it's extension
114  static String getIconForFileType(AbstractFile file) {
115 
116  return "org/sleuthkit/autopsy/images/file-icon.png"; //NON-NLS
117  }
118 
119  @Override
120  public boolean isLeafTypeNode() {
121  // This seems wrong, but it also seems that it is never called
122  // because the visitor to figure out if there are children or
123  // not will check if it has children using the Content API
124  return true;
125  }
126 
127  @Override
128  public String getItemType() {
129  return getClass().getName();
130  }
131 }
static synchronized ExtractAction getInstance()
SlackFileNode(AbstractFile file, boolean directoryBrowseMode)
static synchronized DeleteFileContentTagAction getInstance()
static synchronized AddContentTagAction getInstance()

Copyright © 2012-2016 Basis Technology. Generated on: Tue Jun 13 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.