19 package org.sleuthkit.autopsy.filesearch;
21 import java.awt.event.ActionListener;
22 import javax.swing.JComboBox;
24 import org.openide.util.NbBundle;
31 class SizeSearchFilter
extends AbstractFileSearchFilter<SizeSearchPanel> {
34 this(
new SizeSearchPanel());
37 SizeSearchFilter(SizeSearchPanel component) {
42 public boolean isEnabled() {
43 return this.getComponent().getSizeCheckBox().isSelected();
47 public String getPredicate() throws FilterValidationException {
48 int size = ((Number) this.getComponent().getSizeTextField().getValue()).intValue();
49 String
operator = compareComboBoxToOperator(this.getComponent().getSizeCompareComboBox());
50 int unit = this.getComponent().getSizeUnitComboBox().getSelectedIndex();
51 int divider = (int) Math.pow(2, (unit * 10));
52 size = size * divider;
53 return "size " +
operator +
" " + size;
56 private String compareComboBoxToOperator(JComboBox<String> compare) {
57 String compareSize = compare.getSelectedItem().toString();
59 if (compareSize.equals(NbBundle.getMessage(
this.getClass(),
"SizeSearchPanel.sizeCompareComboBox.equalTo"))) {
61 }
else if (compareSize.equals(
62 NbBundle.getMessage(
this.getClass(),
"SizeSearchPanel.sizeCompareComboBox.greaterThan"))) {
64 }
else if (compareSize.equals(
65 NbBundle.getMessage(
this.getClass(),
"SizeSearchPanel.sizeCompareComboBox.lessThan"))) {
68 throw new IllegalArgumentException();
73 public void addActionListener(ActionListener l) {
74 getComponent().addActionListener(l);