Autopsy  4.5.0
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-2017 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 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;
34 
39 class NameSearchPanel extends javax.swing.JPanel {
40 
41  private static final long serialVersionUID = 1L;
42 
46  NameSearchPanel() {
47  initComponents();
48  customizeComponents();
49  setComponentsEnabled();
50  }
51 
52  private void customizeComponents() {
53 
54  searchTextField.setComponentPopupMenu(rightClickMenu);
55  ActionListener actList = new ActionListener() {
56  @Override
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();
67  }
68  }
69  };
70  cutMenuItem.addActionListener(actList);
71  copyMenuItem.addActionListener(actList);
72  pasteMenuItem.addActionListener(actList);
73  selectAllMenuItem.addActionListener(actList);
74  this.searchTextField.getDocument().addDocumentListener(new DocumentListener() {
75  @Override
76  public void insertUpdate(DocumentEvent e) {
77  firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
78  }
79 
80  @Override
81  public void removeUpdate(DocumentEvent e) {
82  firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
83  }
84 
85  @Override
86  public void changedUpdate(DocumentEvent e) {
87  firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
88  }
89  });
90 
91  }
92 
93  JCheckBox getNameCheckBox() {
94  return nameCheckBox;
95  }
96 
97  JTextField getSearchTextField() {
98  return searchTextField;
99  }
100 
101  void setComponentsEnabled() {
102  boolean enabled = nameCheckBox.isSelected();
103  this.searchTextField.setEnabled(enabled);
104  this.noteNameLabel.setEnabled(enabled);
105  }
106 
112  @SuppressWarnings("unchecked")
113  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
114  private void initComponents() {
115 
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();
124 
125  cutMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.cutMenuItem.text")); // NOI18N
126  rightClickMenu.add(cutMenuItem);
127 
128  copyMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.copyMenuItem.text")); // NOI18N
129  rightClickMenu.add(copyMenuItem);
130 
131  pasteMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.pasteMenuItem.text")); // NOI18N
132  rightClickMenu.add(pasteMenuItem);
133 
134  selectAllMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.selectAllMenuItem.text")); // NOI18N
135  rightClickMenu.add(selectAllMenuItem);
136 
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")); // NOI18N
139  nameCheckBox.addActionListener(new java.awt.event.ActionListener() {
140  public void actionPerformed(java.awt.event.ActionEvent evt) {
141  nameCheckBoxActionPerformed(evt);
142  }
143  });
144 
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")); // NOI18N
147 
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")); // NOI18N
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));
153 
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()
159  .addGap(0, 0, 0)
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)))
166  .addGap(0, 0, 0))
167  );
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))
177  );
178  }// </editor-fold>//GEN-END:initComponents
179 
180  private void nameCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameCheckBoxActionPerformed
181  setComponentsEnabled();
182  firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
183  }//GEN-LAST:event_nameCheckBoxActionPerformed
184 
185  // Variables declaration - do not modify//GEN-BEGIN:variables
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;
194  // End of variables declaration//GEN-END:variables
195 
196  void addActionListener(ActionListener l) {
197  searchTextField.addActionListener(l);
198  }
199 }

Copyright © 2012-2016 Basis Technology. Generated on: Tue Feb 20 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.