Autopsy  4.5.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
HashSearchPanel.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 package org.sleuthkit.autopsy.filesearch;
20 
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;
28 
32 class HashSearchPanel extends javax.swing.JPanel {
33 
34  private static final long serialVersionUID = 1L;
35 
39  HashSearchPanel() {
40  initComponents();
41  customizeComponents();
42  setComponentsEnabled();
43  }
44 
45  private void customizeComponents() {
46 
47  searchTextField.setComponentPopupMenu(rightClickMenu);
48  ActionListener actList = new ActionListener() {
49  @Override
50  public void actionPerformed(ActionEvent e) {
51  JMenuItem jmi = (JMenuItem) e.getSource();
52  if (jmi.equals(cutMenuItem)) {
53  searchTextField.cut();
54  } else if (jmi.equals(copyMenuItem)) {
55  searchTextField.copy();
56  } else if (jmi.equals(pasteMenuItem)) {
57  searchTextField.paste();
58  } else if (jmi.equals(selectAllMenuItem)) {
59  searchTextField.selectAll();
60  }
61  }
62  };
63  cutMenuItem.addActionListener(actList);
64  copyMenuItem.addActionListener(actList);
65  pasteMenuItem.addActionListener(actList);
66  selectAllMenuItem.addActionListener(actList);
67  this.searchTextField.getDocument().addDocumentListener(new DocumentListener() {
68  @Override
69  public void insertUpdate(DocumentEvent e) {
70  firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
71  }
72 
73  @Override
74  public void removeUpdate(DocumentEvent e) {
75  firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
76  }
77 
78  @Override
79  public void changedUpdate(DocumentEvent e) {
80  firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
81  }
82  });
83 
84  }
85 
86  JCheckBox getHashCheckBox() {
87  return hashCheckBox;
88  }
89 
90  JTextField getSearchTextField() {
91  return searchTextField;
92  }
93 
94  void setComponentsEnabled() {
95  boolean enabled = hashCheckBox.isSelected();
96  this.searchTextField.setEnabled(enabled);
97  }
98 
104  @SuppressWarnings("unchecked")
105  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
106  private void initComponents() {
107 
108  rightClickMenu = new javax.swing.JPopupMenu();
109  cutMenuItem = new javax.swing.JMenuItem();
110  copyMenuItem = new javax.swing.JMenuItem();
111  pasteMenuItem = new javax.swing.JMenuItem();
112  selectAllMenuItem = new javax.swing.JMenuItem();
113  hashCheckBox = new javax.swing.JCheckBox();
114  searchTextField = new javax.swing.JTextField();
115 
116  cutMenuItem.setText(org.openide.util.NbBundle.getMessage(HashSearchPanel.class, "NameSearchPanel.cutMenuItem.text")); // NOI18N
117  rightClickMenu.add(cutMenuItem);
118 
119  copyMenuItem.setText(org.openide.util.NbBundle.getMessage(HashSearchPanel.class, "NameSearchPanel.copyMenuItem.text")); // NOI18N
120  rightClickMenu.add(copyMenuItem);
121 
122  pasteMenuItem.setText(org.openide.util.NbBundle.getMessage(HashSearchPanel.class, "NameSearchPanel.pasteMenuItem.text")); // NOI18N
123  rightClickMenu.add(pasteMenuItem);
124 
125  selectAllMenuItem.setText(org.openide.util.NbBundle.getMessage(HashSearchPanel.class, "NameSearchPanel.selectAllMenuItem.text")); // NOI18N
126  rightClickMenu.add(selectAllMenuItem);
127 
128  hashCheckBox.setFont(hashCheckBox.getFont().deriveFont(hashCheckBox.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
129  hashCheckBox.setText(org.openide.util.NbBundle.getMessage(HashSearchPanel.class, "HashSearchPanel.md5CheckBox.text")); // NOI18N
130  hashCheckBox.addActionListener(new java.awt.event.ActionListener() {
131  public void actionPerformed(java.awt.event.ActionEvent evt) {
132  hashCheckBoxActionPerformed(evt);
133  }
134  });
135 
136  searchTextField.setFont(searchTextField.getFont().deriveFont(searchTextField.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
137 
138  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
139  this.setLayout(layout);
140  layout.setHorizontalGroup(
141  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
142  .addGroup(layout.createSequentialGroup()
143  .addGap(0, 0, 0)
144  .addComponent(hashCheckBox)
145  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
146  .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)
147  .addGap(0, 0, 0))
148  );
149  layout.setVerticalGroup(
150  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
151  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
152  .addComponent(hashCheckBox)
153  .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
154  );
155  }// </editor-fold>//GEN-END:initComponents
156 
157  private void hashCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hashCheckBoxActionPerformed
158  setComponentsEnabled();
159  firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
160  }//GEN-LAST:event_hashCheckBoxActionPerformed
161 
162  // Variables declaration - do not modify//GEN-BEGIN:variables
163  private javax.swing.JMenuItem copyMenuItem;
164  private javax.swing.JMenuItem cutMenuItem;
165  private javax.swing.JCheckBox hashCheckBox;
166  private javax.swing.JMenuItem pasteMenuItem;
167  private javax.swing.JPopupMenu rightClickMenu;
168  private javax.swing.JTextField searchTextField;
169  private javax.swing.JMenuItem selectAllMenuItem;
170  // End of variables declaration//GEN-END:variables
171 
172  void addActionListener(ActionListener l) {
173  searchTextField.addActionListener(l);
174  }
175 }

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.