Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
SizeSearchPanel.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 package org.sleuthkit.autopsy.filesearch;
20 
21 import org.openide.util.NbBundle;
22 
23 import java.awt.event.ActionEvent;
24 import java.awt.event.ActionListener;
25 import java.text.NumberFormat;
26 import javax.swing.JCheckBox;
27 import javax.swing.JComboBox;
28 import javax.swing.JFormattedTextField;
29 import javax.swing.JMenuItem;
30 
35 class SizeSearchPanel extends javax.swing.JPanel {
36 
40  SizeSearchPanel() {
41  initComponents();
42  customizeComponents();
43  }
44 
45  private void customizeComponents() {
46 
47  sizeTextField.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  sizeTextField.cut();
54  } else if (jmi.equals(copyMenuItem)) {
55  sizeTextField.copy();
56  } else if (jmi.equals(pasteMenuItem)) {
57  sizeTextField.paste();
58  } else if (jmi.equals(selectAllMenuItem)) {
59  sizeTextField.selectAll();
60  }
61  }
62  };
63  cutMenuItem.addActionListener(actList);
64  copyMenuItem.addActionListener(actList);
65  pasteMenuItem.addActionListener(actList);
66  selectAllMenuItem.addActionListener(actList);
67 
68  }
69 
70  JCheckBox getSizeCheckBox() {
71  return sizeCheckBox;
72  }
73 
74  JComboBox<String> getSizeCompareComboBox() {
75  return sizeCompareComboBox;
76  }
77 
78  JFormattedTextField getSizeTextField() {
79  return sizeTextField;
80  }
81 
82  JComboBox<String> getSizeUnitComboBox() {
83  return sizeUnitComboBox;
84  }
85 
91  @SuppressWarnings("unchecked")
92  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
93  private void initComponents() {
94 
95  rightClickMenu = new javax.swing.JPopupMenu();
96  cutMenuItem = new javax.swing.JMenuItem();
97  copyMenuItem = new javax.swing.JMenuItem();
98  pasteMenuItem = new javax.swing.JMenuItem();
99  selectAllMenuItem = new javax.swing.JMenuItem();
100  sizeUnitComboBox = new javax.swing.JComboBox<String>();
101  sizeTextField = new JFormattedTextField(NumberFormat.getIntegerInstance());
102  sizeCompareComboBox = new javax.swing.JComboBox<String>();
103  sizeCheckBox = new javax.swing.JCheckBox();
104 
105  cutMenuItem.setText(org.openide.util.NbBundle.getMessage(SizeSearchPanel.class, "SizeSearchPanel.cutMenuItem.text")); // NOI18N
106  rightClickMenu.add(cutMenuItem);
107 
108  copyMenuItem.setText(org.openide.util.NbBundle.getMessage(SizeSearchPanel.class, "SizeSearchPanel.copyMenuItem.text")); // NOI18N
109  rightClickMenu.add(copyMenuItem);
110 
111  pasteMenuItem.setText(org.openide.util.NbBundle.getMessage(SizeSearchPanel.class, "SizeSearchPanel.pasteMenuItem.text")); // NOI18N
112  rightClickMenu.add(pasteMenuItem);
113 
114  selectAllMenuItem.setText(org.openide.util.NbBundle.getMessage(SizeSearchPanel.class, "SizeSearchPanel.selectAllMenuItem.text")); // NOI18N
115  rightClickMenu.add(selectAllMenuItem);
116 
117  sizeUnitComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { "Byte(s)", "KB", "MB", "GB", "TB" })); //NON-NLS
118 
119  sizeTextField.setValue(0);
120  sizeTextField.addMouseListener(new java.awt.event.MouseAdapter() {
121  public void mouseClicked(java.awt.event.MouseEvent evt) {
122  sizeTextFieldMouseClicked(evt);
123  }
124  });
125 
126  sizeCompareComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] {
127  NbBundle.getMessage(this.getClass(), "SizeSearchPanel.sizeCompareComboBox.equalTo"),
128  NbBundle.getMessage(this.getClass(), "SizeSearchPanel.sizeCompareComboBox.greaterThan"),
129  NbBundle.getMessage(this.getClass(), "SizeSearchPanel.sizeCompareComboBox.lessThan") }));
130 
131  sizeCheckBox.setText(org.openide.util.NbBundle.getMessage(SizeSearchPanel.class, "SizeSearchPanel.sizeCheckBox.text")); // NOI18N
132 
133  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
134  this.setLayout(layout);
135  layout.setHorizontalGroup(
136  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
137  .addGroup(layout.createSequentialGroup()
138  .addComponent(sizeCheckBox)
139  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
140  .addComponent(sizeCompareComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
141  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
142  .addComponent(sizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
143  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
144  .addComponent(sizeUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))
145  );
146  layout.setVerticalGroup(
147  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
148  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
149  .addComponent(sizeCompareComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
150  .addComponent(sizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
151  .addComponent(sizeUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
152  .addComponent(sizeCheckBox))
153  );
154  }// </editor-fold>//GEN-END:initComponents
155 
156  private void sizeTextFieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sizeTextFieldMouseClicked
157  this.sizeCheckBox.setSelected(true);
158  this.sizeTextField.selectAll(); // select all so user can change it easily
159  }//GEN-LAST:event_sizeTextFieldMouseClicked
160  // Variables declaration - do not modify//GEN-BEGIN:variables
161  private javax.swing.JMenuItem copyMenuItem;
162  private javax.swing.JMenuItem cutMenuItem;
163  private javax.swing.JMenuItem pasteMenuItem;
164  private javax.swing.JPopupMenu rightClickMenu;
165  private javax.swing.JMenuItem selectAllMenuItem;
166  private javax.swing.JCheckBox sizeCheckBox;
167  private javax.swing.JComboBox<String> sizeCompareComboBox;
168  private javax.swing.JFormattedTextField sizeTextField;
169  private javax.swing.JComboBox<String> sizeUnitComboBox;
170  // End of variables declaration//GEN-END:variables
171 
172  void addActionListener(ActionListener l) {
173  sizeTextField.addActionListener(l);
174  }
175 }

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.