19 package org.sleuthkit.autopsy.filesearch;
21 import java.awt.event.ActionListener;
22 import javax.swing.JComboBox;
23 import org.openide.util.NbBundle;
30 class SizeSearchFilter
extends AbstractFileSearchFilter<SizeSearchPanel> {
33 this(
new SizeSearchPanel());
36 SizeSearchFilter(SizeSearchPanel component) {
41 public boolean isEnabled() {
42 return this.getComponent().getSizeCheckBox().isSelected();
46 public String getPredicate() throws FilterValidationException {
47 int size = ((Number) this.getComponent().getSizeTextField().getValue()).intValue();
48 String
operator = compareComboBoxToOperator(this.getComponent().getSizeCompareComboBox());
49 int unit = this.getComponent().getSizeUnitComboBox().getSelectedIndex();
50 int divider = (int) Math.pow(2, (unit * 10));
51 size = size * divider;
52 return "size " +
operator +
" " + size;
55 private String compareComboBoxToOperator(JComboBox<String> compare) {
56 String compareSize = compare.getSelectedItem().toString();
58 if (compareSize.equals(NbBundle.getMessage(
this.getClass(),
"SizeSearchPanel.sizeCompareComboBox.equalTo"))) {
60 }
else if (compareSize.equals(
61 NbBundle.getMessage(
this.getClass(),
"SizeSearchPanel.sizeCompareComboBox.greaterThan"))) {
63 }
else if (compareSize.equals(
64 NbBundle.getMessage(
this.getClass(),
"SizeSearchPanel.sizeCompareComboBox.lessThan"))) {
67 throw new IllegalArgumentException();
72 public void addActionListener(ActionListener l) {
73 getComponent().addActionListener(l);
77 public boolean isValid() {