Autopsy  4.11.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 javax.swing.ComboBoxModel;
31 import org.openide.util.Exceptions;
34 
39 public final class InterCasePanel extends javax.swing.JPanel {
40 
41  private static final long serialVersionUID = 1L;
42  private final Observable fileTypeFilterObservable;
43  static final int NO_CASE_SELECTED = -1;
44 
45  private ComboBoxModel<String> casesList = new DataSourceComboBoxModel();
46 
47  private final Map<Integer, String> caseMap;
48 
50 
54  public InterCasePanel() {
56  this.caseMap = new HashMap<>();
57  fileTypeFilterObservable = new Observable() {
58  @Override
59  public void notifyObservers() {
60  //set changed before notify observers
61  //we want this observerable to always cause the observer to update when notified
62  this.setChanged();
63  super.notifyObservers();
64  }
65  };
66  }
67 
74  void addObserver(Observer observer) {
75  fileTypeFilterObservable.addObserver(observer);
76  }
77 
85  boolean fileCategoriesButtonIsSelected() {
86  return selectedFileCategoriesButton.isEnabled() && selectedFileCategoriesButton.isSelected();
87  }
88 
96  boolean pictureVideoCheckboxIsSelected() {
97  return pictureVideoCheckbox.isEnabled() && pictureVideoCheckbox.isSelected();
98  }
99 
107  boolean documentsCheckboxIsSelected() {
108  return documentsCheckbox.isEnabled() && documentsCheckbox.isSelected();
109  }
110 
115  void setupCorrelationTypeFilter() {
116  this.correlationTypeFilters = new HashMap<>();
117  try {
118  List<CorrelationAttributeInstance.Type> types = CorrelationAttributeInstance.getDefaultCorrelationTypes();
119  for (CorrelationAttributeInstance.Type type : types) {
120  correlationTypeFilters.put(type.getDisplayName(), type);
121  this.correlationTypeComboBox.addItem(type.getDisplayName());
122  }
123  } catch (EamDbException ex) {
124  Exceptions.printStackTrace(ex);
125  }
126  this.correlationTypeComboBox.setSelectedIndex(0);
127  }
128 
134  @SuppressWarnings("unchecked")
135  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
136  private void initComponents() {
137 
138  buttonGroup = new javax.swing.ButtonGroup();
139  caseComboBox = new javax.swing.JComboBox<>();
140  correlationComboBoxLabel = new javax.swing.JLabel();
141  correlationTypeComboBox = new javax.swing.JComboBox<>();
142  categoriesLabel = new javax.swing.JLabel();
143  allFileCategoriesRadioButton = new javax.swing.JRadioButton();
144  selectedFileCategoriesButton = new javax.swing.JRadioButton();
145  pictureVideoCheckbox = new javax.swing.JCheckBox();
146  documentsCheckbox = new javax.swing.JCheckBox();
147  specificCentralRepoCaseCheckbox = new javax.swing.JCheckBox();
148 
149  caseComboBox.setModel(casesList);
150  caseComboBox.setEnabled(false);
151 
152  org.openide.awt.Mnemonics.setLocalizedText(correlationComboBoxLabel, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.correlationComboBoxLabel.text")); // NOI18N
153 
154  correlationTypeComboBox.setSelectedItem(null);
155  correlationTypeComboBox.setToolTipText(org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.correlationTypeComboBox.toolTipText")); // NOI18N
156  correlationTypeComboBox.addActionListener(new java.awt.event.ActionListener() {
157  public void actionPerformed(java.awt.event.ActionEvent evt) {
159  }
160  });
161 
162  org.openide.awt.Mnemonics.setLocalizedText(categoriesLabel, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.categoriesLabel.text")); // NOI18N
163  categoriesLabel.setEnabled(false);
164  categoriesLabel.setName(""); // NOI18N
165 
167  org.openide.awt.Mnemonics.setLocalizedText(allFileCategoriesRadioButton, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.allFileCategoriesRadioButton.text")); // NOI18N
168  allFileCategoriesRadioButton.setToolTipText(org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.allFileCategoriesRadioButton.toolTipText")); // NOI18N
169  allFileCategoriesRadioButton.setEnabled(false);
170  allFileCategoriesRadioButton.addActionListener(new java.awt.event.ActionListener() {
171  public void actionPerformed(java.awt.event.ActionEvent evt) {
173  }
174  });
175 
177  selectedFileCategoriesButton.setSelected(true);
178  org.openide.awt.Mnemonics.setLocalizedText(selectedFileCategoriesButton, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.selectedFileCategoriesButton.text")); // NOI18N
179  selectedFileCategoriesButton.setToolTipText(org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.selectedFileCategoriesButton.toolTipText")); // NOI18N
180  selectedFileCategoriesButton.setEnabled(false);
181  selectedFileCategoriesButton.addActionListener(new java.awt.event.ActionListener() {
182  public void actionPerformed(java.awt.event.ActionEvent evt) {
184  }
185  });
186 
187  pictureVideoCheckbox.setSelected(true);
188  org.openide.awt.Mnemonics.setLocalizedText(pictureVideoCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.pictureVideoCheckbox.text")); // NOI18N
189  pictureVideoCheckbox.setEnabled(false);
190  pictureVideoCheckbox.addActionListener(new java.awt.event.ActionListener() {
191  public void actionPerformed(java.awt.event.ActionEvent evt) {
193  }
194  });
195 
196  documentsCheckbox.setSelected(true);
197  org.openide.awt.Mnemonics.setLocalizedText(documentsCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.documentsCheckbox.text")); // NOI18N
198  documentsCheckbox.setEnabled(false);
199  documentsCheckbox.addActionListener(new java.awt.event.ActionListener() {
200  public void actionPerformed(java.awt.event.ActionEvent evt) {
202  }
203  });
204 
205  org.openide.awt.Mnemonics.setLocalizedText(specificCentralRepoCaseCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.specificCentralRepoCaseCheckbox.text")); // NOI18N
206  specificCentralRepoCaseCheckbox.addActionListener(new java.awt.event.ActionListener() {
207  public void actionPerformed(java.awt.event.ActionEvent evt) {
209  }
210  });
211 
212  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
213  this.setLayout(layout);
214  layout.setHorizontalGroup(
215  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
216  .addComponent(specificCentralRepoCaseCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
217  .addGroup(layout.createSequentialGroup()
218  .addComponent(correlationComboBoxLabel)
219  .addGap(0, 0, Short.MAX_VALUE))
220  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
221  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
222  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
223  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
224  .addComponent(categoriesLabel)
225  .addGroup(layout.createSequentialGroup()
226  .addGap(19, 19, 19)
227  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
228  .addComponent(allFileCategoriesRadioButton)
229  .addComponent(selectedFileCategoriesButton)
230  .addGroup(layout.createSequentialGroup()
231  .addGap(21, 21, 21)
232  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
233  .addComponent(documentsCheckbox)
234  .addComponent(pictureVideoCheckbox))))))
235  .addGap(0, 0, Short.MAX_VALUE))
236  .addGroup(layout.createSequentialGroup()
237  .addGap(21, 21, 21)
238  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
239  .addComponent(caseComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
240  .addComponent(correlationTypeComboBox, 0, 353, Short.MAX_VALUE))))
241  .addContainerGap())
242  );
243  layout.setVerticalGroup(
244  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
245  .addGroup(layout.createSequentialGroup()
246  .addContainerGap()
247  .addComponent(specificCentralRepoCaseCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
248  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
249  .addComponent(caseComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
250  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
251  .addComponent(correlationComboBoxLabel)
252  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
253  .addComponent(correlationTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
254  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
255  .addComponent(categoriesLabel)
256  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
257  .addComponent(allFileCategoriesRadioButton)
258  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
259  .addComponent(selectedFileCategoriesButton)
260  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
261  .addComponent(pictureVideoCheckbox)
262  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
263  .addComponent(documentsCheckbox)
264  .addGap(0, 0, 0))
265  );
266  }// </editor-fold>//GEN-END:initComponents
267 
268  private void allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allFileCategoriesRadioButtonActionPerformed
269  //When the allFileCategoriesRadioButton is selected disable the options
270  //related to selected file categories and notify observers that the panel has changed
271  //incase the current settings are invalid
272  pictureVideoCheckbox.setEnabled(false);
273  documentsCheckbox.setEnabled(false);
274  fileTypeFilterObservable.notifyObservers();
275  }//GEN-LAST:event_allFileCategoriesRadioButtonActionPerformed
276 
277  private void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectedFileCategoriesButtonActionPerformed
278  //When the selectedFileCategoriesButton is selected enable its related options
279  //and notify observers that the panel has changed incase the current settings are invalid
280  pictureVideoCheckbox.setEnabled(true);
281  documentsCheckbox.setEnabled(true);
282  fileTypeFilterObservable.notifyObservers();
283  }//GEN-LAST:event_selectedFileCategoriesButtonActionPerformed
284 
285  private void specificCentralRepoCaseCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_specificCentralRepoCaseCheckboxActionPerformed
286  //When the specificCentralRepoCaseCheckbox is clicked update its related options
287  this.caseComboBox.setEnabled(specificCentralRepoCaseCheckbox.isSelected());
288  if (specificCentralRepoCaseCheckbox.isSelected()) {
289  this.caseComboBox.setSelectedIndex(0);
290  }
291  }//GEN-LAST:event_specificCentralRepoCaseCheckboxActionPerformed
292 
293 
294  private void correlationTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_correlationTypeComboBoxActionPerformed
295  boolean enableFileTypesFilter = this.correlationTypeComboBox.getSelectedItem().equals("Files");
296  categoriesLabel.setEnabled(enableFileTypesFilter);
297  allFileCategoriesRadioButton.setEnabled(enableFileTypesFilter);
298  selectedFileCategoriesButton.setEnabled(enableFileTypesFilter);
299  boolean enableIndividualFilters = (enableFileTypesFilter && selectedFileCategoriesButton.isSelected());
300  pictureVideoCheckbox.setEnabled(enableIndividualFilters);
301  documentsCheckbox.setEnabled(enableIndividualFilters);
302  }//GEN-LAST:event_correlationTypeComboBoxActionPerformed
303 
304  private void pictureVideoCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pictureVideoCheckboxActionPerformed
305  //notify observers that the panel has changed incase the current settings are invalid
306  fileTypeFilterObservable.notifyObservers();
307  }//GEN-LAST:event_pictureVideoCheckboxActionPerformed
308 
309  private void documentsCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_documentsCheckboxActionPerformed
310  //notify observers that the panel has changed incase the current settings are invalid
311  fileTypeFilterObservable.notifyObservers();
312  }//GEN-LAST:event_documentsCheckboxActionPerformed
313 
314 
315  // Variables declaration - do not modify//GEN-BEGIN:variables
316  private javax.swing.JRadioButton allFileCategoriesRadioButton;
317  private javax.swing.ButtonGroup buttonGroup;
318  private javax.swing.JComboBox<String> caseComboBox;
319  private javax.swing.JLabel categoriesLabel;
320  private javax.swing.JLabel correlationComboBoxLabel;
321  private javax.swing.JComboBox<String> correlationTypeComboBox;
322  private javax.swing.JCheckBox documentsCheckbox;
323  private javax.swing.JCheckBox pictureVideoCheckbox;
324  private javax.swing.JRadioButton selectedFileCategoriesButton;
325  private javax.swing.JCheckBox specificCentralRepoCaseCheckbox;
326  // End of variables declaration//GEN-END:variables
327 
334  Map<Integer, String> getCaseMap() {
335  return Collections.unmodifiableMap(this.caseMap);
336  }
337 
344  void setCaseComboboxModel(DataSourceComboBoxModel dataSourceComboBoxModel) {
345  this.casesList = dataSourceComboBoxModel;
346  this.caseComboBox.setModel(dataSourceComboBoxModel);
347  }
348 
354  void setCaseMap(Map<Integer, String> caseMap) {
355  this.caseMap.clear();
356  this.caseMap.putAll(caseMap);
357  }
358 
365  boolean centralRepoHasMultipleCases() {
366  return this.caseMap.size() >= 2;
367  }
368 
375  Integer getSelectedCaseId() {
376  if (specificCentralRepoCaseCheckbox.isSelected()) {
377  for (Entry<Integer, String> entry : this.caseMap.entrySet()) {
378  if (entry.getValue().equals(this.caseComboBox.getSelectedItem())) {
379  return entry.getKey();
380  }
381  }
382  }
383  return InterCasePanel.NO_CASE_SELECTED;
384  }
385 
392  CorrelationAttributeInstance.Type getSelectedCorrelationType() {
393  return correlationTypeFilters.get(this.correlationTypeComboBox.getSelectedItem().toString());
394  }
395 }
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)

Copyright © 2012-2018 Basis Technology. Generated on: Fri Jun 21 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.