diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonAttributesSearchResultsViewerTable.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonAttributesSearchResultsViewerTable.java index 97a41b27bef1451bf8769c83d7d55eb90e7ff494..a33e23ffa019f84eb09b7a022611660c82cf3706 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonAttributesSearchResultsViewerTable.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonAttributesSearchResultsViewerTable.java @@ -29,7 +29,6 @@ import javax.swing.table.TableColumnModel; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; -import org.sleuthkit.autopsy.corecomponents.DelayedLoadChildNodesOnTreeExpansion; /** * <code>DataResultViewerTable</code> which overrides the default column @@ -70,7 +69,7 @@ public class CommonAttributesSearchResultsViewerTable extends DataResultViewerTa */ public CommonAttributesSearchResultsViewerTable() { super(); - outlineView.addTreeExpansionListener(new DelayedLoadChildNodesOnTreeExpansion()); + outlineView.addTreeExpansionListener(new InstanceCountNodeTreeExpansionListener()); } @NbBundle.Messages({ diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/InstanceCountNode.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/InstanceCountNode.java index fa298c121d15f77dbcd43fa5a3ee83a21c448664..93de3267d0302abb12aaca6d8d8d5fd8da2c0ace 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/InstanceCountNode.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/InstanceCountNode.java @@ -1,16 +1,16 @@ /* - * + * * Autopsy Forensic Browser - * + * * Copyright 2018 Basis Technology Corp. * Contact: carrier <at> sleuthkit <dot> org - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,7 +37,7 @@ * Node used to indicate the number of matches found with the MD5 children of * this Node. */ -final public class InstanceCountNode extends DisplayableItemNode { +public final class InstanceCountNode extends DisplayableItemNode { private static final Logger logger = Logger.getLogger(InstanceCountNode.class.getName()); @@ -74,11 +74,10 @@ int getInstanceCount() { } /** - * Refresh the node, by dynamically loading in the children when called, and - * calling the CommonAttributeValueNodeFactory to generate nodes for the - * children in attributeValues. + * Creates the Children of this node. By doing this here instead of in the + * constructor, lazy creation of the Children is made possible. */ - public void refresh() { + void createChildren() { attributeValues.displayDelayedMetadata(); setChildren(Children.create(new CommonAttributeValueNodeFactory(attributeValues.getMetadataList()), true)); } diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DelayedLoadChildNodesOnTreeExpansion.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/InstanceCountNodeTreeExpansionListener.java similarity index 52% rename from Core/src/org/sleuthkit/autopsy/corecomponents/DelayedLoadChildNodesOnTreeExpansion.java rename to Core/src/org/sleuthkit/autopsy/commonfilesearch/InstanceCountNodeTreeExpansionListener.java index 6e6d28af2ac5eeefa1bd4b9e4b94ee048ab0ee83..3de4d44b7f75cd20a32554acd318d2c57621e8f9 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DelayedLoadChildNodesOnTreeExpansion.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/InstanceCountNodeTreeExpansionListener.java @@ -1,54 +1,54 @@ /* - * + * * Autopsy Forensic Browser - * + * * Copyright 2018 Basis Technology Corp. * Contact: carrier <at> sleuthkit <dot> org - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -package org.sleuthkit.autopsy.corecomponents; +package org.sleuthkit.autopsy.commonfilesearch; import javax.swing.event.TreeExpansionEvent; import javax.swing.event.TreeExpansionListener; import org.openide.explorer.view.Visualizer; import org.openide.nodes.Node; +import org.sleuthkit.autopsy.corecomponents.TableFilterNode; +import org.sleuthkit.autopsy.directorytree.DataResultFilterNode; /** - * A tree expansion listener that will trigger a recreation of childs through - * its child factory on re-expansion of a node (causes to recreate the - * ChildFactory for this purpose.). + * A tree expansion listener used to do lazy creation of the Childfren of an + * InstanceCountNode when the node is expanded. */ -public final class DelayedLoadChildNodesOnTreeExpansion implements TreeExpansionListener { - - /** - * A flag for avoiding endless recursion inside the expansion listener that - * could trigger collapsing and (re-)expanding nodes again. - * @param event - */ +final class InstanceCountNodeTreeExpansionListener implements TreeExpansionListener { @Override public synchronized void treeCollapsed(final TreeExpansionEvent event) { - // Do nothing on collapse. Netbeans should manage nodes falling out of scope and GC. } @Override public synchronized void treeExpanded(final TreeExpansionEvent event) { - Node eventNode = Visualizer.findNode(event.getPath().getLastPathComponent()); + final Node eventNode = Visualizer.findNode(event.getPath().getLastPathComponent()); if (eventNode instanceof TableFilterNode) { - final TableFilterNode node = (TableFilterNode) eventNode; - node.refresh(); + final TableFilterNode tableFilterNode = (TableFilterNode) eventNode; + final DataResultFilterNode dataResultFilterNode = tableFilterNode.getLookup().lookup(DataResultFilterNode.class); + if (dataResultFilterNode != null) { + final InstanceCountNode instanceCountNode = dataResultFilterNode.getLookup().lookup(InstanceCountNode.class); + if (instanceCountNode != null) { + instanceCountNode.createChildren(); + } + } } - } + } diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/TableFilterNode.java b/Core/src/org/sleuthkit/autopsy/corecomponents/TableFilterNode.java index 2ba02f694aa324d14ad38982c19824762ce71d1f..eb36cf2e8747ae034f7e2c101be0eed8fbe39c42 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/TableFilterNode.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/TableFilterNode.java @@ -128,16 +128,6 @@ public NodeSelectionInfo getChildNodeSelectionInfo() { return null; } } - - /** - * 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(); - - } /** * @return the column order key, which allows custom column ordering to be diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java b/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java index c94ad5709428363d0298510f9a1fc72c11adb9f0..3a27f9fa9bba980d25ce998402da3ed4e31939db 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java @@ -140,18 +140,6 @@ public DataResultFilterNode(Node node, ExplorerManager em) { 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); - innerNode.refresh(); - } - } - /** * Constructs a node used to wrap another node before passing it to the * result viewers. The wrapper node defines the actions associated with the