20 package org.sleuthkit.autopsy.filesearch;
22 import org.openide.util.NbBundle;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.ActionListener;
26 import java.text.NumberFormat;
27 import javax.swing.JCheckBox;
28 import javax.swing.JComboBox;
29 import javax.swing.JFormattedTextField;
30 import javax.swing.JMenuItem;
36 class SizeSearchPanel
extends javax.swing.JPanel {
41 customizeComponents();
44 private void customizeComponents(){
46 sizeTextField.setComponentPopupMenu(rightClickMenu);
47 ActionListener actList =
new ActionListener(){
49 public void actionPerformed(ActionEvent e){
50 JMenuItem jmi = (JMenuItem) e.getSource();
51 if(jmi.equals(cutMenuItem))
53 else if(jmi.equals(copyMenuItem))
55 else if(jmi.equals(pasteMenuItem))
56 sizeTextField.paste();
57 else if(jmi.equals(selectAllMenuItem))
58 sizeTextField.selectAll();
61 cutMenuItem.addActionListener(actList);
62 copyMenuItem.addActionListener(actList);
63 pasteMenuItem.addActionListener(actList);
64 selectAllMenuItem.addActionListener(actList);
68 JCheckBox getSizeCheckBox() {
72 JComboBox<String> getSizeCompareComboBox() {
73 return sizeCompareComboBox;
76 JFormattedTextField getSizeTextField() {
80 JComboBox<String> getSizeUnitComboBox() {
81 return sizeUnitComboBox;
89 @SuppressWarnings(
"unchecked")
91 private
void initComponents() {
93 rightClickMenu =
new javax.swing.JPopupMenu();
94 cutMenuItem =
new javax.swing.JMenuItem();
95 copyMenuItem =
new javax.swing.JMenuItem();
96 pasteMenuItem =
new javax.swing.JMenuItem();
97 selectAllMenuItem =
new javax.swing.JMenuItem();
98 sizeUnitComboBox =
new javax.swing.JComboBox<String>();
99 sizeTextField =
new JFormattedTextField(NumberFormat.getIntegerInstance());
100 sizeCompareComboBox =
new javax.swing.JComboBox<String>();
101 sizeCheckBox =
new javax.swing.JCheckBox();
103 cutMenuItem.setText(
org.openide.util.NbBundle.getMessage(SizeSearchPanel.class,
"SizeSearchPanel.cutMenuItem.text"));
104 rightClickMenu.add(cutMenuItem);
106 copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(SizeSearchPanel.class,
"SizeSearchPanel.copyMenuItem.text"));
107 rightClickMenu.add(copyMenuItem);
109 pasteMenuItem.setText(
org.openide.util.NbBundle.getMessage(SizeSearchPanel.class,
"SizeSearchPanel.pasteMenuItem.text"));
110 rightClickMenu.add(pasteMenuItem);
112 selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(SizeSearchPanel.class,
"SizeSearchPanel.selectAllMenuItem.text"));
113 rightClickMenu.add(selectAllMenuItem);
115 sizeUnitComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
"Byte(s)",
"KB",
"MB",
"GB",
"TB" }));
117 sizeTextField.setValue(0);
118 sizeTextField.addMouseListener(
new java.awt.event.MouseAdapter() {
119 public void mouseClicked(java.awt.event.MouseEvent evt) {
120 sizeTextFieldMouseClicked(evt);
124 sizeCompareComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
125 NbBundle.getMessage(this.getClass(),
"SizeSearchPanel.sizeCompareComboBox.equalTo"),
126 NbBundle.getMessage(this.getClass(),
"SizeSearchPanel.sizeCompareComboBox.greaterThan"),
127 NbBundle.getMessage(this.getClass(),
"SizeSearchPanel.sizeCompareComboBox.lessThan") }));
129 sizeCheckBox.setText(
org.openide.util.NbBundle.getMessage(SizeSearchPanel.class,
"SizeSearchPanel.sizeCheckBox.text"));
131 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
132 this.setLayout(layout);
133 layout.setHorizontalGroup(
134 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
135 .addGroup(layout.createSequentialGroup()
136 .addComponent(sizeCheckBox)
137 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
138 .addComponent(sizeCompareComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
139 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
140 .addComponent(sizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
141 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
142 .addComponent(sizeUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))
144 layout.setVerticalGroup(
145 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
146 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
147 .addComponent(sizeCompareComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
148 .addComponent(sizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
149 .addComponent(sizeUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
150 .addComponent(sizeCheckBox))
154 private void sizeTextFieldMouseClicked(java.awt.event.MouseEvent evt) {
155 this.sizeCheckBox.setSelected(
true);
156 this.sizeTextField.selectAll();
159 private javax.swing.JMenuItem copyMenuItem;
160 private javax.swing.JMenuItem cutMenuItem;
161 private javax.swing.JMenuItem pasteMenuItem;
162 private javax.swing.JPopupMenu rightClickMenu;
163 private javax.swing.JMenuItem selectAllMenuItem;
164 private javax.swing.JCheckBox sizeCheckBox;
165 private javax.swing.JComboBox<String> sizeCompareComboBox;
166 private javax.swing.JFormattedTextField sizeTextField;
167 private javax.swing.JComboBox<String> sizeUnitComboBox;
170 void addActionListener(ActionListener l) {
171 sizeTextField.addActionListener(l);