This commit is contained in:
Greg DiCristofaro 2021-09-08 14:19:52 -04:00
parent 5170c03bcb
commit 7adfcf4b17
2 changed files with 26 additions and 11 deletions

View File

@ -117,12 +117,13 @@ public class InterestingHits implements AutopsyVisitableItem {
Map<String, Set<Long>> setMapping = interestingItemsMap.getOrDefault(type, Collections.emptyMap()); Map<String, Set<Long>> setMapping = interestingItemsMap.getOrDefault(type, Collections.emptyMap());
setNames = new ArrayList<>(setMapping.keySet()); setNames = new ArrayList<>(setMapping.keySet());
} }
Collections.sort(setNames); Collections.sort(setNames, (a, b) -> a.compareToIgnoreCase(b));
return setNames; return setNames;
} }
/** /**
* Returns all types currently in the map. * Returns all types currently in the map.
*
* @return The types present in the map. * @return The types present in the map.
*/ */
List<BlackboardArtifact.Type> getTypes() { List<BlackboardArtifact.Type> getTypes() {
@ -130,7 +131,7 @@ public class InterestingHits implements AutopsyVisitableItem {
synchronized (interestingItemsMap) { synchronized (interestingItemsMap) {
types = new ArrayList<>(interestingItemsMap.keySet()); types = new ArrayList<>(interestingItemsMap.keySet());
} }
Collections.sort(types, (a,b) -> a.getDisplayName().compareToIgnoreCase(b.getDisplayName())); Collections.sort(types, (a, b) -> a.getDisplayName().compareToIgnoreCase(b.getDisplayName()));
return types; return types;
} }
@ -287,6 +288,17 @@ public class InterestingHits implements AutopsyVisitableItem {
return new SetNameNode(this.type, key); return new SetNameNode(this.type, key);
} }
@Override
protected void addNotify() {
interestingResults.update();
interestingResults.addObserver(this);
}
@Override
protected void finalize() throws Throwable {
interestingResults.deleteObserver(this);
}
@Override @Override
public void update(Observable o, Object arg) { public void update(Observable o, Object arg) {
refresh(true); refresh(true);
@ -318,7 +330,7 @@ public class InterestingHits implements AutopsyVisitableItem {
@Override @Override
public boolean isLeafTypeNode() { public boolean isLeafTypeNode() {
return false; return true;
} }
@Override @Override

View File

@ -1409,7 +1409,7 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat
private Node getInterestingItemNode(Children typesChildren, BlackboardArtifact art) { private Node getInterestingItemNode(Children typesChildren, BlackboardArtifact art) {
Node interestingItemsRootNode = typesChildren.findChild(NbBundle Node interestingItemsRootNode = typesChildren.findChild(NbBundle
.getMessage(InterestingHits.class, "InterestingHits.interestingItems.text")); .getMessage(InterestingHits.class, "InterestingHits.interestingItems.text"));
Children interestingItemsRootChildren = interestingItemsRootNode.getChildren(); Children interestingItemsRootChildren = interestingItemsRootNode.getChildren();
String setName = null; String setName = null;
try { try {
@ -1418,17 +1418,17 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat
.map(attr -> attr.getValueString()) .map(attr -> attr.getValueString())
.findFirst() .findFirst()
.orElse(null); .orElse(null);
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
LOGGER.log(Level.WARNING, "Error retrieving attributes", ex); //NON-NLS LOGGER.log(Level.WARNING, "Error retrieving attributes", ex); //NON-NLS
return null; return null;
} }
// if no set name, no set node will be identified. // if no set name, no set node will be identified.
if (setName == null) { if (setName == null) {
return null; return null;
} }
Stream<Node> typeNodes = interestingItemsRootChildren != null ? Stream.of(interestingItemsRootChildren.getNodes(true)) : Stream.empty(); Stream<Node> typeNodes = interestingItemsRootChildren != null ? Stream.of(interestingItemsRootChildren.getNodes(true)) : Stream.empty();
Children setNodeChildren = typeNodes Children setNodeChildren = typeNodes
@ -1444,10 +1444,13 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat
if (setNodeChildren == null) { if (setNodeChildren == null) {
return null; return null;
} }
// make sure data is fully loaded // make sure data is fully loaded
setNodeChildren.getNodes(true); final String finalSetName = setName;
return interestingItemsRootChildren.findChild(setName); return Stream.of(setNodeChildren.getNodes(true))
.filter(setNode -> finalSetName.equals(setNode.getLookup().lookup(String.class)))
.findFirst()
.orElse(null);
} }
/** /**