Autopsy  4.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-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.Map;
22 import org.openide.nodes.AbstractNode;
23 import org.openide.nodes.Children;
24 import org.openide.nodes.Sheet;
25 import org.openide.util.Lookup;
26 import org.openide.util.NbBundle;
27 import org.openide.util.lookup.Lookups;
28 import org.sleuthkit.datamodel.AbstractFile;
29 
35 public class KeyValueNode extends AbstractNode {
36 
37  private KeyValue data;
38 
39  public KeyValueNode(KeyValue thing, Children children) {
40  super(children, Lookups.singleton(thing));
41  this.setName(thing.getName());
42  this.data = thing;
43 
44  setIcon();
45  }
46 
47  public KeyValueNode(KeyValue thing, Children children, Lookup lookup) {
48  super(children, lookup);
49  this.setName(thing.getName());
50  this.data = thing;
51 
52  setIcon();
53  }
54 
55  private void setIcon() {
56  //if file/dir, set icon
57  AbstractFile af = Lookup.getDefault().lookup(AbstractFile.class);
58  if (af != null) {
59  // set name, display name, and icon
60  if (af.isDir()) {
61  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png"); //NON-NLS
62  } else {
63  this.setIconBaseWithExtension(FileNode.getIconForFileType(af));
64  }
65 
66  }
67  }
68 
69  @Override
70  protected Sheet createSheet() {
71  Sheet s = super.createSheet();
72  Sheet.Set ss = s.get(Sheet.PROPERTIES);
73  if (ss == null) {
74  ss = Sheet.createPropertiesSet();
75  s.put(ss);
76  }
77 
78  // table view drops first column of properties under assumption
79  // that it contains the node's name
80  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "KeyValueNode.createSheet.name.name"),
81  NbBundle.getMessage(this.getClass(), "KeyValueNode.createSheet.name.displayName"),
82  NbBundle.getMessage(this.getClass(), "KeyValueNode.createSheet.name.desc"),
83  data.getName()));
84 
85  for (Map.Entry<String, Object> entry : data.getMap().entrySet()) {
86  String key = entry.getKey();
87  Object value = entry.getValue();
88  ss.put(new NodeProperty<>(key,
89  key,
90  NbBundle.getMessage(this.getClass(), "KeyValueNode.createSheet.map.desc"),
91  value));
92  }
93 
94  return s;
95  }
96 }
Map< String, Object > getMap()
Definition: KeyValue.java:61
KeyValueNode(KeyValue thing, Children children)
KeyValueNode(KeyValue thing, Children children, Lookup lookup)

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.