19 package org.sleuthkit.autopsy.discovery;
21 import java.util.List;
22 import java.util.logging.Level;
23 import javax.swing.DefaultListModel;
24 import javax.swing.JCheckBox;
25 import javax.swing.JLabel;
26 import javax.swing.JList;
35 final class HashSetFilterPanel
extends AbstractDiscoveryFilterPanel {
37 private static final long serialVersionUID = 1L;
38 private final static Logger logger = Logger.getLogger(HashSetFilterPanel.class.getName());
43 HashSetFilterPanel() {
51 private void setUpHashFilter() {
54 DefaultListModel<String> hashListModel = (DefaultListModel<String>) hashSetList.getModel();
55 hashListModel.removeAllElements();
56 List<String> setNames = DiscoveryUiUtils.getSetNames(BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT,
57 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME);
58 for (String name : setNames) {
59 hashListModel.add(count, name);
62 }
catch (TskCoreException ex) {
63 logger.log(Level.SEVERE,
"Error loading hash set names", ex);
64 hashSetCheckbox.setEnabled(
false);
65 hashSetList.setEnabled(
false);
74 @SuppressWarnings(
"unchecked")
76 private
void initComponents() {
78 hashSetCheckbox =
new javax.swing.JCheckBox();
79 hashSetScrollPane =
new javax.swing.JScrollPane();
80 hashSetList =
new javax.swing.JList<>();
82 org.openide.awt.Mnemonics.setLocalizedText(hashSetCheckbox,
org.openide.util.NbBundle.getMessage(HashSetFilterPanel.class,
"HashSetFilterPanel.hashSetCheckbox.text"));
83 hashSetCheckbox.setMaximumSize(
new java.awt.Dimension(150, 25));
84 hashSetCheckbox.setMinimumSize(
new java.awt.Dimension(150, 25));
85 hashSetCheckbox.setPreferredSize(
new java.awt.Dimension(150, 25));
86 hashSetCheckbox.addActionListener(
new java.awt.event.ActionListener() {
87 public void actionPerformed(java.awt.event.ActionEvent evt) {
88 hashSetCheckboxActionPerformed(evt);
92 setMinimumSize(
new java.awt.Dimension(250, 30));
93 setPreferredSize(
new java.awt.Dimension(250, 30));
95 hashSetList.setModel(
new DefaultListModel<String>());
96 hashSetList.setEnabled(
false);
97 hashSetList.setVisibleRowCount(3);
98 hashSetScrollPane.setViewportView(hashSetList);
100 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
101 this.setLayout(layout);
102 layout.setHorizontalGroup(
103 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
104 .addComponent(hashSetScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
106 layout.setVerticalGroup(
107 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
108 .addComponent(hashSetScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)
112 private void hashSetCheckboxActionPerformed(java.awt.event.ActionEvent evt) {
113 hashSetList.setEnabled(hashSetCheckbox.isSelected());
118 private javax.swing.JCheckBox hashSetCheckbox;
119 private javax.swing.JList<String> hashSetList;
120 private javax.swing.JScrollPane hashSetScrollPane;
124 void configurePanel(
boolean selected,
int[] indicesSelected) {
125 boolean hasHashSets = hashSetList.getModel().getSize() > 0;
126 hashSetCheckbox.setEnabled(hasHashSets);
127 hashSetCheckbox.setSelected(selected && hasHashSets);
128 if (hashSetCheckbox.isEnabled() && hashSetCheckbox.isSelected()) {
129 hashSetScrollPane.setEnabled(
true);
130 hashSetList.setEnabled(
true);
131 if (indicesSelected != null) {
132 hashSetList.setSelectedIndices(indicesSelected);
135 hashSetScrollPane.setEnabled(
false);
136 hashSetList.setEnabled(
false);
141 JCheckBox getCheckbox() {
142 return hashSetCheckbox;
146 JLabel getAdditionalLabel() {
151 String checkForError() {
152 if (hashSetCheckbox.isSelected() && hashSetList.getSelectedValuesList().isEmpty()) {
153 return "At least one hash set name must be selected";
164 FileSearchFiltering.FileFilter getFilter() {
165 if (hashSetCheckbox.isSelected()) {
166 return new FileSearchFiltering.HashSetFilter(hashSetList.getSelectedValuesList());