Autopsy  4.4.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-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 java.text.NumberFormat;
24 import javax.swing.JCheckBox;
25 import javax.swing.JComboBox;
26 import javax.swing.JFormattedTextField;
27 import javax.swing.JMenuItem;
28 
33 class SizeSearchPanel extends javax.swing.JPanel {
34 
35  private static final long serialVersionUID = 1L;
36 
40  SizeSearchPanel() {
41  initComponents();
42  customizeComponents();
43  setComponentsEnabled();
44  }
45 
46  private void customizeComponents() {
47 
48  sizeTextField.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  sizeTextField.cut();
55  } else if (jmi.equals(copyMenuItem)) {
56  sizeTextField.copy();
57  } else if (jmi.equals(pasteMenuItem)) {
58  sizeTextField.paste();
59  } else if (jmi.equals(selectAllMenuItem)) {
60  sizeTextField.selectAll();
61  }
62  }
63  };
64  cutMenuItem.addActionListener(actList);
65  copyMenuItem.addActionListener(actList);
66  pasteMenuItem.addActionListener(actList);
67  selectAllMenuItem.addActionListener(actList);
68 
69  }
70 
71  JCheckBox getSizeCheckBox() {
72  return sizeCheckBox;
73  }
74 
75  JComboBox<String> getSizeCompareComboBox() {
76  return sizeCompareComboBox;
77  }
78 
79  JFormattedTextField getSizeTextField() {
80  return sizeTextField;
81  }
82 
83  JComboBox<String> getSizeUnitComboBox() {
84  return sizeUnitComboBox;
85  }
86 
87  void setComponentsEnabled() {
88  boolean enabled = this.sizeCheckBox.isSelected();
89  this.sizeCompareComboBox.setEnabled(enabled);
90  this.sizeUnitComboBox.setEnabled(enabled);
91  this.sizeTextField.setEnabled(enabled);
92  }
93 
99  @SuppressWarnings("unchecked")
100  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
101  private void initComponents() {
102 
103  rightClickMenu = new javax.swing.JPopupMenu();
104  cutMenuItem = new javax.swing.JMenuItem();
105  copyMenuItem = new javax.swing.JMenuItem();
106  pasteMenuItem = new javax.swing.JMenuItem();
107  selectAllMenuItem = new javax.swing.JMenuItem();
108  sizeUnitComboBox = new javax.swing.JComboBox<>();
109  sizeTextField = new JFormattedTextField(NumberFormat.getIntegerInstance());
110  sizeCompareComboBox = new javax.swing.JComboBox<>();
111  sizeCheckBox = new javax.swing.JCheckBox();
112 
113  cutMenuItem.setText(org.openide.util.NbBundle.getMessage(SizeSearchPanel.class, "SizeSearchPanel.cutMenuItem.text")); // NOI18N
114  rightClickMenu.add(cutMenuItem);
115 
116  copyMenuItem.setText(org.openide.util.NbBundle.getMessage(SizeSearchPanel.class, "SizeSearchPanel.copyMenuItem.text")); // NOI18N
117  rightClickMenu.add(copyMenuItem);
118 
119  pasteMenuItem.setText(org.openide.util.NbBundle.getMessage(SizeSearchPanel.class, "SizeSearchPanel.pasteMenuItem.text")); // NOI18N
120  rightClickMenu.add(pasteMenuItem);
121 
122  selectAllMenuItem.setText(org.openide.util.NbBundle.getMessage(SizeSearchPanel.class, "SizeSearchPanel.selectAllMenuItem.text")); // NOI18N
123  rightClickMenu.add(selectAllMenuItem);
124 
125  sizeUnitComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { "Byte(s)", "KB", "MB", "GB", "TB" }));
126 
127  sizeTextField.setValue(0);
128 
129  sizeCompareComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { "equal to", "greater than", "less than" }));
130 
131  sizeCheckBox.setText(org.openide.util.NbBundle.getMessage(SizeSearchPanel.class, "SizeSearchPanel.sizeCheckBox.text")); // NOI18N
132  sizeCheckBox.addActionListener(new java.awt.event.ActionListener() {
133  public void actionPerformed(java.awt.event.ActionEvent evt) {
134  sizeCheckBoxActionPerformed(evt);
135  }
136  });
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  .addComponent(sizeCheckBox)
144  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
145  .addComponent(sizeCompareComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
146  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
147  .addComponent(sizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
148  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
149  .addComponent(sizeUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))
150  );
151  layout.setVerticalGroup(
152  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
153  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
154  .addComponent(sizeCompareComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
155  .addComponent(sizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
156  .addComponent(sizeUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
157  .addComponent(sizeCheckBox))
158  );
159  }// </editor-fold>//GEN-END:initComponents
160 
161  private void sizeCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sizeCheckBoxActionPerformed
162  setComponentsEnabled();
163  firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
164  }//GEN-LAST:event_sizeCheckBoxActionPerformed
165 
166  // Variables declaration - do not modify//GEN-BEGIN:variables
167  private javax.swing.JMenuItem copyMenuItem;
168  private javax.swing.JMenuItem cutMenuItem;
169  private javax.swing.JMenuItem pasteMenuItem;
170  private javax.swing.JPopupMenu rightClickMenu;
171  private javax.swing.JMenuItem selectAllMenuItem;
172  private javax.swing.JCheckBox sizeCheckBox;
173  private javax.swing.JComboBox<String> sizeCompareComboBox;
174  private javax.swing.JFormattedTextField sizeTextField;
175  private javax.swing.JComboBox<String> sizeUnitComboBox;
176  // End of variables declaration//GEN-END:variables
177 
178  void addActionListener(ActionListener l) {
179  sizeTextField.addActionListener(l);
180  }
181 }

Copyright © 2012-2016 Basis Technology. Generated on: Fri Sep 29 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.