Autopsy  4.15.0
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  correlationTypeFilters.put(type.getDisplayName(), type);
132  this.correlationTypeComboBox.addItem(type.getDisplayName());
133  }
134  } catch (CentralRepoException ex) {
135  logger.log(Level.WARNING, "Error getting correlation types", ex);
136  }
137  this.correlationTypeComboBox.setSelectedIndex(0);
138  }
139 
145  @SuppressWarnings("unchecked")
146  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
147  private void initComponents() {
148 
149  buttonGroup = new javax.swing.ButtonGroup();
150  caseComboBox = new javax.swing.JComboBox<>();
151  correlationComboBoxLabel = new javax.swing.JLabel();
152  correlationTypeComboBox = new javax.swing.JComboBox<>();
153  categoriesLabel = new javax.swing.JLabel();
154  allFileCategoriesRadioButton = new javax.swing.JRadioButton();
155  selectedFileCategoriesButton = new javax.swing.JRadioButton();
156  pictureVideoCheckbox = new javax.swing.JCheckBox();
157  documentsCheckbox = new javax.swing.JCheckBox();
158  specificCentralRepoCaseCheckbox = new javax.swing.JCheckBox();
159 
160  caseComboBox.setModel(casesList);
161  caseComboBox.setEnabled(false);
162 
163  org.openide.awt.Mnemonics.setLocalizedText(correlationComboBoxLabel, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.correlationComboBoxLabel.text")); // NOI18N
164 
165  correlationTypeComboBox.setSelectedItem(null);
166  correlationTypeComboBox.setToolTipText(org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.correlationTypeComboBox.toolTipText")); // NOI18N
167  correlationTypeComboBox.addActionListener(new java.awt.event.ActionListener() {
168  public void actionPerformed(java.awt.event.ActionEvent evt) {
170  }
171  });
172 
173  org.openide.awt.Mnemonics.setLocalizedText(categoriesLabel, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.categoriesLabel.text")); // NOI18N
174  categoriesLabel.setEnabled(false);
175  categoriesLabel.setName(""); // NOI18N
176 
178  org.openide.awt.Mnemonics.setLocalizedText(allFileCategoriesRadioButton, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.allFileCategoriesRadioButton.text")); // NOI18N
179  allFileCategoriesRadioButton.setToolTipText(org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.allFileCategoriesRadioButton.toolTipText")); // NOI18N
180  allFileCategoriesRadioButton.setEnabled(false);
181  allFileCategoriesRadioButton.addActionListener(new java.awt.event.ActionListener() {
182  public void actionPerformed(java.awt.event.ActionEvent evt) {
184  }
185  });
186 
188  selectedFileCategoriesButton.setSelected(true);
189  org.openide.awt.Mnemonics.setLocalizedText(selectedFileCategoriesButton, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.selectedFileCategoriesButton.text")); // NOI18N
190  selectedFileCategoriesButton.setToolTipText(org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.selectedFileCategoriesButton.toolTipText")); // NOI18N
191  selectedFileCategoriesButton.setEnabled(false);
192  selectedFileCategoriesButton.addActionListener(new java.awt.event.ActionListener() {
193  public void actionPerformed(java.awt.event.ActionEvent evt) {
195  }
196  });
197 
198  pictureVideoCheckbox.setSelected(true);
199  org.openide.awt.Mnemonics.setLocalizedText(pictureVideoCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.pictureVideoCheckbox.text")); // NOI18N
200  pictureVideoCheckbox.setEnabled(false);
201  pictureVideoCheckbox.addActionListener(new java.awt.event.ActionListener() {
202  public void actionPerformed(java.awt.event.ActionEvent evt) {
204  }
205  });
206 
207  documentsCheckbox.setSelected(true);
208  org.openide.awt.Mnemonics.setLocalizedText(documentsCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.documentsCheckbox.text")); // NOI18N
209  documentsCheckbox.setEnabled(false);
210  documentsCheckbox.addActionListener(new java.awt.event.ActionListener() {
211  public void actionPerformed(java.awt.event.ActionEvent evt) {
213  }
214  });
215 
216  org.openide.awt.Mnemonics.setLocalizedText(specificCentralRepoCaseCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.specificCentralRepoCaseCheckbox.text")); // NOI18N
217  specificCentralRepoCaseCheckbox.addActionListener(new java.awt.event.ActionListener() {
218  public void actionPerformed(java.awt.event.ActionEvent evt) {
220  }
221  });
222 
223  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
224  this.setLayout(layout);
225  layout.setHorizontalGroup(
226  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
227  .addComponent(specificCentralRepoCaseCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
228  .addGroup(layout.createSequentialGroup()
229  .addComponent(correlationComboBoxLabel)
230  .addGap(0, 0, Short.MAX_VALUE))
231  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
232  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
233  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
234  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
235  .addComponent(categoriesLabel)
236  .addGroup(layout.createSequentialGroup()
237  .addGap(19, 19, 19)
238  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
239  .addComponent(allFileCategoriesRadioButton)
240  .addComponent(selectedFileCategoriesButton)
241  .addGroup(layout.createSequentialGroup()
242  .addGap(21, 21, 21)
243  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
244  .addComponent(documentsCheckbox)
245  .addComponent(pictureVideoCheckbox))))))
246  .addGap(0, 0, Short.MAX_VALUE))
247  .addGroup(layout.createSequentialGroup()
248  .addGap(21, 21, 21)
249  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
250  .addComponent(caseComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
251  .addComponent(correlationTypeComboBox, 0, 353, Short.MAX_VALUE))))
252  .addContainerGap())
253  );
254  layout.setVerticalGroup(
255  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
256  .addGroup(layout.createSequentialGroup()
257  .addContainerGap()
258  .addComponent(specificCentralRepoCaseCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
259  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
260  .addComponent(caseComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
261  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
262  .addComponent(correlationComboBoxLabel)
263  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
264  .addComponent(correlationTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
265  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
266  .addComponent(categoriesLabel)
267  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
268  .addComponent(allFileCategoriesRadioButton)
269  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
270  .addComponent(selectedFileCategoriesButton)
271  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
272  .addComponent(pictureVideoCheckbox)
273  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
274  .addComponent(documentsCheckbox)
275  .addGap(0, 0, 0))
276  );
277  }// </editor-fold>//GEN-END:initComponents
278 
279  private void allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allFileCategoriesRadioButtonActionPerformed
280  //When the allFileCategoriesRadioButton is selected disable the options
281  //related to selected file categories and notify observers that the panel has changed
282  //incase the current settings are invalid
283  pictureVideoCheckbox.setEnabled(false);
284  documentsCheckbox.setEnabled(false);
285  fileTypeFilterObservable.notifyObservers();
286  }//GEN-LAST:event_allFileCategoriesRadioButtonActionPerformed
287 
288  private void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectedFileCategoriesButtonActionPerformed
289  //When the selectedFileCategoriesButton is selected enable its related options
290  //and notify observers that the panel has changed incase the current settings are invalid
291  pictureVideoCheckbox.setEnabled(true);
292  documentsCheckbox.setEnabled(true);
293  fileTypeFilterObservable.notifyObservers();
294  }//GEN-LAST:event_selectedFileCategoriesButtonActionPerformed
295 
296  private void specificCentralRepoCaseCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_specificCentralRepoCaseCheckboxActionPerformed
297  //When the specificCentralRepoCaseCheckbox is clicked update its related options
298  this.caseComboBox.setEnabled(specificCentralRepoCaseCheckbox.isSelected());
299  if (specificCentralRepoCaseCheckbox.isSelected()) {
300  this.caseComboBox.setSelectedIndex(0);
301  }
302  }//GEN-LAST:event_specificCentralRepoCaseCheckboxActionPerformed
303 
304 
305  private void correlationTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_correlationTypeComboBoxActionPerformed
306  boolean enableFileTypesFilter = this.correlationTypeComboBox.getSelectedItem().equals("Files");
307  categoriesLabel.setEnabled(enableFileTypesFilter);
308  allFileCategoriesRadioButton.setEnabled(enableFileTypesFilter);
309  selectedFileCategoriesButton.setEnabled(enableFileTypesFilter);
310  boolean enableIndividualFilters = (enableFileTypesFilter && selectedFileCategoriesButton.isSelected());
311  pictureVideoCheckbox.setEnabled(enableIndividualFilters);
312  documentsCheckbox.setEnabled(enableIndividualFilters);
313  }//GEN-LAST:event_correlationTypeComboBoxActionPerformed
314 
315  private void pictureVideoCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pictureVideoCheckboxActionPerformed
316  //notify observers that the panel has changed incase the current settings are invalid
317  fileTypeFilterObservable.notifyObservers();
318  }//GEN-LAST:event_pictureVideoCheckboxActionPerformed
319 
320  private void documentsCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_documentsCheckboxActionPerformed
321  //notify observers that the panel has changed incase the current settings are invalid
322  fileTypeFilterObservable.notifyObservers();
323  }//GEN-LAST:event_documentsCheckboxActionPerformed
324 
325 
326  // Variables declaration - do not modify//GEN-BEGIN:variables
327  private javax.swing.JRadioButton allFileCategoriesRadioButton;
328  private javax.swing.ButtonGroup buttonGroup;
329  private javax.swing.JComboBox<String> caseComboBox;
330  private javax.swing.JLabel categoriesLabel;
331  private javax.swing.JLabel correlationComboBoxLabel;
332  private javax.swing.JComboBox<String> correlationTypeComboBox;
333  private javax.swing.JCheckBox documentsCheckbox;
334  private javax.swing.JCheckBox pictureVideoCheckbox;
335  private javax.swing.JRadioButton selectedFileCategoriesButton;
336  private javax.swing.JCheckBox specificCentralRepoCaseCheckbox;
337  // End of variables declaration//GEN-END:variables
338 
345  Map<Integer, String> getCaseMap() {
346  return Collections.unmodifiableMap(this.caseMap);
347  }
348 
355  void setCaseComboboxModel(DataSourceComboBoxModel dataSourceComboBoxModel) {
356  this.casesList = dataSourceComboBoxModel;
357  this.caseComboBox.setModel(dataSourceComboBoxModel);
358  }
359 
365  void setCaseMap(Map<Integer, String> caseMap) {
366  this.caseMap.clear();
367  this.caseMap.putAll(caseMap);
368  }
369 
376  boolean centralRepoHasMultipleCases() {
377  return this.caseMap.size() >= 2;
378  }
379 
386  Integer getSelectedCaseId() {
387  if (specificCentralRepoCaseCheckbox.isSelected()) {
388  for (Entry<Integer, String> entry : this.caseMap.entrySet()) {
389  if (entry.getValue().equals(this.caseComboBox.getSelectedItem())) {
390  return entry.getKey();
391  }
392  }
393  }
394  return InterCasePanel.NO_CASE_SELECTED;
395  }
396 
403  CorrelationAttributeInstance.Type getSelectedCorrelationType() {
404  return correlationTypeFilters.get(this.correlationTypeComboBox.getSelectedItem().toString());
405  }
406 }
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-2020 Basis Technology. Generated on: Mon Jul 6 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.