Autopsy  4.9.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
IntraCasePanel.java
Go to the documentation of this file.
1 /*
2  *
3  * Autopsy Forensic Browser
4  *
5  * Copyright 2018 Basis Technology Corp.
6  * Contact: carrier <at> sleuthkit <dot> org
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 package org.sleuthkit.autopsy.commonfilesearch;
21 
23 import java.util.Collections;
24 import java.util.HashMap;
25 import java.util.Map;
26 import java.util.Map.Entry;
27 import java.util.Observable;
28 import java.util.Observer;
29 import javax.swing.ComboBoxModel;
30 
37 public final class IntraCasePanel extends javax.swing.JPanel {
38 
39  private static final long serialVersionUID = 1L;
40  static final long NO_DATA_SOURCE_SELECTED = -1;
41  private final Observable fileTypeFilterObservable;
42  private ComboBoxModel<String> dataSourcesList = new DataSourceComboBoxModel();
43  private final Map<Long, String> dataSourceMap;
44 
48  public IntraCasePanel() {
50  this.dataSourceMap = new HashMap<>();
51  this.onlySpecificDataSourceCheckbox.setEnabled(true);
52  fileTypeFilterObservable = new Observable() {
53  @Override
54  public void notifyObservers() {
55  //set changed before notify observers
56  //we want this observerable to always cause the observer to update when notified
57  this.setChanged();
58  super.notifyObservers();
59  }
60  };
61  }
62 
69  void addObserver(Observer observer) {
70  fileTypeFilterObservable.addObserver(observer);
71  }
72 
79  Map<Long, String> getDataSourceMap() {
80  return Collections.unmodifiableMap(this.dataSourceMap);
81  }
82 
89  Long getSelectedDataSourceId() {
90  if (onlySpecificDataSourceCheckbox.isSelected()) {
91  for (Entry<Long, String> entry : this.dataSourceMap.entrySet()) {
92  if (entry.getValue().equals(this.selectDataSourceComboBox.getSelectedItem())) {
93  return entry.getKey();
94  }
95  }
96  }
97  return IntraCasePanel.NO_DATA_SOURCE_SELECTED;
98  }
99 
106  boolean fileCategoriesButtonIsSelected() {
107  return selectedFileCategoriesButton.isSelected();
108  }
109 
117  boolean pictureVideoCheckboxIsSelected() {
118  return pictureVideoCheckbox.isEnabled() && pictureVideoCheckbox.isSelected();
119  }
120 
128  boolean documentsCheckboxIsSelected() {
129  return documentsCheckbox.isEnabled() && documentsCheckbox.isSelected();
130  }
131 
137  @SuppressWarnings("unchecked")
138  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
139  private void initComponents() {
140 
141  buttonGroup = new javax.swing.ButtonGroup();
142  selectDataSourceComboBox = new javax.swing.JComboBox<>();
143  categoriesLabel = new javax.swing.JLabel();
144  selectedFileCategoriesButton = new javax.swing.JRadioButton();
145  pictureVideoCheckbox = new javax.swing.JCheckBox();
146  documentsCheckbox = new javax.swing.JCheckBox();
147  allFileCategoriesRadioButton = new javax.swing.JRadioButton();
148  onlySpecificDataSourceCheckbox = new javax.swing.JCheckBox();
149 
150  selectDataSourceComboBox.setModel(dataSourcesList);
151  selectDataSourceComboBox.setEnabled(false);
152 
153  org.openide.awt.Mnemonics.setLocalizedText(categoriesLabel, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.categoriesLabel.text")); // NOI18N
154  categoriesLabel.setName(""); // NOI18N
155 
157  org.openide.awt.Mnemonics.setLocalizedText(selectedFileCategoriesButton, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.selectedFileCategoriesButton.text")); // NOI18N
158  selectedFileCategoriesButton.setToolTipText(org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.selectedFileCategoriesButton.toolTipText")); // NOI18N
159  selectedFileCategoriesButton.addActionListener(new java.awt.event.ActionListener() {
160  public void actionPerformed(java.awt.event.ActionEvent evt) {
162  }
163  });
164 
165  pictureVideoCheckbox.setSelected(true);
166  org.openide.awt.Mnemonics.setLocalizedText(pictureVideoCheckbox, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.pictureVideoCheckbox.text")); // NOI18N
167  pictureVideoCheckbox.setEnabled(false);
168  pictureVideoCheckbox.addActionListener(new java.awt.event.ActionListener() {
169  public void actionPerformed(java.awt.event.ActionEvent evt) {
171  }
172  });
173 
174  documentsCheckbox.setSelected(true);
175  org.openide.awt.Mnemonics.setLocalizedText(documentsCheckbox, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.documentsCheckbox.text")); // NOI18N
176  documentsCheckbox.setEnabled(false);
177  documentsCheckbox.addActionListener(new java.awt.event.ActionListener() {
178  public void actionPerformed(java.awt.event.ActionEvent evt) {
180  }
181  });
182 
184  allFileCategoriesRadioButton.setSelected(true);
185  org.openide.awt.Mnemonics.setLocalizedText(allFileCategoriesRadioButton, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.allFileCategoriesRadioButton.text")); // NOI18N
186  allFileCategoriesRadioButton.setToolTipText(org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.allFileCategoriesRadioButton.toolTipText")); // NOI18N
187  allFileCategoriesRadioButton.addActionListener(new java.awt.event.ActionListener() {
188  public void actionPerformed(java.awt.event.ActionEvent evt) {
190  }
191  });
192 
193  org.openide.awt.Mnemonics.setLocalizedText(onlySpecificDataSourceCheckbox, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.onlySpecificDataSourceCheckbox.text")); // NOI18N
194  onlySpecificDataSourceCheckbox.setMaximumSize(new java.awt.Dimension(243, 23));
195  onlySpecificDataSourceCheckbox.setMinimumSize(new java.awt.Dimension(243, 23));
196  onlySpecificDataSourceCheckbox.setPreferredSize(new java.awt.Dimension(243, 23));
197  onlySpecificDataSourceCheckbox.addActionListener(new java.awt.event.ActionListener() {
198  public void actionPerformed(java.awt.event.ActionEvent evt) {
200  }
201  });
202 
203  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
204  this.setLayout(layout);
205  layout.setHorizontalGroup(
206  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
207  .addGroup(layout.createSequentialGroup()
208  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
209  .addGroup(layout.createSequentialGroup()
210  .addGap(21, 21, 21)
211  .addComponent(selectDataSourceComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
212  .addGroup(layout.createSequentialGroup()
213  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
214  .addComponent(categoriesLabel)
215  .addGroup(layout.createSequentialGroup()
216  .addGap(19, 19, 19)
217  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
218  .addComponent(allFileCategoriesRadioButton)
219  .addComponent(selectedFileCategoriesButton)
220  .addGroup(layout.createSequentialGroup()
221  .addGap(21, 21, 21)
222  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
223  .addComponent(documentsCheckbox)
224  .addComponent(pictureVideoCheckbox))))))
225  .addGap(0, 0, Short.MAX_VALUE)))
226  .addContainerGap())
227  .addComponent(onlySpecificDataSourceCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE)
228  );
229  layout.setVerticalGroup(
230  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
231  .addGroup(layout.createSequentialGroup()
232  .addContainerGap()
233  .addComponent(onlySpecificDataSourceCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
234  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
235  .addComponent(selectDataSourceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
236  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
237  .addComponent(categoriesLabel)
238  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
239  .addComponent(allFileCategoriesRadioButton)
240  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
241  .addComponent(selectedFileCategoriesButton)
242  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
243  .addComponent(pictureVideoCheckbox)
244  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
245  .addComponent(documentsCheckbox)
246  .addContainerGap())
247  );
248  }// </editor-fold>//GEN-END:initComponents
249 
250  private void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectedFileCategoriesButtonActionPerformed
251  //When the selectedFileCategoriesButton is selected enable its related options
252  //and notify observers that the panel has changed incase the current settings are invalid
253  pictureVideoCheckbox.setEnabled(true);
254  documentsCheckbox.setEnabled(true);
255  fileTypeFilterObservable.notifyObservers();
256  }//GEN-LAST:event_selectedFileCategoriesButtonActionPerformed
257 
258  private void allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allFileCategoriesRadioButtonActionPerformed
259  //When the allFileCategoriesRadioButton is selected disable the options
260  //related to selected file categories and notify observers that the panel has changed
261  //incase the current settings are invalid
262  pictureVideoCheckbox.setEnabled(false);
263  documentsCheckbox.setEnabled(false);
264  fileTypeFilterObservable.notifyObservers();
265  }//GEN-LAST:event_allFileCategoriesRadioButtonActionPerformed
266 
267  private void onlySpecificDataSourceCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onlySpecificDataSourceCheckboxActionPerformed
268  //When the onlySpecificDataSourceCheckbox is clicked update its related options
270  if (selectDataSourceComboBox.isEnabled()) {
271  selectDataSourceComboBox.setSelectedIndex(0);
272  }
273  }//GEN-LAST:event_onlySpecificDataSourceCheckboxActionPerformed
274 
275  private void pictureVideoCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pictureVideoCheckboxActionPerformed
276  //notify observers that the panel has changed incase the current settings are invalid
277  fileTypeFilterObservable.notifyObservers();
278  }//GEN-LAST:event_pictureVideoCheckboxActionPerformed
279 
280  private void documentsCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_documentsCheckboxActionPerformed
281  //notify observers that the panel has changed incase the current settings are invalid
282  fileTypeFilterObservable.notifyObservers();
283  }//GEN-LAST:event_documentsCheckboxActionPerformed
284 
285  // Variables declaration - do not modify//GEN-BEGIN:variables
286  private javax.swing.JRadioButton allFileCategoriesRadioButton;
287  private javax.swing.ButtonGroup buttonGroup;
288  private javax.swing.JLabel categoriesLabel;
289  private javax.swing.JCheckBox documentsCheckbox;
290  private javax.swing.JCheckBox onlySpecificDataSourceCheckbox;
291  private javax.swing.JCheckBox pictureVideoCheckbox;
292  private javax.swing.JComboBox<String> selectDataSourceComboBox;
293  private javax.swing.JRadioButton selectedFileCategoriesButton;
294  // End of variables declaration//GEN-END:variables
295 
302  void setDatasourceComboboxModel(DataSourceComboBoxModel dataSourceComboBoxModel) {
303  this.dataSourcesList = dataSourceComboBoxModel;
304  this.selectDataSourceComboBox.setModel(dataSourcesList);
305  }
306 
313  void setDataSourceMap(Map<Long, String> dataSourceMap) {
314  this.dataSourceMap.clear();
315  this.dataSourceMap.putAll(dataSourceMap);
316  }
317 }
void allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JComboBox< String > selectDataSourceComboBox
void pictureVideoCheckboxActionPerformed(java.awt.event.ActionEvent evt)
void documentsCheckboxActionPerformed(java.awt.event.ActionEvent evt)
void onlySpecificDataSourceCheckboxActionPerformed(java.awt.event.ActionEvent evt)
void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt)

Copyright © 2012-2018 Basis Technology. Generated on: Tue Dec 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.