19 package org.sleuthkit.autopsy.discovery.ui;
22 import java.util.List;
23 import java.util.logging.Level;
24 import javax.swing.DefaultListModel;
25 import javax.swing.JCheckBox;
26 import javax.swing.JLabel;
27 import javax.swing.JList;
28 import org.openide.util.NbBundle;
39 final class HashSetFilterPanel
extends AbstractDiscoveryFilterPanel {
41 private static final long serialVersionUID = 1L;
42 private final static Logger logger = Logger.getLogger(HashSetFilterPanel.class.getName());
47 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
48 HashSetFilterPanel() {
56 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
57 private
void setUpHashFilter() {
60 DefaultListModel<String> hashListModel = (DefaultListModel<String>) hashSetList.getModel();
61 hashListModel.removeAllElements();
62 List<String> setNames = DiscoveryUiUtils.getSetNames(BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT,
63 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME);
64 for (String name : setNames) {
65 hashListModel.add(count, name);
68 }
catch (TskCoreException ex) {
69 logger.log(Level.SEVERE,
"Error loading hash set names", ex);
70 hashSetCheckbox.setEnabled(
false);
71 hashSetList.setEnabled(
false);
80 @SuppressWarnings(
"unchecked")
82 private
void initComponents() {
84 hashSetCheckbox =
new javax.swing.JCheckBox();
85 hashSetScrollPane =
new javax.swing.JScrollPane();
86 hashSetList =
new javax.swing.JList<>();
88 org.openide.awt.Mnemonics.setLocalizedText(hashSetCheckbox,
org.openide.util.NbBundle.getMessage(HashSetFilterPanel.class,
"HashSetFilterPanel.hashSetCheckbox.text"));
89 hashSetCheckbox.setMaximumSize(
new java.awt.Dimension(150, 25));
90 hashSetCheckbox.setMinimumSize(
new java.awt.Dimension(150, 25));
91 hashSetCheckbox.setPreferredSize(
new java.awt.Dimension(150, 25));
92 hashSetCheckbox.addActionListener(
new java.awt.event.ActionListener() {
93 public void actionPerformed(java.awt.event.ActionEvent evt) {
94 hashSetCheckboxActionPerformed(evt);
98 setMinimumSize(
new java.awt.Dimension(250, 30));
99 setPreferredSize(
new java.awt.Dimension(250, 30));
101 hashSetList.setModel(
new DefaultListModel<String>());
102 hashSetList.setEnabled(
false);
103 hashSetList.setVisibleRowCount(3);
104 hashSetScrollPane.setViewportView(hashSetList);
106 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
107 this.setLayout(layout);
108 layout.setHorizontalGroup(
109 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
110 .addComponent(hashSetScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
112 layout.setVerticalGroup(
113 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
114 .addComponent(hashSetScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)
118 private void hashSetCheckboxActionPerformed(java.awt.event.ActionEvent evt) {
119 hashSetList.setEnabled(hashSetCheckbox.isSelected());
124 private javax.swing.JCheckBox hashSetCheckbox;
125 private javax.swing.JList<String> hashSetList;
126 private javax.swing.JScrollPane hashSetScrollPane;
129 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
131 void configurePanel(
boolean selected,
int[] indicesSelected) {
132 boolean hasHashSets = hashSetList.getModel().getSize() > 0;
133 hashSetCheckbox.setEnabled(hasHashSets);
134 hashSetCheckbox.setSelected(selected && hasHashSets);
135 if (hashSetCheckbox.isEnabled() && hashSetCheckbox.isSelected()) {
136 hashSetScrollPane.setEnabled(
true);
137 hashSetList.setEnabled(
true);
138 if (indicesSelected != null) {
139 hashSetList.setSelectedIndices(indicesSelected);
142 hashSetScrollPane.setEnabled(
false);
143 hashSetList.setEnabled(
false);
147 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
149 JCheckBox getCheckbox() {
150 return hashSetCheckbox;
154 JLabel getAdditionalLabel() {
158 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
159 @NbBundle.Messages({
"HashSetFilterPanel.error.text=At least one hash set name must be selected."})
161 String checkForError() {
162 if (hashSetCheckbox.isSelected() && hashSetList.getSelectedValuesList().isEmpty()) {
163 return Bundle.HashSetFilterPanel_error_text();
168 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
174 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
176 AbstractFilter getFilter() {
177 if (hashSetCheckbox.isSelected()) {
178 return new SearchFiltering.HashSetFilter(hashSetList.getSelectedValuesList());