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 searchTextField.setComponentPopupMenu(rightClickMenu);
49 ActionListener actList =
new ActionListener() {
51 public void actionPerformed(ActionEvent e) {
52 JMenuItem jmi = (JMenuItem) e.getSource();
53 if (jmi.equals(cutMenuItem)) {
54 searchTextField.cut();
55 }
else if (jmi.equals(copyMenuItem)) {
56 searchTextField.copy();
57 }
else if (jmi.equals(pasteMenuItem)) {
58 searchTextField.paste();
59 }
else if (jmi.equals(selectAllMenuItem)) {
60 searchTextField.selectAll();
64 cutMenuItem.addActionListener(actList);
65 copyMenuItem.addActionListener(actList);
66 pasteMenuItem.addActionListener(actList);
67 selectAllMenuItem.addActionListener(actList);
68 this.searchTextField.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);
87 JCheckBox getHashCheckBox() {
91 JTextField getSearchTextField() {
92 return searchTextField;
95 void setComponentsEnabled() {
96 boolean enabled = hashCheckBox.isSelected();
97 this.searchTextField.setEnabled(enabled);
105 @SuppressWarnings(
"unchecked")
107 private
void initComponents() {
109 rightClickMenu =
new javax.swing.JPopupMenu();
110 cutMenuItem =
new javax.swing.JMenuItem();
111 copyMenuItem =
new javax.swing.JMenuItem();
112 pasteMenuItem =
new javax.swing.JMenuItem();
113 selectAllMenuItem =
new javax.swing.JMenuItem();
114 hashCheckBox =
new javax.swing.JCheckBox();
115 searchTextField =
new javax.swing.JTextField();
117 cutMenuItem.setText(
org.openide.util.NbBundle.getMessage(HashSearchPanel.class,
"NameSearchPanel.cutMenuItem.text"));
118 rightClickMenu.add(cutMenuItem);
120 copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(HashSearchPanel.class,
"NameSearchPanel.copyMenuItem.text"));
121 rightClickMenu.add(copyMenuItem);
123 pasteMenuItem.setText(
org.openide.util.NbBundle.getMessage(HashSearchPanel.class,
"NameSearchPanel.pasteMenuItem.text"));
124 rightClickMenu.add(pasteMenuItem);
126 selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(HashSearchPanel.class,
"NameSearchPanel.selectAllMenuItem.text"));
127 rightClickMenu.add(selectAllMenuItem);
129 hashCheckBox.setText(
org.openide.util.NbBundle.getMessage(HashSearchPanel.class,
"HashSearchPanel.md5CheckBox.text"));
130 hashCheckBox.addActionListener(
new java.awt.event.ActionListener() {
131 public void actionPerformed(java.awt.event.ActionEvent evt) {
132 hashCheckBoxActionPerformed(evt);
136 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
137 this.setLayout(layout);
138 layout.setHorizontalGroup(
139 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
140 .addGroup(layout.createSequentialGroup()
142 .addComponent(hashCheckBox)
143 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
144 .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)
147 layout.setVerticalGroup(
148 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
149 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
150 .addComponent(hashCheckBox)
151 .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
155 private void hashCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
156 setComponentsEnabled();
157 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
161 private javax.swing.JMenuItem copyMenuItem;
162 private javax.swing.JMenuItem cutMenuItem;
163 private javax.swing.JCheckBox hashCheckBox;
164 private javax.swing.JMenuItem pasteMenuItem;
165 private javax.swing.JPopupMenu rightClickMenu;
166 private javax.swing.JTextField searchTextField;
167 private javax.swing.JMenuItem selectAllMenuItem;
170 void addActionListener(ActionListener l) {
171 searchTextField.addActionListener(l);