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

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