Autopsy  3.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.*;
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 
41  NameSearchPanel() {
42  initComponents();
43  customizeComponents();
44  }
45 
46  private void customizeComponents(){
47 
48  searchTextField.setComponentPopupMenu(rightClickMenu);
49  ActionListener actList = new ActionListener(){
50  @Override
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();
61  }
62  };
63  cutMenuItem.addActionListener(actList);
64  copyMenuItem.addActionListener(actList);
65  pasteMenuItem.addActionListener(actList);
66  selectAllMenuItem.addActionListener(actList);
67 
68  }
69 
70  JCheckBox getNameCheckBox() {
71  return nameCheckBox;
72  }
73 
74  JTextField getSearchTextField() {
75  return searchTextField;
76  }
77 
83  @SuppressWarnings("unchecked")
84  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
85  private void initComponents() {
86 
87  rightClickMenu = new javax.swing.JPopupMenu();
88  cutMenuItem = new javax.swing.JMenuItem();
89  copyMenuItem = new javax.swing.JMenuItem();
90  pasteMenuItem = new javax.swing.JMenuItem();
91  selectAllMenuItem = new javax.swing.JMenuItem();
92  nameCheckBox = new javax.swing.JCheckBox();
93  searchTextField = new javax.swing.JTextField();
94  noteNameLabel = new javax.swing.JLabel();
95 
96  cutMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.cutMenuItem.text")); // NOI18N
97  rightClickMenu.add(cutMenuItem);
98 
99  copyMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.copyMenuItem.text")); // NOI18N
100  rightClickMenu.add(copyMenuItem);
101 
102  pasteMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.pasteMenuItem.text")); // NOI18N
103  rightClickMenu.add(pasteMenuItem);
104 
105  selectAllMenuItem.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.selectAllMenuItem.text")); // NOI18N
106  rightClickMenu.add(selectAllMenuItem);
107 
108  nameCheckBox.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.nameCheckBox.text")); // NOI18N
109 
110  searchTextField.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.searchTextField.text")); // NOI18N
111  searchTextField.addMouseListener(new java.awt.event.MouseAdapter() {
112  public void mouseClicked(java.awt.event.MouseEvent evt) {
113  searchTextFieldMouseClicked(evt);
114  }
115  });
116 
117  noteNameLabel.setFont(noteNameLabel.getFont().deriveFont(Font.PLAIN, 10));
118  noteNameLabel.setText(org.openide.util.NbBundle.getMessage(NameSearchPanel.class, "NameSearchPanel.noteNameLabel.text")); // NOI18N
119 
120  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
121  this.setLayout(layout);
122  layout.setHorizontalGroup(
123  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
124  .addGroup(layout.createSequentialGroup()
125  .addComponent(nameCheckBox)
126  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
127  .addGroup(layout.createSequentialGroup()
128  .addGap(12, 12, 12)
129  .addComponent(noteNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
130  .addContainerGap())
131  .addGroup(layout.createSequentialGroup()
132  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
133  .addComponent(searchTextField))))
134  );
135  layout.setVerticalGroup(
136  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
137  .addGroup(layout.createSequentialGroup()
138  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
139  .addComponent(nameCheckBox)
140  .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
141  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
142  .addComponent(noteNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
143  );
144  }// </editor-fold>//GEN-END:initComponents
145 
146  private void searchTextFieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_searchTextFieldMouseClicked
147 
148  this.nameCheckBox.setSelected(true); }//GEN-LAST:event_searchTextFieldMouseClicked
149  // Variables declaration - do not modify//GEN-BEGIN:variables
150  private javax.swing.JMenuItem copyMenuItem;
151  private javax.swing.JMenuItem cutMenuItem;
152  private javax.swing.JCheckBox nameCheckBox;
153  private javax.swing.JLabel noteNameLabel;
154  private javax.swing.JMenuItem pasteMenuItem;
155  private javax.swing.JPopupMenu rightClickMenu;
156  private javax.swing.JTextField searchTextField;
157  private javax.swing.JMenuItem selectAllMenuItem;
158  // End of variables declaration//GEN-END:variables
159 
160  void addActionListener(ActionListener l) {
161  searchTextField.addActionListener(l);
162  }
163 }

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.