Autopsy  4.8.0
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 
22 import java.util.Collections;
23 import java.util.HashMap;
24 import java.util.Map;
25 import java.util.Map.Entry;
26 import java.util.Observable;
27 import java.util.Observer;
28 import javax.swing.ComboBoxModel;
29 
36 public final class IntraCasePanel extends javax.swing.JPanel {
37 
38  private static final long serialVersionUID = 1L;
39  static final long NO_DATA_SOURCE_SELECTED = -1;
40  private final Observable fileTypeFilterObservable;
41  private ComboBoxModel<String> dataSourcesList = new DataSourceComboBoxModel();
42  private final Map<Long, String> dataSourceMap;
43 
47  public IntraCasePanel() {
49  this.dataSourceMap = new HashMap<>();
50  this.onlySpecificDataSourceCheckbox.setEnabled(true);
51  fileTypeFilterObservable = new Observable() {
52  @Override
53  public void notifyObservers() {
54  //set changed before notify observers
55  //we want this observerable to always cause the observer to update when notified
56  this.setChanged();
57  super.notifyObservers();
58  }
59  };
60  }
61 
68  void addObserver(Observer observer) {
69  fileTypeFilterObservable.addObserver(observer);
70  }
71 
78  Map<Long, String> getDataSourceMap() {
79  return Collections.unmodifiableMap(this.dataSourceMap);
80  }
81 
88  Long getSelectedDataSourceId() {
89  if (onlySpecificDataSourceCheckbox.isSelected()) {
90  for (Entry<Long, String> entry : this.dataSourceMap.entrySet()) {
91  if (entry.getValue().equals(this.selectDataSourceComboBox.getSelectedItem())) {
92  return entry.getKey();
93  }
94  }
95  }
96  return IntraCasePanel.NO_DATA_SOURCE_SELECTED;
97  }
98 
105  boolean fileCategoriesButtonIsSelected() {
106  return selectedFileCategoriesButton.isSelected();
107  }
108 
116  boolean pictureVideoCheckboxIsSelected() {
117  return pictureVideoCheckbox.isEnabled() && pictureVideoCheckbox.isSelected();
118  }
119 
127  boolean documentsCheckboxIsSelected() {
128  return documentsCheckbox.isEnabled() && documentsCheckbox.isSelected();
129  }
130 
136  @SuppressWarnings("unchecked")
137  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
138  private void initComponents() {
139 
140  buttonGroup = new javax.swing.ButtonGroup();
141  selectDataSourceComboBox = new javax.swing.JComboBox<>();
142  categoriesLabel = new javax.swing.JLabel();
143  selectedFileCategoriesButton = new javax.swing.JRadioButton();
144  pictureVideoCheckbox = new javax.swing.JCheckBox();
145  documentsCheckbox = new javax.swing.JCheckBox();
146  allFileCategoriesRadioButton = new javax.swing.JRadioButton();
147  onlySpecificDataSourceCheckbox = new javax.swing.JCheckBox();
148 
149  selectDataSourceComboBox.setModel(dataSourcesList);
150  selectDataSourceComboBox.setEnabled(false);
151 
152  org.openide.awt.Mnemonics.setLocalizedText(categoriesLabel, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.categoriesLabel.text")); // NOI18N
153  categoriesLabel.setName(""); // NOI18N
154 
156  org.openide.awt.Mnemonics.setLocalizedText(selectedFileCategoriesButton, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.selectedFileCategoriesButton.text")); // NOI18N
157  selectedFileCategoriesButton.setToolTipText(org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.selectedFileCategoriesButton.toolTipText")); // NOI18N
158  selectedFileCategoriesButton.addActionListener(new java.awt.event.ActionListener() {
159  public void actionPerformed(java.awt.event.ActionEvent evt) {
161  }
162  });
163 
164  pictureVideoCheckbox.setSelected(true);
165  org.openide.awt.Mnemonics.setLocalizedText(pictureVideoCheckbox, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.pictureVideoCheckbox.text")); // NOI18N
166  pictureVideoCheckbox.setEnabled(false);
167  pictureVideoCheckbox.addActionListener(new java.awt.event.ActionListener() {
168  public void actionPerformed(java.awt.event.ActionEvent evt) {
170  }
171  });
172 
173  documentsCheckbox.setSelected(true);
174  org.openide.awt.Mnemonics.setLocalizedText(documentsCheckbox, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.documentsCheckbox.text")); // NOI18N
175  documentsCheckbox.setEnabled(false);
176  documentsCheckbox.addActionListener(new java.awt.event.ActionListener() {
177  public void actionPerformed(java.awt.event.ActionEvent evt) {
179  }
180  });
181 
183  allFileCategoriesRadioButton.setSelected(true);
184  org.openide.awt.Mnemonics.setLocalizedText(allFileCategoriesRadioButton, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.allFileCategoriesRadioButton.text")); // NOI18N
185  allFileCategoriesRadioButton.setToolTipText(org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.allFileCategoriesRadioButton.toolTipText")); // NOI18N
186  allFileCategoriesRadioButton.addActionListener(new java.awt.event.ActionListener() {
187  public void actionPerformed(java.awt.event.ActionEvent evt) {
189  }
190  });
191 
192  org.openide.awt.Mnemonics.setLocalizedText(onlySpecificDataSourceCheckbox, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.onlySpecificDataSourceCheckbox.text")); // NOI18N
193  onlySpecificDataSourceCheckbox.setMaximumSize(new java.awt.Dimension(243, 23));
194  onlySpecificDataSourceCheckbox.setMinimumSize(new java.awt.Dimension(243, 23));
195  onlySpecificDataSourceCheckbox.setPreferredSize(new java.awt.Dimension(243, 23));
196  onlySpecificDataSourceCheckbox.addActionListener(new java.awt.event.ActionListener() {
197  public void actionPerformed(java.awt.event.ActionEvent evt) {
199  }
200  });
201 
202  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
203  this.setLayout(layout);
204  layout.setHorizontalGroup(
205  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
206  .addGroup(layout.createSequentialGroup()
207  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
208  .addGroup(layout.createSequentialGroup()
209  .addGap(21, 21, 21)
210  .addComponent(selectDataSourceComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
211  .addGroup(layout.createSequentialGroup()
212  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
213  .addComponent(categoriesLabel)
214  .addGroup(layout.createSequentialGroup()
215  .addGap(19, 19, 19)
216  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
217  .addComponent(allFileCategoriesRadioButton)
218  .addComponent(selectedFileCategoriesButton)
219  .addGroup(layout.createSequentialGroup()
220  .addGap(21, 21, 21)
221  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
222  .addComponent(documentsCheckbox)
223  .addComponent(pictureVideoCheckbox))))))
224  .addGap(0, 0, Short.MAX_VALUE)))
225  .addContainerGap())
226  .addComponent(onlySpecificDataSourceCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE)
227  );
228  layout.setVerticalGroup(
229  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
230  .addGroup(layout.createSequentialGroup()
231  .addContainerGap()
232  .addComponent(onlySpecificDataSourceCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
233  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
234  .addComponent(selectDataSourceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
235  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
236  .addComponent(categoriesLabel)
237  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
238  .addComponent(allFileCategoriesRadioButton)
239  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
240  .addComponent(selectedFileCategoriesButton)
241  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
242  .addComponent(pictureVideoCheckbox)
243  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
244  .addComponent(documentsCheckbox)
245  .addContainerGap())
246  );
247  }// </editor-fold>//GEN-END:initComponents
248 
249  private void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectedFileCategoriesButtonActionPerformed
250  //When the selectedFileCategoriesButton is selected enable its related options
251  //and notify observers that the panel has changed incase the current settings are invalid
252  pictureVideoCheckbox.setEnabled(true);
253  documentsCheckbox.setEnabled(true);
254  fileTypeFilterObservable.notifyObservers();
255  }//GEN-LAST:event_selectedFileCategoriesButtonActionPerformed
256 
257  private void allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allFileCategoriesRadioButtonActionPerformed
258  //When the allFileCategoriesRadioButton is selected disable the options
259  //related to selected file categories and notify observers that the panel has changed
260  //incase the current settings are invalid
261  pictureVideoCheckbox.setEnabled(false);
262  documentsCheckbox.setEnabled(false);
263  fileTypeFilterObservable.notifyObservers();
264  }//GEN-LAST:event_allFileCategoriesRadioButtonActionPerformed
265 
266  private void onlySpecificDataSourceCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onlySpecificDataSourceCheckboxActionPerformed
267  //When the onlySpecificDataSourceCheckbox is clicked update its related options
269  if (selectDataSourceComboBox.isEnabled()) {
270  selectDataSourceComboBox.setSelectedIndex(0);
271  }
272  }//GEN-LAST:event_onlySpecificDataSourceCheckboxActionPerformed
273 
274  private void pictureVideoCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pictureVideoCheckboxActionPerformed
275  //notify observers that the panel has changed incase the current settings are invalid
276  fileTypeFilterObservable.notifyObservers();
277  }//GEN-LAST:event_pictureVideoCheckboxActionPerformed
278 
279  private void documentsCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_documentsCheckboxActionPerformed
280  //notify observers that the panel has changed incase the current settings are invalid
281  fileTypeFilterObservable.notifyObservers();
282  }//GEN-LAST:event_documentsCheckboxActionPerformed
283 
284  // Variables declaration - do not modify//GEN-BEGIN:variables
285  private javax.swing.JRadioButton allFileCategoriesRadioButton;
286  private javax.swing.ButtonGroup buttonGroup;
287  private javax.swing.JLabel categoriesLabel;
288  private javax.swing.JCheckBox documentsCheckbox;
289  private javax.swing.JCheckBox onlySpecificDataSourceCheckbox;
290  private javax.swing.JCheckBox pictureVideoCheckbox;
291  private javax.swing.JComboBox<String> selectDataSourceComboBox;
292  private javax.swing.JRadioButton selectedFileCategoriesButton;
293  // End of variables declaration//GEN-END:variables
294 
301  void setDatasourceComboboxModel(DataSourceComboBoxModel dataSourceComboBoxModel) {
302  this.dataSourcesList = dataSourceComboBoxModel;
303  this.selectDataSourceComboBox.setModel(dataSourcesList);
304  }
305 
312  void setDataSourceMap(Map<Long, String> dataSourceMap) {
313  this.dataSourceMap.clear();
314  this.dataSourceMap.putAll(dataSourceMap);
315  }
316 }
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: Thu Oct 4 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.