25 package org.sleuthkit.autopsy.filesearch;
27 import java.awt.event.ActionEvent;
28 import java.awt.event.ActionListener;
29 import javax.swing.JCheckBox;
30 import javax.swing.JMenuItem;
31 import javax.swing.JTextField;
32 import javax.swing.event.DocumentEvent;
33 import javax.swing.event.DocumentListener;
39 class NameSearchPanel
extends javax.swing.JPanel {
41 private static final long serialVersionUID = 1L;
48 customizeComponents();
49 setComponentsEnabled();
52 private void customizeComponents() {
54 searchTextField.setComponentPopupMenu(rightClickMenu);
55 ActionListener actList =
new ActionListener() {
57 public void actionPerformed(ActionEvent e) {
58 JMenuItem jmi = (JMenuItem) e.getSource();
59 if (jmi.equals(cutMenuItem)) {
60 searchTextField.cut();
61 }
else if (jmi.equals(copyMenuItem)) {
62 searchTextField.copy();
63 }
else if (jmi.equals(pasteMenuItem)) {
64 searchTextField.paste();
65 }
else if (jmi.equals(selectAllMenuItem)) {
66 searchTextField.selectAll();
70 cutMenuItem.addActionListener(actList);
71 copyMenuItem.addActionListener(actList);
72 pasteMenuItem.addActionListener(actList);
73 selectAllMenuItem.addActionListener(actList);
74 this.searchTextField.getDocument().addDocumentListener(
new DocumentListener() {
76 public void insertUpdate(DocumentEvent e) {
77 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
81 public void removeUpdate(DocumentEvent e) {
82 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
86 public void changedUpdate(DocumentEvent e) {
87 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
93 JCheckBox getNameCheckBox() {
97 JTextField getSearchTextField() {
98 return searchTextField;
101 void setComponentsEnabled() {
102 boolean enabled = nameCheckBox.isSelected();
103 this.searchTextField.setEnabled(enabled);
104 this.noteNameLabel.setEnabled(enabled);
112 @SuppressWarnings(
"unchecked")
114 private
void initComponents() {
116 rightClickMenu =
new javax.swing.JPopupMenu();
117 cutMenuItem =
new javax.swing.JMenuItem();
118 copyMenuItem =
new javax.swing.JMenuItem();
119 pasteMenuItem =
new javax.swing.JMenuItem();
120 selectAllMenuItem =
new javax.swing.JMenuItem();
121 nameCheckBox =
new javax.swing.JCheckBox();
122 searchTextField =
new javax.swing.JTextField();
123 noteNameLabel =
new javax.swing.JLabel();
125 cutMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class,
"NameSearchPanel.cutMenuItem.text"));
126 rightClickMenu.add(cutMenuItem);
128 copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class,
"NameSearchPanel.copyMenuItem.text"));
129 rightClickMenu.add(copyMenuItem);
131 pasteMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class,
"NameSearchPanel.pasteMenuItem.text"));
132 rightClickMenu.add(pasteMenuItem);
134 selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class,
"NameSearchPanel.selectAllMenuItem.text"));
135 rightClickMenu.add(selectAllMenuItem);
137 nameCheckBox.setFont(nameCheckBox.getFont().deriveFont(nameCheckBox.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
138 nameCheckBox.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class,
"NameSearchPanel.nameCheckBox.text"));
139 nameCheckBox.addActionListener(
new java.awt.event.ActionListener() {
140 public void actionPerformed(java.awt.event.ActionEvent evt) {
141 nameCheckBoxActionPerformed(evt);
145 searchTextField.setFont(searchTextField.getFont().deriveFont(searchTextField.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
146 searchTextField.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class,
"NameSearchPanel.searchTextField.text"));
148 noteNameLabel.setFont(noteNameLabel.getFont().deriveFont(noteNameLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 10));
149 noteNameLabel.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class,
"NameSearchPanel.noteNameLabel.text"));
150 noteNameLabel.setMaximumSize(
new java.awt.Dimension(250, 30));
151 noteNameLabel.setMinimumSize(
new java.awt.Dimension(250, 30));
152 noteNameLabel.setPreferredSize(
new java.awt.Dimension(250, 30));
154 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
155 this.setLayout(layout);
156 layout.setHorizontalGroup(
157 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
158 .addGroup(layout.createSequentialGroup()
160 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
161 .addComponent(noteNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)
162 .addGroup(layout.createSequentialGroup()
163 .addComponent(nameCheckBox)
164 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
165 .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)))
168 layout.setVerticalGroup(
169 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
170 .addGroup(layout.createSequentialGroup()
171 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
172 .addComponent(nameCheckBox)
173 .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
174 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
175 .addComponent(noteNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
176 .addGap(0, 0, Short.MAX_VALUE))
180 private void nameCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
181 setComponentsEnabled();
182 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
186 private javax.swing.JMenuItem copyMenuItem;
187 private javax.swing.JMenuItem cutMenuItem;
188 private javax.swing.JCheckBox nameCheckBox;
189 private javax.swing.JLabel noteNameLabel;
190 private javax.swing.JMenuItem pasteMenuItem;
191 private javax.swing.JPopupMenu rightClickMenu;
192 private javax.swing.JTextField searchTextField;
193 private javax.swing.JMenuItem selectAllMenuItem;
196 void addActionListener(ActionListener l) {
197 searchTextField.addActionListener(l);