Autopsy  4.5.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
KeyValueNode.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.Arrays;
23 import java.util.List;
24 import java.util.Map;
25 import javax.swing.Action;
26 import org.openide.nodes.AbstractNode;
27 import org.openide.nodes.Children;
28 import org.openide.nodes.Sheet;
29 import org.openide.util.Lookup;
30 import org.openide.util.NbBundle;
31 import org.openide.util.lookup.Lookups;
33 import org.sleuthkit.datamodel.AbstractFile;
34 
40 public class KeyValueNode extends AbstractNode {
41 
42  private KeyValue data;
43 
44  public KeyValueNode(KeyValue thing, Children children) {
45  super(children, Lookups.singleton(thing));
46  this.setName(thing.getName());
47  this.data = thing;
48 
49  setIcon();
50  }
51 
52  public KeyValueNode(KeyValue thing, Children children, Lookup lookup) {
53  super(children, lookup);
54  this.setName(thing.getName());
55  this.data = thing;
56 
57  setIcon();
58  }
59 
60  private void setIcon() {
61  //if file/dir, set icon
62  AbstractFile af = Lookup.getDefault().lookup(AbstractFile.class);
63  if (af != null) {
64  // set name, display name, and icon
65  if (af.isDir()) {
66  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png"); //NON-NLS
67  } else {
68  this.setIconBaseWithExtension(FileNode.getIconForFileType(af));
69  }
70 
71  }
72  }
73 
74  @Override
75  protected Sheet createSheet() {
76  Sheet s = super.createSheet();
77  Sheet.Set ss = s.get(Sheet.PROPERTIES);
78  if (ss == null) {
79  ss = Sheet.createPropertiesSet();
80  s.put(ss);
81  }
82 
83  // table view drops first column of properties under assumption
84  // that it contains the node's name
85  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "KeyValueNode.createSheet.name.name"),
86  NbBundle.getMessage(this.getClass(), "KeyValueNode.createSheet.name.displayName"),
87  NbBundle.getMessage(this.getClass(), "KeyValueNode.createSheet.name.desc"),
88  data.getName()));
89 
90  for (Map.Entry<String, Object> entry : data.getMap().entrySet()) {
91  String key = entry.getKey();
92  Object value = entry.getValue();
93  ss.put(new NodeProperty<>(key,
94  key,
95  NbBundle.getMessage(this.getClass(), "KeyValueNode.createSheet.map.desc"),
96  value));
97  }
98 
99  return s;
100  }
101 
110  @Override
111  public Action[] getActions(boolean popup) {
112  List<Action> actions = new ArrayList<>();
113  actions.addAll(Arrays.asList(super.getActions(popup)));
114  //if this artifact has associated content, add the action to view the content in the timeline
115  AbstractFile file = getLookup().lookup(AbstractFile.class);
116  if (null != file) {
118  }
119  actions.add(null); // creates a menu separator
120 
121  return actions.toArray(new Action[actions.size()]);
122  }
123 }
Map< String, Object > getMap()
Definition: KeyValue.java:61
static ViewFileInTimelineAction createViewSourceFileAction(AbstractFile file)
KeyValueNode(KeyValue thing, Children children)
KeyValueNode(KeyValue thing, Children children, Lookup lookup)

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