25 package org.sleuthkit.autopsy.filesearch;
 
   27 import java.awt.event.ActionEvent;
 
   28 import java.awt.event.ActionListener;
 
   29 import java.beans.PropertyChangeListener;
 
   30 import javax.swing.JCheckBox;
 
   31 import javax.swing.JMenuItem;
 
   32 import javax.swing.JTextField;
 
   33 import javax.swing.event.DocumentEvent;
 
   34 import javax.swing.event.DocumentListener;
 
   40 class NameSearchPanel 
extends javax.swing.JPanel {
 
   47         customizeComponents();
 
   48         setComponentsEnabled();
 
   51     private void customizeComponents() {
 
   53         searchTextField.setComponentPopupMenu(rightClickMenu);
 
   54         ActionListener actList = 
new ActionListener() {
 
   56             public void actionPerformed(ActionEvent e) {
 
   57                 JMenuItem jmi = (JMenuItem) e.getSource();
 
   58                 if (jmi.equals(cutMenuItem)) {
 
   59                     searchTextField.cut();
 
   60                 } 
else if (jmi.equals(copyMenuItem)) {
 
   61                     searchTextField.copy();
 
   62                 } 
else if (jmi.equals(pasteMenuItem)) {
 
   63                     searchTextField.paste();
 
   64                 } 
else if (jmi.equals(selectAllMenuItem)) {
 
   65                     searchTextField.selectAll();
 
   69         cutMenuItem.addActionListener(actList);
 
   70         copyMenuItem.addActionListener(actList);
 
   71         pasteMenuItem.addActionListener(actList);
 
   72         selectAllMenuItem.addActionListener(actList);
 
   73         this.searchTextField.getDocument().addDocumentListener(
new DocumentListener() {
 
   75             public void insertUpdate(DocumentEvent e) {
 
   76                 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
 
   80             public void removeUpdate(DocumentEvent e) {
 
   81                 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
 
   85             public void changedUpdate(DocumentEvent e) {
 
   86                 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
 
   92     JCheckBox getNameCheckBox() {
 
   96     JTextField getSearchTextField() {
 
   97         return searchTextField;
 
  100     void setComponentsEnabled() {
 
  101         boolean enabled = nameCheckBox.isSelected();
 
  102         this.searchTextField.setEnabled(enabled);
 
  103         this.noteNameLabel.setEnabled(enabled);
 
  111     @SuppressWarnings(
"unchecked")
 
  113     private 
void initComponents() {
 
  115         rightClickMenu = 
new javax.swing.JPopupMenu();
 
  116         cutMenuItem = 
new javax.swing.JMenuItem();
 
  117         copyMenuItem = 
new javax.swing.JMenuItem();
 
  118         pasteMenuItem = 
new javax.swing.JMenuItem();
 
  119         selectAllMenuItem = 
new javax.swing.JMenuItem();
 
  120         nameCheckBox = 
new javax.swing.JCheckBox();
 
  121         searchTextField = 
new javax.swing.JTextField();
 
  122         noteNameLabel = 
new javax.swing.JLabel();
 
  124         cutMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class, 
"NameSearchPanel.cutMenuItem.text")); 
 
  125         rightClickMenu.add(cutMenuItem);
 
  127         copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class, 
"NameSearchPanel.copyMenuItem.text")); 
 
  128         rightClickMenu.add(copyMenuItem);
 
  130         pasteMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class, 
"NameSearchPanel.pasteMenuItem.text")); 
 
  131         rightClickMenu.add(pasteMenuItem);
 
  133         selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class, 
"NameSearchPanel.selectAllMenuItem.text")); 
 
  134         rightClickMenu.add(selectAllMenuItem);
 
  136         nameCheckBox.setFont(nameCheckBox.getFont().deriveFont(nameCheckBox.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
 
  137         nameCheckBox.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class, 
"NameSearchPanel.nameCheckBox.text")); 
 
  138         nameCheckBox.addActionListener(
new java.awt.event.ActionListener() {
 
  139             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  140                 nameCheckBoxActionPerformed(evt);
 
  144         searchTextField.setFont(searchTextField.getFont().deriveFont(searchTextField.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
 
  145         searchTextField.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class, 
"NameSearchPanel.searchTextField.text")); 
 
  146         searchTextField.addMouseListener(
new java.awt.event.MouseAdapter() {
 
  147             public void mouseClicked(java.awt.event.MouseEvent evt) {
 
  148                 searchTextFieldMouseClicked(evt);
 
  152         noteNameLabel.setFont(noteNameLabel.getFont().deriveFont(noteNameLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 10));
 
  153         noteNameLabel.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class, 
"NameSearchPanel.noteNameLabel.text")); 
 
  154         noteNameLabel.setMaximumSize(
new java.awt.Dimension(250, 30));
 
  155         noteNameLabel.setMinimumSize(
new java.awt.Dimension(250, 30));
 
  156         noteNameLabel.setPreferredSize(
new java.awt.Dimension(250, 30));
 
  158         javax.swing.GroupLayout layout = 
new javax.swing.GroupLayout(
this);
 
  159         this.setLayout(layout);
 
  160         layout.setHorizontalGroup(
 
  161             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  162             .addGroup(layout.createSequentialGroup()
 
  164                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
 
  165                     .addComponent(noteNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  166                     .addGroup(layout.createSequentialGroup()
 
  167                         .addComponent(nameCheckBox)
 
  168                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  169                         .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)))
 
  172         layout.setVerticalGroup(
 
  173             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  174             .addGroup(layout.createSequentialGroup()
 
  175                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  176                     .addComponent(nameCheckBox)
 
  177                     .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  178                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  179                 .addComponent(noteNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  180                 .addGap(0, 0, Short.MAX_VALUE))
 
  184     private void searchTextFieldMouseClicked(java.awt.event.MouseEvent evt) {
 
  186         this.nameCheckBox.setSelected(
true);     }
 
  188     private void nameCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
 
  189         setComponentsEnabled();
 
  190         firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
 
  194     private javax.swing.JMenuItem copyMenuItem;
 
  195     private javax.swing.JMenuItem cutMenuItem;
 
  196     private javax.swing.JCheckBox nameCheckBox;
 
  197     private javax.swing.JLabel noteNameLabel;
 
  198     private javax.swing.JMenuItem pasteMenuItem;
 
  199     private javax.swing.JPopupMenu rightClickMenu;
 
  200     private javax.swing.JTextField searchTextField;
 
  201     private javax.swing.JMenuItem selectAllMenuItem;
 
  204     void addActionListener(ActionListener l) {
 
  205         searchTextField.addActionListener(l);