Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
DiscoveryDialog.java
Go to the documentation of this file.
1 /*
2  * Autopsy
3  *
4  * Copyright 2020-2021 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.discovery.ui;
20 
22 import static java.awt.BorderLayout.CENTER;
23 import java.awt.Color;
24 import java.awt.event.ItemEvent;
25 import java.awt.event.ItemListener;
26 import java.beans.PropertyChangeEvent;
27 import java.beans.PropertyChangeListener;
28 import java.util.ArrayList;
29 import java.util.EnumSet;
30 import java.util.HashSet;
31 import java.util.List;
32 import java.util.Set;
33 import java.util.logging.Level;
34 import org.apache.commons.lang.StringUtils;
35 import org.openide.util.NbBundle.Messages;
36 import org.openide.windows.WindowManager;
53 import org.sleuthkit.datamodel.BlackboardArtifact;
54 import org.sleuthkit.datamodel.BlackboardAttribute;
55 import org.sleuthkit.datamodel.TskCoreException;
56 
61 final class DiscoveryDialog extends javax.swing.JDialog {
62 
63  private static final Set<Case.Events> CASE_EVENTS_OF_INTEREST = EnumSet.of(Case.Events.CURRENT_CASE,
64  Case.Events.DATA_SOURCE_ADDED, Case.Events.DATA_SOURCE_DELETED);
65  private static final Set<IngestManager.IngestModuleEvent> INGEST_MODULE_EVENTS_OF_INTEREST = EnumSet.of(IngestManager.IngestModuleEvent.DATA_ADDED);
66  private static final long serialVersionUID = 1L;
67  private final static Logger logger = Logger.getLogger(DiscoveryDialog.class.getName());
68  private ImageFilterPanel imageFilterPanel = null;
69  private VideoFilterPanel videoFilterPanel = null;
70  private DocumentFilterPanel documentFilterPanel = null;
71  private DomainFilterPanel domainFilterPanel = null;
72  private static final Color SELECTED_COLOR = new Color(216, 230, 242);
73  private static final Color UNSELECTED_COLOR = new Color(240, 240, 240);
74  private SearchWorker searchWorker = null;
75  private static DiscoveryDialog discDialog;
76  private static volatile boolean shouldUpdate = false;
77  private SearchData.Type type = SearchData.Type.IMAGE;
78  private final PropertyChangeListener listener;
79  private final Set<BlackboardAttribute> objectsDetected = new HashSet<>();
80  private final Set<BlackboardAttribute> interestingItems = new HashSet<>();
81  private final Set<BlackboardAttribute> hashSets = new HashSet<>();
82 
88  static synchronized DiscoveryDialog getDiscoveryDialogInstance() {
89  if (discDialog == null) {
90  discDialog = new DiscoveryDialog();
91  }
92  if (shouldUpdate) {
93  discDialog.updateSearchSettings();
94  shouldUpdate = false;
95  }
96  return discDialog;
97  }
98 
102  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
103  @Messages("DiscoveryDialog.name.text=Discovery")
104  private DiscoveryDialog() {
105  super(WindowManager.getDefault().getMainWindow(), Bundle.DiscoveryDialog_name_text(), true);
106  initComponents();
107  listener = new PropertyChangeListener() {
108  @Override
109  public void propertyChange(PropertyChangeEvent evt) {
110  if (evt.getPropertyName().equals("FilterError") && evt.getNewValue() != null) {
111  setValid(evt.getNewValue().toString());
112  }
113  }
114  };
115  updateSearchSettings();
116  groupByCombobox.addItemListener(new ItemListener() {
117  @Override
118  public void itemStateChanged(ItemEvent event) {
119  if (event.getStateChange() == ItemEvent.SELECTED) {
120  getSelectedFilterPanel().setLastGroupingAttributeType(groupByCombobox.getItemAt(groupByCombobox.getSelectedIndex()));
121  }
122  }
123  });
124  orderByCombobox.addItemListener(new ItemListener() {
125  @Override
126  public void itemStateChanged(ItemEvent event) {
127  if (event.getStateChange() == ItemEvent.SELECTED) {
128  getSelectedFilterPanel().setLastSortingMethod(orderByCombobox.getItemAt(orderByCombobox.getSelectedIndex()));
129  }
130  }
131  });
132  groupSortingComboBox.addItemListener(new ItemListener() {
133  @Override
134  public void itemStateChanged(ItemEvent event) {
135  if (event.getStateChange() == ItemEvent.SELECTED) {
136  getSelectedFilterPanel().setLastGroupSortingAlg(groupSortingComboBox.getItemAt(groupSortingComboBox.getSelectedIndex()));
137  }
138  }
139  });
140  Case.addEventTypeSubscriber(CASE_EVENTS_OF_INTEREST, this.new CasePropertyChangeListener());
141  IngestManager.getInstance().addIngestModuleEventListener(INGEST_MODULE_EVENTS_OF_INTEREST, this.new ModuleChangeListener());
142  setPreferredSize(new java.awt.Dimension(1000, 800));
143  }
144 
148  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
149  void updateSearchSettings() {
150  removeAllPanels();
151  imageFilterPanel = null;
152  videoFilterPanel = null;
153  documentFilterPanel = null;
154  imageFilterPanel = new ImageFilterPanel();
155  videoFilterPanel = new VideoFilterPanel();
156  documentFilterPanel = new DocumentFilterPanel();
157  domainFilterPanel = new DomainFilterPanel();
158  unselectAllButtons();
159  imagesButton.setSelected(true);
160  imagesButton.setEnabled(false);
161  imagesButton.setBackground(SELECTED_COLOR);
162  imagesButton.setForeground(Color.BLACK);
163  type = SearchData.Type.IMAGE;
164  add(imageFilterPanel, CENTER);
165  imageFilterPanel.addPropertyChangeListener(listener);
166  updateComboBoxes();
167  pack();
168  repaint();
169  }
170 
174  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
175  private void unselectAllButtons() {
176  imagesButton.setSelected(false);
177  imagesButton.setEnabled(true);
178  imagesButton.setBackground(UNSELECTED_COLOR);
179  videosButton.setSelected(false);
180  videosButton.setEnabled(true);
181  videosButton.setBackground(UNSELECTED_COLOR);
182  documentsButton.setSelected(false);
183  documentsButton.setEnabled(true);
184  documentsButton.setBackground(UNSELECTED_COLOR);
185  domainsButton.setSelected(false);
186  domainsButton.setEnabled(true);
187  domainsButton.setBackground(UNSELECTED_COLOR);
188  }
189 
193  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
194  private void updateComboBoxes() {
195  // Set up the grouping attributes
196  List<GroupingAttributeType> groupingAttrs = new ArrayList<>();
197  List<SortingMethod> sortingMethods = new ArrayList<>();
198  groupByCombobox.removeAllItems();
199  if (type == SearchData.Type.DOMAIN) {
200  groupingAttrs.addAll(GroupingAttributeType.getOptionsForGroupingForDomains());
201  sortingMethods.addAll(SortingMethod.getOptionsForOrderingDomains());
202  } else {
203  groupingAttrs.addAll(GroupingAttributeType.getOptionsForGroupingForFiles());
204  sortingMethods.addAll(SortingMethod.getOptionsForOrderingFiles());
205  }
206  for (GroupingAttributeType groupingType : groupingAttrs) {
207  addTypeToGroupByComboBox(groupingType);
208  }
209  groupByCombobox.setSelectedItem(getSelectedFilterPanel().getLastGroupingAttributeType());
210  orderByCombobox.removeAllItems();
211  // Set up the file order list
212  for (SortingMethod method : sortingMethods) {
213  if (method != SortingMethod.BY_FREQUENCY || CentralRepository.isEnabled()) {
214  orderByCombobox.addItem(method);
215  }
216  }
217  orderByCombobox.setSelectedItem(getSelectedFilterPanel().getLastSortingMethod());
218  groupSortingComboBox.removeAllItems();
219  for (GroupSortingAlgorithm groupSortAlgorithm : GroupSortingAlgorithm.values()) {
220  groupSortingComboBox.addItem(groupSortAlgorithm);
221  }
222  groupSortingComboBox.setSelectedItem(getSelectedFilterPanel().getLastGroupSortingAlg());
223  }
224 
230  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
231  private AbstractFiltersPanel getSelectedFilterPanel() {
232  switch (type) {
233  case IMAGE:
234  return imageFilterPanel;
235  case VIDEO:
236  return videoFilterPanel;
237  case DOCUMENT:
238  return documentFilterPanel;
239  case DOMAIN:
240  return domainFilterPanel;
241  default:
242  return imageFilterPanel;
243  }
244  }
245 
252  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
253  private void addTypeToGroupByComboBox(GroupingAttributeType type) {
254  switch (type) {
255  case FREQUENCY:
256  if (!CentralRepository.isEnabled()) {
257  return;
258  }
259  break;
260  case OBJECT_DETECTED:
261  if (!imageFilterPanel.isObjectsFilterSupported()) {
262  return;
263  }
264  break;
265  case INTERESTING_ITEM_SET:
266  if (!imageFilterPanel.isInterestingItemsFilterSupported()) {
267  return;
268  }
269  break;
270  case HASH_LIST_NAME:
271  if (!imageFilterPanel.isHashSetFilterSupported()) {
272  return;
273  }
274  break;
275  default:
276  break;
277  }
278  groupByCombobox.addItem(type);
279  }
280 
284  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
285  void validateDialog() {
286  AbstractFiltersPanel panel = getSelectedFilterPanel();
287  if (panel != null) {
288  panel.validateFields();
289  }
290  }
291 
297  @SuppressWarnings("unchecked")
298  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
299  private void initComponents() {
300 
301  javax.swing.JPanel toolBarPanel = new javax.swing.JPanel();
302  imagesButton = new javax.swing.JButton();
303  videosButton = new javax.swing.JButton();
304  documentsButton = new javax.swing.JButton();
305  javax.swing.JLabel step1Label = new javax.swing.JLabel();
306  javax.swing.Box.Filler filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(104, 0), new java.awt.Dimension(104, 0), new java.awt.Dimension(104, 32767));
307  domainsButton = new javax.swing.JButton();
308  javax.swing.JPanel displaySettingsPanel = new javax.swing.JPanel();
309  searchButton = new javax.swing.JButton();
310  errorLabel = new javax.swing.JLabel();
311  javax.swing.JPanel sortingPanel = new javax.swing.JPanel();
312  groupByCombobox = new javax.swing.JComboBox<>();
313  orderByCombobox = new javax.swing.JComboBox<>();
314  javax.swing.JLabel orderGroupsByLabel = new javax.swing.JLabel();
315  javax.swing.JLabel orderByLabel = new javax.swing.JLabel();
316  javax.swing.JLabel groupByLabel = new javax.swing.JLabel();
317  groupSortingComboBox = new javax.swing.JComboBox<>();
318 
319  setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
320  setMinimumSize(new java.awt.Dimension(600, 300));
321  setPreferredSize(new java.awt.Dimension(1000, 800));
322 
323  imagesButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/pictures-icon.png"))); // NOI18N
324  org.openide.awt.Mnemonics.setLocalizedText(imagesButton, org.openide.util.NbBundle.getMessage(DiscoveryDialog.class, "DiscoveryDialog.imagesButton.text")); // NOI18N
325  imagesButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/pictures-icon.png"))); // NOI18N
326  imagesButton.setFocusable(false);
327  imagesButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
328  imagesButton.setMaximumSize(new java.awt.Dimension(90, 43));
329  imagesButton.setMinimumSize(new java.awt.Dimension(90, 43));
330  imagesButton.setPreferredSize(new java.awt.Dimension(90, 43));
331  imagesButton.addActionListener(new java.awt.event.ActionListener() {
332  public void actionPerformed(java.awt.event.ActionEvent evt) {
333  imagesButtonActionPerformed(evt);
334  }
335  });
336 
337  videosButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/video-icon.png"))); // NOI18N
338  org.openide.awt.Mnemonics.setLocalizedText(videosButton, org.openide.util.NbBundle.getMessage(DiscoveryDialog.class, "DiscoveryDialog.videosButton.text")); // NOI18N
339  videosButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/video-icon.png"))); // NOI18N
340  videosButton.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/video-icon.png"))); // NOI18N
341  videosButton.setFocusable(false);
342  videosButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
343  videosButton.setMaximumSize(new java.awt.Dimension(90, 43));
344  videosButton.setMinimumSize(new java.awt.Dimension(90, 43));
345  videosButton.setPreferredSize(new java.awt.Dimension(90, 43));
346  videosButton.addActionListener(new java.awt.event.ActionListener() {
347  public void actionPerformed(java.awt.event.ActionEvent evt) {
348  videosButtonActionPerformed(evt);
349  }
350  });
351 
352  documentsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/documents-icon.png"))); // NOI18N
353  org.openide.awt.Mnemonics.setLocalizedText(documentsButton, org.openide.util.NbBundle.getMessage(DiscoveryDialog.class, "DiscoveryDialog.documentsButton.text")); // NOI18N
354  documentsButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/documents-icon.png"))); // NOI18N
355  documentsButton.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/documents-icon.png"))); // NOI18N
356  documentsButton.setFocusable(false);
357  documentsButton.addActionListener(new java.awt.event.ActionListener() {
358  public void actionPerformed(java.awt.event.ActionEvent evt) {
359  documentsButtonActionPerformed(evt);
360  }
361  });
362 
363  org.openide.awt.Mnemonics.setLocalizedText(step1Label, org.openide.util.NbBundle.getMessage(DiscoveryDialog.class, "DiscoveryDialog.step1Label.text")); // NOI18N
364 
365  domainsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/domain-32.png"))); // NOI18N
366  org.openide.awt.Mnemonics.setLocalizedText(domainsButton, org.openide.util.NbBundle.getMessage(DiscoveryDialog.class, "DiscoveryDialog.domainsButton.text")); // NOI18N
367  domainsButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/domain-32.png"))); // NOI18N
368  domainsButton.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/domain-32.png"))); // NOI18N
369  domainsButton.setFocusable(false);
370  domainsButton.addActionListener(new java.awt.event.ActionListener() {
371  public void actionPerformed(java.awt.event.ActionEvent evt) {
372  domainsButtonActionPerformed(evt);
373  }
374  });
375 
376  javax.swing.GroupLayout toolBarPanelLayout = new javax.swing.GroupLayout(toolBarPanel);
377  toolBarPanel.setLayout(toolBarPanelLayout);
378  toolBarPanelLayout.setHorizontalGroup(
379  toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
380  .addGroup(toolBarPanelLayout.createSequentialGroup()
381  .addContainerGap()
382  .addGroup(toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
383  .addGroup(toolBarPanelLayout.createSequentialGroup()
384  .addGap(10, 10, 10)
385  .addComponent(imagesButton, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
386  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
387  .addComponent(videosButton, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
388  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
389  .addComponent(documentsButton)
390  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
391  .addComponent(domainsButton)
392  .addContainerGap(190, Short.MAX_VALUE))
393  .addGroup(toolBarPanelLayout.createSequentialGroup()
394  .addComponent(step1Label, javax.swing.GroupLayout.PREFERRED_SIZE, 243, javax.swing.GroupLayout.PREFERRED_SIZE)
395  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
396  .addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
397  .addContainerGap(391, Short.MAX_VALUE))))
398  );
399 
400  toolBarPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {documentsButton, domainsButton, imagesButton, videosButton});
401 
402  toolBarPanelLayout.setVerticalGroup(
403  toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
404  .addGroup(toolBarPanelLayout.createSequentialGroup()
405  .addGap(6, 6, 6)
406  .addGroup(toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
407  .addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
408  .addComponent(step1Label))
409  .addGap(6, 6, 6)
410  .addGroup(toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
411  .addComponent(videosButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
412  .addComponent(imagesButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
413  .addComponent(documentsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
414  .addComponent(domainsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
415  .addGap(6, 6, 6))
416  );
417 
418  getContentPane().add(toolBarPanel, java.awt.BorderLayout.PAGE_START);
419 
420  org.openide.awt.Mnemonics.setLocalizedText(searchButton, org.openide.util.NbBundle.getMessage(DiscoveryDialog.class, "DiscoveryDialog.searchButton.text")); // NOI18N
421  searchButton.addActionListener(new java.awt.event.ActionListener() {
422  public void actionPerformed(java.awt.event.ActionEvent evt) {
423  searchButtonActionPerformed(evt);
424  }
425  });
426 
427  errorLabel.setForeground(new java.awt.Color(255, 0, 0));
428 
429  sortingPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(DiscoveryDialog.class, "DiscoveryDialog.sortingPanel.border.title"))); // NOI18N
430  sortingPanel.setPreferredSize(new java.awt.Dimension(345, 112));
431 
432  org.openide.awt.Mnemonics.setLocalizedText(orderGroupsByLabel, org.openide.util.NbBundle.getMessage(DiscoveryDialog.class, "DiscoveryDialog.orderGroupsByLabel.text")); // NOI18N
433 
434  org.openide.awt.Mnemonics.setLocalizedText(orderByLabel, org.openide.util.NbBundle.getMessage(DiscoveryDialog.class, "DiscoveryDialog.orderByLabel.text")); // NOI18N
435 
436  org.openide.awt.Mnemonics.setLocalizedText(groupByLabel, org.openide.util.NbBundle.getMessage(DiscoveryDialog.class, "DiscoveryDialog.groupByLabel.text")); // NOI18N
437 
438  javax.swing.GroupLayout sortingPanelLayout = new javax.swing.GroupLayout(sortingPanel);
439  sortingPanel.setLayout(sortingPanelLayout);
440  sortingPanelLayout.setHorizontalGroup(
441  sortingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
442  .addGroup(sortingPanelLayout.createSequentialGroup()
443  .addContainerGap()
444  .addGroup(sortingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
445  .addComponent(orderGroupsByLabel)
446  .addComponent(groupByLabel))
447  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
448  .addGroup(sortingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
449  .addComponent(groupSortingComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
450  .addComponent(groupByCombobox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
451  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
452  .addComponent(orderByLabel)
453  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
454  .addComponent(orderByCombobox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
455  .addContainerGap())
456  );
457  sortingPanelLayout.setVerticalGroup(
458  sortingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
459  .addGroup(sortingPanelLayout.createSequentialGroup()
460  .addGap(6, 6, 6)
461  .addGroup(sortingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
462  .addComponent(groupByCombobox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
463  .addComponent(groupByLabel)
464  .addComponent(orderByCombobox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
465  .addComponent(orderByLabel))
466  .addGap(6, 6, 6)
467  .addGroup(sortingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
468  .addComponent(groupSortingComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
469  .addComponent(orderGroupsByLabel))
470  .addGap(6, 6, 6))
471  );
472 
473  javax.swing.GroupLayout displaySettingsPanelLayout = new javax.swing.GroupLayout(displaySettingsPanel);
474  displaySettingsPanel.setLayout(displaySettingsPanelLayout);
475  displaySettingsPanelLayout.setHorizontalGroup(
476  displaySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
477  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, displaySettingsPanelLayout.createSequentialGroup()
478  .addGap(8, 8, 8)
479  .addGroup(displaySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
480  .addComponent(sortingPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 741, Short.MAX_VALUE)
481  .addGroup(displaySettingsPanelLayout.createSequentialGroup()
482  .addComponent(errorLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 575, Short.MAX_VALUE)
483  .addGap(65, 65, 65)
484  .addComponent(searchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)))
485  .addGap(8, 8, 8))
486  );
487  displaySettingsPanelLayout.setVerticalGroup(
488  displaySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
489  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, displaySettingsPanelLayout.createSequentialGroup()
490  .addGap(6, 6, 6)
491  .addComponent(sortingPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
492  .addGap(6, 6, 6)
493  .addGroup(displaySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
494  .addComponent(errorLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
495  .addComponent(searchButton))
496  .addGap(6, 6, 6))
497  );
498 
499  getContentPane().add(displaySettingsPanel, java.awt.BorderLayout.PAGE_END);
500 
501  pack();
502  }// </editor-fold>//GEN-END:initComponents
503 
504  private void imagesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imagesButtonActionPerformed
505  removeAllPanels();
506  add(imageFilterPanel, CENTER);
507  unselectAllButtons();
508  imagesButton.setSelected(true);
509  imagesButton.setEnabled(false);
510  imagesButton.setBackground(SELECTED_COLOR);
511  imagesButton.setForeground(Color.BLACK);
512  type = SearchData.Type.IMAGE;
513  imageFilterPanel.addPropertyChangeListener(listener);
514  updateComboBoxes();
515  validateDialog();
516  pack();
517  repaint();
518  }//GEN-LAST:event_imagesButtonActionPerformed
519 
520  private void videosButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_videosButtonActionPerformed
521  removeAllPanels();
522  add(videoFilterPanel, CENTER);
523  unselectAllButtons();
524  videosButton.setSelected(true);
525  videosButton.setEnabled(false);
526  videosButton.setBackground(SELECTED_COLOR);
527  videosButton.setForeground(Color.BLACK);
528  videoFilterPanel.addPropertyChangeListener(listener);
529  type = SearchData.Type.VIDEO;
530  updateComboBoxes();
531  validateDialog();
532  pack();
533  repaint();
534  }//GEN-LAST:event_videosButtonActionPerformed
535 
536  private void documentsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_documentsButtonActionPerformed
537  removeAllPanels();
538  add(documentFilterPanel, CENTER);
539  unselectAllButtons();
540  documentsButton.setSelected(true);
541  documentsButton.setEnabled(false);
542  documentsButton.setBackground(SELECTED_COLOR);
543  documentsButton.setForeground(Color.BLACK);
544  type = SearchData.Type.DOCUMENT;
545  documentFilterPanel.addPropertyChangeListener(listener);
546  updateComboBoxes();
547  validateDialog();
548  pack();
549  repaint();
550  }//GEN-LAST:event_documentsButtonActionPerformed
551 
555  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
556  private void removeAllPanels() {
557  if (imageFilterPanel != null) {
558  remove(imageFilterPanel);
559  imageFilterPanel.removePropertyChangeListener(listener);
560  }
561  if (domainFilterPanel != null) {
562  remove(domainFilterPanel);
563  domainFilterPanel.removePropertyChangeListener(listener);
564  }
565  if (documentFilterPanel != null) {
566  remove(documentFilterPanel);
567  documentFilterPanel.removePropertyChangeListener(listener);
568  }
569  if (videoFilterPanel != null) {
570  remove(videoFilterPanel);
571  videoFilterPanel.removePropertyChangeListener(listener);
572  }
573  }
574 
575  private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed
576  setVisible(false); //set visible used here instead of dispose incase dispose code changes
577  final DiscoveryTopComponent tc = DiscoveryTopComponent.getTopComponent();
578  if (tc == null) {
579  setValid("No Top Component Found");
580  return;
581  }
582  if (tc.isOpened() == false) {
583  tc.open();
584  }
585  tc.resetTopComponent();
586  // Get the selected filters
587  List<AbstractFilter> filters;
588  if (videosButton.isSelected()) {
589  filters = videoFilterPanel.getFilters();
590  } else if (documentsButton.isSelected()) {
591  filters = documentFilterPanel.getFilters();
592  } else if (imagesButton.isSelected()) {
593  filters = imageFilterPanel.getFilters();
594  } else if (domainsButton.isSelected()) {
595  filters = domainFilterPanel.getFilters();
596  } else {
597  logger.log(Level.SEVERE, "No filter type selected");
598  filters = new ArrayList<>();
599  }
600 
601  DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.SearchStartedEvent(type));
602 
603  // Get the grouping attribute and group sorting method
604  DiscoveryAttributes.AttributeType groupingAttr = groupByCombobox.getItemAt(groupByCombobox.getSelectedIndex()).getAttributeType();
605  Group.GroupSortingAlgorithm groupSortAlgorithm = groupSortingComboBox.getItemAt(groupSortingComboBox.getSelectedIndex());
606 
607  // Get the file sorting method
608  ResultsSorter.SortingMethod fileSort = (ResultsSorter.SortingMethod) orderByCombobox.getSelectedItem();
609  CentralRepository centralRepoDb = null;
610  if (CentralRepository.isEnabled()) {
611  try {
612  centralRepoDb = CentralRepository.getInstance();
613  } catch (CentralRepoException ex) {
614  centralRepoDb = null;
615  logger.log(Level.SEVERE, "Error loading central repository database, no central repository options will be available for Discovery", ex);
616  }
617  }
618  searchWorker = new SearchWorker(centralRepoDb, type, filters, groupingAttr, groupSortAlgorithm, fileSort);
619  searchWorker.execute();
620  tc.toFront();
621  tc.requestActive();
622  }//GEN-LAST:event_searchButtonActionPerformed
623 
624  private void domainsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_domainsButtonActionPerformed
625  removeAllPanels();
626  add(domainFilterPanel, CENTER);
627  unselectAllButtons();
628  domainsButton.setSelected(true);
629  domainsButton.setEnabled(false);
630  domainsButton.setBackground(SELECTED_COLOR);
631  domainsButton.setForeground(Color.BLACK);
632  type = SearchData.Type.DOMAIN;
633  domainFilterPanel.addPropertyChangeListener(listener);
634  updateComboBoxes();
635  validateDialog();
636  pack();
637  repaint();
638  }//GEN-LAST:event_domainsButtonActionPerformed
639 
640  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
641  @Override
642  public void dispose() {
643  setVisible(false);
644  }
645 
649  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
650  void cancelSearch() {
651  if (searchWorker != null) {
652  searchWorker.cancel(true);
653  searchWorker = null;
654  }
655  }
656 
664  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
665  private void setValid(String error) {
666  if (StringUtils.isBlank(error)) {
667  errorLabel.setText("");
668  searchButton.setEnabled(true);
669  } else {
670  errorLabel.setText(error);
671  searchButton.setEnabled(false);
672  }
673  }
674 
675 
676  // Variables declaration - do not modify//GEN-BEGIN:variables
677  private javax.swing.JButton documentsButton;
678  private javax.swing.JButton domainsButton;
679  private javax.swing.JLabel errorLabel;
680  private javax.swing.JComboBox<GroupingAttributeType> groupByCombobox;
681  private javax.swing.JComboBox<GroupSortingAlgorithm> groupSortingComboBox;
682  private javax.swing.JButton imagesButton;
683  private javax.swing.JComboBox<SortingMethod> orderByCombobox;
684  private javax.swing.JButton searchButton;
685  private javax.swing.JButton videosButton;
686  // End of variables declaration//GEN-END:variables
687 
692  private class CasePropertyChangeListener implements PropertyChangeListener {
693 
694  @Override
695  @SuppressWarnings("fallthrough")
696  public void propertyChange(PropertyChangeEvent evt) {
697  switch (Case.Events.valueOf(evt.getPropertyName())) {
698  case CURRENT_CASE: {
699  if (evt.getNewValue() == null) {
700  //do not refresh when a case is closed only when it is opened.
701  break;
702  }
703  //else fallthrough
704  }
705  case DATA_SOURCE_ADDED:
706  //fallthrough
707  case DATA_SOURCE_DELETED:
708  shouldUpdate = true;
709  break;
710  default:
711  //do nothing if the event is not one of the above events.
712  break;
713  }
714  }
715  }
716 
721  private class ModuleChangeListener implements PropertyChangeListener {
722 
727  @SuppressWarnings("deprecation")
728  @Override
729  public void propertyChange(PropertyChangeEvent evt) {
730  if (!shouldUpdate) {
731  String eventType = evt.getPropertyName();
732  if (eventType.equals(IngestManager.IngestModuleEvent.DATA_ADDED.toString())) {
739  try {
747  ModuleDataEvent eventData = (ModuleDataEvent) evt.getOldValue();
748  if (null != eventData) {
749  if (eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_OBJECT_DETECTED.getTypeID() && eventData.getArtifacts() != null) {
750  shouldUpdate = shouldUpdateFilters(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DESCRIPTION.getTypeID(), eventData, objectsDetected);
751  } else if (eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()) {
752  shouldUpdate = shouldUpdateFilters(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID(), eventData, hashSets);
753  } else if (eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ITEM.getTypeID()
754  || eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT.getTypeID()
755  || eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) {
756  shouldUpdate = shouldUpdateFilters(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID(), eventData, interestingItems);
757  }
758  }
759  } catch (NoCurrentCaseException notUsed) {
760  // Case is closed, do nothing.
761  } catch (TskCoreException ex) {
762  logger.log(Level.WARNING, "Unable to determine if discovery UI should be updated", ex);
763  }
764  }
765  }
766  }
767 
785  private boolean shouldUpdateFilters(int attributeTypeId, ModuleDataEvent eventData, Set<BlackboardAttribute> filterSetToCheck) throws TskCoreException {
786  for (BlackboardArtifact artifact : eventData.getArtifacts()) {
787  if (artifact.getAttributes() != null) {
788  for (BlackboardAttribute attr : artifact.getAttributes()) {
789  if (attr.getAttributeType().getTypeID() == attributeTypeId && !filterSetToCheck.contains(attr)) {
790  filterSetToCheck.add(attr);
791  return true;
792  }
793  }
794  }
795  }
796  return false;
797  }
798  }
799 }
Collection< BlackboardArtifact > getArtifacts()
BlackboardArtifact.Type getBlackboardArtifactType()
boolean shouldUpdateFilters(int attributeTypeId, ModuleDataEvent eventData, Set< BlackboardAttribute > filterSetToCheck)

Copyright © 2012-2022 Basis Technology. Generated on: Sat Sep 24 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.