Autopsy  4.8.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 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.List;
25 import java.util.Map;
26 import java.util.Map.Entry;
27 import java.util.Observable;
28 import java.util.Observer;
29 import javax.swing.ComboBoxModel;
30 import org.openide.util.Exceptions;
33 
38 public final class InterCasePanel extends javax.swing.JPanel {
39 
40  private static final long serialVersionUID = 1L;
41  private final Observable fileTypeFilterObservable;
42  static final int NO_CASE_SELECTED = -1;
43 
44  private ComboBoxModel<String> casesList = new DataSourceComboBoxModel();
45 
46  private final Map<Integer, String> caseMap;
47 
49 
53  public InterCasePanel() {
55  this.caseMap = new HashMap<>();
56  fileTypeFilterObservable = new Observable() {
57  @Override
58  public void notifyObservers() {
59  //set changed before notify observers
60  //we want this observerable to always cause the observer to update when notified
61  this.setChanged();
62  super.notifyObservers();
63  }
64  };
65  }
66 
73  void addObserver(Observer observer) {
74  fileTypeFilterObservable.addObserver(observer);
75  }
76 
84  boolean fileCategoriesButtonIsSelected() {
85  return selectedFileCategoriesButton.isEnabled() && selectedFileCategoriesButton.isSelected();
86  }
87 
95  boolean pictureVideoCheckboxIsSelected() {
96  return pictureVideoCheckbox.isEnabled() && pictureVideoCheckbox.isSelected();
97  }
98 
106  boolean documentsCheckboxIsSelected() {
107  return documentsCheckbox.isEnabled() && documentsCheckbox.isSelected();
108  }
109 
114  void setupCorrelationTypeFilter() {
115  this.correlationTypeFilters = new HashMap<>();
116  try {
117  List<CorrelationAttributeInstance.Type> types = CorrelationAttributeInstance.getDefaultCorrelationTypes();
118  for (CorrelationAttributeInstance.Type type : types) {
119  correlationTypeFilters.put(type.getDisplayName(), type);
120  this.correlationTypeComboBox.addItem(type.getDisplayName());
121  }
122  } catch (EamDbException ex) {
123  Exceptions.printStackTrace(ex);
124  }
125  this.correlationTypeComboBox.setSelectedIndex(0);
126  }
127 
133  @SuppressWarnings("unchecked")
134  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
135  private void initComponents() {
136 
137  buttonGroup = new javax.swing.ButtonGroup();
138  caseComboBox = new javax.swing.JComboBox<>();
139  correlationComboBoxLabel = new javax.swing.JLabel();
140  correlationTypeComboBox = new javax.swing.JComboBox<>();
141  categoriesLabel = new javax.swing.JLabel();
142  allFileCategoriesRadioButton = new javax.swing.JRadioButton();
143  selectedFileCategoriesButton = new javax.swing.JRadioButton();
144  pictureVideoCheckbox = new javax.swing.JCheckBox();
145  documentsCheckbox = new javax.swing.JCheckBox();
146  specificCentralRepoCaseCheckbox = new javax.swing.JCheckBox();
147 
148  caseComboBox.setModel(casesList);
149  caseComboBox.setEnabled(false);
150 
151  org.openide.awt.Mnemonics.setLocalizedText(correlationComboBoxLabel, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.correlationComboBoxLabel.text")); // NOI18N
152 
153  correlationTypeComboBox.setSelectedItem(null);
154  correlationTypeComboBox.setToolTipText(org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.correlationTypeComboBox.toolTipText")); // NOI18N
155  correlationTypeComboBox.addActionListener(new java.awt.event.ActionListener() {
156  public void actionPerformed(java.awt.event.ActionEvent evt) {
158  }
159  });
160 
161  org.openide.awt.Mnemonics.setLocalizedText(categoriesLabel, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.categoriesLabel.text")); // NOI18N
162  categoriesLabel.setEnabled(false);
163  categoriesLabel.setName(""); // NOI18N
164 
166  allFileCategoriesRadioButton.setSelected(true);
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  org.openide.awt.Mnemonics.setLocalizedText(selectedFileCategoriesButton, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.selectedFileCategoriesButton.text")); // NOI18N
178  selectedFileCategoriesButton.setToolTipText(org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.selectedFileCategoriesButton.toolTipText")); // NOI18N
179  selectedFileCategoriesButton.setEnabled(false);
180  selectedFileCategoriesButton.addActionListener(new java.awt.event.ActionListener() {
181  public void actionPerformed(java.awt.event.ActionEvent evt) {
183  }
184  });
185 
186  pictureVideoCheckbox.setSelected(true);
187  org.openide.awt.Mnemonics.setLocalizedText(pictureVideoCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.pictureVideoCheckbox.text")); // NOI18N
188  pictureVideoCheckbox.setEnabled(false);
189  pictureVideoCheckbox.addActionListener(new java.awt.event.ActionListener() {
190  public void actionPerformed(java.awt.event.ActionEvent evt) {
192  }
193  });
194 
195  documentsCheckbox.setSelected(true);
196  org.openide.awt.Mnemonics.setLocalizedText(documentsCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.documentsCheckbox.text")); // NOI18N
197  documentsCheckbox.setEnabled(false);
198  documentsCheckbox.addActionListener(new java.awt.event.ActionListener() {
199  public void actionPerformed(java.awt.event.ActionEvent evt) {
201  }
202  });
203 
204  org.openide.awt.Mnemonics.setLocalizedText(specificCentralRepoCaseCheckbox, org.openide.util.NbBundle.getMessage(InterCasePanel.class, "InterCasePanel.specificCentralRepoCaseCheckbox.text")); // NOI18N
205  specificCentralRepoCaseCheckbox.addActionListener(new java.awt.event.ActionListener() {
206  public void actionPerformed(java.awt.event.ActionEvent evt) {
208  }
209  });
210 
211  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
212  this.setLayout(layout);
213  layout.setHorizontalGroup(
214  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
215  .addComponent(specificCentralRepoCaseCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
216  .addGroup(layout.createSequentialGroup()
217  .addComponent(correlationComboBoxLabel)
218  .addGap(0, 0, Short.MAX_VALUE))
219  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
220  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
221  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
222  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
223  .addComponent(categoriesLabel)
224  .addGroup(layout.createSequentialGroup()
225  .addGap(19, 19, 19)
226  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
227  .addComponent(allFileCategoriesRadioButton)
228  .addComponent(selectedFileCategoriesButton)
229  .addGroup(layout.createSequentialGroup()
230  .addGap(21, 21, 21)
231  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
232  .addComponent(documentsCheckbox)
233  .addComponent(pictureVideoCheckbox))))))
234  .addGap(0, 0, Short.MAX_VALUE))
235  .addGroup(layout.createSequentialGroup()
236  .addGap(21, 21, 21)
237  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
238  .addComponent(caseComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
239  .addComponent(correlationTypeComboBox, 0, 353, Short.MAX_VALUE))))
240  .addContainerGap())
241  );
242  layout.setVerticalGroup(
243  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
244  .addGroup(layout.createSequentialGroup()
245  .addContainerGap()
246  .addComponent(specificCentralRepoCaseCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
247  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
248  .addComponent(caseComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
249  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
250  .addComponent(correlationComboBoxLabel)
251  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
252  .addComponent(correlationTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
253  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
254  .addComponent(categoriesLabel)
255  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
256  .addComponent(allFileCategoriesRadioButton)
257  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
258  .addComponent(selectedFileCategoriesButton)
259  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
260  .addComponent(pictureVideoCheckbox)
261  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
262  .addComponent(documentsCheckbox)
263  .addGap(0, 0, 0))
264  );
265  }// </editor-fold>//GEN-END:initComponents
266 
267  private void allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allFileCategoriesRadioButtonActionPerformed
268  //When the allFileCategoriesRadioButton is selected disable the options
269  //related to selected file categories and notify observers that the panel has changed
270  //incase the current settings are invalid
271  pictureVideoCheckbox.setEnabled(false);
272  documentsCheckbox.setEnabled(false);
273  fileTypeFilterObservable.notifyObservers();
274  }//GEN-LAST:event_allFileCategoriesRadioButtonActionPerformed
275 
276  private void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectedFileCategoriesButtonActionPerformed
277  //When the selectedFileCategoriesButton is selected enable its related options
278  //and notify observers that the panel has changed incase the current settings are invalid
279  pictureVideoCheckbox.setEnabled(true);
280  documentsCheckbox.setEnabled(true);
281  fileTypeFilterObservable.notifyObservers();
282  }//GEN-LAST:event_selectedFileCategoriesButtonActionPerformed
283 
284  private void specificCentralRepoCaseCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_specificCentralRepoCaseCheckboxActionPerformed
285  //When the specificCentralRepoCaseCheckbox is clicked update its related options
286  this.caseComboBox.setEnabled(specificCentralRepoCaseCheckbox.isSelected());
287  if (specificCentralRepoCaseCheckbox.isSelected()) {
288  this.caseComboBox.setSelectedIndex(0);
289  }
290  }//GEN-LAST:event_specificCentralRepoCaseCheckboxActionPerformed
291 
292 
293  private void correlationTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_correlationTypeComboBoxActionPerformed
294  //we do not currenlty have mime type in the central repository so this section will always be disabled
295  boolean enableFileTypesFilter = false; //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 allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt)
void documentsCheckboxActionPerformed(java.awt.event.ActionEvent evt)
void correlationTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JComboBox< String > correlationTypeComboBox
void pictureVideoCheckboxActionPerformed(java.awt.event.ActionEvent evt)
void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt)
Map< String, CorrelationAttributeInstance.Type > correlationTypeFilters
void specificCentralRepoCaseCheckboxActionPerformed(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.