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 NameSearchPanel 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 getNameCheckBox() {
 
   91     JTextField getSearchTextField() {
 
   92         return searchTextField;
 
   95     void setComponentsEnabled() {
 
   96         boolean enabled = nameCheckBox.isSelected();
 
   97         this.searchTextField.setEnabled(enabled);
 
   98         this.noteNameLabel.setEnabled(enabled);
 
  106     @SuppressWarnings(
"unchecked")
 
  108     private 
void initComponents() {
 
  110         rightClickMenu = 
new javax.swing.JPopupMenu();
 
  111         cutMenuItem = 
new javax.swing.JMenuItem();
 
  112         copyMenuItem = 
new javax.swing.JMenuItem();
 
  113         pasteMenuItem = 
new javax.swing.JMenuItem();
 
  114         selectAllMenuItem = 
new javax.swing.JMenuItem();
 
  115         nameCheckBox = 
new javax.swing.JCheckBox();
 
  116         searchTextField = 
new javax.swing.JTextField();
 
  117         noteNameLabel = 
new javax.swing.JLabel();
 
  119         cutMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class, 
"NameSearchPanel.cutMenuItem.text")); 
 
  120         rightClickMenu.add(cutMenuItem);
 
  122         copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class, 
"NameSearchPanel.copyMenuItem.text")); 
 
  123         rightClickMenu.add(copyMenuItem);
 
  125         pasteMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class, 
"NameSearchPanel.pasteMenuItem.text")); 
 
  126         rightClickMenu.add(pasteMenuItem);
 
  128         selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class, 
"NameSearchPanel.selectAllMenuItem.text")); 
 
  129         rightClickMenu.add(selectAllMenuItem);
 
  131         nameCheckBox.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class, 
"NameSearchPanel.nameCheckBox.text")); 
 
  132         nameCheckBox.addActionListener(
new java.awt.event.ActionListener() {
 
  133             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  134                 nameCheckBoxActionPerformed(evt);
 
  138         searchTextField.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class, 
"NameSearchPanel.searchTextField.text")); 
 
  140         noteNameLabel.setFont(noteNameLabel.getFont().deriveFont(noteNameLabel.getFont().getSize()-1f));
 
  141         noteNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
 
  142         noteNameLabel.setText(
org.openide.util.NbBundle.getMessage(NameSearchPanel.class, 
"NameSearchPanel.noteNameLabel.text")); 
 
  143         noteNameLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);
 
  144         noteNameLabel.setMaximumSize(
new java.awt.Dimension(250, 30));
 
  145         noteNameLabel.setMinimumSize(
new java.awt.Dimension(250, 30));
 
  146         noteNameLabel.setPreferredSize(
new java.awt.Dimension(250, 40));
 
  148         javax.swing.GroupLayout layout = 
new javax.swing.GroupLayout(
this);
 
  149         this.setLayout(layout);
 
  150         layout.setHorizontalGroup(
 
  151             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  152             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
 
  153                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
 
  154                     .addGroup(layout.createSequentialGroup()
 
  156                         .addComponent(noteNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
 
  157                     .addGroup(layout.createSequentialGroup()
 
  158                         .addComponent(nameCheckBox)
 
  159                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  160                         .addComponent(searchTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)))
 
  163         layout.setVerticalGroup(
 
  164             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  165             .addGroup(layout.createSequentialGroup()
 
  166                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  167                     .addComponent(nameCheckBox)
 
  168                     .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  169                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  170                 .addComponent(noteNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  171                 .addGap(0, 0, Short.MAX_VALUE))
 
  175     private void nameCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
 
  176         setComponentsEnabled();
 
  177         firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
 
  181     private javax.swing.JMenuItem copyMenuItem;
 
  182     private javax.swing.JMenuItem cutMenuItem;
 
  183     private javax.swing.JCheckBox nameCheckBox;
 
  184     private javax.swing.JLabel noteNameLabel;
 
  185     private javax.swing.JMenuItem pasteMenuItem;
 
  186     private javax.swing.JPopupMenu rightClickMenu;
 
  187     private javax.swing.JTextField searchTextField;
 
  188     private javax.swing.JMenuItem selectAllMenuItem;
 
  191     void addActionListener(ActionListener l) {
 
  192         searchTextField.addActionListener(l);