19package org.sleuthkit.autopsy.contentviewers;
21import java.util.Arrays;
23import java.util.Objects;
24import org.openide.nodes.AbstractNode;
25import org.openide.nodes.ChildFactory;
26import org.openide.nodes.Children;
27import org.openide.nodes.Node;
28import org.openide.nodes.Sheet;
29import org.sleuthkit.autopsy.contentviewers.PListViewer.PropKeyValue;
30import org.sleuthkit.autopsy.contentviewers.PListViewer.PropertyType;
31import org.sleuthkit.autopsy.datamodel.NodeProperty;
37class PListRowFactory
extends ChildFactory<Integer> {
39 private final List<PropKeyValue> rows;
41 PListRowFactory(
final List<PropKeyValue> rows) {
52 protected boolean createKeys(
final List<Integer> keys) {
54 for (
int i = 0; i < rows.size(); i++) {
67 protected Node createNodeForKey(
final Integer key) {
68 if (Objects.isNull(rows) || rows.isEmpty() || key >= rows.size()) {
71 return new PListNode(rows.get(key));
78class PListNode
extends AbstractNode {
80 private final PropKeyValue propKeyVal;
82 PListNode(
final PropKeyValue propKeyVal) {
84 super(propKeyVal.getChildren() ==
null ? Children.LEAF :
new PListNodeChildren(propKeyVal.getChildren()));
86 this.propKeyVal = propKeyVal;
88 super.setName(propKeyVal.getKey());
89 super.setDisplayName(propKeyVal.getKey());
90 if (propKeyVal.getType() == PropertyType.ARRAY) {
91 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/keychain-16.png");
92 }
else if (propKeyVal.getType() == PropertyType.DICTIONARY) {
93 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/keys-dict-16.png");
95 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/key-16.png");
104 protected Sheet createSheet() {
106 final Sheet sheet = super.createSheet();
107 Sheet.Set properties = sheet.get(Sheet.PROPERTIES);
108 if (properties ==
null) {
109 properties = Sheet.createPropertiesSet();
110 sheet.put(properties);
113 properties.put(
new NodeProperty<>(Bundle.PListNode_TypeCol(),
114 Bundle.PListNode_TypeCol(),
115 Bundle.PListNode_TypeCol(),
116 propKeyVal.getType().name()));
118 properties.put(
new NodeProperty<>(Bundle.PListNode_ValueCol(),
119 Bundle.PListNode_ValueCol(),
120 Bundle.PListNode_ValueCol(),
121 (propKeyVal.getChildren() ==
null) ? propKeyVal.getValue() :
""));
129 private static class PListNodeChildren
extends Children.Keys<PropKeyValue> {
133 PListNodeChildren(
final PropKeyValue...
children) {
135 this.children = Arrays.asList(
children);
140 super.setKeys(this.children);
145 return new Node[]{
new PListNode(propKeyVal)};
Node[] createNodes(final PropKeyValue propKeyVal)
final List< PropKeyValue > children