Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ArtifactTypeFilterPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy
3  *
4  * Copyright 2020 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 
21 import java.util.ArrayList;
22 import java.util.List;
24 import javax.swing.JCheckBox;
25 import javax.swing.JLabel;
26 import javax.swing.event.ListSelectionListener;
27 import org.openide.util.NbBundle;
31 import org.sleuthkit.datamodel.BlackboardArtifact;
32 
36 final class ArtifactTypeFilterPanel extends AbstractDiscoveryFilterPanel {
37 
38  private static final long serialVersionUID = 1L;
39 
43  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
44  ArtifactTypeFilterPanel() {
45  initComponents();
46  setUpArtifactTypeFilter();
47  }
48 
52  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
53  private void setUpArtifactTypeFilter() {
54  artifactList.clearList();
55  for (BlackboardArtifact.ARTIFACT_TYPE artifactType : SearchData.Type.DOMAIN.getArtifactTypes()) {
56  artifactList.addElement(artifactType.getDisplayName(), null, artifactType);
57  }
58  }
59 
65  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
66  private void initComponents() {
67 
68  artifactTypeCheckbox = new javax.swing.JCheckBox();
69  artifactList = new org.sleuthkit.autopsy.guiutils.CheckBoxListPanel<>();
70 
71  org.openide.awt.Mnemonics.setLocalizedText(artifactTypeCheckbox, org.openide.util.NbBundle.getMessage(ArtifactTypeFilterPanel.class, "ArtifactTypeFilterPanel.artifactTypeCheckbox.text")); // NOI18N
72  artifactTypeCheckbox.addActionListener(new java.awt.event.ActionListener() {
73  public void actionPerformed(java.awt.event.ActionEvent evt) {
74  artifactTypeCheckboxActionPerformed(evt);
75  }
76  });
77 
78  setPreferredSize(new java.awt.Dimension(27, 27));
79  setLayout(new java.awt.BorderLayout());
80  add(artifactList, java.awt.BorderLayout.CENTER);
81  }// </editor-fold>//GEN-END:initComponents
82 
83  private void artifactTypeCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_artifactTypeCheckboxActionPerformed
84  artifactList.setEnabled(artifactTypeCheckbox.isSelected());
85  }//GEN-LAST:event_artifactTypeCheckboxActionPerformed
86 
87  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
88  @Override
89  void configurePanel(boolean selected, List<?> selectedItems) {
90  artifactTypeCheckbox.setSelected(selected);
91  if (artifactTypeCheckbox.isEnabled() && artifactTypeCheckbox.isSelected()) {
92  artifactList.setEnabled(true);
93  if (selectedItems != null) {
94  List<BlackboardArtifact.ARTIFACT_TYPE> artTypeList = new ArrayList<>();
95  for (Object item : selectedItems) {
96  if (item instanceof BlackboardArtifact.ARTIFACT_TYPE) {
97  artTypeList.add((BlackboardArtifact.ARTIFACT_TYPE) item);
98  }
99  }
100  if (!artTypeList.isEmpty()) {
101  artifactList.setSelectedElements(artTypeList);
102  }
103  }
104  } else {
105  artifactList.setEnabled(false);
106  }
107  }
108 
109  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
110  @Override
111  JCheckBox getCheckbox() {
112  return artifactTypeCheckbox;
113  }
114 
115  @Override
116  JLabel getAdditionalLabel() {
117  return null;
118  }
119 
120  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
121  @NbBundle.Messages({"ArtifactTypeFilterPanel.selectionNeeded.text=At least one Result type must be selected."})
122  @Override
123  String checkForError() {
124  if (artifactTypeCheckbox.isSelected() && artifactList.getSelectedElements().isEmpty()) {
125  return Bundle.ArtifactTypeFilterPanel_selectionNeeded_text();
126  }
127  return "";
128  }
129 
130  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
131  @Override
132  AbstractFilter getFilter() {
133  if (artifactTypeCheckbox.isSelected() && isFilterSupported()) {
134  List<BlackboardArtifact.ARTIFACT_TYPE> artifactTypeList = artifactList.getSelectedElements();
135  return new ArtifactTypeFilter(artifactTypeList);
136  }
137  return null;
138  }
139 
140  @Override
141  void addListSelectionListener(ListSelectionListener listener) {
142  artifactList.addListSelectionListener(listener);
143  }
144 
145  @Override
146  boolean isFilterSupported() {
147  return !artifactList.isEmpty();
148  }
149 
150 
151  // Variables declaration - do not modify//GEN-BEGIN:variables
152  private org.sleuthkit.autopsy.guiutils.CheckBoxListPanel<BlackboardArtifact.ARTIFACT_TYPE> artifactList;
153  private javax.swing.JCheckBox artifactTypeCheckbox;
154  // End of variables declaration//GEN-END:variables
155 }

Copyright © 2012-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.