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

Copyright © 2012-2018 Basis Technology. Generated on: Thu Oct 4 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.