19 package org.sleuthkit.autopsy.filesearch;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import javax.swing.JCheckBox;
24 import javax.swing.JMenuItem;
25 import javax.swing.JTextField;
26 import javax.swing.event.DocumentEvent;
27 import javax.swing.event.DocumentListener;
32 @SuppressWarnings(
"PMD.SingularField")
33 class HashSearchPanel extends javax.swing.JPanel {
35 private static final long serialVersionUID = 1L;
42 customizeComponents();
43 setComponentsEnabled();
46 private void customizeComponents() {
48 md5TextField.setComponentPopupMenu(rightClickMenu);
49 ActionListener actList =
new ActionListener() {
51 public void actionPerformed(ActionEvent e) {
52 JMenuItem jmi = (JMenuItem) e.getSource();
53 if (jmi.equals(cutMenuItem)) {
55 }
else if (jmi.equals(copyMenuItem)) {
57 }
else if (jmi.equals(pasteMenuItem)) {
59 }
else if (jmi.equals(selectAllMenuItem)) {
60 md5TextField.selectAll();
64 cutMenuItem.addActionListener(actList);
65 copyMenuItem.addActionListener(actList);
66 pasteMenuItem.addActionListener(actList);
67 selectAllMenuItem.addActionListener(actList);
68 this.md5TextField.getDocument().addDocumentListener(
new DocumentListener() {
70 public void insertUpdate(DocumentEvent e) {
71 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
75 public void removeUpdate(DocumentEvent e) {
76 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
80 public void changedUpdate(DocumentEvent e) {
81 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
85 this.sha256TextField.getDocument().addDocumentListener(
new DocumentListener() {
87 public void insertUpdate(DocumentEvent e) {
88 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
92 public void removeUpdate(DocumentEvent e) {
93 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
97 public void changedUpdate(DocumentEvent e) {
98 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
104 JCheckBox getMd5HashCheckBox() {
108 JTextField getMd5TextField() {
112 JCheckBox getSha256HashCheckBox() {
113 return sha256CheckBox;
116 JTextField getSha256TextField() {
117 return sha256TextField;
120 void setComponentsEnabled() {
121 boolean md5Enabled = md5CheckBox.isSelected();
122 this.md5TextField.setEnabled(md5Enabled);
123 boolean sha256Enabled = sha256CheckBox.isSelected();
124 this.sha256TextField.setEnabled(sha256Enabled);
132 @SuppressWarnings(
"unchecked")
134 private
void initComponents() {
136 rightClickMenu =
new javax.swing.JPopupMenu();
137 cutMenuItem =
new javax.swing.JMenuItem();
138 copyMenuItem =
new javax.swing.JMenuItem();
139 pasteMenuItem =
new javax.swing.JMenuItem();
140 selectAllMenuItem =
new javax.swing.JMenuItem();
141 md5CheckBox =
new javax.swing.JCheckBox();
142 md5TextField =
new javax.swing.JTextField();
143 sha256CheckBox =
new javax.swing.JCheckBox();
144 sha256TextField =
new javax.swing.JTextField();
146 cutMenuItem.setText(
org.openide.util.NbBundle.getMessage(HashSearchPanel.class,
"NameSearchPanel.cutMenuItem.text"));
147 rightClickMenu.add(cutMenuItem);
149 copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(HashSearchPanel.class,
"NameSearchPanel.copyMenuItem.text"));
150 rightClickMenu.add(copyMenuItem);
152 pasteMenuItem.setText(
org.openide.util.NbBundle.getMessage(HashSearchPanel.class,
"NameSearchPanel.pasteMenuItem.text"));
153 rightClickMenu.add(pasteMenuItem);
155 selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(HashSearchPanel.class,
"NameSearchPanel.selectAllMenuItem.text"));
156 rightClickMenu.add(selectAllMenuItem);
158 md5CheckBox.setText(
org.openide.util.NbBundle.getMessage(HashSearchPanel.class,
"HashSearchPanel.md5CheckBox.text"));
159 md5CheckBox.addActionListener(
new java.awt.event.ActionListener() {
160 public void actionPerformed(java.awt.event.ActionEvent evt) {
161 md5CheckBoxActionPerformed(evt);
165 sha256CheckBox.setText(
org.openide.util.NbBundle.getMessage(HashSearchPanel.class,
"HashSearchPanel.sha256CheckBox.text"));
166 sha256CheckBox.addActionListener(
new java.awt.event.ActionListener() {
167 public void actionPerformed(java.awt.event.ActionEvent evt) {
168 sha256CheckBoxActionPerformed(evt);
172 sha256TextField.setText(
org.openide.util.NbBundle.getMessage(HashSearchPanel.class,
"HashSearchPanel.sha256TextField.text"));
174 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
175 this.setLayout(layout);
176 layout.setHorizontalGroup(
177 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
178 .addGroup(layout.createSequentialGroup()
180 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
181 .addGroup(layout.createSequentialGroup()
182 .addComponent(sha256CheckBox)
183 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
184 .addComponent(sha256TextField, javax.swing.GroupLayout.DEFAULT_SIZE, 254, Short.MAX_VALUE))
185 .addGroup(layout.createSequentialGroup()
186 .addComponent(md5CheckBox)
187 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
188 .addComponent(md5TextField)))
191 layout.setVerticalGroup(
192 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
193 .addGroup(layout.createSequentialGroup()
194 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
195 .addComponent(md5CheckBox)
196 .addComponent(md5TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
197 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
198 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
199 .addComponent(sha256CheckBox)
200 .addComponent(sha256TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
204 private void md5CheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
205 setComponentsEnabled();
206 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
209 private void sha256CheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
210 setComponentsEnabled();
211 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
215 private javax.swing.JMenuItem copyMenuItem;
216 private javax.swing.JMenuItem cutMenuItem;
217 private javax.swing.JCheckBox md5CheckBox;
218 private javax.swing.JTextField md5TextField;
219 private javax.swing.JMenuItem pasteMenuItem;
220 private javax.swing.JPopupMenu rightClickMenu;
221 private javax.swing.JMenuItem selectAllMenuItem;
222 private javax.swing.JCheckBox sha256CheckBox;
223 private javax.swing.JTextField sha256TextField;
226 void addActionListener(ActionListener l) {
227 md5TextField.addActionListener(l);