Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
IntraCasePanel.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.Map;
26 import java.util.Map.Entry;
27 import java.util.Observable;
28 import java.util.Observer;
29 import javax.swing.ComboBoxModel;
30 
37 public final class IntraCasePanel extends javax.swing.JPanel {
38 
39  private static final long serialVersionUID = 1L;
40  static final long NO_DATA_SOURCE_SELECTED = -1;
41  private final Observable fileTypeFilterObservable;
42  private ComboBoxModel<String> dataSourcesList = new DataSourceComboBoxModel();
43  private final Map<Long, String> dataSourceMap;
44 
48  public IntraCasePanel() {
50  this.dataSourceMap = new HashMap<>();
51  this.onlySpecificDataSourceCheckbox.setEnabled(true);
52  fileTypeFilterObservable = new Observable() {
53  @Override
54  public void notifyObservers() {
55  //set changed before notify observers
56  //we want this observerable to always cause the observer to update when notified
57  this.setChanged();
58  super.notifyObservers();
59  }
60  };
61  }
62 
69  void addObserver(Observer observer) {
70  fileTypeFilterObservable.addObserver(observer);
71  }
72 
79  Map<Long, String> getDataSourceMap() {
80  return Collections.unmodifiableMap(this.dataSourceMap);
81  }
82 
89  Long getSelectedDataSourceId() {
90  if (onlySpecificDataSourceCheckbox.isSelected()) {
91  for (Entry<Long, String> entry : this.dataSourceMap.entrySet()) {
92  if (entry.getValue().equals(this.selectDataSourceComboBox.getSelectedItem())) {
93  return entry.getKey();
94  }
95  }
96  }
97  return IntraCasePanel.NO_DATA_SOURCE_SELECTED;
98  }
99 
106  boolean fileCategoriesButtonIsSelected() {
107  return selectedFileCategoriesButton.isSelected();
108  }
109 
117  boolean pictureVideoCheckboxIsSelected() {
118  return pictureVideoCheckbox.isEnabled() && pictureVideoCheckbox.isSelected();
119  }
120 
128  boolean documentsCheckboxIsSelected() {
129  return documentsCheckbox.isEnabled() && documentsCheckbox.isSelected();
130  }
131 
137  @SuppressWarnings("unchecked")
138  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
139  private void initComponents() {
140 
141  buttonGroup = new javax.swing.ButtonGroup();
142  selectDataSourceComboBox = new javax.swing.JComboBox<>();
143  categoriesLabel = new javax.swing.JLabel();
144  selectedFileCategoriesButton = new javax.swing.JRadioButton();
145  pictureVideoCheckbox = new javax.swing.JCheckBox();
146  documentsCheckbox = new javax.swing.JCheckBox();
147  allFileCategoriesRadioButton = new javax.swing.JRadioButton();
148  onlySpecificDataSourceCheckbox = new javax.swing.JCheckBox();
149 
150  selectDataSourceComboBox.setModel(dataSourcesList);
151  selectDataSourceComboBox.setEnabled(false);
152 
153  org.openide.awt.Mnemonics.setLocalizedText(categoriesLabel, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.categoriesLabel.text")); // NOI18N
154  categoriesLabel.setName(""); // NOI18N
155 
157  selectedFileCategoriesButton.setSelected(true);
158  org.openide.awt.Mnemonics.setLocalizedText(selectedFileCategoriesButton, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.selectedFileCategoriesButton.text")); // NOI18N
159  selectedFileCategoriesButton.setToolTipText(org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.selectedFileCategoriesButton.toolTipText")); // NOI18N
160  selectedFileCategoriesButton.addActionListener(new java.awt.event.ActionListener() {
161  public void actionPerformed(java.awt.event.ActionEvent evt) {
163  }
164  });
165 
166  pictureVideoCheckbox.setSelected(true);
167  org.openide.awt.Mnemonics.setLocalizedText(pictureVideoCheckbox, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.pictureVideoCheckbox.text")); // NOI18N
168  pictureVideoCheckbox.addActionListener(new java.awt.event.ActionListener() {
169  public void actionPerformed(java.awt.event.ActionEvent evt) {
171  }
172  });
173 
174  documentsCheckbox.setSelected(true);
175  org.openide.awt.Mnemonics.setLocalizedText(documentsCheckbox, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.documentsCheckbox.text")); // NOI18N
176  documentsCheckbox.addActionListener(new java.awt.event.ActionListener() {
177  public void actionPerformed(java.awt.event.ActionEvent evt) {
179  }
180  });
181 
183  org.openide.awt.Mnemonics.setLocalizedText(allFileCategoriesRadioButton, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.allFileCategoriesRadioButton.text")); // NOI18N
184  allFileCategoriesRadioButton.setToolTipText(org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.allFileCategoriesRadioButton.toolTipText")); // NOI18N
185  allFileCategoriesRadioButton.addActionListener(new java.awt.event.ActionListener() {
186  public void actionPerformed(java.awt.event.ActionEvent evt) {
188  }
189  });
190 
191  org.openide.awt.Mnemonics.setLocalizedText(onlySpecificDataSourceCheckbox, org.openide.util.NbBundle.getMessage(IntraCasePanel.class, "IntraCasePanel.onlySpecificDataSourceCheckbox.text")); // NOI18N
192  onlySpecificDataSourceCheckbox.setMaximumSize(new java.awt.Dimension(243, 23));
193  onlySpecificDataSourceCheckbox.setMinimumSize(new java.awt.Dimension(243, 23));
194  onlySpecificDataSourceCheckbox.setPreferredSize(new java.awt.Dimension(243, 23));
195  onlySpecificDataSourceCheckbox.addActionListener(new java.awt.event.ActionListener() {
196  public void actionPerformed(java.awt.event.ActionEvent evt) {
198  }
199  });
200 
201  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
202  this.setLayout(layout);
203  layout.setHorizontalGroup(
204  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
205  .addGroup(layout.createSequentialGroup()
206  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
207  .addGroup(layout.createSequentialGroup()
208  .addGap(21, 21, 21)
209  .addComponent(selectDataSourceComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
210  .addGroup(layout.createSequentialGroup()
211  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
212  .addComponent(categoriesLabel)
213  .addGroup(layout.createSequentialGroup()
214  .addGap(19, 19, 19)
215  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
216  .addComponent(allFileCategoriesRadioButton)
217  .addComponent(selectedFileCategoriesButton)
218  .addGroup(layout.createSequentialGroup()
219  .addGap(21, 21, 21)
220  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
221  .addComponent(documentsCheckbox)
222  .addComponent(pictureVideoCheckbox))))))
223  .addGap(0, 0, Short.MAX_VALUE)))
224  .addContainerGap())
225  .addComponent(onlySpecificDataSourceCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE)
226  );
227  layout.setVerticalGroup(
228  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
229  .addGroup(layout.createSequentialGroup()
230  .addContainerGap()
231  .addComponent(onlySpecificDataSourceCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
232  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
233  .addComponent(selectDataSourceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
234  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
235  .addComponent(categoriesLabel)
236  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
237  .addComponent(allFileCategoriesRadioButton)
238  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
239  .addComponent(selectedFileCategoriesButton)
240  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
241  .addComponent(pictureVideoCheckbox)
242  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
243  .addComponent(documentsCheckbox)
244  .addContainerGap())
245  );
246  }// </editor-fold>//GEN-END:initComponents
247 
248  private void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectedFileCategoriesButtonActionPerformed
249  //When the selectedFileCategoriesButton is selected enable its related options
250  //and notify observers that the panel has changed incase the current settings are invalid
251  pictureVideoCheckbox.setEnabled(true);
252  documentsCheckbox.setEnabled(true);
253  fileTypeFilterObservable.notifyObservers();
254  }//GEN-LAST:event_selectedFileCategoriesButtonActionPerformed
255 
256  private void allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allFileCategoriesRadioButtonActionPerformed
257  //When the allFileCategoriesRadioButton is selected disable the options
258  //related to selected file categories and notify observers that the panel has changed
259  //incase the current settings are invalid
260  pictureVideoCheckbox.setEnabled(false);
261  documentsCheckbox.setEnabled(false);
262  fileTypeFilterObservable.notifyObservers();
263  }//GEN-LAST:event_allFileCategoriesRadioButtonActionPerformed
264 
265  private void onlySpecificDataSourceCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onlySpecificDataSourceCheckboxActionPerformed
266  //When the onlySpecificDataSourceCheckbox is clicked update its related options
268  if (selectDataSourceComboBox.isEnabled()) {
269  selectDataSourceComboBox.setSelectedIndex(0);
270  }
271  }//GEN-LAST:event_onlySpecificDataSourceCheckboxActionPerformed
272 
273  private void pictureVideoCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pictureVideoCheckboxActionPerformed
274  //notify observers that the panel has changed incase the current settings are invalid
275  fileTypeFilterObservable.notifyObservers();
276  }//GEN-LAST:event_pictureVideoCheckboxActionPerformed
277 
278  private void documentsCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_documentsCheckboxActionPerformed
279  //notify observers that the panel has changed incase the current settings are invalid
280  fileTypeFilterObservable.notifyObservers();
281  }//GEN-LAST:event_documentsCheckboxActionPerformed
282 
283  // Variables declaration - do not modify//GEN-BEGIN:variables
284  private javax.swing.JRadioButton allFileCategoriesRadioButton;
285  private javax.swing.ButtonGroup buttonGroup;
286  private javax.swing.JLabel categoriesLabel;
287  private javax.swing.JCheckBox documentsCheckbox;
288  private javax.swing.JCheckBox onlySpecificDataSourceCheckbox;
289  private javax.swing.JCheckBox pictureVideoCheckbox;
290  private javax.swing.JComboBox<String> selectDataSourceComboBox;
291  private javax.swing.JRadioButton selectedFileCategoriesButton;
292  // End of variables declaration//GEN-END:variables
293 
300  void setDatasourceComboboxModel(DataSourceComboBoxModel dataSourceComboBoxModel) {
301  this.dataSourcesList = dataSourceComboBoxModel;
302  this.selectDataSourceComboBox.setModel(dataSourcesList);
303  }
304 
311  void setDataSourceMap(Map<Long, String> dataSourceMap) {
312  this.dataSourceMap.clear();
313  this.dataSourceMap.putAll(dataSourceMap);
314  }
315 }
void pictureVideoCheckboxActionPerformed(java.awt.event.ActionEvent evt)
void onlySpecificDataSourceCheckboxActionPerformed(java.awt.event.ActionEvent evt)
void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt)
void documentsCheckboxActionPerformed(java.awt.event.ActionEvent evt)
void allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt)

Copyright © 2012-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.