This commit is contained in:
Brian Sweeney 2018-06-18 10:49:27 -06:00
parent b8a5bc9b32
commit c3394d9ee7
8 changed files with 24 additions and 32 deletions

View File

@ -24,7 +24,6 @@ import org.openide.nodes.ChildFactory;
import org.openide.nodes.Children; import org.openide.nodes.Children;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.datamodel.DisplayableItemNode; import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor; import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor;
@ -63,7 +62,7 @@ final public class CommonFilesNode extends DisplayableItemNode {
static class InstanceCountNodeFactory extends ChildFactory<Integer>{ static class InstanceCountNodeFactory extends ChildFactory<Integer>{
private CommonFilesMetadata metadata; private final CommonFilesMetadata metadata;
InstanceCountNodeFactory(CommonFilesMetadata metadata){ InstanceCountNodeFactory(CommonFilesMetadata metadata){
this.metadata = metadata; this.metadata = metadata;
@ -77,8 +76,8 @@ final public class CommonFilesNode extends DisplayableItemNode {
@Override @Override
protected Node createNodeForKey(Integer instanceCount){ protected Node createNodeForKey(Integer instanceCount){
List<Md5Metadata> metadata= this.metadata.getMetadataForMd5(instanceCount); List<Md5Metadata> md5Metadata = this.metadata.getMetadataForMd5(instanceCount);
return new InstanceCountNode(instanceCount, metadata); return new InstanceCountNode(instanceCount, md5Metadata);
} }
} }
} }

View File

@ -35,7 +35,6 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer;
import org.sleuthkit.autopsy.corecomponents.DataResultTopComponent; import org.sleuthkit.autopsy.corecomponents.DataResultTopComponent;
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
import org.sleuthkit.autopsy.corecomponents.MultiLayerTableFilterNode; import org.sleuthkit.autopsy.corecomponents.MultiLayerTableFilterNode;
import org.sleuthkit.autopsy.corecomponents.SingleLayerTableFilterNode;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.directorytree.DataResultFilterNode; import org.sleuthkit.autopsy.directorytree.DataResultFilterNode;
@ -243,6 +242,7 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
CommonFilesNode commonFilesNode = new CommonFilesNode(metadata); CommonFilesNode commonFilesNode = new CommonFilesNode(metadata);
//TODO this could be enumerating the children!!!
DataResultFilterNode dataResultFilterNode = new DataResultFilterNode(commonFilesNode, ExplorerManager.find(CommonFilesPanel.this)); DataResultFilterNode dataResultFilterNode = new DataResultFilterNode(commonFilesNode, ExplorerManager.find(CommonFilesPanel.this));
MultiLayerTableFilterNode tableFilterWithDescendantsNode = new MultiLayerTableFilterNode(dataResultFilterNode); MultiLayerTableFilterNode tableFilterWithDescendantsNode = new MultiLayerTableFilterNode(dataResultFilterNode);

View File

@ -34,8 +34,8 @@ import org.sleuthkit.autopsy.directorytree.DataResultFilterNode;
public class MultiLayerTableFilterNode extends FilterNode implements TableFilterNode { public class MultiLayerTableFilterNode extends FilterNode implements TableFilterNode {
private final boolean createChildren; private final boolean createChildren;
private boolean forceUseWrappedDisplayName = false; private final boolean forceUseWrappedDisplayName;
private String columnOrderKey = "NONE"; private static final String columnOrderKey = "NONE";
/** /**
* Constructs a filter node that generates children using * Constructs a filter node that generates children using

View File

@ -33,7 +33,7 @@ import org.sleuthkit.autopsy.directorytree.DataResultFilterNode;
public class SingleLayerTableFilterNode extends FilterNode implements TableFilterNode { public class SingleLayerTableFilterNode extends FilterNode implements TableFilterNode {
private final boolean createChildren; private final boolean createChildren;
private boolean forceUseWrappedDisplayName = false; private final boolean forceUseWrappedDisplayName;
private String columnOrderKey = "NONE"; private String columnOrderKey = "NONE";
/** /**
@ -48,20 +48,9 @@ public class SingleLayerTableFilterNode extends FilterNode implements TableFilte
*/ */
public SingleLayerTableFilterNode(Node node, boolean createChildren) { public SingleLayerTableFilterNode(Node node, boolean createChildren) {
super(node, TableFilterChildren.createInstance(node, createChildren), Lookups.proxy(node)); super(node, TableFilterChildren.createInstance(node, createChildren), Lookups.proxy(node));
this.forceUseWrappedDisplayName = false;
this.createChildren = createChildren; this.createChildren = createChildren;
} }
// /**
// * To be used in TableFilterChildrenWithDescendants.
// *
// * @param node node to wrap
// * @param createChildren node has children?
// * @param forceUseWrappedDisplayName allow use of custom <code>getDisplayName()</code> .
// */
// SingleLayerTableFilterNode(Node node, boolean createChildren, boolean forceUseWrappedDisplayName) {
// super(node, TableFilterChildren.createInstance(node, createChildren), Lookups.proxy(node));
// this.createChildren = createChildren;
// this.forceUseWrappedDisplayName = forceUseWrappedDisplayName;
// }
/** /**
* Constructs a filter node that creates at most one layer of child nodes * Constructs a filter node that creates at most one layer of child nodes
@ -77,6 +66,7 @@ public class SingleLayerTableFilterNode extends FilterNode implements TableFilte
*/ */
public SingleLayerTableFilterNode(Node node, boolean createChildren, String columnOrderKey) { public SingleLayerTableFilterNode(Node node, boolean createChildren, String columnOrderKey) {
super(node, TableFilterChildren.createInstance(node, createChildren)); super(node, TableFilterChildren.createInstance(node, createChildren));
this.forceUseWrappedDisplayName = false;
this.createChildren = createChildren; this.createChildren = createChildren;
this.columnOrderKey = columnOrderKey; this.columnOrderKey = columnOrderKey;
} }
@ -98,6 +88,7 @@ public class SingleLayerTableFilterNode extends FilterNode implements TableFilte
} }
} }
@Override
public String getParentDisplayName() { public String getParentDisplayName() {
return super.getDisplayName(); return super.getDisplayName();
} }
@ -108,6 +99,7 @@ public class SingleLayerTableFilterNode extends FilterNode implements TableFilte
* *
* @param selectedChildNodeInfo The child node selection information. * @param selectedChildNodeInfo The child node selection information.
*/ */
@Override
public void setChildNodeSelectionInfo(NodeSelectionInfo selectedChildNodeInfo) { public void setChildNodeSelectionInfo(NodeSelectionInfo selectedChildNodeInfo) {
/* /*
* Currently, child selection is only supported for nodes selected in * Currently, child selection is only supported for nodes selected in
@ -125,6 +117,7 @@ public class SingleLayerTableFilterNode extends FilterNode implements TableFilte
* @return The child node selection information, or null if no child should * @return The child node selection information, or null if no child should
* be selected. * be selected.
*/ */
@Override
public NodeSelectionInfo getChildNodeSelectionInfo() { public NodeSelectionInfo getChildNodeSelectionInfo() {
/* /*
* Currently, child selection is only supported for nodes selected in * Currently, child selection is only supported for nodes selected in
@ -144,6 +137,7 @@ public class SingleLayerTableFilterNode extends FilterNode implements TableFilte
* DataResultViewerTable. The key should represent what kinds of items the * DataResultViewerTable. The key should represent what kinds of items the
* table is showing. * table is showing.
*/ */
@Override
public String getColumnOrderKey() { public String getColumnOrderKey() {
return columnOrderKey; return columnOrderKey;
} }

View File

@ -90,5 +90,4 @@ class TableFilterChildren extends FilterNode.Children {
protected Node[] createNodes(Node key) { protected Node[] createNodes(Node key) {
return new Node[]{this.copyNode(key)}; return new Node[]{this.copyNode(key)};
} }
} }

View File

@ -25,6 +25,9 @@ import org.sleuthkit.autopsy.datamodel.NodeSelectionInfo;
* Specifies behavior of nodes which are displayed in the DataResultTopComponent. * Specifies behavior of nodes which are displayed in the DataResultTopComponent.
*/ */
public interface TableFilterNode { public interface TableFilterNode {
//TODO DisplayableItemNode
//TODO would be nice if this could be cast to Node - probably not totally critical...
/** /**
* Gets information about which child node of this node, if any, should be * Gets information about which child node of this node, if any, should be

View File

@ -19,6 +19,7 @@
*/ */
package org.sleuthkit.autopsy.datamodel; package org.sleuthkit.autopsy.datamodel;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -29,7 +30,6 @@ import org.openide.nodes.Children;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.commonfilesearch.Md5Metadata; import org.sleuthkit.autopsy.commonfilesearch.Md5Metadata;
/** /**
@ -54,7 +54,7 @@ final public class InstanceCountNode extends DisplayableItemNode {
} }
List<Md5Metadata> getMetadata() { List<Md5Metadata> getMetadata() {
return this.metadataList; return Collections.unmodifiableList(this.metadataList);
} }
@Override @Override
@ -101,7 +101,7 @@ final public class InstanceCountNode extends DisplayableItemNode {
* @param node The item to get properties for. * @param node The item to get properties for.
*/ */
static private void fillPropertyMap(Map<String, Object> map, InstanceCountNode node) { static private void fillPropertyMap(Map<String, Object> map, InstanceCountNode node) {
map.put(InstanceCountNodePropertyType.Match.toString(), node.instanceCount); map.put(InstanceCountNodePropertyType.Match.toString(), node.getInstanceCount());
} }
@NbBundle.Messages({ @NbBundle.Messages({
@ -133,7 +133,7 @@ final public class InstanceCountNode extends DisplayableItemNode {
* List of models, each of which is a parent node matching a single md5, * List of models, each of which is a parent node matching a single md5,
* containing children FileNodes. * containing children FileNodes.
*/ */
private Map<String, Md5Metadata> metadata; private final Map<String, Md5Metadata> metadata;
Md5NodeFactory(List<Md5Metadata> metadata) { Md5NodeFactory(List<Md5Metadata> metadata) {
this.metadata = new HashMap<>(); this.metadata = new HashMap<>();
@ -147,8 +147,8 @@ final public class InstanceCountNode extends DisplayableItemNode {
@Override @Override
protected Node createNodeForKey(String md5) { protected Node createNodeForKey(String md5) {
Md5Metadata metadata = this.metadata.get(md5); Md5Metadata md5Metadata = this.metadata.get(md5);
return new Md5Node(metadata); return new Md5Node(md5Metadata);
} }
@Override @Override
@ -157,4 +157,4 @@ final public class InstanceCountNode extends DisplayableItemNode {
return true; return true;
} }
} }
} }

View File

@ -28,7 +28,6 @@ import org.openide.nodes.Children;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.commonfilesearch.FileInstanceMetadata; import org.sleuthkit.autopsy.commonfilesearch.FileInstanceMetadata;
@ -143,9 +142,7 @@ public class Md5Node extends DisplayableItemNode {
AbstractFile abstractFile = tskDb.findAllFilesWhere(String.format("obj_id in (%s)", file.getObjectId())).get(0); AbstractFile abstractFile = tskDb.findAllFilesWhere(String.format("obj_id in (%s)", file.getObjectId())).get(0);
return new FileInstanceNode(abstractFile, file.getDataSourceName()); return new FileInstanceNode(abstractFile, file.getDataSourceName());
} catch (NoCurrentCaseException ex) { } catch (NoCurrentCaseException | TskCoreException ex) {
LOGGER.log(Level.SEVERE, String.format("Unable to create node for file with obj_id: %s.", new Object[]{file.getObjectId()}), ex);
} catch (TskCoreException ex) {
LOGGER.log(Level.SEVERE, String.format("Unable to create node for file with obj_id: %s.", new Object[]{file.getObjectId()}), ex); LOGGER.log(Level.SEVERE, String.format("Unable to create node for file with obj_id: %s.", new Object[]{file.getObjectId()}), ex);
} }
return null; return null;