Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
NameSearchPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20  /*
21  * NameSearchPanel.java
22  *
23  * Created on Oct 19, 2011, 11:58:53 AM
24  */
25 package org.sleuthkit.autopsy.filesearch;
26 
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;
35 
40 class NameSearchPanel extends javax.swing.JPanel {
41 
45  NameSearchPanel() {
46  initComponents();
47  customizeComponents();
48  setComponentsEnabled();
49  }
50 
51  private void customizeComponents() {
52 
53  searchTextField.setComponentPopupMenu(rightClickMenu);
54  ActionListener actList = new ActionListener() {
55  @Override
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();
66  }
67  }
68  };
69  cutMenuItem.addActionListener(actList);
70  copyMenuItem.addActionListener(actList);
71  pasteMenuItem.addActionListener(actList);
72  selectAllMenuItem.addActionListener(actList);
73  this.searchTextField.getDocument().addDocumentListener(new DocumentListener() {
74  @Override
75  public void insertUpdate(DocumentEvent e) {
76  firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
77  }
78 
79  @Override
80  public void removeUpdate(DocumentEvent e) {
81  firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
82  }
83 
84  @Override
85  public void changedUpdate(DocumentEvent e) {
86  firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
87  }
88  });
89 
90  }
91 
92  JCheckBox getNameCheckBox() {
93  return nameCheckBox;
94  }
95 
96  JTextField getSearchTextField() {
97  return searchTextField;
98  }
99 
100  void setComponentsEnabled() {
101  boolean enabled = nameCheckBox.isSelected();
102  this.searchTextField.setEnabled(enabled);
103  this.noteNameLabel.setEnabled(enabled);
104  }
105 
111  @SuppressWarnings("unchecked")
112  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
113  private void initComponents() {
114 
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();
123 
124  cutMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.cutMenuItem.text")); // NOI18N
125  rightClickMenu.add(cutMenuItem);
126 
127  copyMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.copyMenuItem.text")); // NOI18N
128  rightClickMenu.add(copyMenuItem);
129 
130  pasteMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.pasteMenuItem.text")); // NOI18N
131  rightClickMenu.add(pasteMenuItem);
132 
133  selectAllMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.selectAllMenuItem.text")); // NOI18N
134  rightClickMenu.add(selectAllMenuItem);
135 
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")); // NOI18N
138  nameCheckBox.addActionListener(new java.awt.event.ActionListener() {
139  public void actionPerformed(java.awt.event.ActionEvent evt) {
140  nameCheckBoxActionPerformed(evt);
141  }
142  });
143 
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")); // NOI18N
146  searchTextField.addMouseListener(new java.awt.event.MouseAdapter() {
147  public void mouseClicked(java.awt.event.MouseEvent evt) {
148  searchTextFieldMouseClicked(evt);
149  }
150  });
151 
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")); // NOI18N
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));
157 
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()
163  .addGap(0, 0, 0)
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)))
170  .addGap(0, 0, 0))
171  );
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))
181  );
182  }// </editor-fold>//GEN-END:initComponents
183 
184  private void searchTextFieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_searchTextFieldMouseClicked
185 
186  this.nameCheckBox.setSelected(true); }//GEN-LAST:event_searchTextFieldMouseClicked
187 
188  private void nameCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameCheckBoxActionPerformed
189  setComponentsEnabled();
190  firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
191  }//GEN-LAST:event_nameCheckBoxActionPerformed
192 
193  // Variables declaration - do not modify//GEN-BEGIN:variables
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;
202  // End of variables declaration//GEN-END:variables
203 
204  void addActionListener(ActionListener l) {
205  searchTextField.addActionListener(l);
206  }
207 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.