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.setFont(hashCheckBox.getFont().deriveFont(hashCheckBox.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
131 hashCheckBox.addActionListener(
new java.awt.event.ActionListener() {
132 public void actionPerformed(java.awt.event.ActionEvent evt) {
133 hashCheckBoxActionPerformed(evt);
137 searchTextField.setFont(searchTextField.getFont().deriveFont(searchTextField.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
139 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
140 this.setLayout(layout);
141 layout.setHorizontalGroup(
142 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
143 .addGroup(layout.createSequentialGroup()
145 .addComponent(hashCheckBox)
146 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
147 .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)
150 layout.setVerticalGroup(
151 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
152 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
153 .addComponent(hashCheckBox)
154 .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
158 private void hashCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
159 setComponentsEnabled();
160 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
164 private javax.swing.JMenuItem copyMenuItem;
165 private javax.swing.JMenuItem cutMenuItem;
166 private javax.swing.JCheckBox hashCheckBox;
167 private javax.swing.JMenuItem pasteMenuItem;
168 private javax.swing.JPopupMenu rightClickMenu;
169 private javax.swing.JTextField searchTextField;
170 private javax.swing.JMenuItem selectAllMenuItem;
173 void addActionListener(ActionListener l) {
174 searchTextField.addActionListener(l);