Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
LayoutFileNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-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;
33 import org.sleuthkit.datamodel.LayoutFile;
34 import org.sleuthkit.datamodel.TskData;
35 
39 public class LayoutFileNode extends AbstractAbstractFileNode<LayoutFile> {
40 
41  public static enum LayoutContentPropertyType {
42 
43  PARTS {
44  @Override
45  public String toString() {
46  return NbBundle.getMessage(this.getClass(), "LayoutFileNode.propertyType.parts");
47  }
48  }
49  }
50 
51  public static String nameForLayoutFile(LayoutFile lf) {
52  return lf.getName();
53  }
54 
55  public LayoutFileNode(LayoutFile lf) {
56  super(lf);
57 
58  this.setDisplayName(nameForLayoutFile(lf));
59 
60  if (lf.getType().equals(TskData.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  }
66 
67  @Override
68  protected Sheet createSheet() {
69  Sheet s = super.createSheet();
70  Sheet.Set ss = s.get(Sheet.PROPERTIES);
71  if (ss == null) {
72  ss = Sheet.createPropertiesSet();
73  s.put(ss);
74  }
75 
76  Map<String, Object> map = new LinkedHashMap<>();
77  fillPropertyMap(map, content);
78 
79  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.name.name"),
80  NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.name.displayName"),
81  NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.name.desc"),
82  getName()));
83 
84  final String NO_DESCR = NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.noDescr.text");
85  for (Map.Entry<String, Object> entry : map.entrySet()) {
86  ss.put(new NodeProperty<>(entry.getKey(), entry.getKey(), NO_DESCR, entry.getValue()));
87  }
88 
89  // add tags property to the sheet
90  addTagProperty(ss);
91 
92  return s;
93  }
94 
95  @Override
96  public <T> T accept(ContentNodeVisitor<T> v) {
97  return v.visit(this);
98  }
99 
100  @Override
101  public boolean isLeafTypeNode() {
102  return false;
103  }
104 
105  @Override
106  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
107  return v.visit(this);
108  }
109 
110  @Override
111  public Action[] getActions(boolean context) {
112  List<Action> actionsList = new ArrayList<>();
113  for (Action a : super.getActions(true)) {
114  actionsList.add(a);
115  }
116  actionsList.add(new NewWindowViewAction(
117  NbBundle.getMessage(this.getClass(), "LayoutFileNode.getActions.viewInNewWin.text"), this));
118  actionsList.add(new ExternalViewerAction(
119  NbBundle.getMessage(this.getClass(), "LayoutFileNode.getActions.openInExtViewer.text"), this));
120  actionsList.add(null); // creates a menu separator
121  actionsList.add(ExtractAction.getInstance());
122  actionsList.add(null); // creates a menu separator
123  actionsList.add(AddContentTagAction.getInstance());
124  actionsList.addAll(ContextMenuExtensionPoint.getActions());
125  return actionsList.toArray(new Action[0]);
126  }
127 
128  private static void fillPropertyMap(Map<String, Object> map, LayoutFile content) {
130  map.put(LayoutContentPropertyType.PARTS.toString(), content.getNumParts());
131  }
132 
133  @Override
134  public String getItemType() {
135  return getClass().getName();
136  }
137 
138 }
static void fillPropertyMap(Map< String, Object > map, AbstractFile content)
static synchronized ExtractAction getInstance()
static String nameForLayoutFile(LayoutFile lf)
static void fillPropertyMap(Map< String, Object > map, LayoutFile content)
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.