diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties index 9188abd346..8cedeffa0c 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties @@ -24,22 +24,18 @@ ExtractedContentPanel.hitPreviousButton.text= ExtractedContentPanel.hitNextButton.text= KeywordSearchSimpleTopComponent.filesIndexedValLabel.text=- KeywordSearchSimpleTopComponent.filesIndexedNameLabel.text=Files indexed: -KeywordSearchSimpleTopComponent.queryLabel.text=Query: KeywordSearchSimpleTopComponent.searchButton.text=Search KeywordSearchListTopComponent.searchButton.text=Search KeywordSearchListTopComponent.filesIndexedNameLabel.text=Files indexed: KeywordSearchListTopComponent.filesIndexedValLabel.text=- KeywordSearchListTopComponent.titleLabel.text=Search for or load a saved list of keywords -KeywordSearchListTopComponent.listLabel.text=Current list of keywords: KeywordSearchListTopComponent.addWordButton.text=Add -KeywordSearchListTopComponent.loadListButton.text=Load +KeywordSearchListTopComponent.loadListButton.text=Load List KeywordSearchListTopComponent.addWordField.text= -KeywordSearchListTopComponent.saveListButton.text=Save -KeywordSearchListTopComponent.chLiteralWord.text=Literal -KeywordSearchListTopComponent.addWordLabel.text=Add a new keyword: -KeywordSearchListTopComponent.deleteWordButton.text=Delete -KeywordSearchListTopComponent.deleteAllWordsButton.text=Delete All -KeywordSearchSimpleTopComponent.chRegex.text=RegEx +KeywordSearchListTopComponent.saveListButton.text=Save List +KeywordSearchListTopComponent.deleteWordButton.text=Remove +KeywordSearchListTopComponent.deleteAllWordsButton.text=Remove All +KeywordSearchSimpleTopComponent.chRegex.text=Regular Expression KeywordSearchListImportExportTopComponent.topLabel.text=Manage (import, export, delete) lists of keywords KeywordSearchListImportExportTopComponent.curKeywordsLabel.text=Current lists: KeywordSearchListImportExportTopComponent.importButton.text=Import @@ -47,11 +43,14 @@ KeywordSearchListImportExportTopComponent.exportButton.text=Export KeywordSearchListImportExportTopComponent.deleteButton.text=Delete KeywordSearchListImportExportTopComponent.filesIndexedNameLabel.text=Files indexed: KeywordSearchListImportExportTopComponent.filesIndexedValLabel.text=- -KeywordSearchListTopComponent.curListNameLabel.text=Loaded list name: +KeywordSearchListTopComponent.curListNameLabel.text=Loaded list: KeywordSearchListTopComponent.curListValLabel.text=- -KeywordSearchListTopComponent.importButton.text=Import +KeywordSearchListTopComponent.importButton.text=Import List KeywordSearchHistoryTopComponent.topLabel.text=Review keyword search history and saved results KeywordSearchHistoryTopComponent.filesIndexedNameLabel.text=Files indexed: KeywordSearchHistoryTopComponent.filesIndexedValLabel.text=- KeywordSearchHistoryTopComponent.withHitsLabel.text=Keyword searches with hits: KeywordSearchHistoryTopComponent.noHitsLabel.text=Keyword searches without hits: +KeywordSearchSimpleTopComponent.queryTextField.text= +KeywordSearchListTopComponent.curListLabel.text=Current List +KeywordSearchListTopComponent.chRegex.text=Regular Expression diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchDataExplorer.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchDataExplorer.java index 455b3f574b..512c28d694 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchDataExplorer.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchDataExplorer.java @@ -23,6 +23,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.util.Map; import org.openide.util.lookup.ServiceProvider; import org.sleuthkit.autopsy.corecomponentinterfaces.DataExplorer; import org.sleuthkit.autopsy.keywordsearch.KeywordSearch.QueryType; @@ -73,7 +74,12 @@ public class KeywordSearchDataExplorer implements DataExplorer { private void search() { KeywordSearchQueryManager man = null; if (tc.isMultiwordQuery()) { - man = new KeywordSearchQueryManager(tc.getQueryList(), Presentation.COLLAPSE); + final Map keywords = tc.getQueryList(); + if (keywords.isEmpty()) { + KeywordSearchUtil.displayDialog("Keyword Search Error", "Keyword list is empty, please add at least one keyword to the list", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR); + return; + } + man = new KeywordSearchQueryManager(keywords, Presentation.COLLAPSE); } else { QueryType queryType = null; if (tc.isLuceneQuerySelected()) { @@ -81,6 +87,11 @@ public class KeywordSearchDataExplorer implements DataExplorer { } else { queryType = QueryType.REGEX; } + final String queryText = tc.getQueryText(); + if (queryText == null || queryText.trim().equals("")) { + KeywordSearchUtil.displayDialog("Keyword Search Error", "Please enter a keyword to search for", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR); + return; + } man = new KeywordSearchQueryManager(tc.getQueryText(), queryType, Presentation.COLLAPSE); } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchListTopComponent.form b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchListTopComponent.form index d6a0e9be0d..9da12060f9 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchListTopComponent.form +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchListTopComponent.form @@ -16,47 +16,64 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -69,38 +86,40 @@ - - - + + + + + - - - + - - + + - + - + + + - + - + - + @@ -137,13 +156,6 @@ - - - - - - - @@ -151,13 +163,6 @@ - - - - - - - @@ -208,14 +213,14 @@ - + - + - + @@ -261,5 +266,16 @@ + + + + + + + + + + + diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchListTopComponent.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchListTopComponent.java index 40a35c8fda..39b7d7fe7d 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchListTopComponent.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchListTopComponent.java @@ -83,7 +83,7 @@ public final class KeywordSearchListTopComponent extends TopComponent implements } private void customizeComponents() { - chLiteralWord.setToolTipText("Literal word (auto-escape special characters)"); + chRegex.setToolTipText("Keyword is a regular expression"); addWordButton.setToolTipText(("Add a new word to the keyword search list")); addWordField.setToolTipText("Enter a new word or regex to search"); @@ -117,7 +117,7 @@ public final class KeywordSearchListTopComponent extends TopComponent implements } keywordTable.setCellSelectionEnabled(false); - loadDefaultKeywords(); + //loadDefaultKeywords(); KeywordSearchListsXML.getCurrent().addPropertyChangeListener(new PropertyChangeListener() { @@ -173,20 +173,21 @@ public final class KeywordSearchListTopComponent extends TopComponent implements filesIndexedNameLabel = new javax.swing.JLabel(); filesIndexedValLabel = new javax.swing.JLabel(); titleLabel = new javax.swing.JLabel(); - listLabel = new javax.swing.JLabel(); addWordField = new javax.swing.JTextField(); - addWordLabel = new javax.swing.JLabel(); addWordButton = new javax.swing.JButton(); loadListButton = new javax.swing.JButton(); deleteWordButton = new javax.swing.JButton(); deleteAllWordsButton = new javax.swing.JButton(); saveListButton = new javax.swing.JButton(); - chLiteralWord = new javax.swing.JCheckBox(); + chRegex = new javax.swing.JCheckBox(); jScrollPane1 = new javax.swing.JScrollPane(); keywordTable = new javax.swing.JTable(); curListNameLabel = new javax.swing.JLabel(); curListValLabel = new javax.swing.JLabel(); importButton = new javax.swing.JButton(); + curListLabel = new javax.swing.JLabel(); + jSeparator1 = new javax.swing.JSeparator(); + jSeparator2 = new javax.swing.JSeparator(); org.openide.awt.Mnemonics.setLocalizedText(searchButton, org.openide.util.NbBundle.getMessage(KeywordSearchListTopComponent.class, "KeywordSearchListTopComponent.searchButton.text")); // NOI18N searchButton.addActionListener(new java.awt.event.ActionListener() { @@ -201,12 +202,8 @@ public final class KeywordSearchListTopComponent extends TopComponent implements org.openide.awt.Mnemonics.setLocalizedText(titleLabel, org.openide.util.NbBundle.getMessage(KeywordSearchListTopComponent.class, "KeywordSearchListTopComponent.titleLabel.text")); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(listLabel, org.openide.util.NbBundle.getMessage(KeywordSearchListTopComponent.class, "KeywordSearchListTopComponent.listLabel.text")); // NOI18N - addWordField.setText(org.openide.util.NbBundle.getMessage(KeywordSearchListTopComponent.class, "KeywordSearchListTopComponent.addWordField.text")); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(addWordLabel, org.openide.util.NbBundle.getMessage(KeywordSearchListTopComponent.class, "KeywordSearchListTopComponent.addWordLabel.text")); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(addWordButton, org.openide.util.NbBundle.getMessage(KeywordSearchListTopComponent.class, "KeywordSearchListTopComponent.addWordButton.text")); // NOI18N addWordButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -242,10 +239,10 @@ public final class KeywordSearchListTopComponent extends TopComponent implements } }); - org.openide.awt.Mnemonics.setLocalizedText(chLiteralWord, org.openide.util.NbBundle.getMessage(KeywordSearchListTopComponent.class, "KeywordSearchListTopComponent.chLiteralWord.text")); // NOI18N - chLiteralWord.addActionListener(new java.awt.event.ActionListener() { + org.openide.awt.Mnemonics.setLocalizedText(chRegex, org.openide.util.NbBundle.getMessage(KeywordSearchListTopComponent.class, "KeywordSearchListTopComponent.chRegex.text")); // NOI18N + chRegex.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - chLiteralWordActionPerformed(evt); + chRegexActionPerformed(evt); } }); @@ -266,43 +263,60 @@ public final class KeywordSearchListTopComponent extends TopComponent implements } }); + org.openide.awt.Mnemonics.setLocalizedText(curListLabel, org.openide.util.NbBundle.getMessage(KeywordSearchListTopComponent.class, "KeywordSearchListTopComponent.curListLabel.text")); // NOI18N + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(chLiteralWord) - .addComponent(titleLabel) - .addGroup(layout.createSequentialGroup() + .addComponent(curListLabel) + .addContainerGap(263, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(9, 9, 9) + .addComponent(curListNameLabel) + .addGap(18, 18, 18) + .addComponent(curListValLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE) + .addGap(163, 163, 163)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(deleteWordButton) + .addGap(18, 18, 18) + .addComponent(deleteAllWordsButton) + .addGap(18, 18, 18) + .addComponent(saveListButton) + .addContainerGap(52, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(filesIndexedNameLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(filesIndexedValLabel) + .addContainerGap(243, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(searchButton) + .addContainerGap(254, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(chRegex) + .addContainerGap(206, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(titleLabel, javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(addWordField, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(addWordButton)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addComponent(loadListButton) .addGap(18, 18, 18) .addComponent(importButton)) - .addComponent(addWordLabel) - .addGroup(layout.createSequentialGroup() - .addComponent(addWordField, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(31, 31, 31) - .addComponent(addWordButton)) - .addComponent(listLabel) - .addComponent(searchButton) - .addGroup(layout.createSequentialGroup() - .addComponent(filesIndexedNameLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(filesIndexedValLabel)) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 272, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() - .addComponent(curListNameLabel) - .addGap(18, 18, 18) - .addComponent(curListValLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() - .addComponent(deleteWordButton) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(deleteAllWordsButton) - .addGap(18, 18, 18) - .addComponent(saveListButton)))) - .addContainerGap(15, Short.MAX_VALUE)) + .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 272, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(47, Short.MAX_VALUE)) + .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 329, Short.MAX_VALUE) + .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 329, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -313,34 +327,36 @@ public final class KeywordSearchListTopComponent extends TopComponent implements .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(loadListButton) .addComponent(importButton)) - .addGap(19, 19, 19) - .addComponent(addWordLabel) - .addGap(18, 18, 18) + .addGap(8, 8, 8) + .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(curListLabel) + .addGap(14, 14, 14) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(addWordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(addWordButton)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(chLiteralWord) - .addGap(9, 9, 9) - .addComponent(listLabel) + .addComponent(chRegex) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(28, 28, 28) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(deleteWordButton) .addComponent(deleteAllWordsButton) + .addComponent(deleteWordButton) .addComponent(saveListButton)) - .addGap(29, 29, 29) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(4, 4, 4) .addComponent(searchButton) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(curListNameLabel) .addComponent(curListValLabel)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(filesIndexedNameLabel) .addComponent(filesIndexedValLabel)) - .addGap(46, 46, 46)) + .addGap(71, 71, 71)) ); }// //GEN-END:initComponents @@ -349,10 +365,10 @@ public final class KeywordSearchListTopComponent extends TopComponent implements private void addWordButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addWordButtonActionPerformed - String newWord = addWordField.getText(); + String newWord = addWordField.getText().trim(); String newWordEscaped = Pattern.quote(newWord); - if (newWord.trim().equals("")) { + if (newWord.equals("")) { return; } else if (keywordExists(newWord) || keywordExists(newWordEscaped)) { KeywordSearchUtil.displayDialog("New Keyword Entry", "Keyword already exists in the list.", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO); @@ -360,7 +376,7 @@ public final class KeywordSearchListTopComponent extends TopComponent implements } String toAdd = null; - if (chLiteralWord.isSelected()) { + if (! chRegex.isSelected()) { toAdd = newWordEscaped; } else { toAdd = newWord; @@ -381,7 +397,7 @@ public final class KeywordSearchListTopComponent extends TopComponent implements } //add & reset checkbox - chLiteralWord.setSelected(false); + chRegex.setSelected(false); tableModel.addKeyword(toAdd); addWordField.setText(""); @@ -427,8 +443,8 @@ public final class KeywordSearchListTopComponent extends TopComponent implements }//GEN-LAST:event_saveListButtonActionPerformed - private void chLiteralWordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chLiteralWordActionPerformed - }//GEN-LAST:event_chLiteralWordActionPerformed + private void chRegexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chRegexActionPerformed + }//GEN-LAST:event_chRegexActionPerformed private void deleteWordButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteWordButtonActionPerformed tableModel.deleteSelected(); @@ -471,8 +487,8 @@ public final class KeywordSearchListTopComponent extends TopComponent implements // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton addWordButton; private javax.swing.JTextField addWordField; - private javax.swing.JLabel addWordLabel; - private javax.swing.JCheckBox chLiteralWord; + private javax.swing.JCheckBox chRegex; + private javax.swing.JLabel curListLabel; private javax.swing.JLabel curListNameLabel; private javax.swing.JLabel curListValLabel; private javax.swing.JButton deleteAllWordsButton; @@ -481,8 +497,9 @@ public final class KeywordSearchListTopComponent extends TopComponent implements private javax.swing.JLabel filesIndexedValLabel; private javax.swing.JButton importButton; private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JSeparator jSeparator1; + private javax.swing.JSeparator jSeparator2; private javax.swing.JTable keywordTable; - private javax.swing.JLabel listLabel; private javax.swing.JButton loadListButton; private javax.swing.JButton saveListButton; private javax.swing.JButton searchButton; diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchSimpleTopComponent.form b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchSimpleTopComponent.form index 157b833141..339cd0b8a4 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchSimpleTopComponent.form +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchSimpleTopComponent.form @@ -1,6 +1,9 @@
+ + + @@ -19,65 +22,39 @@ - - - - - - - - - - - - + + + + - - - - - - - - + + + + + - + - + - - - - - - - - - - - - - - - @@ -85,13 +62,6 @@ - - - - - - - @@ -126,5 +96,16 @@ + + + + + + + + + + + diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchSimpleTopComponent.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchSimpleTopComponent.java index 1b9a002bf7..802367bcf8 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchSimpleTopComponent.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchSimpleTopComponent.java @@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.keywordsearch; import java.awt.event.ActionListener; import java.util.Map; +import java.util.logging.Level; import java.util.logging.Logger; import org.openide.windows.TopComponent; @@ -39,10 +40,10 @@ public class KeywordSearchSimpleTopComponent extends TopComponent implements Key private void customizeComponents() { searchButton.setToolTipText("Execute a keyword search using the query specified."); - chRegex.setToolTipText("Select if query is a regular expression"); - queryTextArea.setToolTipText("For non-regex search enter one or more keywords separated by white-space.
" - + "For a regex search, enter a Java-supported regular expression.
" - + "Examples of regex (in double-quotes): \"\\d\\d\\d-\\d\\d\\d\" \\d{8,10} \"phone\" \"ftp|sftp|ssh|http|https|www\".
" + chRegex.setToolTipText("Select if keyword is a regular expression"); + queryTextField.setToolTipText("For non-regex search enter one or more keywords separated by white-space.
" + + "For a regular expression search, enter a valid regular expression.
" + + "Examples (in double-quotes): \"\\d\\d\\d-\\d\\d\\d\" \\d{8,10} \"phone\" \"ftp|sftp|ssh|http|https|www\".
" + "Note: a word can be also searched using a regex search.
Regex containing whitespace [ \\s] matches are currently not supported."); } @@ -55,23 +56,16 @@ public class KeywordSearchSimpleTopComponent extends TopComponent implements Key // //GEN-BEGIN:initComponents private void initComponents() { - buttonGroup1 = new javax.swing.ButtonGroup(); - jScrollPane1 = new javax.swing.JScrollPane(); - queryTextArea = new javax.swing.JTextArea(); searchButton = new javax.swing.JButton(); - queryLabel = new javax.swing.JLabel(); filesIndexedNameLabel = new javax.swing.JLabel(); filesIndexedValLabel = new javax.swing.JLabel(); chRegex = new javax.swing.JCheckBox(); + queryTextField = new javax.swing.JTextField(); - queryTextArea.setColumns(20); - queryTextArea.setRows(5); - jScrollPane1.setViewportView(queryTextArea); + setAutoscrolls(true); searchButton.setText(org.openide.util.NbBundle.getMessage(KeywordSearchSimpleTopComponent.class, "KeywordSearchSimpleTopComponent.searchButton.text")); // NOI18N - queryLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchSimpleTopComponent.class, "KeywordSearchSimpleTopComponent.queryLabel.text")); // NOI18N - filesIndexedNameLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchSimpleTopComponent.class, "KeywordSearchSimpleTopComponent.filesIndexedNameLabel.text")); // NOI18N filesIndexedValLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchSimpleTopComponent.class, "KeywordSearchSimpleTopComponent.filesIndexedValLabel.text")); // NOI18N @@ -83,6 +77,14 @@ public class KeywordSearchSimpleTopComponent extends TopComponent implements Key } }); + queryTextField.setHorizontalAlignment(javax.swing.JTextField.LEFT); + queryTextField.setText(org.openide.util.NbBundle.getMessage(KeywordSearchSimpleTopComponent.class, "KeywordSearchSimpleTopComponent.queryTextField.text")); // NOI18N + queryTextField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + queryTextFieldActionPerformed(evt); + } + }); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -90,36 +92,29 @@ public class KeywordSearchSimpleTopComponent extends TopComponent implements Key .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(queryLabel) - .addGap(50, 50, 50) - .addComponent(chRegex)) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE) - .addComponent(searchButton)) - .addContainerGap()) + .addComponent(chRegex) .addGroup(layout.createSequentialGroup() .addComponent(filesIndexedNameLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(filesIndexedValLabel)))) + .addComponent(filesIndexedValLabel)) + .addComponent(searchButton) + .addComponent(queryTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(125, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(queryLabel) - .addComponent(chRegex)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(32, 32, 32) + .addComponent(queryTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(chRegex) .addGap(18, 18, 18) .addComponent(searchButton) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGap(49, 49, 49) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(filesIndexedNameLabel) .addComponent(filesIndexedValLabel)) - .addContainerGap(106, Short.MAX_VALUE)) + .addContainerGap(87, Short.MAX_VALUE)) ); filesIndexedNameLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(KeywordSearchSimpleTopComponent.class, "KeywordSearchTopComponent.filesIndexedNameLabel.AccessibleContext.accessibleName")); // NOI18N @@ -127,23 +122,25 @@ public class KeywordSearchSimpleTopComponent extends TopComponent implements Key }// //GEN-END:initComponents private void chRegexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chRegexActionPerformed - // TODO add your handling code here: + }//GEN-LAST:event_chRegexActionPerformed + + private void queryTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_queryTextFieldActionPerformed + + }//GEN-LAST:event_queryTextFieldActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JCheckBox chRegex; private javax.swing.JLabel filesIndexedNameLabel; private javax.swing.JLabel filesIndexedValLabel; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JLabel queryLabel; - private javax.swing.JTextArea queryTextArea; + private javax.swing.JTextField queryTextField; private javax.swing.JButton searchButton; // End of variables declaration//GEN-END:variables @Override protected void componentOpened() { // clear old search - queryTextArea.setText(""); + queryTextField.setText(""); } @Override @@ -154,11 +151,12 @@ public class KeywordSearchSimpleTopComponent extends TopComponent implements Key @Override public void addSearchButtonListener(ActionListener l) { searchButton.addActionListener(l); + queryTextField.addActionListener(l); } @Override public String getQueryText() { - return queryTextArea.getText(); + return queryTextField.getText().trim(); } @Override