Autopsy  4.6.0
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-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.Collection;
23 import java.util.HashSet;
24 import java.util.LinkedHashMap;
25 import java.util.List;
26 import java.util.Map;
27 import javax.swing.Action;
28 import org.openide.nodes.Sheet;
29 import org.openide.util.NbBundle;
30 import org.openide.util.Utilities;
37 import org.sleuthkit.datamodel.AbstractFile;
38 import org.sleuthkit.datamodel.LayoutFile;
39 import org.sleuthkit.datamodel.TskData;
40 
44 public class LayoutFileNode extends AbstractAbstractFileNode<LayoutFile> {
45 
46  public static enum LayoutContentPropertyType {
47 
48  PARTS {
49  @Override
50  public String toString() {
51  return NbBundle.getMessage(this.getClass(), "LayoutFileNode.propertyType.parts");
52  }
53  }
54  }
55 
56  public static String nameForLayoutFile(LayoutFile lf) {
57  return lf.getName();
58  }
59 
60  public LayoutFileNode(LayoutFile lf) {
61  super(lf);
62 
63  this.setDisplayName(nameForLayoutFile(lf));
64 
65  if (lf.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.CARVED)) {
66  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/carved-file-icon-16.png"); //NON-NLS
67  } else {
68  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon-deleted.png"); //NON-NLS
69  }
70  }
71 
72  @Override
73  protected Sheet createSheet() {
74  Sheet sheet = super.createSheet();
75  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
76  if (sheetSet == null) {
77  sheetSet = Sheet.createPropertiesSet();
78  sheet.put(sheetSet);
79  }
80 
81  Map<String, Object> map = new LinkedHashMap<>();
82  fillPropertyMap(map);
83 
84  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.name.name"),
85  NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.name.displayName"),
86  NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.name.desc"),
87  getName()));
88 
89  final String NO_DESCR = NbBundle.getMessage(this.getClass(), "LayoutFileNode.createSheet.noDescr.text");
90  for (Map.Entry<String, Object> entry : map.entrySet()) {
91  sheetSet.put(new NodeProperty<>(entry.getKey(), entry.getKey(), NO_DESCR, entry.getValue()));
92  }
93 
94  // add tags property to the sheet
95  addTagProperty(sheetSet);
96 
97  return sheet;
98  }
99 
100  @Override
101  public <T> T accept(ContentNodeVisitor<T> visitor) {
102  return visitor.visit(this);
103  }
104 
105  @Override
106  public boolean isLeafTypeNode() {
107  return false;
108  }
109 
110  @Override
111  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
112  return visitor.visit(this);
113  }
114 
115  @Override
116  public Action[] getActions(boolean context) {
117  List<Action> actionsList = new ArrayList<>();
118  for (Action a : super.getActions(true)) {
119  actionsList.add(a);
120  }
121  actionsList.add(new NewWindowViewAction(
122  NbBundle.getMessage(this.getClass(), "LayoutFileNode.getActions.viewInNewWin.text"), this));
123  actionsList.add(new ExternalViewerAction(
124  NbBundle.getMessage(this.getClass(), "LayoutFileNode.getActions.openInExtViewer.text"), this));
125  actionsList.add(null); // creates a menu separator
126  actionsList.add(ExtractAction.getInstance());
127  actionsList.add(null); // creates a menu separator
128  actionsList.add(AddContentTagAction.getInstance());
129 
130  final Collection<AbstractFile> selectedFilesList =
131  new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
132  if(selectedFilesList.size() == 1) {
133  actionsList.add(DeleteFileContentTagAction.getInstance());
134  }
135 
136  actionsList.addAll(ContextMenuExtensionPoint.getActions());
137  return actionsList.toArray(new Action[actionsList.size()]);
138  }
139 
140 
141  void fillPropertyMap(Map<String, Object> map) {
142  AbstractAbstractFileNode.fillPropertyMap(map, getContent());
143  map.put(LayoutContentPropertyType.PARTS.toString(), content.getNumParts());
144  }
145 
146  @Override
147  public String getItemType() {
148  return getClass().getName();
149  }
150 
151 }
static void fillPropertyMap(Map< String, Object > map, AbstractFile content)
static synchronized ExtractAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
static String nameForLayoutFile(LayoutFile lf)
static synchronized AddContentTagAction getInstance()

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