Autopsy  4.12.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-2019 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.HashMap;
25 import java.util.List;
26 import java.util.Map;
27 import java.util.Map.Entry;
28 import java.util.Observable;
29 import java.util.Observer;
30 import java.util.logging.Level;
31 import javax.swing.ComboBoxModel;
35 
40 public final class InterCasePanel extends javax.swing.JPanel {
41 
42  private final static Logger logger = Logger.getLogger(InterCasePanel.class.getName());
43  private static final long serialVersionUID = 1L;
44  private final Observable fileTypeFilterObservable;
45  static final int NO_CASE_SELECTED = -1;
46 
47  private ComboBoxModel<String> casesList = new DataSourceComboBoxModel();
48 
49  private final Map<Integer, String> caseMap;
50 
52 
56  public InterCasePanel() {
58  this.caseMap = new HashMap<>();
59  fileTypeFilterObservable = new Observable() {
60  @Override
61  public void notifyObservers() {
62  //set changed before notify observers
63  //we want this observerable to always cause the observer to update when notified
64  this.setChanged();
65  super.notifyObservers();
66  }
67  };
68  }
69 
76  void addObserver(Observer observer) {
77  fileTypeFilterObservable.addObserver(observer);
78  }
79 
87  boolean fileCategoriesButtonIsSelected() {
88  return selectedFileCategoriesButton.isEnabled() && selectedFileCategoriesButton.isSelected();
89  }
90 
98  boolean pictureVideoCheckboxIsSelected() {
99  return pictureVideoCheckbox.isEnabled() && pictureVideoCheckbox.isSelected();
100  }
101 
109  boolean documentsCheckboxIsSelected() {
110  return documentsCheckbox.isEnabled() && documentsCheckbox.isSelected();
111  }
112 
117  void setupCorrelationTypeFilter() {
118  this.correlationTypeFilters = new HashMap<>();
119  try {
120  List<CorrelationAttributeInstance.Type> types = CorrelationAttributeInstance.getDefaultCorrelationTypes();
121  for (CorrelationAttributeInstance.Type type : types) {
122  correlationTypeFilters.put(type.getDisplayName(), type);
123  this.correlationTypeComboBox.addItem(type.getDisplayName());
124  }
125  } catch (EamDbException ex) {
126  logger.log(Level.WARNING, "Error getting correlation types", ex);
127  }
128  this.correlationTypeComboBox.setSelectedIndex(0);
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  caseComboBox = new javax.swing.JComboBox<>();
142  correlationComboBoxLabel = new javax.swing.JLabel();
143  correlationTypeComboBox = new javax.swing.JComboBox<>();
144  categoriesLabel = new javax.swing.JLabel();
145  allFileCategoriesRadioButton = new javax.swing.JRadioButton();
146  selectedFileCategoriesButton = new javax.swing.JRadioButton();
147  pictureVideoCheckbox = new javax.swing.JCheckBox();
148  documentsCheckbox = new javax.swing.JCheckBox();
149  specificCentralRepoCaseCheckbox = new javax.swing.JCheckBox();
150 
151  caseComboBox.setModel(casesList);
152  caseComboBox.setEnabled(false);
153 
154  org.openide.awt.Mnemonics.setLocalizedText(correlationComboBoxLabel, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.correlationComboBoxLabel.text")); // NOI18N
155 
156  correlationTypeComboBox.setSelectedItem(null);
157  correlationTypeComboBox.setToolTipText(org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.correlationTypeComboBox.toolTipText")); // NOI18N
158  correlationTypeComboBox.addActionListener(new java.awt.event.ActionListener() {
159  public void actionPerformed(java.awt.event.ActionEvent evt) {
161  }
162  });
163 
164  org.openide.awt.Mnemonics.setLocalizedText(categoriesLabel, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.categoriesLabel.text")); // NOI18N
165  categoriesLabel.setEnabled(false);
166  categoriesLabel.setName(""); // NOI18N
167 
169  org.openide.awt.Mnemonics.setLocalizedText(allFileCategoriesRadioButton, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.allFileCategoriesRadioButton.text")); // NOI18N
170  allFileCategoriesRadioButton.setToolTipText(org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.allFileCategoriesRadioButton.toolTipText")); // NOI18N
171  allFileCategoriesRadioButton.setEnabled(false);
172  allFileCategoriesRadioButton.addActionListener(new java.awt.event.ActionListener() {
173  public void actionPerformed(java.awt.event.ActionEvent evt) {
175  }
176  });
177 
179  selectedFileCategoriesButton.setSelected(true);
180  org.openide.awt.Mnemonics.setLocalizedText(selectedFileCategoriesButton, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.selectedFileCategoriesButton.text")); // NOI18N
181  selectedFileCategoriesButton.setToolTipText(org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.selectedFileCategoriesButton.toolTipText")); // NOI18N
182  selectedFileCategoriesButton.setEnabled(false);
183  selectedFileCategoriesButton.addActionListener(new java.awt.event.ActionListener() {
184  public void actionPerformed(java.awt.event.ActionEvent evt) {
186  }
187  });
188 
189  pictureVideoCheckbox.setSelected(true);
190  org.openide.awt.Mnemonics.setLocalizedText(pictureVideoCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.pictureVideoCheckbox.text")); // NOI18N
191  pictureVideoCheckbox.setEnabled(false);
192  pictureVideoCheckbox.addActionListener(new java.awt.event.ActionListener() {
193  public void actionPerformed(java.awt.event.ActionEvent evt) {
195  }
196  });
197 
198  documentsCheckbox.setSelected(true);
199  org.openide.awt.Mnemonics.setLocalizedText(documentsCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.documentsCheckbox.text")); // NOI18N
200  documentsCheckbox.setEnabled(false);
201  documentsCheckbox.addActionListener(new java.awt.event.ActionListener() {
202  public void actionPerformed(java.awt.event.ActionEvent evt) {
204  }
205  });
206 
207  org.openide.awt.Mnemonics.setLocalizedText(specificCentralRepoCaseCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.specificCentralRepoCaseCheckbox.text")); // NOI18N
208  specificCentralRepoCaseCheckbox.addActionListener(new java.awt.event.ActionListener() {
209  public void actionPerformed(java.awt.event.ActionEvent evt) {
211  }
212  });
213 
214  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
215  this.setLayout(layout);
216  layout.setHorizontalGroup(
217  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
218  .addComponent(specificCentralRepoCaseCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
219  .addGroup(layout.createSequentialGroup()
220  .addComponent(correlationComboBoxLabel)
221  .addGap(0, 0, Short.MAX_VALUE))
222  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
223  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
224  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
225  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
226  .addComponent(categoriesLabel)
227  .addGroup(layout.createSequentialGroup()
228  .addGap(19, 19, 19)
229  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
230  .addComponent(allFileCategoriesRadioButton)
231  .addComponent(selectedFileCategoriesButton)
232  .addGroup(layout.createSequentialGroup()
233  .addGap(21, 21, 21)
234  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
235  .addComponent(documentsCheckbox)
236  .addComponent(pictureVideoCheckbox))))))
237  .addGap(0, 0, Short.MAX_VALUE))
238  .addGroup(layout.createSequentialGroup()
239  .addGap(21, 21, 21)
240  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
241  .addComponent(caseComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
242  .addComponent(correlationTypeComboBox, 0, 353, Short.MAX_VALUE))))
243  .addContainerGap())
244  );
245  layout.setVerticalGroup(
246  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
247  .addGroup(layout.createSequentialGroup()
248  .addContainerGap()
249  .addComponent(specificCentralRepoCaseCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
250  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
251  .addComponent(caseComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
252  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
253  .addComponent(correlationComboBoxLabel)
254  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
255  .addComponent(correlationTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
256  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
257  .addComponent(categoriesLabel)
258  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
259  .addComponent(allFileCategoriesRadioButton)
260  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
261  .addComponent(selectedFileCategoriesButton)
262  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
263  .addComponent(pictureVideoCheckbox)
264  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
265  .addComponent(documentsCheckbox)
266  .addGap(0, 0, 0))
267  );
268  }// </editor-fold>//GEN-END:initComponents
269 
270  private void allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allFileCategoriesRadioButtonActionPerformed
271  //When the allFileCategoriesRadioButton is selected disable the options
272  //related to selected file categories and notify observers that the panel has changed
273  //incase the current settings are invalid
274  pictureVideoCheckbox.setEnabled(false);
275  documentsCheckbox.setEnabled(false);
276  fileTypeFilterObservable.notifyObservers();
277  }//GEN-LAST:event_allFileCategoriesRadioButtonActionPerformed
278 
279  private void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectedFileCategoriesButtonActionPerformed
280  //When the selectedFileCategoriesButton is selected enable its related options
281  //and notify observers that the panel has changed incase the current settings are invalid
282  pictureVideoCheckbox.setEnabled(true);
283  documentsCheckbox.setEnabled(true);
284  fileTypeFilterObservable.notifyObservers();
285  }//GEN-LAST:event_selectedFileCategoriesButtonActionPerformed
286 
287  private void specificCentralRepoCaseCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_specificCentralRepoCaseCheckboxActionPerformed
288  //When the specificCentralRepoCaseCheckbox is clicked update its related options
289  this.caseComboBox.setEnabled(specificCentralRepoCaseCheckbox.isSelected());
290  if (specificCentralRepoCaseCheckbox.isSelected()) {
291  this.caseComboBox.setSelectedIndex(0);
292  }
293  }//GEN-LAST:event_specificCentralRepoCaseCheckboxActionPerformed
294 
295 
296  private void correlationTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_correlationTypeComboBoxActionPerformed
297  boolean enableFileTypesFilter = this.correlationTypeComboBox.getSelectedItem().equals("Files");
298  categoriesLabel.setEnabled(enableFileTypesFilter);
299  allFileCategoriesRadioButton.setEnabled(enableFileTypesFilter);
300  selectedFileCategoriesButton.setEnabled(enableFileTypesFilter);
301  boolean enableIndividualFilters = (enableFileTypesFilter && selectedFileCategoriesButton.isSelected());
302  pictureVideoCheckbox.setEnabled(enableIndividualFilters);
303  documentsCheckbox.setEnabled(enableIndividualFilters);
304  }//GEN-LAST:event_correlationTypeComboBoxActionPerformed
305 
306  private void pictureVideoCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pictureVideoCheckboxActionPerformed
307  //notify observers that the panel has changed incase the current settings are invalid
308  fileTypeFilterObservable.notifyObservers();
309  }//GEN-LAST:event_pictureVideoCheckboxActionPerformed
310 
311  private void documentsCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_documentsCheckboxActionPerformed
312  //notify observers that the panel has changed incase the current settings are invalid
313  fileTypeFilterObservable.notifyObservers();
314  }//GEN-LAST:event_documentsCheckboxActionPerformed
315 
316 
317  // Variables declaration - do not modify//GEN-BEGIN:variables
318  private javax.swing.JRadioButton allFileCategoriesRadioButton;
319  private javax.swing.ButtonGroup buttonGroup;
320  private javax.swing.JComboBox<String> caseComboBox;
321  private javax.swing.JLabel categoriesLabel;
322  private javax.swing.JLabel correlationComboBoxLabel;
323  private javax.swing.JComboBox<String> correlationTypeComboBox;
324  private javax.swing.JCheckBox documentsCheckbox;
325  private javax.swing.JCheckBox pictureVideoCheckbox;
326  private javax.swing.JRadioButton selectedFileCategoriesButton;
327  private javax.swing.JCheckBox specificCentralRepoCaseCheckbox;
328  // End of variables declaration//GEN-END:variables
329 
336  Map<Integer, String> getCaseMap() {
337  return Collections.unmodifiableMap(this.caseMap);
338  }
339 
346  void setCaseComboboxModel(DataSourceComboBoxModel dataSourceComboBoxModel) {
347  this.casesList = dataSourceComboBoxModel;
348  this.caseComboBox.setModel(dataSourceComboBoxModel);
349  }
350 
356  void setCaseMap(Map<Integer, String> caseMap) {
357  this.caseMap.clear();
358  this.caseMap.putAll(caseMap);
359  }
360 
367  boolean centralRepoHasMultipleCases() {
368  return this.caseMap.size() >= 2;
369  }
370 
377  Integer getSelectedCaseId() {
378  if (specificCentralRepoCaseCheckbox.isSelected()) {
379  for (Entry<Integer, String> entry : this.caseMap.entrySet()) {
380  if (entry.getValue().equals(this.caseComboBox.getSelectedItem())) {
381  return entry.getKey();
382  }
383  }
384  }
385  return InterCasePanel.NO_CASE_SELECTED;
386  }
387 
394  CorrelationAttributeInstance.Type getSelectedCorrelationType() {
395  return correlationTypeFilters.get(this.correlationTypeComboBox.getSelectedItem().toString());
396  }
397 }
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-2018 Basis Technology. Generated on: Wed Sep 18 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.