19 package org.sleuthkit.autopsy.contentviewers;
 
   21 import java.util.Arrays;
 
   22 import java.util.List;
 
   23 import java.util.Objects;
 
   24 import org.openide.nodes.AbstractNode;
 
   25 import org.openide.nodes.ChildFactory;
 
   26 import org.openide.nodes.Children;
 
   27 import org.openide.nodes.Node;
 
   28 import org.openide.nodes.Sheet;
 
   37 class 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));
 
   78 class 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() : 
"")); 
 
  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