19 package org.sleuthkit.autopsy.contentviewers;
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.List;
25 import java.util.Objects;
26 import javax.swing.Action;
27 import org.openide.nodes.AbstractNode;
28 import org.openide.nodes.ChildFactory;
29 import org.openide.nodes.Children;
30 import org.openide.nodes.Node;
31 import org.openide.nodes.Sheet;
38 class SQLiteTableRowFactory
extends ChildFactory<Integer> {
40 private final List<Map<String, Object>> rows;
41 private final List<Action> colActions;
43 SQLiteTableRowFactory(List<Map<String, Object>> rows, List<Action> actions ) {
45 this.colActions = actions;
49 protected boolean createKeys(List<Integer> keys) {
51 for (
int i = 0; i < rows.size(); i++) {
59 protected Node createNodeForKey(Integer key) {
60 if (Objects.isNull(rows) || rows.isEmpty() || key >= rows.size()) {
64 return new SQLiteTableRowNode(rows.get(key), this.colActions );
73 class SQLiteTableRowNode
extends AbstractNode {
75 private final Map<String, Object> row;
76 private final List<Action> nodeActions;
78 SQLiteTableRowNode(Map<String, Object> row, List<Action> actions) {
81 this.nodeActions = actions;
85 protected Sheet createSheet() {
87 Sheet sheet = super.createSheet();
88 Sheet.Set properties = sheet.get(Sheet.PROPERTIES);
89 if (properties == null) {
90 properties = Sheet.createPropertiesSet();
91 sheet.put(properties);
94 for (Map.Entry<String, Object> col : row.entrySet()) {
95 String colName = col.getKey();
96 String colVal = col.getValue().toString();
97 properties.put(
new NodeProperty<>(colName, colName, colName, colVal));
104 public Action[] getActions(
boolean context) {
105 List<Action> actions =
new ArrayList<>();
107 actions.addAll(Arrays.asList(super.getActions(context)));
108 actions.addAll(nodeActions);
110 return actions.toArray(
new Action[actions.size()]);