From f70ffb5dc5bb530f7fcb287664d778db769391cd Mon Sep 17 00:00:00 2001 From: "Samuel H. Kenyon" Date: Fri, 14 Mar 2014 15:10:38 -0400 Subject: [PATCH 1/2] Fix NullPointerException. Modified ResultCollapsedChildFactory.createKeys() to loop through the flattened file set as it did in previous versions (which fixes current null bugs), but still use the new approach of calling getSnippet(). --- .../KeywordSearchResultFactory.java | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchResultFactory.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchResultFactory.java index 8aeb41354d..31892ca464 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchResultFactory.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchResultFactory.java @@ -260,23 +260,40 @@ class KeywordSearchResultFactory extends ChildFactory { final boolean literal_query = tcq.isLiteral(); int resID = 0; - for(ContentHit chit : tcqRes.get(tcq.getQueryString())) { - AbstractFile f = chit.getContent(); + + final Map hitContents = ContentHit.flattenResults(tcqRes); + for (final AbstractFile f : hitContents.keySet()) { + final int previewChunk = hitContents.get(f); + //get unique match result files Map resMap = new LinkedHashMap<>(); - if (chit.hasSnippet()) { - setCommonProperty(resMap, CommonPropertyTypes.CONTEXT, chit.getSnippet()); + //to generate the preview snippet + //just pick any term that hit that file (since we are compressing result view) + String hit = null; + //find the first hit for this file + for (String hitKey : tcqRes.keySet()) { + List chits = tcqRes.get(hitKey); + for (ContentHit chit : chits) { + if (chit.getContent().equals(f)) { + hit = hitKey; + if (chit.hasSnippet() && (KeywordSearchUtil.escapeLuceneQuery(hit) != null)) { + setCommonProperty(resMap, CommonPropertyTypes.CONTEXT, chit.getSnippet()); + } + break; + } + } + if (hit != null) { + break; + } } - if (f.getType() == TSK_DB_FILES_TYPE_ENUM.FS) { AbstractFsContentNode.fillPropertyMap(resMap, (FsContent) f); } - final String highlightQueryEscaped = getHighlightQuery(tcq, literal_query, tcqRes, f); - tempList.add(new KeyValueQueryContent(f.getName(), resMap, ++resID, f, highlightQueryEscaped, tcq, chit.getChunkId(), tcqRes)); + tempList.add(new KeyValueQueryContent(f.getName(), resMap, ++resID, f, highlightQueryEscaped, tcq, previewChunk, tcqRes)); } - + // Add all the nodes to toPopulate at once. Minimizes node creation // EDT threads, which can slow and/or hang the UI on large queries. toPopulate.addAll(tempList); From 4cde7ed8cae5d43102e4389923430be3583c4b3f Mon Sep 17 00:00:00 2001 From: "Samuel H. Kenyon" Date: Fri, 14 Mar 2014 15:13:12 -0400 Subject: [PATCH 2/2] Revert keyword list panel icon to the watch icon. --- .../sleuthkit/autopsy/keywordsearch/KeywordSearchPanel.form | 6 +++--- .../sleuthkit/autopsy/keywordsearch/KeywordSearchPanel.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchPanel.form b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchPanel.form index 10994b34e2..a769778ffa 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchPanel.form +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchPanel.form @@ -60,7 +60,7 @@ - + @@ -69,10 +69,10 @@ - + - + diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchPanel.java index 432d6a98b8..384bfc8526 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchPanel.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchPanel.java @@ -143,13 +143,13 @@ class KeywordSearchPanel extends javax.swing.JPanel { setOpaque(false); - listsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/dropdown-icon.png"))); // NOI18N + listsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon.png"))); // NOI18N listsButton.setText(org.openide.util.NbBundle.getMessage(KeywordSearchPanel.class, "ListBundleName")); // NOI18N listsButton.setBorderPainted(false); listsButton.setContentAreaFilled(false); listsButton.setEnabled(false); - listsButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/dropdown-icon-rollover.png"))); // NOI18N - listsButton.setRolloverSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/dropdown-icon-pressed.png"))); // NOI18N + listsButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon-rollover.png"))); // NOI18N + listsButton.setRolloverSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon-pressed.png"))); // NOI18N listsButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { listsButtonMousePressed(evt);