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

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