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

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.