Autopsy  4.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-2016 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.List;
23 import javax.swing.Action;
24 import org.openide.util.NbBundle;
33 
38 public class SlackFileNode extends AbstractFsContentNode<AbstractFile> {
39 
45  public SlackFileNode(AbstractFile file) {
46  this(file, true);
47 
48  setIcon(file);
49  }
50 
52  super(file, directoryBrowseMode);
53 
54  setIcon(file);
55  }
56 
57  private void setIcon(AbstractFile file) {
58  // set name, display name, and icon
60  if (file.getType().equals(TSK_DB_FILES_TYPE_ENUM.CARVED)) {
61  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/carved-file-icon-16.png"); //NON-NLS
62  } else {
63  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon-deleted.png"); //NON-NLS
64  }
65  } else {
66  this.setIconBaseWithExtension(getIconForFileType(file));
67  }
68  }
69 
70  @Override
71  public Action[] getActions(boolean popup) {
72  List<Action> actionsList = new ArrayList<>();
73  for (Action a : super.getActions(true)) {
74  actionsList.add(a);
75  }
76 
77  if (!this.getDirectoryBrowseMode()) {
78  actionsList.add(new ViewContextAction(NbBundle.getMessage(this.getClass(), "SlackFileNode.viewFileInDir.text"), this.content));
79  actionsList.add(null); // creates a menu separator
80  }
81  actionsList.add(new NewWindowViewAction(
82  NbBundle.getMessage(this.getClass(), "SlackFileNode.getActions.viewInNewWin.text"), this));
83  actionsList.add(null); // creates a menu separator
84  actionsList.add(ExtractAction.getInstance());
85  actionsList.add(null); // creates a menu separator
86  actionsList.add(AddContentTagAction.getInstance());
87  actionsList.addAll(ContextMenuExtensionPoint.getActions());
88  return actionsList.toArray(new Action[actionsList.size()]);
89  }
90 
91  @Override
92  public <T> T accept(ContentNodeVisitor<T> v) {
93  return v.visit(this);
94  }
95 
96  @Override
97  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
98  return v.visit(this);
99  }
100 
101  // Given a file, returns the correct icon for said
102  // file based off it's extension
103  static String getIconForFileType(AbstractFile file) {
104 
105  return "org/sleuthkit/autopsy/images/file-icon.png"; //NON-NLS
106  }
107 
108  @Override
109  public boolean isLeafTypeNode() {
110  // This seems wrong, but it also seems that it is never called
111  // because the visitor to figure out if there are children or
112  // not will check if it has children using the Content API
113  return true;
114  }
115 
116  @Override
117  public String getItemType() {
118  return getClass().getName();
119  }
120 }
boolean isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM flag)
TskData.TSK_DB_FILES_TYPE_ENUM getType()
static synchronized ExtractAction getInstance()
SlackFileNode(AbstractFile file, boolean directoryBrowseMode)
static synchronized AddContentTagAction getInstance()

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