From accf9a6133841773df5e89de9a86dce0147d79a3 Mon Sep 17 00:00:00 2001 From: adam-m Date: Thu, 29 Dec 2011 13:50:14 -0500 Subject: [PATCH] Add parent node to results containing query. --- .../KeywordSearchSimpleTopComponent.java | 2 +- .../autopsy/keywordsearch/RegexQuery.java | 42 ++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchSimpleTopComponent.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchSimpleTopComponent.java index 625920e04e..364c1e22bc 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchSimpleTopComponent.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchSimpleTopComponent.java @@ -159,7 +159,7 @@ public class KeywordSearchSimpleTopComponent extends TopComponent implements Key * Overwrite when you want to change default persistence type. Default * persistence type is PERSISTENCE_ALWAYS * - * @return TopComponent.PERSISTENCE_ALWAYS + * @return TopComponent.PERSISTENCE_NEVER */ @Override public int getPersistenceType() { diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/RegexQuery.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/RegexQuery.java index 83f8c56f50..855e5ecce6 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/RegexQuery.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/RegexQuery.java @@ -120,9 +120,9 @@ public class RegexQuery implements KeywordSearchQuery { } Node rootNode = null; - if (things.size() > 0) { + if (things.size() > 0) { Children childThingNodes = - Children.create(new RegexResultChildFactory(things), true); + Children.create(new RegexResultQueryChildFactory(regexQuery, things), true); rootNode = new AbstractNode(childThingNodes); } else { @@ -136,6 +136,44 @@ public class RegexQuery implements KeywordSearchQuery { searchResultWin.requestActive(); // make it the active top component } + + /** + * factory produces top level result nodes showing query used + */ + class RegexResultQueryChildFactory extends ChildFactory { + + Collection queries; + Collection things; + + + RegexResultQueryChildFactory(Collectionqueries, Collection things) { + this.queries = queries; + this.things = things; + } + + RegexResultQueryChildFactory(String query, Collection things) { + queries = new ArrayList(); + queries.add(query); + this.things = things; + } + + @Override + protected boolean createKeys(List toPopulate) { + int id = 0; + for (String query : queries) { + LinkedHashMap map = new LinkedHashMap(); + map.put("Query", query); + toPopulate.add(new KeyValueThing(query, map, ++id)); + } + + return true; + } + + @Override + protected Node createNodeForKey(KeyValueThing thing) { + return new KeyValueNode(thing, Children.create(new RegexResultChildFactory(things), true)); + } + } /** * factory produces top level result nodes showing *exact* regex match result