25 package org.sleuthkit.autopsy.filesearch;
28 import java.awt.event.ActionEvent;
29 import java.awt.event.ActionListener;
30 import javax.swing.JCheckBox;
31 import javax.swing.JMenuItem;
32 import javax.swing.JTextField;
38 class NameSearchPanel
extends javax.swing.JPanel {
45 customizeComponents();
48 private void customizeComponents() {
50 searchTextField.setComponentPopupMenu(rightClickMenu);
51 ActionListener actList =
new ActionListener() {
53 public void actionPerformed(ActionEvent e) {
54 JMenuItem jmi = (JMenuItem) e.getSource();
55 if (jmi.equals(cutMenuItem)) {
56 searchTextField.cut();
57 }
else if (jmi.equals(copyMenuItem)) {
58 searchTextField.copy();
59 }
else if (jmi.equals(pasteMenuItem)) {
60 searchTextField.paste();
61 }
else if (jmi.equals(selectAllMenuItem)) {
62 searchTextField.selectAll();
66 cutMenuItem.addActionListener(actList);
67 copyMenuItem.addActionListener(actList);
68 pasteMenuItem.addActionListener(actList);
69 selectAllMenuItem.addActionListener(actList);
73 JCheckBox getNameCheckBox() {
77 JTextField getSearchTextField() {
78 return searchTextField;
86 @SuppressWarnings(
"unchecked")
88 private
void initComponents() {
90 rightClickMenu =
new javax.swing.JPopupMenu();
91 cutMenuItem =
new javax.swing.JMenuItem();
92 copyMenuItem =
new javax.swing.JMenuItem();
93 pasteMenuItem =
new javax.swing.JMenuItem();
94 selectAllMenuItem =
new javax.swing.JMenuItem();
95 nameCheckBox =
new javax.swing.JCheckBox();
96 searchTextField =
new javax.swing.JTextField();
97 noteNameLabel =
new javax.swing.JLabel();
99 cutMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class,
"NameSearchPanel.cutMenuItem.text"));
100 rightClickMenu.add(cutMenuItem);
102 copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class,
"NameSearchPanel.copyMenuItem.text"));
103 rightClickMenu.add(copyMenuItem);
105 pasteMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class,
"NameSearchPanel.pasteMenuItem.text"));
106 rightClickMenu.add(pasteMenuItem);
108 selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class,
"NameSearchPanel.selectAllMenuItem.text"));
109 rightClickMenu.add(selectAllMenuItem);
111 nameCheckBox.setFont(nameCheckBox.getFont().deriveFont(nameCheckBox.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
112 nameCheckBox.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class,
"NameSearchPanel.nameCheckBox.text"));
114 searchTextField.setFont(searchTextField.getFont().deriveFont(searchTextField.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
115 searchTextField.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class,
"NameSearchPanel.searchTextField.text"));
116 searchTextField.addMouseListener(
new java.awt.event.MouseAdapter() {
117 public void mouseClicked(java.awt.event.MouseEvent evt) {
118 searchTextFieldMouseClicked(evt);
122 noteNameLabel.setFont(noteNameLabel.getFont().deriveFont(noteNameLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 10));
123 noteNameLabel.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class,
"NameSearchPanel.noteNameLabel.text"));
124 noteNameLabel.setMaximumSize(
new java.awt.Dimension(250, 30));
125 noteNameLabel.setMinimumSize(
new java.awt.Dimension(250, 30));
126 noteNameLabel.setPreferredSize(
new java.awt.Dimension(250, 30));
128 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
129 this.setLayout(layout);
130 layout.setHorizontalGroup(
131 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
132 .addGroup(layout.createSequentialGroup()
134 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
135 .addComponent(noteNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)
136 .addGroup(layout.createSequentialGroup()
137 .addComponent(nameCheckBox)
138 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
139 .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)))
142 layout.setVerticalGroup(
143 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
144 .addGroup(layout.createSequentialGroup()
145 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
146 .addComponent(nameCheckBox)
147 .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
148 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
149 .addComponent(noteNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
150 .addGap(0, 0, Short.MAX_VALUE))
154 private void searchTextFieldMouseClicked(java.awt.event.MouseEvent evt) {
156 this.nameCheckBox.setSelected(
true); }
158 private javax.swing.JMenuItem copyMenuItem;
159 private javax.swing.JMenuItem cutMenuItem;
160 private javax.swing.JCheckBox nameCheckBox;
161 private javax.swing.JLabel noteNameLabel;
162 private javax.swing.JMenuItem pasteMenuItem;
163 private javax.swing.JPopupMenu rightClickMenu;
164 private javax.swing.JTextField searchTextField;
165 private javax.swing.JMenuItem selectAllMenuItem;
168 void addActionListener(ActionListener l) {
169 searchTextField.addActionListener(l);