Autopsy  3.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;
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 
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  return s;
90  }
91 
92  @Override
93  public <T> T accept(ContentNodeVisitor<T> v) {
94  return v.visit(this);
95  }
96 
97  @Override
98  public boolean isLeafTypeNode() {
99  return false;
100  }
101 
102  @Override
103  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
104  return v.visit(this);
105  }
106 
107  @Override
108  public Action[] getActions(boolean context) {
109  List<Action> actionsList = new ArrayList<>();
110  actionsList.add(new NewWindowViewAction(
111  NbBundle.getMessage(this.getClass(), "LayoutFileNode.getActions.viewInNewWin.text"), this));
112  actionsList.add(new ExternalViewerAction(
113  NbBundle.getMessage(this.getClass(), "LayoutFileNode.getActions.openInExtViewer.text"), this));
114  actionsList.add(null); // creates a menu separator
115  actionsList.add(ExtractAction.getInstance());
116  actionsList.add(null); // creates a menu separator
117  actionsList.add(AddContentTagAction.getInstance());
118  actionsList.addAll(ContextMenuExtensionPoint.getActions());
119  return actionsList.toArray(new Action[0]);
120  }
121 
122  private static void fillPropertyMap(Map<String, Object> map, LayoutFile content) {
124  map.put(LayoutContentPropertyType.PARTS.toString(), content.getNumParts());
125  }
126 }
TskData.TSK_DB_FILES_TYPE_ENUM getType()
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-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.