diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties index 1ac7f0fbbd..2afdc83e03 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties @@ -29,6 +29,7 @@ KeywordSearchEditListPanel.pasteMenuItem.text=Paste KeywordSearchEditListPanel.copyMenuItem.text=Copy KeywordSearchEditListPanel.exportButton.text=Export List KeywordSearchEditListPanel.deleteListButton.text=Delete List +KeywordSearchEditListPanel.emptyKeyword.text=Empty keyword KeywordSearchListsManagementPanel.newListButton.text=New List KeywordSearchListsManagementPanel.importButton.text=Import List KeywordSearchListsViewerPanel.searchAddButton.text=Search @@ -101,7 +102,6 @@ KeywordSearchEditListPanel.exportButtonActionPerformed.fileFilterLabel=Keyword L KeywordSearchEditListPanel.exportButtonActionPerformed.fileExistPrompt=File {0} exists, overwrite? KeywordSearchEditListPanel.exportButtonActionPerformed.kwListExportedMsg=Keyword lists exported KeywordSearchEditListPanel.kwColName=Keyword -KeywordSearchEditListPanel.exportButtonActionPerformed.regExColName=RegEx KeywordSearchEditListPanel.addKeyword.message=Add a new word to the keyword search list\: KeywordSearchEditListPanel.addKeyword.title=New keyword KeywordSearchFilterNode.getFileActions.openExternViewActLbl=Open in External Viewer @@ -132,7 +132,7 @@ KeywordSearchListsViewerPanel.initIngest.ongoingIngestMsg=Files Indexed\: {0} (i KeywordSearchListsViewerPanel.initIngest.fileIndexCtMsg=Files Indexed\: {0} KeywordSearch.selectedColLbl=Selected KeywordSearch.nameColLbl=Name -KeywordSearch.regExColLbl=RegEx +KeywordSearch.typeColLbl=Keyword Type KeywordSearchQueryManager.execute.exeWinTitle=Keyword search {0} - {1} KeywordSearch.newKeywordListMsg=New Keyword List KeywordSearch.importListFileDialogMsg=Error importing keyword list from file {0} @@ -290,3 +290,8 @@ RawText.getText.error.msg=Error getting text GlobalListsManagementPanel.newListButton.text=New List GlobalListsManagementPanel.importButton.text=Import List GlobalListsManagementPanel.keywordListsLabel.text=Keyword Lists: +NewKeywordPanel.regexButton.text=Regular Expression +NewKeywordPanel.exactButton.text=Exact Match +NewKeywordPanel.substringButton.text=Substring Match +NewKeywordPanel.keywordTextField.text= +NewKeywordPanel.newKeywordLabel.text=Enter a new keyword: diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownListSearchPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownListSearchPanel.java index 7a1986d341..40cc83cd92 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownListSearchPanel.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownListSearchPanel.java @@ -1,15 +1,15 @@ /* * Autopsy Forensic Browser - * + * * Copyright 2011-2015 Basis Technology Corp. * Contact: carrier sleuthkit 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. @@ -39,9 +39,6 @@ import org.openide.util.NbBundle; import org.openide.util.actions.SystemAction; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.ingest.IngestManager; -import javax.swing.ImageIcon; -import static javax.swing.SwingConstants.CENTER; -import javax.swing.table.DefaultTableCellRenderer; /** * Viewer panel widget for keyword lists that is used in the ingest config and @@ -93,10 +90,9 @@ class DropdownListSearchPanel extends KeywordSearchPanel { for (int i = 0; i < keywordsTable.getColumnCount(); i++) { column = keywordsTable.getColumnModel().getColumn(i); if (i == 0) { - column.setPreferredWidth(((int) (rightWidth * 0.78))); + column.setPreferredWidth(((int) (rightWidth * 0.60))); } else { - column.setPreferredWidth(((int) (rightWidth * 0.20))); - column.setCellRenderer(new CheckBoxRenderer()); + column.setPreferredWidth(((int) (rightWidth * 0.38))); } } @@ -123,12 +119,9 @@ class DropdownListSearchPanel extends KeywordSearchPanel { public void propertyChange(PropertyChangeEvent evt) { Object source = evt.getSource(); if (source instanceof String && ((String) source).equals("LOCAL")) { //NON-NLS - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - ingestRunning = IngestManager.getInstance().isIngestRunning(); - updateComponents(); - } + EventQueue.invokeLater(() -> { + ingestRunning = IngestManager.getInstance().isIngestRunning(); + updateComponents(); }); } } @@ -320,8 +313,8 @@ class DropdownListSearchPanel extends KeywordSearchPanel { private class KeywordListsTableModel extends AbstractTableModel { //data - private XmlKeywordSearchList listsHandle = XmlKeywordSearchList.getCurrent(); - private List listData = new ArrayList<>(); + private final XmlKeywordSearchList listsHandle = XmlKeywordSearchList.getCurrent(); + private final List listData = new ArrayList<>(); @Override public int getColumnCount() { @@ -496,7 +489,7 @@ class DropdownListSearchPanel extends KeywordSearchPanel { ret = NbBundle.getMessage(this.getClass(), "KeywordSearch.nameColLbl"); break; case 1: - ret = NbBundle.getMessage(this.getClass(), "KeywordSearch.regExColLbl"); + ret = NbBundle.getMessage(this.getClass(), "KeywordSearch.typeColLbl"); break; default: break; @@ -519,7 +512,7 @@ class DropdownListSearchPanel extends KeywordSearchPanel { ret = (Object) entry.name; break; case 1: - ret = (Object) entry.regex; + ret = (Object) entry.keywordType; break; default: break; @@ -559,11 +552,11 @@ class DropdownListSearchPanel extends KeywordSearchPanel { private class KeywordTableEntry implements Comparable { String name; - Boolean regex; + String keywordType; KeywordTableEntry(Keyword keyword) { this.name = keyword.getSearchTerm(); - this.regex = !keyword.searchTermIsLiteral(); + this.keywordType = keyword.getSearchTermType(); } @Override @@ -598,33 +591,4 @@ class DropdownListSearchPanel extends KeywordSearchPanel { return this; } } - - /** - * A cell renderer for boolean cells that shows a center-aligned green check - * mark if true, nothing if false. - */ - private class CheckBoxRenderer extends DefaultTableCellRenderer { - - private static final long serialVersionUID = 1L; - final ImageIcon theCheck = new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/checkmark.png")); // NON-NLS - - CheckBoxRenderer() { - setHorizontalAlignment(CENTER); - } - - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - - if ((value instanceof Boolean)) { - if ((Boolean) value) { - setIcon(theCheck); - setToolTipText(Bundle.IsRegularExpression()); - } else { - setIcon(null); - setToolTipText(null); - } - } - return this; - } - } } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownSingleKeywordSearchPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownSingleKeywordSearchPanel.java index 9201bcfddf..c6b079bc70 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownSingleKeywordSearchPanel.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownSingleKeywordSearchPanel.java @@ -52,6 +52,7 @@ public class DropdownSingleKeywordSearchPanel extends KeywordSearchPanel { * Gets the default instance of a dropdown panel that provides GUI * components that allow a user to do three types of ad hoc single keyword * searches. + * @return the default instance of DropdownSingleKeywordSearchPanel */ public static synchronized DropdownSingleKeywordSearchPanel getDefault() { if (null == defaultInstance) { diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalEditListPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalEditListPanel.java index 5ec5463d8e..4b9ea3a7bd 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalEditListPanel.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalEditListPanel.java @@ -1,15 +1,15 @@ /* * Autopsy Forensic Browser - * + * * Copyright 2011-2016 Basis Technology Corp. * Contact: carrier sleuthkit 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. @@ -42,18 +42,7 @@ import org.openide.util.NbBundle; import org.sleuthkit.autopsy.corecomponents.OptionsPanel; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.ingest.IngestManager; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import javax.swing.ImageIcon; -import javax.swing.JCheckBox; -import javax.swing.JLabel; import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import static javax.swing.SwingConstants.CENTER; -import javax.swing.table.DefaultTableCellRenderer; -import org.openide.util.NbBundle.Messages; /** * GlobalEditListPanel widget to manage keywords in lists @@ -90,7 +79,6 @@ class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionLis column.setPreferredWidth(((int) (width * 0.90))); } else { column.setPreferredWidth(((int) (width * 0.10))); - column.setCellRenderer(new CheckBoxRenderer()); } } keywordTable.setCellSelectionEnabled(false); @@ -110,18 +98,13 @@ class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionLis setButtonStates(); - setButtonStates(); - IngestManager.getInstance().addIngestJobEventListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { Object source = evt.getSource(); if (source instanceof String && ((String) source).equals("LOCAL")) { //NON-NLS - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - setButtonStates(); - } + EventQueue.invokeLater(() -> { + setButtonStates(); }); } } @@ -351,35 +334,26 @@ class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionLis }// //GEN-END:initComponents private void newWordButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newWordButtonActionPerformed - JCheckBox chRegex = new JCheckBox(NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.chRegex.text")); - chRegex.setToolTipText(NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.customizeComponents.kwReToolTip")); - JTextField addWordField = new JTextField(25); - addWordField.setToolTipText(NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.customizeComponents.enterNewWordToolTip")); + NewKeywordPanel panel = new NewKeywordPanel(); - JPanel addKeywordPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - addKeywordPanel.add(new JLabel(NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.addKeyword.message"))); - addKeywordPanel.add(addWordField); - addKeywordPanel.add(chRegex); - - addKeywordPanel.setPreferredSize(new Dimension(250, 80)); - - int result = JOptionPane.showConfirmDialog(null, addKeywordPanel, + int result = JOptionPane.showConfirmDialog(null, panel, NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.addKeyword.title"), JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { - String newWord = addWordField.getText().trim(); - boolean isLiteral = !chRegex.isSelected(); - final Keyword keyword = new Keyword(newWord, isLiteral); - - if (newWord.equals("")) { + String newWord = panel.getKeywordText(); + if (newWord.isEmpty()) { + KeywordSearchUtil.displayDialog(NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.newKwTitle"), + NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.emptyKeyword.text"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO); return; - } else if (currentKeywordList.hasKeyword(keyword)) { + } + final Keyword keyword = new Keyword(newWord, !panel.isKeywordRegex(), panel.isKeywordExact()); + if (currentKeywordList.hasKeyword(keyword)) { KeywordSearchUtil.displayDialog(NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.newKwTitle"), NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.addWordButtonAction.kwAlreadyExistsMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO); return; } - + //check if valid boolean valid = true; try { @@ -394,15 +368,13 @@ class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionLis NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.invalidKwMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR); return; } - + //add & reset checkbox tableModel.addKeyword(keyword); XmlKeywordSearchList.getCurrent().addList(currentKeywordList); firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null); setFocusOnKeywordTextBox(); setButtonStates(); - } else { - return; } }//GEN-LAST:event_newWordButtonActionPerformed @@ -563,11 +535,10 @@ class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionLis colName = NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.kwColName"); break; case 1: - colName = NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.exportButtonActionPerformed.regExColName"); + colName = NbBundle.getMessage(this.getClass(), "KeywordSearch.typeColLbl"); break; default: ; - } return colName; } @@ -581,10 +552,10 @@ class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionLis Keyword word = currentKeywordList.getKeywords().get(rowIndex); switch (columnIndex) { case 0: - ret = (Object) word.getSearchTerm(); + ret = word.getSearchTerm(); break; case 1: - ret = (Object) !word.searchTermIsLiteral(); + ret = word.getSearchTermType(); break; default: logger.log(Level.SEVERE, "Invalid table column index: {0}", columnIndex); //NON-NLS @@ -629,36 +600,6 @@ class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionLis } } - /** - * A cell renderer for boolean cells that shows a center-aligned green check - * mark if true, nothing if false. - */ - private class CheckBoxRenderer extends DefaultTableCellRenderer { - - private static final long serialVersionUID = 1L; - final ImageIcon theCheck = new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/checkmark.png")); // NON-NLS - - CheckBoxRenderer() { - setHorizontalAlignment(CENTER); - } - - @Override - @Messages("IsRegularExpression=Keyword is a regular expression") - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - - if ((value instanceof Boolean)) { - if ((Boolean) value) { - setIcon(theCheck); - setToolTipText(Bundle.IsRegularExpression()); - } else { - setIcon(null); - setToolTipText(null); - } - } - return this; - } - } - /** * Set the keyboard focus to new keyword textbox. */ diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalListSettingsPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalListSettingsPanel.java index 6bae3b666c..bac57fc76d 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalListSettingsPanel.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalListSettingsPanel.java @@ -1,15 +1,15 @@ /* * Autopsy Forensic Browser - * - * Copyright 2011-2014 Basis Technology Corp. + * + * Copyright 2011-2016 Basis Technology Corp. * Contact: carrier sleuthkit 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. @@ -76,7 +76,7 @@ final class GlobalListSettingsPanel extends javax.swing.JPanel implements Option JOptionPane.PLAIN_MESSAGE, null, null, - currentKeywordList != null ? currentKeywordList.getName() : ""); + currentKeywordList.getName()); if (listName == null || listName.trim().equals("")) { return; } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalListsManagementPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalListsManagementPanel.java index 031ec3199f..abc9a0bebd 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalListsManagementPanel.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalListsManagementPanel.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2014 Basis Technology Corp. + * Copyright 2011-2016 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -40,8 +40,8 @@ class GlobalListsManagementPanel extends javax.swing.JPanel implements OptionsPa private static final long serialVersionUID = 1L; - private Logger logger = Logger.getLogger(GlobalListsManagementPanel.class.getName()); - private KeywordListTableModel tableModel; + private final Logger logger = Logger.getLogger(GlobalListsManagementPanel.class.getName()); + private final KeywordListTableModel tableModel; private final org.sleuthkit.autopsy.keywordsearch.GlobalListSettingsPanel globalListSettingsPanel; GlobalListsManagementPanel(org.sleuthkit.autopsy.keywordsearch.GlobalListSettingsPanel gsp) { @@ -345,7 +345,7 @@ class GlobalListsManagementPanel extends javax.swing.JPanel implements OptionsPa private class KeywordListTableModel extends AbstractTableModel { - private XmlKeywordSearchList listsHandle = XmlKeywordSearchList.getCurrent(); + private final XmlKeywordSearchList listsHandle = XmlKeywordSearchList.getCurrent(); @Override public int getColumnCount() { diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Keyword.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Keyword.java index 93acd0ee78..0c84da9c73 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Keyword.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Keyword.java @@ -18,6 +18,7 @@ */ package org.sleuthkit.autopsy.keywordsearch; +import org.openide.util.NbBundle; import org.sleuthkit.datamodel.BlackboardAttribute; /** @@ -119,6 +120,18 @@ class Keyword { return isWholeWord; } + String getSearchTermType() { + if (isLiteral) { + if (isWholeWord) { + return NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.exactButton.text"); + } else { + return NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.substringButton.text"); + } + } else { + return NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.regexButton.text"); + } + } + /** * Sets the artifact attribute type associated with the keyword, if any. * @@ -159,9 +172,9 @@ class Keyword { return false; } Keyword other = (Keyword) obj; - return (this.searchTerm.equals(other.searchTerm) - && this.isLiteral == other.isLiteral - && this.isWholeWord == other.isWholeWord); + return (this.searchTerm.equals(other.getSearchTerm()) + && this.isLiteral == other.searchTermIsLiteral() + && this.isWholeWord == other.searchTermIsWholeWord()); } @Override diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchGlobalSettingsPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchGlobalSettingsPanel.java index a88b11582b..1756bfc1ec 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchGlobalSettingsPanel.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchGlobalSettingsPanel.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2014 Basis Technology Corp. + * Copyright 2011-2016 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchList.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchList.java index 79e09cd788..01f0e146f0 100755 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchList.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchList.java @@ -46,7 +46,7 @@ abstract class KeywordSearchList { private static final String CCN_REGEX = ".*[3456]([ -]?\\d){11,18}.*"; //12-19 digits, with possible single spaces or dashes in between. first digit is 3,4,5, or 6 //NON-NLS protected String filePath; - Map theLists; //the keyword data + Map theLists; //the keyword data PropertyChangeSupport changeSupport; protected List lockedLists; @@ -320,7 +320,7 @@ abstract class KeywordSearchList { } boolean addList(String name, List newList, boolean useForIngest, boolean ingestMessages) { - //make sure that the list is readded as a locked/built in list + //make sure that the list is readded as a locked/built in list boolean isLocked = this.lockedLists.contains(name); return addList(name, newList, useForIngest, ingestMessages, isLocked); } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/NewKeywordPanel.form b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/NewKeywordPanel.form new file mode 100755 index 0000000000..2c72c5055c --- /dev/null +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/NewKeywordPanel.form @@ -0,0 +1,108 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/NewKeywordPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/NewKeywordPanel.java new file mode 100755 index 0000000000..f96738be67 --- /dev/null +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/NewKeywordPanel.java @@ -0,0 +1,142 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2011-2016 Basis Technology Corp. + * Contact: carrier sleuthkit 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.keywordsearch; + +/** + * A panel that is contained in NewKeywordDialog used when the user wants to add + * a new keyword to a list via the options panel. This panel allows the user to + * indicate whether they want the keyword to be an exact match, a substring, or + * a regular expression. + */ +class NewKeywordPanel extends javax.swing.JPanel { + + /** + * Creates new form NewKeywordPanel + */ + public NewKeywordPanel() { + initComponents(); + } + + /** + * @return the text for the new keyword + */ + String getKeywordText() { + return keywordTextField.getText(); + } + + /** + * @return true if the regular expression radio button is selected + */ + boolean isKeywordRegex() { + return regexButton.isSelected(); + } + + /** + * @return true if the exact match radio button is selected + */ + boolean isKeywordExact() { + return exactButton.isSelected(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + keywordTypeButtonGroup = new javax.swing.ButtonGroup(); + keywordTextField = new javax.swing.JTextField(); + exactButton = new javax.swing.JRadioButton(); + substringButton = new javax.swing.JRadioButton(); + regexButton = new javax.swing.JRadioButton(); + newKeywordLabel = new javax.swing.JLabel(); + + keywordTextField.setText(org.openide.util.NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.keywordTextField.text")); // NOI18N + keywordTextField.addAncestorListener(new javax.swing.event.AncestorListener() { + public void ancestorMoved(javax.swing.event.AncestorEvent evt) { + } + public void ancestorAdded(javax.swing.event.AncestorEvent evt) { + keywordTextFieldAncestorAdded(evt); + } + public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { + } + }); + + keywordTypeButtonGroup.add(exactButton); + exactButton.setSelected(true); + org.openide.awt.Mnemonics.setLocalizedText(exactButton, org.openide.util.NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.exactButton.text")); // NOI18N + + keywordTypeButtonGroup.add(substringButton); + org.openide.awt.Mnemonics.setLocalizedText(substringButton, org.openide.util.NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.substringButton.text")); // NOI18N + + keywordTypeButtonGroup.add(regexButton); + org.openide.awt.Mnemonics.setLocalizedText(regexButton, org.openide.util.NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.regexButton.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(newKeywordLabel, org.openide.util.NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.newKeywordLabel.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) + .addGroup(layout.createSequentialGroup() + .addComponent(exactButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(substringButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(regexButton)) + .addComponent(newKeywordLabel) + .addComponent(keywordTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 305, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(newKeywordLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(keywordTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(exactButton) + .addComponent(substringButton) + .addComponent(regexButton)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void keywordTextFieldAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_keywordTextFieldAncestorAdded + evt.getComponent().requestFocusInWindow(); + }//GEN-LAST:event_keywordTextFieldAncestorAdded + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JRadioButton exactButton; + private javax.swing.JTextField keywordTextField; + private javax.swing.ButtonGroup keywordTypeButtonGroup; + private javax.swing.JLabel newKeywordLabel; + private javax.swing.JRadioButton regexButton; + private javax.swing.JRadioButton substringButton; + // End of variables declaration//GEN-END:variables +} diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/XmlKeywordSearchList.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/XmlKeywordSearchList.java index 87d792557f..a5c25d1dc7 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/XmlKeywordSearchList.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/XmlKeywordSearchList.java @@ -55,6 +55,7 @@ final class XmlKeywordSearchList extends KeywordSearchList { private static final String LIST_INGEST_MSGS = "ingest_messages"; //NON-NLS private static final String KEYWORD_EL = "keyword"; //NON-NLS private static final String KEYWORD_LITERAL_ATTR = "literal"; //NON-NLS + private static final String KEYWORD_WHOLE_ATTR = "whole"; //NON-NLS private static final String KEYWORD_SELECTOR_ATTR = "selector"; //NON-NLS private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; //NON-NLS private static final String ENCODING = "UTF-8"; //NON-NLS @@ -125,6 +126,8 @@ final class XmlKeywordSearchList extends KeywordSearchList { Element keywordEl = doc.createElement(KEYWORD_EL); String literal = keyword.searchTermIsLiteral() ? "true" : "false"; //NON-NLS keywordEl.setAttribute(KEYWORD_LITERAL_ATTR, literal); + String whole = keyword.searchTermIsWholeWord() ? "true" : "false"; //NON-NLS + keywordEl.setAttribute(KEYWORD_WHOLE_ATTR, whole); BlackboardAttribute.ATTRIBUTE_TYPE selectorType = keyword.getArtifactAttributeType(); if (selectorType != null) { keywordEl.setAttribute(KEYWORD_SELECTOR_ATTR, selectorType.getLabel()); @@ -195,14 +198,20 @@ final class XmlKeywordSearchList extends KeywordSearchList { Element wordEl = (Element) wordsNList.item(j); String literal = wordEl.getAttribute(KEYWORD_LITERAL_ATTR); boolean isLiteral = literal.equals("true"); //NON-NLS - Keyword keyword = new Keyword(wordEl.getTextContent(), isLiteral); + Keyword keyword; + String whole = wordEl.getAttribute(KEYWORD_WHOLE_ATTR); + if (whole.equals("")) { + keyword = new Keyword(wordEl.getTextContent(), isLiteral); + } else { + boolean isWhole = whole.equals("true"); + keyword = new Keyword(wordEl.getTextContent(), isLiteral, isWhole); + } String selector = wordEl.getAttribute(KEYWORD_SELECTOR_ATTR); if (!selector.equals("")) { BlackboardAttribute.ATTRIBUTE_TYPE selectorType = BlackboardAttribute.ATTRIBUTE_TYPE.fromLabel(selector); keyword.setArtifactAttributeType(selectorType); } words.add(keyword); - } theLists.put(name, list); }