Autopsy  3.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;
36 
40 public class LocalFileNode extends AbstractAbstractFileNode<AbstractFile> {
41 
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  actionsList.add(new ViewContextAction(NbBundle.getMessage(this.getClass(), "LocalFileNode.viewFileInDir.text"), this.content));
86  actionsList.add(null); // creates a menu separator
87  actionsList.add(new NewWindowViewAction(
88  NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.viewInNewWin.text"), this));
89  actionsList.add(new ExternalViewerAction(
90  NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.openInExtViewer.text"), this));
91  actionsList.add(null); // creates a menu separator
92  actionsList.add(ExtractAction.getInstance());
93  actionsList.add(new HashSearchAction(
94  NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.searchFilesSameMd5.text"), this));
95  actionsList.add(null); // creates a menu separator
96  actionsList.add(AddContentTagAction.getInstance());
97  actionsList.addAll(ContextMenuExtensionPoint.getActions());
98  return actionsList.toArray(new Action[0]);
99  }
100 
101  @Override
102  public <T> T accept(ContentNodeVisitor<T> v) {
103  return v.visit(this);
104  }
105 
106  @Override
107  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
108  return v.visit(this);
109  }
110 
111  @Override
112  public boolean isLeafTypeNode() {
113  // This seems wrong, but it also seems that it is never called
114  // because the visitor to figure out if there are children or
115  // not will check if it has children using the Content API
116  return true;
117  }
118 }
static void fillPropertyMap(Map< String, Object > map, AbstractFile content)
static synchronized ExtractAction getInstance()
static synchronized AddContentTagAction getInstance()

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