mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-16 17:57:43 +00:00
Merge pull request #2187 from BasisOlivers/search-button-enabling
Made search button disable based upon whether a filter is enabled.
This commit is contained in:
commit
49929cf94d
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.filesearch;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
@ -39,4 +40,9 @@ abstract class AbstractFileSearchFilter<T extends JComponent> implements FileSea
|
||||
public T getComponent() {
|
||||
return this.component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
this.getComponent().addPropertyChangeListener(listener);
|
||||
}
|
||||
}
|
||||
|
@ -205,6 +205,11 @@ class DateSearchFilter extends AbstractFileSearchFilter<DateSearchPanel> {
|
||||
getComponent().addActionListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return this.getComponent().isValidSearch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inner class to put the separator inside the combo box.
|
||||
*/
|
||||
|
@ -236,6 +236,9 @@
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/filesearch/Bundle.properties" key="DateSearchPanel.modifiedCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="modifiedCheckBoxActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="changedCheckBox">
|
||||
<Properties>
|
||||
@ -244,6 +247,9 @@
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/filesearch/Bundle.properties" key="DateSearchPanel.changedCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="changedCheckBoxActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="accessedCheckBox">
|
||||
<Properties>
|
||||
@ -252,6 +258,9 @@
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/filesearch/Bundle.properties" key="DateSearchPanel.accessedCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="accessedCheckBoxActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="createdCheckBox">
|
||||
<Properties>
|
||||
@ -260,6 +269,9 @@
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/filesearch/Bundle.properties" key="DateSearchPanel.createdCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="createdCheckBoxActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="org.jbundle.thin.base.screen.jcalendarbutton.JCalendarButton" name="dateFromButtonCalendar">
|
||||
<Properties>
|
||||
|
@ -20,6 +20,8 @@ package org.sleuthkit.autopsy.filesearch;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
@ -37,6 +39,7 @@ class DateSearchPanel extends javax.swing.JPanel {
|
||||
|
||||
DateFormat dateFormat;
|
||||
List<String> timeZones;
|
||||
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||
|
||||
DateSearchPanel(DateFormat dateFormat, List<String> timeZones) {
|
||||
this.dateFormat = dateFormat;
|
||||
@ -133,6 +136,16 @@ class DateSearchPanel extends javax.swing.JPanel {
|
||||
this.changedCheckBox.setEnabled(enable);
|
||||
this.createdCheckBox.setEnabled(enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener pcl) {
|
||||
pcs.addPropertyChangeListener(pcl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener pcl) {
|
||||
pcs.removePropertyChangeListener(pcl);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
@ -209,15 +222,35 @@ class DateSearchPanel extends javax.swing.JPanel {
|
||||
|
||||
modifiedCheckBox.setSelected(true);
|
||||
modifiedCheckBox.setText(org.openide.util.NbBundle.getMessage(DateSearchPanel.class, "DateSearchPanel.modifiedCheckBox.text")); // NOI18N
|
||||
modifiedCheckBox.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
modifiedCheckBoxActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
changedCheckBox.setSelected(true);
|
||||
changedCheckBox.setText(org.openide.util.NbBundle.getMessage(DateSearchPanel.class, "DateSearchPanel.changedCheckBox.text")); // NOI18N
|
||||
changedCheckBox.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
changedCheckBoxActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
accessedCheckBox.setSelected(true);
|
||||
accessedCheckBox.setText(org.openide.util.NbBundle.getMessage(DateSearchPanel.class, "DateSearchPanel.accessedCheckBox.text")); // NOI18N
|
||||
accessedCheckBox.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
accessedCheckBoxActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
createdCheckBox.setSelected(true);
|
||||
createdCheckBox.setText(org.openide.util.NbBundle.getMessage(DateSearchPanel.class, "DateSearchPanel.createdCheckBox.text")); // NOI18N
|
||||
createdCheckBox.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
createdCheckBoxActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
dateFromButtonCalendar.setText(org.openide.util.NbBundle.getMessage(DateSearchPanel.class, "DateSearchPanel.dateFromButtonCalendar.text")); // NOI18N
|
||||
dateFromButtonCalendar.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
|
||||
@ -349,8 +382,25 @@ class DateSearchPanel extends javax.swing.JPanel {
|
||||
|
||||
private void dateCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dateCheckBoxActionPerformed
|
||||
this.setComponentsEnabled();
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}//GEN-LAST:event_dateCheckBoxActionPerformed
|
||||
|
||||
private void modifiedCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modifiedCheckBoxActionPerformed
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}//GEN-LAST:event_modifiedCheckBoxActionPerformed
|
||||
|
||||
private void accessedCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_accessedCheckBoxActionPerformed
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}//GEN-LAST:event_accessedCheckBoxActionPerformed
|
||||
|
||||
private void createdCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createdCheckBoxActionPerformed
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}//GEN-LAST:event_createdCheckBoxActionPerformed
|
||||
|
||||
private void changedCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changedCheckBoxActionPerformed
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}//GEN-LAST:event_changedCheckBoxActionPerformed
|
||||
|
||||
/**
|
||||
* Validate and set the datetime field on the screen given a datetime
|
||||
* string.
|
||||
@ -379,6 +429,13 @@ class DateSearchPanel extends javax.swing.JPanel {
|
||||
dateToTextField.setText(dateStringResult);
|
||||
dateToButtonCalendar.setTargetDate(date);
|
||||
}
|
||||
|
||||
boolean isValidSearch() {
|
||||
return this.accessedCheckBox.isSelected() ||
|
||||
this.changedCheckBox.isSelected() ||
|
||||
this.createdCheckBox.isSelected() ||
|
||||
this.modifiedCheckBox.isSelected();
|
||||
}
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JCheckBox accessedCheckBox;
|
||||
private javax.swing.JCheckBox changedCheckBox;
|
||||
|
@ -19,6 +19,7 @@
|
||||
package org.sleuthkit.autopsy.filesearch;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
@ -40,6 +41,13 @@ interface FileSearchFilter {
|
||||
*/
|
||||
boolean isEnabled();
|
||||
|
||||
/**
|
||||
* Checks if the panel has valid input for search.
|
||||
*
|
||||
* @return Whether the panel has valid input for search.
|
||||
*/
|
||||
boolean isValid();
|
||||
|
||||
/**
|
||||
* Gets predicate expression to include in the SQL filter expression
|
||||
*
|
||||
@ -56,6 +64,13 @@ interface FileSearchFilter {
|
||||
*/
|
||||
void addActionListener(ActionListener l);
|
||||
|
||||
/**
|
||||
* Adds the property change listener to the panel
|
||||
*
|
||||
* @param listener the listener to add.
|
||||
*/
|
||||
void addPropertyChangeListener(PropertyChangeListener listener);
|
||||
|
||||
/**
|
||||
* Thrown if a filter's inputs are invalid
|
||||
*/
|
||||
|
@ -17,38 +17,35 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* FileSearchPanel.java
|
||||
*
|
||||
* Created on Mar 5, 2012, 1:51:50 PM
|
||||
*/
|
||||
package org.sleuthkit.autopsy.filesearch;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import org.openide.DialogDisplayer;
|
||||
import org.openide.NotifyDescriptor;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.windows.TopComponent;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultTopComponent;
|
||||
import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||
import org.sleuthkit.autopsy.filesearch.FileSearchFilter.FilterValidationException;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
@ -64,6 +61,10 @@ class FileSearchPanel extends javax.swing.JPanel {
|
||||
private static int resultWindowCount = 0; //keep track of result windows so they get unique names
|
||||
private static final String EMPTY_WHERE_CLAUSE = NbBundle.getMessage(DateSearchFilter.class, "FileSearchPanel.emptyWhereClause.text");
|
||||
|
||||
enum EVENT {
|
||||
CHECKED
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new form FileSearchPanel
|
||||
*/
|
||||
@ -100,25 +101,39 @@ class FileSearchPanel extends javax.swing.JPanel {
|
||||
filterPanel.add(fa);
|
||||
}
|
||||
|
||||
for (FileSearchFilter filter : this.getFilters()) {
|
||||
filter.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
searchButton.setEnabled(isValidSearch());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addListenerToAll(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
search();
|
||||
}
|
||||
});
|
||||
searchButton.setEnabled(isValidSearch());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if any of the filters in the panel are enabled (checked)
|
||||
*/
|
||||
private boolean anyFiltersEnabled() {
|
||||
private boolean isValidSearch() {
|
||||
boolean enabled = false;
|
||||
for (FileSearchFilter filter : this.getFilters()) {
|
||||
if (filter.isEnabled()) {
|
||||
return true;
|
||||
enabled = true;
|
||||
if (!filter.isValid()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -129,7 +144,7 @@ class FileSearchPanel extends javax.swing.JPanel {
|
||||
// change the cursor to "waiting cursor" for this operation
|
||||
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
try {
|
||||
if (this.anyFiltersEnabled()) {
|
||||
if (this.isValidSearch()) {
|
||||
String title = NbBundle.getMessage(this.getClass(), "FileSearchPanel.search.results.title", ++resultWindowCount);
|
||||
String pathText = NbBundle.getMessage(this.getClass(), "FileSearchPanel.search.results.pathText");
|
||||
|
||||
@ -290,6 +305,7 @@ class FileSearchPanel extends javax.swing.JPanel {
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel filterPanel;
|
||||
private javax.swing.JButton searchButton;
|
||||
|
@ -19,7 +19,6 @@
|
||||
package org.sleuthkit.autopsy.filesearch;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.datamodel.TskData.FileKnown;
|
||||
|
||||
@ -42,6 +41,7 @@ class KnownStatusSearchFilter extends AbstractFileSearchFilter<KnownStatusSearch
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.getComponent().getKnownCheckBox().isSelected();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -83,4 +83,9 @@ class KnownStatusSearchFilter extends AbstractFileSearchFilter<KnownStatusSearch
|
||||
@Override
|
||||
public void addActionListener(ActionListener l) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return this.getComponent().isValidSearch();
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,9 @@
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/filesearch/Bundle.properties" key="KnownStatusSearchPanel.unknownOptionCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="unknownOptionCheckBoxActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="knownOptionCheckBox">
|
||||
<Properties>
|
||||
@ -83,6 +86,9 @@
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/filesearch/Bundle.properties" key="KnownStatusSearchPanel.knownBadOptionCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="knownBadOptionCheckBoxActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -17,13 +17,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* KnownStatusSearchPanel.java
|
||||
*
|
||||
* Created on Oct 19, 2011, 11:45:44 AM
|
||||
*/
|
||||
package org.sleuthkit.autopsy.filesearch;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import javax.swing.JCheckBox;
|
||||
|
||||
/**
|
||||
@ -32,6 +34,8 @@ import javax.swing.JCheckBox;
|
||||
*/
|
||||
class KnownStatusSearchPanel extends javax.swing.JPanel {
|
||||
|
||||
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||
|
||||
/**
|
||||
* Creates new form KnownStatusSearchPanel
|
||||
*/
|
||||
@ -55,7 +59,7 @@ class KnownStatusSearchPanel extends javax.swing.JPanel {
|
||||
JCheckBox getUnknownOptionCheckBox() {
|
||||
return unknownOptionCheckBox;
|
||||
}
|
||||
|
||||
|
||||
private void setComponentsEnabled() {
|
||||
boolean enabled = this.knownCheckBox.isSelected();
|
||||
this.unknownOptionCheckBox.setEnabled(enabled);
|
||||
@ -63,6 +67,20 @@ class KnownStatusSearchPanel extends javax.swing.JPanel {
|
||||
this.knownBadOptionCheckBox.setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener pcl) {
|
||||
pcs.addPropertyChangeListener(pcl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener pcl) {
|
||||
pcs.removePropertyChangeListener(pcl);
|
||||
}
|
||||
|
||||
boolean isValidSearch() {
|
||||
return this.unknownOptionCheckBox.isSelected() || this.knownBadOptionCheckBox.isSelected() || this.knownOptionCheckBox.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
|
||||
@ -86,6 +104,11 @@ class KnownStatusSearchPanel extends javax.swing.JPanel {
|
||||
|
||||
unknownOptionCheckBox.setSelected(true);
|
||||
unknownOptionCheckBox.setText(org.openide.util.NbBundle.getMessage(KnownStatusSearchPanel.class, "KnownStatusSearchPanel.unknownOptionCheckBox.text")); // NOI18N
|
||||
unknownOptionCheckBox.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
unknownOptionCheckBoxActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
knownOptionCheckBox.setSelected(true);
|
||||
knownOptionCheckBox.setText(org.openide.util.NbBundle.getMessage(KnownStatusSearchPanel.class, "KnownStatusSearchPanel.knownOptionCheckBox.text")); // NOI18N
|
||||
@ -97,6 +120,11 @@ class KnownStatusSearchPanel extends javax.swing.JPanel {
|
||||
|
||||
knownBadOptionCheckBox.setSelected(true);
|
||||
knownBadOptionCheckBox.setText(org.openide.util.NbBundle.getMessage(KnownStatusSearchPanel.class, "KnownStatusSearchPanel.knownBadOptionCheckBox.text")); // NOI18N
|
||||
knownBadOptionCheckBox.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
knownBadOptionCheckBoxActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
@ -127,13 +155,22 @@ class KnownStatusSearchPanel extends javax.swing.JPanel {
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void knownOptionCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_knownOptionCheckBoxActionPerformed
|
||||
// TODO add your handling code here:
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}//GEN-LAST:event_knownOptionCheckBoxActionPerformed
|
||||
|
||||
private void knownCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_knownCheckBoxActionPerformed
|
||||
setComponentsEnabled();
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}//GEN-LAST:event_knownCheckBoxActionPerformed
|
||||
|
||||
private void unknownOptionCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unknownOptionCheckBoxActionPerformed
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}//GEN-LAST:event_unknownOptionCheckBoxActionPerformed
|
||||
|
||||
private void knownBadOptionCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_knownBadOptionCheckBoxActionPerformed
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}//GEN-LAST:event_knownBadOptionCheckBoxActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JCheckBox knownBadOptionCheckBox;
|
||||
private javax.swing.JCheckBox knownCheckBox;
|
||||
|
@ -10,28 +10,28 @@ import java.awt.event.ActionListener;
|
||||
/**
|
||||
* Filter by mime type used in filter areas of file search by attribute.
|
||||
*/
|
||||
class MimeTypeFilter extends AbstractFileSearchFilter<MimeTypePanel> {
|
||||
class MimeTypeFilter extends AbstractFileSearchFilter<MimeTypePanel> {
|
||||
|
||||
public MimeTypeFilter(MimeTypePanel component) {
|
||||
super(component);
|
||||
}
|
||||
|
||||
public MimeTypeFilter() {
|
||||
this(new MimeTypePanel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.getComponent().isSelected() &&
|
||||
!this.getComponent().getMimeTypesSelected().isEmpty();
|
||||
return this.getComponent().isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPredicate() throws FilterValidationException {
|
||||
String predicate = "";
|
||||
for(String mimeType : this.getComponent().getMimeTypesSelected()) {
|
||||
for (String mimeType : this.getComponent().getMimeTypesSelected()) {
|
||||
predicate += "mime_type = '" + mimeType + "' OR ";
|
||||
}
|
||||
if(predicate.length() > 3) {
|
||||
if (predicate.length() > 3) {
|
||||
predicate = predicate.substring(0, predicate.length() - 3);
|
||||
}
|
||||
return predicate;
|
||||
@ -40,5 +40,9 @@ class MimeTypeFilter extends AbstractFileSearchFilter<MimeTypePanel> {
|
||||
@Override
|
||||
public void addActionListener(ActionListener l) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return !this.getComponent().getMimeTypesSelected().isEmpty();
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" pref="298" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" pref="246" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
|
@ -5,12 +5,16 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.filesearch;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import org.apache.tika.mime.MediaType;
|
||||
import org.apache.tika.mime.MimeTypes;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
@ -25,6 +29,7 @@ public class MimeTypePanel extends javax.swing.JPanel {
|
||||
private static final SortedSet<MediaType> mediaTypes = MimeTypes.getDefaultMimeTypes().getMediaTypeRegistry().getTypes();
|
||||
private static final Logger logger = Logger.getLogger(MimeTypePanel.class.getName());
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||
|
||||
/**
|
||||
* Creates new form MimeTypePanel
|
||||
@ -32,6 +37,12 @@ public class MimeTypePanel extends javax.swing.JPanel {
|
||||
public MimeTypePanel() {
|
||||
initComponents();
|
||||
setComponentsEnabled();
|
||||
this.mimeTypeList.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String[] getMimeTypeArray() {
|
||||
@ -75,6 +86,16 @@ public class MimeTypePanel extends javax.swing.JPanel {
|
||||
this.mimeTypeList.setEnabled(enabled);
|
||||
this.jLabel1.setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener pcl) {
|
||||
pcs.addPropertyChangeListener(pcl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener pcl) {
|
||||
pcs.removePropertyChangeListener(pcl);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
@ -141,6 +162,8 @@ public class MimeTypePanel extends javax.swing.JPanel {
|
||||
|
||||
private void mimeTypeCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mimeTypeCheckBoxActionPerformed
|
||||
setComponentsEnabled();
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
this.mimeTypeList.setSelectedIndices(new int[0]);
|
||||
}//GEN-LAST:event_mimeTypeCheckBoxActionPerformed
|
||||
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
package org.sleuthkit.autopsy.filesearch;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.filesearch.FileSearchFilter.FilterValidationException;
|
||||
|
||||
@ -63,4 +62,9 @@ class NameSearchFilter extends AbstractFileSearchFilter<NameSearchPanel> {
|
||||
public void addActionListener(ActionListener l) {
|
||||
getComponent().addActionListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return !this.getComponent().getSearchTextField().getText().isEmpty();
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* NameSearchPanel.java
|
||||
*
|
||||
* Created on Oct 19, 2011, 11:58:53 AM
|
||||
@ -26,9 +26,13 @@ package org.sleuthkit.autopsy.filesearch;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -36,6 +40,8 @@ import javax.swing.JTextField;
|
||||
*/
|
||||
class NameSearchPanel extends javax.swing.JPanel {
|
||||
|
||||
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||
|
||||
/**
|
||||
* Creates new form NameSearchPanel
|
||||
*/
|
||||
@ -67,6 +73,22 @@ class NameSearchPanel extends javax.swing.JPanel {
|
||||
copyMenuItem.addActionListener(actList);
|
||||
pasteMenuItem.addActionListener(actList);
|
||||
selectAllMenuItem.addActionListener(actList);
|
||||
this.searchTextField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -77,12 +99,22 @@ class NameSearchPanel extends javax.swing.JPanel {
|
||||
JTextField getSearchTextField() {
|
||||
return searchTextField;
|
||||
}
|
||||
|
||||
|
||||
void setComponentsEnabled() {
|
||||
boolean enabled = nameCheckBox.isSelected();
|
||||
this.searchTextField.setEnabled(enabled);
|
||||
this.noteNameLabel.setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener pcl) {
|
||||
pcs.addPropertyChangeListener(pcl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener pcl) {
|
||||
pcs.removePropertyChangeListener(pcl);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
@ -168,6 +200,7 @@ class NameSearchPanel extends javax.swing.JPanel {
|
||||
|
||||
private void nameCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameCheckBoxActionPerformed
|
||||
setComponentsEnabled();
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}//GEN-LAST:event_nameCheckBoxActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
@ -20,7 +20,6 @@ package org.sleuthkit.autopsy.filesearch;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.JComboBox;
|
||||
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.filesearch.FileSearchFilter.FilterValidationException;
|
||||
|
||||
@ -73,4 +72,9 @@ class SizeSearchFilter extends AbstractFileSearchFilter<SizeSearchPanel> {
|
||||
public void addActionListener(ActionListener l) {
|
||||
getComponent().addActionListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ package org.sleuthkit.autopsy.filesearch;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.text.NumberFormat;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
@ -32,6 +34,8 @@ import javax.swing.JMenuItem;
|
||||
*/
|
||||
class SizeSearchPanel extends javax.swing.JPanel {
|
||||
|
||||
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||
|
||||
/**
|
||||
* Creates new form SizeSearchPanel
|
||||
*/
|
||||
@ -81,13 +85,23 @@ class SizeSearchPanel extends javax.swing.JPanel {
|
||||
JComboBox<String> getSizeUnitComboBox() {
|
||||
return sizeUnitComboBox;
|
||||
}
|
||||
|
||||
|
||||
void setComponentsEnabled() {
|
||||
boolean enabled = this.sizeCheckBox.isSelected();
|
||||
this.sizeCompareComboBox.setEnabled(enabled);
|
||||
this.sizeUnitComboBox.setEnabled(enabled);
|
||||
this.sizeTextField.setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener pcl) {
|
||||
pcs.addPropertyChangeListener(pcl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener pcl) {
|
||||
pcs.removePropertyChangeListener(pcl);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
@ -168,6 +182,7 @@ class SizeSearchPanel extends javax.swing.JPanel {
|
||||
|
||||
private void sizeCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sizeCheckBoxActionPerformed
|
||||
setComponentsEnabled();
|
||||
pcs.firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
|
||||
}//GEN-LAST:event_sizeCheckBoxActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
Loading…
x
Reference in New Issue
Block a user