Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
LocalFileNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-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.Arrays;
23 import java.util.LinkedHashMap;
24 import java.util.List;
25 import java.util.Map;
26 import javax.swing.Action;
27 import org.openide.nodes.Sheet;
28 import org.openide.util.NbBundle;
36 import org.sleuthkit.datamodel.AbstractFile;
37 
41 public class LocalFileNode extends AbstractAbstractFileNode<AbstractFile> {
42 
43  public LocalFileNode(AbstractFile af) {
44  super(af);
45 
46  this.setDisplayName(af.getName());
47 
48  // set name, display name, and icon
49  if (af.isDir()) {
50  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png"); //NON-NLS
51  } else {
52  this.setIconBaseWithExtension(FileNode.getIconForFileType(af));
53  }
54 
55  }
56 
57  @Override
58  protected Sheet createSheet() {
59  Sheet s = super.createSheet();
60  Sheet.Set ss = s.get(Sheet.PROPERTIES);
61  if (ss == null) {
62  ss = Sheet.createPropertiesSet();
63  s.put(ss);
64  }
65 
66  Map<String, Object> map = new LinkedHashMap<>();
67  fillPropertyMap(map, content);
68 
69  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "LocalFileNode.createSheet.name.name"),
70  NbBundle.getMessage(this.getClass(), "LocalFileNode.createSheet.name.displayName"),
71  NbBundle.getMessage(this.getClass(), "LocalFileNode.createSheet.name.desc"),
72  getName()));
73 
74  final String NO_DESCR = NbBundle.getMessage(this.getClass(), "LocalFileNode.createSheet.noDescr.text");
75  for (Map.Entry<String, Object> entry : map.entrySet()) {
76  ss.put(new NodeProperty<>(entry.getKey(), entry.getKey(), NO_DESCR, entry.getValue()));
77  }
78 
79  // add tags property to the sheet
80  addTagProperty(ss);
81 
82  return s;
83  }
84 
85  @Override
86  public Action[] getActions(boolean context) {
87  List<Action> actionsList = new ArrayList<>();
88  actionsList.addAll(Arrays.asList(super.getActions(true)));
89  actionsList.add(new ViewContextAction(NbBundle.getMessage(this.getClass(), "LocalFileNode.viewFileInDir.text"), this.content));
90  actionsList.add(null); // creates a menu separator
91  actionsList.add(new NewWindowViewAction(
92  NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.viewInNewWin.text"), this));
93  actionsList.add(new ExternalViewerAction(
94  NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.openInExtViewer.text"), this));
95  actionsList.add(null); // creates a menu separator
96  actionsList.add(ExtractAction.getInstance());
97  actionsList.add(new HashSearchAction(
98  NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.searchFilesSameMd5.text"), this));
99  actionsList.add(null); // creates a menu separator
100  actionsList.add(AddContentTagAction.getInstance());
101  actionsList.addAll(ContextMenuExtensionPoint.getActions());
102  return actionsList.toArray(new Action[0]);
103  }
104 
105  @Override
106  public <T> T accept(ContentNodeVisitor<T> v) {
107  return v.visit(this);
108  }
109 
110  @Override
111  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
112  return v.visit(this);
113  }
114 
115  @Override
116  public boolean isLeafTypeNode() {
117  // This seems wrong, but it also seems that it is never called
118  // because the visitor to figure out if there are children or
119  // not will check if it has children using the Content API
120  return true;
121  }
122 
123  @Override
124  public String getItemType() {
125  return getClass().getName();
126  }
127 }
static void fillPropertyMap(Map< String, Object > map, AbstractFile content)
static synchronized ExtractAction getInstance()
static synchronized AddContentTagAction getInstance()

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