19 package org.sleuthkit.autopsy.filesearch;
21 import org.openide.util.NbBundle;
23 import java.awt.event.ActionEvent;
24 import java.awt.event.ActionListener;
25 import java.text.NumberFormat;
26 import javax.swing.JCheckBox;
27 import javax.swing.JComboBox;
28 import javax.swing.JFormattedTextField;
29 import javax.swing.JMenuItem;
35 class SizeSearchPanel
extends javax.swing.JPanel {
42 customizeComponents();
45 private void customizeComponents() {
47 sizeTextField.setComponentPopupMenu(rightClickMenu);
48 ActionListener actList =
new ActionListener() {
50 public void actionPerformed(ActionEvent e) {
51 JMenuItem jmi = (JMenuItem) e.getSource();
52 if (jmi.equals(cutMenuItem)) {
54 }
else if (jmi.equals(copyMenuItem)) {
56 }
else if (jmi.equals(pasteMenuItem)) {
57 sizeTextField.paste();
58 }
else if (jmi.equals(selectAllMenuItem)) {
59 sizeTextField.selectAll();
63 cutMenuItem.addActionListener(actList);
64 copyMenuItem.addActionListener(actList);
65 pasteMenuItem.addActionListener(actList);
66 selectAllMenuItem.addActionListener(actList);
70 JCheckBox getSizeCheckBox() {
74 JComboBox<String> getSizeCompareComboBox() {
75 return sizeCompareComboBox;
78 JFormattedTextField getSizeTextField() {
82 JComboBox<String> getSizeUnitComboBox() {
83 return sizeUnitComboBox;
91 @SuppressWarnings(
"unchecked")
93 private
void initComponents() {
95 rightClickMenu =
new javax.swing.JPopupMenu();
96 cutMenuItem =
new javax.swing.JMenuItem();
97 copyMenuItem =
new javax.swing.JMenuItem();
98 pasteMenuItem =
new javax.swing.JMenuItem();
99 selectAllMenuItem =
new javax.swing.JMenuItem();
100 sizeUnitComboBox =
new javax.swing.JComboBox<String>();
101 sizeTextField =
new JFormattedTextField(NumberFormat.getIntegerInstance());
102 sizeCompareComboBox =
new javax.swing.JComboBox<String>();
103 sizeCheckBox =
new javax.swing.JCheckBox();
105 cutMenuItem.setText(
org.openide.util.NbBundle.getMessage(SizeSearchPanel.class,
"SizeSearchPanel.cutMenuItem.text"));
106 rightClickMenu.add(cutMenuItem);
108 copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(SizeSearchPanel.class,
"SizeSearchPanel.copyMenuItem.text"));
109 rightClickMenu.add(copyMenuItem);
111 pasteMenuItem.setText(
org.openide.util.NbBundle.getMessage(SizeSearchPanel.class,
"SizeSearchPanel.pasteMenuItem.text"));
112 rightClickMenu.add(pasteMenuItem);
114 selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(SizeSearchPanel.class,
"SizeSearchPanel.selectAllMenuItem.text"));
115 rightClickMenu.add(selectAllMenuItem);
117 sizeUnitComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
"Byte(s)",
"KB",
"MB",
"GB",
"TB" }));
119 sizeTextField.setValue(0);
120 sizeTextField.addMouseListener(
new java.awt.event.MouseAdapter() {
121 public void mouseClicked(java.awt.event.MouseEvent evt) {
122 sizeTextFieldMouseClicked(evt);
126 sizeCompareComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
127 NbBundle.getMessage(this.getClass(),
"SizeSearchPanel.sizeCompareComboBox.equalTo"),
128 NbBundle.getMessage(this.getClass(),
"SizeSearchPanel.sizeCompareComboBox.greaterThan"),
129 NbBundle.getMessage(this.getClass(),
"SizeSearchPanel.sizeCompareComboBox.lessThan") }));
131 sizeCheckBox.setText(
org.openide.util.NbBundle.getMessage(SizeSearchPanel.class,
"SizeSearchPanel.sizeCheckBox.text"));
133 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
134 this.setLayout(layout);
135 layout.setHorizontalGroup(
136 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
137 .addGroup(layout.createSequentialGroup()
138 .addComponent(sizeCheckBox)
139 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
140 .addComponent(sizeCompareComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
141 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
142 .addComponent(sizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
143 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
144 .addComponent(sizeUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))
146 layout.setVerticalGroup(
147 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
148 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
149 .addComponent(sizeCompareComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
150 .addComponent(sizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
151 .addComponent(sizeUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
152 .addComponent(sizeCheckBox))
156 private void sizeTextFieldMouseClicked(java.awt.event.MouseEvent evt) {
157 this.sizeCheckBox.setSelected(
true);
158 this.sizeTextField.selectAll();
161 private javax.swing.JMenuItem copyMenuItem;
162 private javax.swing.JMenuItem cutMenuItem;
163 private javax.swing.JMenuItem pasteMenuItem;
164 private javax.swing.JPopupMenu rightClickMenu;
165 private javax.swing.JMenuItem selectAllMenuItem;
166 private javax.swing.JCheckBox sizeCheckBox;
167 private javax.swing.JComboBox<String> sizeCompareComboBox;
168 private javax.swing.JFormattedTextField sizeTextField;
169 private javax.swing.JComboBox<String> sizeUnitComboBox;
172 void addActionListener(ActionListener l) {
173 sizeTextField.addActionListener(l);