Autopsy  4.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 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.*;
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;
33 
38 class NameSearchPanel extends javax.swing.JPanel {
39 
43  NameSearchPanel() {
44  initComponents();
45  customizeComponents();
46  }
47 
48  private void customizeComponents() {
49 
50  searchTextField.setComponentPopupMenu(rightClickMenu);
51  ActionListener actList = new ActionListener() {
52  @Override
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();
63  }
64  }
65  };
66  cutMenuItem.addActionListener(actList);
67  copyMenuItem.addActionListener(actList);
68  pasteMenuItem.addActionListener(actList);
69  selectAllMenuItem.addActionListener(actList);
70 
71  }
72 
73  JCheckBox getNameCheckBox() {
74  return nameCheckBox;
75  }
76 
77  JTextField getSearchTextField() {
78  return searchTextField;
79  }
80 
86  @SuppressWarnings("unchecked")
87  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
88  private void initComponents() {
89 
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();
98 
99  cutMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.cutMenuItem.text")); // NOI18N
100  rightClickMenu.add(cutMenuItem);
101 
102  copyMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.copyMenuItem.text")); // NOI18N
103  rightClickMenu.add(copyMenuItem);
104 
105  pasteMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.pasteMenuItem.text")); // NOI18N
106  rightClickMenu.add(pasteMenuItem);
107 
108  selectAllMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.selectAllMenuItem.text")); // NOI18N
109  rightClickMenu.add(selectAllMenuItem);
110 
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")); // NOI18N
113 
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")); // NOI18N
116  searchTextField.addMouseListener(new java.awt.event.MouseAdapter() {
117  public void mouseClicked(java.awt.event.MouseEvent evt) {
118  searchTextFieldMouseClicked(evt);
119  }
120  });
121 
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")); // NOI18N
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));
127 
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()
133  .addGap(0, 0, 0)
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)))
140  .addGap(0, 0, 0))
141  );
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))
151  );
152  }// </editor-fold>//GEN-END:initComponents
153 
154  private void searchTextFieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_searchTextFieldMouseClicked
155 
156  this.nameCheckBox.setSelected(true); }//GEN-LAST:event_searchTextFieldMouseClicked
157  // Variables declaration - do not modify//GEN-BEGIN:variables
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;
166  // End of variables declaration//GEN-END:variables
167 
168  void addActionListener(ActionListener l) {
169  searchTextField.addActionListener(l);
170  }
171 }

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