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  /*
42  * TODO (AUT-1849): Correct or remove peristent column reordering code
43  *
44  * Added to support this feature.
45  */
46 // @Override
47 // public String getItemType() {
48 // return "LayoutFile"; //NON-NLS
49 // }
50  public static enum LayoutContentPropertyType {
51 
52  PARTS {
53  @Override
54  public String toString() {
55  return NbBundle.getMessage(this.getClass(), "LayoutFileNode.propertyType.parts");
56  }
57  }
58  }
59 
60  public static String nameForLayoutFile(LayoutFile lf) {
61  return lf.getName();
62  }
63 
64  public LayoutFileNode(LayoutFile lf) {
65  super(lf);
66 
67  this.setDisplayName(nameForLayoutFile(lf));
68 
69  if (lf.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.CARVED)) {
70  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/carved-file-icon-16.png"); //NON-NLS
71  } else {
72  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon-deleted.png"); //NON-NLS
73  }
74  }
75 
76  @Override
77  protected Sheet createSheet() {
78  Sheet s = super.createSheet();
79  Sheet.Set ss = s.get(Sheet.PROPERTIES);
80  if (ss == null) {
81  ss = Sheet.createPropertiesSet();
82  s.put(ss);
83  }
84 
85  Map<String, Object> map = new LinkedHashMap<>();
86  fillPropertyMap(map, content);
87 
88  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.name.name"),
89  NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.name.displayName"),
90  NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.name.desc"),
91  getName()));
92 
93  final String NO_DESCR = NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.noDescr.text");
94  for (Map.Entry<String, Object> entry : map.entrySet()) {
95  ss.put(new NodeProperty<>(entry.getKey(), entry.getKey(), NO_DESCR, entry.getValue()));
96  }
97 
98  return s;
99  }
100 
101  @Override
102  public <T> T accept(ContentNodeVisitor<T> v) {
103  return v.visit(this);
104  }
105 
106  @Override
107  public boolean isLeafTypeNode() {
108  return false;
109  }
110 
111  @Override
112  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
113  return v.visit(this);
114  }
115 
116  @Override
117  public Action[] getActions(boolean context) {
118  List<Action> actionsList = new ArrayList<>();
119  for (Action a : super.getActions(true)) {
120  actionsList.add(a);
121  }
122  actionsList.add(new NewWindowViewAction(
123  NbBundle.getMessage(this.getClass(), "LayoutFileNode.getActions.viewInNewWin.text"), this));
124  actionsList.add(new ExternalViewerAction(
125  NbBundle.getMessage(this.getClass(), "LayoutFileNode.getActions.openInExtViewer.text"), this));
126  actionsList.add(null); // creates a menu separator
127  actionsList.add(ExtractAction.getInstance());
128  actionsList.add(null); // creates a menu separator
129  actionsList.add(AddContentTagAction.getInstance());
130  actionsList.addAll(ContextMenuExtensionPoint.getActions());
131  return actionsList.toArray(new Action[0]);
132  }
133 
134  private static void fillPropertyMap(Map<String, Object> map, LayoutFile content) {
136  map.put(LayoutContentPropertyType.PARTS.toString(), content.getNumParts());
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: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.