diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonAttributeValueList.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonAttributeValueList.java index f86f4c23ff..4797dbfd94 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonAttributeValueList.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonAttributeValueList.java @@ -30,7 +30,15 @@ import java.util.List; */ final public class CommonAttributeValueList { + /** + * The list of value nodes, which begins empty. + */ private final List metadataList; + + /** + * The backing list of value nodes, which will be dynamically loaded + * when requested. + */ private final List delayedMetadataList; /** @@ -49,21 +57,41 @@ final public class CommonAttributeValueList { this.delayedMetadataList = new ArrayList<>(); } + /** + * Get the list of value nodes. Will be empty if + * displayDelayedMetadata() has not been called for the + * parent InstanceCountNode + * @return metadataList the list of nodes + */ public List getMetadataList() { return Collections.unmodifiableList(this.metadataList); } - public int getCommonAttributeListSize() { + /** + * Return the size of the backing list, in case + * displayDelayedMetadata() has not be called yet. + * @return int the number of matches for this value + */ + int getCommonAttributeListSize() { return this.delayedMetadataList.size(); } + /** + * Dynamically load the list CommonAttributeValue when called. Until called + * metadataList should be empty. The parent node, InstanceCountNode, will + * trigger the factory call and refresh. + */ public void displayDelayedMetadata() { if (metadataList.isEmpty()) { this.metadataList.addAll(this.delayedMetadataList); } } - public void addMetadataToList(CommonAttributeValue metadata) { + /** + * A a value node to the list, to be loaded later. + * @param metadata the node to add + */ + void addMetadataToList(CommonAttributeValue metadata) { delayedMetadataList.add(metadata); } } diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/InstanceCountNode.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/InstanceCountNode.java index b662102fc9..fa298c121d 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/InstanceCountNode.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/InstanceCountNode.java @@ -23,9 +23,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.logging.Level; -import javax.swing.SwingWorker; import org.openide.nodes.ChildFactory; import org.openide.nodes.Children; import org.openide.nodes.Node; @@ -76,26 +73,14 @@ final public class InstanceCountNode extends DisplayableItemNode { return this.instanceCount; } + /** + * Refresh the node, by dynamically loading in the children when called, and + * calling the CommonAttributeValueNodeFactory to generate nodes for the + * children in attributeValues. + */ public void refresh() { - new SwingWorker() { - - @Override - protected Void doInBackground() throws Exception { - attributeValues.displayDelayedMetadata(); - setChildren(Children.create(new CommonAttributeValueNodeFactory(attributeValues.getMetadataList()), false)); - return null; - } - - @Override - protected void done() { - super.done(); - try { - get(); - } catch (InterruptedException | ExecutionException ex) { - logger.log(Level.SEVERE, "Unexpected exception while loading common search result instances", ex); //NON-NLS - } - } - }.execute(); + attributeValues.displayDelayedMetadata(); + setChildren(Children.create(new CommonAttributeValueNodeFactory(attributeValues.getMetadataList()), true)); } /** @@ -147,7 +132,7 @@ final public class InstanceCountNode extends DisplayableItemNode { /** * ChildFactory which builds CommonFileParentNodes from the - * CommonFilesMetaaData models. + * CommonAttributeValue metadata models. */ static class CommonAttributeValueNodeFactory extends ChildFactory { diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DelayedLoadChildNodesOnTreeExpansion.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DelayedLoadChildNodesOnTreeExpansion.java index a66f4a876a..6e6d28af2a 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DelayedLoadChildNodesOnTreeExpansion.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DelayedLoadChildNodesOnTreeExpansion.java @@ -39,7 +39,7 @@ public final class DelayedLoadChildNodesOnTreeExpansion implements TreeExpansion @Override public synchronized void treeCollapsed(final TreeExpansionEvent event) { - + // Do nothing on collapse. Netbeans should manage nodes falling out of scope and GC. } @Override diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/TableFilterNode.java b/Core/src/org/sleuthkit/autopsy/corecomponents/TableFilterNode.java index 890fb4ace3..2ba02f694a 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/TableFilterNode.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/TableFilterNode.java @@ -129,6 +129,10 @@ public class TableFilterNode extends FilterNode { } } + /** + * Refreshes the inner node, which depending on the actual node type that was wrapped + * could trigger a dynamic refresh of the children, if supported. + */ void refresh() { DataResultFilterNode innerNode = getLookup().lookup(DataResultFilterNode.class); innerNode.refresh(); diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java b/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java index c639a96672..c94ad57094 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java @@ -140,6 +140,11 @@ public class DataResultFilterNode extends FilterNode { this.sourceEm = em; } + /** + * Refreshes the inner node. If the actual underlying node is an InstanceCountNode, + * refresh() that node, which refreshes the children. + * + */ public void refresh() { if (getOriginal() instanceof InstanceCountNode) { InstanceCountNode innerNode = getLookup().lookup(InstanceCountNode.class); diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/InterCaseTestUtils.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/InterCaseTestUtils.java index cf6bd36fbc..0feb32ee4c 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/InterCaseTestUtils.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/InterCaseTestUtils.java @@ -57,6 +57,7 @@ import org.sleuthkit.autopsy.commonfilesearch.CentralRepoCommonAttributeInstance import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeSearchResults; import org.sleuthkit.autopsy.commonfilesearch.DataSourceLoader; import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeValue; +import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeValueList; import org.sleuthkit.autopsy.datamodel.DisplayableItemNode; import org.sleuthkit.datamodel.AbstractFile; @@ -309,9 +310,9 @@ class InterCaseTestUtils { int tally = 0; - for(Map.Entry> entry : searchDomain.getMetadata().entrySet()){ - - for(CommonAttributeValue value : entry.getValue()){ + for(Map.Entry entry : searchDomain.getMetadata().entrySet()){ + entry.getValue().displayDelayedMetadata(); + for(CommonAttributeValue value : entry.getValue().getMetadataList()) { for(AbstractCommonAttributeInstance commonAttribute : value.getInstances()){ diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/IntraCaseTestUtils.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/IntraCaseTestUtils.java index 82c38cdf56..b03e6b2dfa 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/IntraCaseTestUtils.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/IntraCaseTestUtils.java @@ -37,6 +37,7 @@ import org.sleuthkit.autopsy.commonfilesearch.AbstractCommonAttributeInstance; import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeSearchResults; import org.sleuthkit.autopsy.commonfilesearch.DataSourceLoader; import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeValue; +import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeValueList; import org.sleuthkit.autopsy.testutils.CaseUtils; import org.sleuthkit.autopsy.testutils.IngestUtils; import org.sleuthkit.datamodel.AbstractFile; @@ -205,8 +206,9 @@ class IntraCaseTestUtils { static Map mapFileInstancesToDataSources(CommonAttributeSearchResults metadata) { Map instanceIdToDataSource = new HashMap<>(); - for (Map.Entry> entry : metadata.getMetadata().entrySet()) { - for (CommonAttributeValue md : entry.getValue()) { + for (Map.Entry entry : metadata.getMetadata().entrySet()) { + entry.getValue().displayDelayedMetadata(); + for (CommonAttributeValue md : entry.getValue().getMetadataList()) { for (AbstractCommonAttributeInstance fim : md.getInstances()) { instanceIdToDataSource.put(fim.getAbstractFileObjectId(), fim.getDataSource()); }