Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
InterCasePanel.java
Go to the documentation of this file.
1 /*
2  *
3  * Autopsy Forensic Browser
4  *
5  * Copyright 2018-2020 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.commonpropertiessearch;
21 
23 import java.util.Collections;
24 import java.util.Comparator;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28 import java.util.Map.Entry;
29 import java.util.Observable;
30 import java.util.Observer;
31 import java.util.logging.Level;
32 import javax.swing.ComboBoxModel;
37 
42 public final class InterCasePanel extends javax.swing.JPanel {
43 
44  private final static Logger logger = Logger.getLogger(InterCasePanel.class.getName());
45  private static final long serialVersionUID = 1L;
46  private final Observable fileTypeFilterObservable;
47  static final int NO_CASE_SELECTED = -1;
48 
49  private ComboBoxModel<String> casesList = new DataSourceComboBoxModel();
50 
51  private final Map<Integer, String> caseMap;
52 
54 
58  public InterCasePanel() {
60  this.caseMap = new HashMap<>();
61  fileTypeFilterObservable = new Observable() {
62  @Override
63  public void notifyObservers() {
64  //set changed before notify observers
65  //we want this observerable to always cause the observer to update when notified
66  this.setChanged();
67  super.notifyObservers();
68  }
69  };
70  }
71 
78  void addObserver(Observer observer) {
79  fileTypeFilterObservable.addObserver(observer);
80  }
81 
89  boolean fileCategoriesButtonIsSelected() {
90  return selectedFileCategoriesButton.isEnabled() && selectedFileCategoriesButton.isSelected();
91  }
92 
100  boolean pictureVideoCheckboxIsSelected() {
101  return pictureVideoCheckbox.isEnabled() && pictureVideoCheckbox.isSelected();
102  }
103 
111  boolean documentsCheckboxIsSelected() {
112  return documentsCheckbox.isEnabled() && documentsCheckbox.isSelected();
113  }
114 
119  void setupCorrelationTypeFilter() {
120  this.correlationTypeFilters = new HashMap<>();
121  try {
122  List<CorrelationAttributeInstance.Type> types = CentralRepository.getInstance().getDefinedCorrelationTypes();
123  Collections.sort(types, new Comparator<CorrelationAttributeInstance.Type>() {
124  //The types should be sorted so that the File type is the first item in the combo box.
125  @Override
126  public int compare(CorrelationAttributeInstance.Type type1, CorrelationAttributeInstance.Type type2) {
127  return Integer.compare(type1.getId(), type2.getId());
128  }
129  });
130  for (CorrelationAttributeInstance.Type type : types) {
131  if (! type.getDbTableName().contains("os_account") && ! type.getDbTableName().contains("installed_program")) {
132  correlationTypeFilters.put(type.getDisplayName(), type);
133  this.correlationTypeComboBox.addItem(type.getDisplayName());
134  }
135  }
136  } catch (CentralRepoException ex) {
137  logger.log(Level.WARNING, "Error getting correlation types", ex);
138  }
139  this.correlationTypeComboBox.setSelectedIndex(0);
140  }
141 
147  @SuppressWarnings("unchecked")
148  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
149  private void initComponents() {
150 
151  buttonGroup = new javax.swing.ButtonGroup();
152  caseComboBox = new javax.swing.JComboBox<>();
153  correlationComboBoxLabel = new javax.swing.JLabel();
154  correlationTypeComboBox = new javax.swing.JComboBox<>();
155  categoriesLabel = new javax.swing.JLabel();
156  allFileCategoriesRadioButton = new javax.swing.JRadioButton();
157  selectedFileCategoriesButton = new javax.swing.JRadioButton();
158  pictureVideoCheckbox = new javax.swing.JCheckBox();
159  documentsCheckbox = new javax.swing.JCheckBox();
160  specificCentralRepoCaseCheckbox = new javax.swing.JCheckBox();
161 
162  caseComboBox.setModel(casesList);
163  caseComboBox.setEnabled(false);
164 
165  org.openide.awt.Mnemonics.setLocalizedText(correlationComboBoxLabel, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.correlationComboBoxLabel.text")); // NOI18N
166 
167  correlationTypeComboBox.setSelectedItem(null);
168  correlationTypeComboBox.setToolTipText(org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.correlationTypeComboBox.toolTipText")); // NOI18N
169  correlationTypeComboBox.addActionListener(new java.awt.event.ActionListener() {
170  public void actionPerformed(java.awt.event.ActionEvent evt) {
172  }
173  });
174 
175  org.openide.awt.Mnemonics.setLocalizedText(categoriesLabel, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.categoriesLabel.text")); // NOI18N
176  categoriesLabel.setEnabled(false);
177  categoriesLabel.setName(""); // NOI18N
178 
180  org.openide.awt.Mnemonics.setLocalizedText(allFileCategoriesRadioButton, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.allFileCategoriesRadioButton.text")); // NOI18N
181  allFileCategoriesRadioButton.setToolTipText(org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.allFileCategoriesRadioButton.toolTipText")); // NOI18N
182  allFileCategoriesRadioButton.setEnabled(false);
183  allFileCategoriesRadioButton.addActionListener(new java.awt.event.ActionListener() {
184  public void actionPerformed(java.awt.event.ActionEvent evt) {
186  }
187  });
188 
190  selectedFileCategoriesButton.setSelected(true);
191  org.openide.awt.Mnemonics.setLocalizedText(selectedFileCategoriesButton, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.selectedFileCategoriesButton.text")); // NOI18N
192  selectedFileCategoriesButton.setToolTipText(org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.selectedFileCategoriesButton.toolTipText")); // NOI18N
193  selectedFileCategoriesButton.setEnabled(false);
194  selectedFileCategoriesButton.addActionListener(new java.awt.event.ActionListener() {
195  public void actionPerformed(java.awt.event.ActionEvent evt) {
197  }
198  });
199 
200  pictureVideoCheckbox.setSelected(true);
201  org.openide.awt.Mnemonics.setLocalizedText(pictureVideoCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.pictureVideoCheckbox.text")); // NOI18N
202  pictureVideoCheckbox.setEnabled(false);
203  pictureVideoCheckbox.addActionListener(new java.awt.event.ActionListener() {
204  public void actionPerformed(java.awt.event.ActionEvent evt) {
206  }
207  });
208 
209  documentsCheckbox.setSelected(true);
210  org.openide.awt.Mnemonics.setLocalizedText(documentsCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.documentsCheckbox.text")); // NOI18N
211  documentsCheckbox.setEnabled(false);
212  documentsCheckbox.addActionListener(new java.awt.event.ActionListener() {
213  public void actionPerformed(java.awt.event.ActionEvent evt) {
215  }
216  });
217 
218  org.openide.awt.Mnemonics.setLocalizedText(specificCentralRepoCaseCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.specificCentralRepoCaseCheckbox.text")); // NOI18N
219  specificCentralRepoCaseCheckbox.addActionListener(new java.awt.event.ActionListener() {
220  public void actionPerformed(java.awt.event.ActionEvent evt) {
222  }
223  });
224 
225  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
226  this.setLayout(layout);
227  layout.setHorizontalGroup(
228  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
229  .addComponent(specificCentralRepoCaseCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
230  .addGroup(layout.createSequentialGroup()
231  .addComponent(correlationComboBoxLabel)
232  .addGap(0, 0, Short.MAX_VALUE))
233  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
234  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
235  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
236  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
237  .addComponent(categoriesLabel)
238  .addGroup(layout.createSequentialGroup()
239  .addGap(19, 19, 19)
240  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
241  .addComponent(allFileCategoriesRadioButton)
242  .addComponent(selectedFileCategoriesButton)
243  .addGroup(layout.createSequentialGroup()
244  .addGap(21, 21, 21)
245  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
246  .addComponent(documentsCheckbox)
247  .addComponent(pictureVideoCheckbox))))))
248  .addGap(0, 0, Short.MAX_VALUE))
249  .addGroup(layout.createSequentialGroup()
250  .addGap(21, 21, 21)
251  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
252  .addComponent(caseComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
253  .addComponent(correlationTypeComboBox, 0, 353, Short.MAX_VALUE))))
254  .addContainerGap())
255  );
256  layout.setVerticalGroup(
257  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
258  .addGroup(layout.createSequentialGroup()
259  .addContainerGap()
260  .addComponent(specificCentralRepoCaseCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
261  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
262  .addComponent(caseComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
263  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
264  .addComponent(correlationComboBoxLabel)
265  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
266  .addComponent(correlationTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
267  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
268  .addComponent(categoriesLabel)
269  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
270  .addComponent(allFileCategoriesRadioButton)
271  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
272  .addComponent(selectedFileCategoriesButton)
273  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
274  .addComponent(pictureVideoCheckbox)
275  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
276  .addComponent(documentsCheckbox)
277  .addGap(0, 0, 0))
278  );
279  }// </editor-fold>//GEN-END:initComponents
280 
281  private void allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allFileCategoriesRadioButtonActionPerformed
282  //When the allFileCategoriesRadioButton is selected disable the options
283  //related to selected file categories and notify observers that the panel has changed
284  //incase the current settings are invalid
285  pictureVideoCheckbox.setEnabled(false);
286  documentsCheckbox.setEnabled(false);
287  fileTypeFilterObservable.notifyObservers();
288  }//GEN-LAST:event_allFileCategoriesRadioButtonActionPerformed
289 
290  private void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectedFileCategoriesButtonActionPerformed
291  //When the selectedFileCategoriesButton is selected enable its related options
292  //and notify observers that the panel has changed incase the current settings are invalid
293  pictureVideoCheckbox.setEnabled(true);
294  documentsCheckbox.setEnabled(true);
295  fileTypeFilterObservable.notifyObservers();
296  }//GEN-LAST:event_selectedFileCategoriesButtonActionPerformed
297 
298  private void specificCentralRepoCaseCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_specificCentralRepoCaseCheckboxActionPerformed
299  //When the specificCentralRepoCaseCheckbox is clicked update its related options
300  this.caseComboBox.setEnabled(specificCentralRepoCaseCheckbox.isSelected());
301  if (specificCentralRepoCaseCheckbox.isSelected()) {
302  this.caseComboBox.setSelectedIndex(0);
303  }
304  }//GEN-LAST:event_specificCentralRepoCaseCheckboxActionPerformed
305 
306 
307  private void correlationTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_correlationTypeComboBoxActionPerformed
308  boolean enableFileTypesFilter = this.correlationTypeComboBox.getSelectedItem().equals("Files");
309  categoriesLabel.setEnabled(enableFileTypesFilter);
310  allFileCategoriesRadioButton.setEnabled(enableFileTypesFilter);
311  selectedFileCategoriesButton.setEnabled(enableFileTypesFilter);
312  boolean enableIndividualFilters = (enableFileTypesFilter && selectedFileCategoriesButton.isSelected());
313  pictureVideoCheckbox.setEnabled(enableIndividualFilters);
314  documentsCheckbox.setEnabled(enableIndividualFilters);
315  }//GEN-LAST:event_correlationTypeComboBoxActionPerformed
316 
317  private void pictureVideoCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pictureVideoCheckboxActionPerformed
318  //notify observers that the panel has changed incase the current settings are invalid
319  fileTypeFilterObservable.notifyObservers();
320  }//GEN-LAST:event_pictureVideoCheckboxActionPerformed
321 
322  private void documentsCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_documentsCheckboxActionPerformed
323  //notify observers that the panel has changed incase the current settings are invalid
324  fileTypeFilterObservable.notifyObservers();
325  }//GEN-LAST:event_documentsCheckboxActionPerformed
326 
327 
328  // Variables declaration - do not modify//GEN-BEGIN:variables
329  private javax.swing.JRadioButton allFileCategoriesRadioButton;
330  private javax.swing.ButtonGroup buttonGroup;
331  private javax.swing.JComboBox<String> caseComboBox;
332  private javax.swing.JLabel categoriesLabel;
333  private javax.swing.JLabel correlationComboBoxLabel;
334  private javax.swing.JComboBox<String> correlationTypeComboBox;
335  private javax.swing.JCheckBox documentsCheckbox;
336  private javax.swing.JCheckBox pictureVideoCheckbox;
337  private javax.swing.JRadioButton selectedFileCategoriesButton;
338  private javax.swing.JCheckBox specificCentralRepoCaseCheckbox;
339  // End of variables declaration//GEN-END:variables
340 
347  Map<Integer, String> getCaseMap() {
348  return Collections.unmodifiableMap(this.caseMap);
349  }
350 
357  void setCaseComboboxModel(DataSourceComboBoxModel dataSourceComboBoxModel) {
358  this.casesList = dataSourceComboBoxModel;
359  this.caseComboBox.setModel(dataSourceComboBoxModel);
360  }
361 
367  void setCaseMap(Map<Integer, String> caseMap) {
368  this.caseMap.clear();
369  this.caseMap.putAll(caseMap);
370  }
371 
378  boolean centralRepoHasMultipleCases() {
379  return this.caseMap.size() >= 2;
380  }
381 
388  Integer getSelectedCaseId() {
389  if (specificCentralRepoCaseCheckbox.isSelected()) {
390  for (Entry<Integer, String> entry : this.caseMap.entrySet()) {
391  if (entry.getValue().equals(this.caseComboBox.getSelectedItem())) {
392  return entry.getKey();
393  }
394  }
395  }
396  return InterCasePanel.NO_CASE_SELECTED;
397  }
398 
405  CorrelationAttributeInstance.Type getSelectedCorrelationType() {
406  return correlationTypeFilters.get(this.correlationTypeComboBox.getSelectedItem().toString());
407  }
408 }
void documentsCheckboxActionPerformed(java.awt.event.ActionEvent evt)
void allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt)
Map< String, CorrelationAttributeInstance.Type > correlationTypeFilters
void pictureVideoCheckboxActionPerformed(java.awt.event.ActionEvent evt)
void specificCentralRepoCaseCheckboxActionPerformed(java.awt.event.ActionEvent evt)
void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt)
void correlationTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2021 Basis Technology. Generated on: Thu Sep 30 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.