diff --git a/Core/src/org/sleuthkit/autopsy/filesearch/AbstractFileSearchFilter.java b/Core/src/org/sleuthkit/autopsy/filesearch/AbstractFileSearchFilter.java index 67f65be80b..149e11afa5 100755 --- a/Core/src/org/sleuthkit/autopsy/filesearch/AbstractFileSearchFilter.java +++ b/Core/src/org/sleuthkit/autopsy/filesearch/AbstractFileSearchFilter.java @@ -31,9 +31,20 @@ import javax.swing.JComponent; abstract class AbstractFileSearchFilter implements FileSearchFilter { final private T component; - + private String lastErrorMessage; + AbstractFileSearchFilter(T component) { this.component = component; + this.lastErrorMessage = ""; + } + + void setLastError(String mes){ + lastErrorMessage = mes; + } + + @Override + public String getLastError(){ + return this.lastErrorMessage; } @Override diff --git a/Core/src/org/sleuthkit/autopsy/filesearch/Bundle.properties b/Core/src/org/sleuthkit/autopsy/filesearch/Bundle.properties index fff8007fd4..bb91c8e05c 100755 --- a/Core/src/org/sleuthkit/autopsy/filesearch/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/filesearch/Bundle.properties @@ -57,4 +57,5 @@ MimeTypePanel.jLabel1.text=*Note: Multiple MIME types can be selected FileSearchPanel.searchButton.text=Search MimeTypePanel.mimeTypeCheckBox.text=MIME Type: HashSearchPanel.md5CheckBox.text=MD5: -HashSearchPanel.emptyHashMsg.text=Must enter something for hash search. \ No newline at end of file +HashSearchPanel.emptyHashMsg.text=Must enter something for hash search. +FileSearchPanel.errorLabel.text=\ diff --git a/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchFilter.java b/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchFilter.java index 457db56570..db16fdd1e0 100755 --- a/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchFilter.java +++ b/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchFilter.java @@ -47,6 +47,13 @@ interface FileSearchFilter { * @return Whether the panel has valid input for search. */ boolean isValid(); + + /** + * Get the last error recorded during the call to isValid + * + * @return Description of why the filter is invalid + */ + String getLastError(); /** * Gets predicate expression to include in the SQL filter expression diff --git a/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchPanel.form b/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchPanel.form index dbb90bea12..a64489bb01 100755 --- a/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchPanel.form +++ b/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchPanel.form @@ -23,7 +23,9 @@ - + + + @@ -32,9 +34,14 @@ - - - + + + + + + + + @@ -63,6 +70,19 @@ + + + + + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchPanel.java b/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchPanel.java index d7efb0b46f..2a27be8297 100755 --- a/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchPanel.java @@ -111,13 +111,7 @@ class FileSearchPanel extends javax.swing.JPanel { } }); } - - addListenerToAll(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - search(); - } - }); + searchButton.setEnabled(isValidSearch()); } @@ -130,11 +124,13 @@ class FileSearchPanel extends javax.swing.JPanel { if (filter.isEnabled()) { enabled = true; if (!filter.isValid()) { + errorLabel.setText(filter.getLastError()); return false; } } } + errorLabel.setText(""); return enabled; } @@ -280,6 +276,7 @@ class FileSearchPanel extends javax.swing.JPanel { filterPanel = new javax.swing.JPanel(); searchButton = new javax.swing.JButton(); + errorLabel = new javax.swing.JLabel(); setPreferredSize(new java.awt.Dimension(300, 300)); @@ -288,6 +285,14 @@ class FileSearchPanel extends javax.swing.JPanel { filterPanel.setLayout(new javax.swing.BoxLayout(filterPanel, javax.swing.BoxLayout.Y_AXIS)); searchButton.setText(org.openide.util.NbBundle.getMessage(FileSearchPanel.class, "FileSearchPanel.searchButton.text")); // NOI18N + searchButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + searchButtonActionPerformed(evt); + } + }); + + errorLabel.setForeground(new java.awt.Color(255, 51, 51)); + errorLabel.setText(org.openide.util.NbBundle.getMessage(FileSearchPanel.class, "FileSearchPanel.errorLabel.text")); // NOI18N javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); @@ -295,21 +300,31 @@ class FileSearchPanel extends javax.swing.JPanel { layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(filterPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap() + .addComponent(errorLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(searchButton) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addComponent(filterPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGap(0, 0, 0) - .addComponent(searchButton) + .addComponent(filterPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(searchButton) + .addGroup(layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(errorLabel))) .addContainerGap()) ); }// //GEN-END:initComponents + private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed + search(); + }//GEN-LAST:event_searchButtonActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel errorLabel; private javax.swing.JPanel filterPanel; private javax.swing.JButton searchButton; // End of variables declaration//GEN-END:variables