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;
38 final class HashSetFilterPanel
extends AbstractDiscoveryFilterPanel {
40 private static final long serialVersionUID = 1L;
41 private final static Logger logger = Logger.getLogger(HashSetFilterPanel.class.getName());
46 HashSetFilterPanel() {
54 private void setUpHashFilter() {
57 DefaultListModel<String> hashListModel = (DefaultListModel<String>) hashSetList.getModel();
58 hashListModel.removeAllElements();
59 List<String> setNames = DiscoveryUiUtils.getSetNames(BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT,
60 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME);
61 for (String name : setNames) {
62 hashListModel.add(count, name);
65 }
catch (TskCoreException ex) {
66 logger.log(Level.SEVERE,
"Error loading hash set names", ex);
67 hashSetCheckbox.setEnabled(
false);
68 hashSetList.setEnabled(
false);
77 @SuppressWarnings(
"unchecked")
79 private
void initComponents() {
81 hashSetCheckbox =
new javax.swing.JCheckBox();
82 hashSetScrollPane =
new javax.swing.JScrollPane();
83 hashSetList =
new javax.swing.JList<>();
85 org.openide.awt.Mnemonics.setLocalizedText(hashSetCheckbox,
org.openide.util.NbBundle.getMessage(HashSetFilterPanel.class,
"HashSetFilterPanel.hashSetCheckbox.text"));
86 hashSetCheckbox.setMaximumSize(
new java.awt.Dimension(150, 25));
87 hashSetCheckbox.setMinimumSize(
new java.awt.Dimension(150, 25));
88 hashSetCheckbox.setPreferredSize(
new java.awt.Dimension(150, 25));
89 hashSetCheckbox.addActionListener(
new java.awt.event.ActionListener() {
90 public void actionPerformed(java.awt.event.ActionEvent evt) {
91 hashSetCheckboxActionPerformed(evt);
95 setMinimumSize(
new java.awt.Dimension(250, 30));
96 setPreferredSize(
new java.awt.Dimension(250, 30));
98 hashSetList.setModel(
new DefaultListModel<String>());
99 hashSetList.setEnabled(
false);
100 hashSetList.setVisibleRowCount(3);
101 hashSetScrollPane.setViewportView(hashSetList);
103 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
104 this.setLayout(layout);
105 layout.setHorizontalGroup(
106 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
107 .addComponent(hashSetScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
109 layout.setVerticalGroup(
110 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
111 .addComponent(hashSetScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)
115 private void hashSetCheckboxActionPerformed(java.awt.event.ActionEvent evt) {
116 hashSetList.setEnabled(hashSetCheckbox.isSelected());
121 private javax.swing.JCheckBox hashSetCheckbox;
122 private javax.swing.JList<String> hashSetList;
123 private javax.swing.JScrollPane hashSetScrollPane;
127 void configurePanel(
boolean selected,
int[] indicesSelected) {
128 boolean hasHashSets = hashSetList.getModel().getSize() > 0;
129 hashSetCheckbox.setEnabled(hasHashSets);
130 hashSetCheckbox.setSelected(selected && hasHashSets);
131 if (hashSetCheckbox.isEnabled() && hashSetCheckbox.isSelected()) {
132 hashSetScrollPane.setEnabled(
true);
133 hashSetList.setEnabled(
true);
134 if (indicesSelected != null) {
135 hashSetList.setSelectedIndices(indicesSelected);
138 hashSetScrollPane.setEnabled(
false);
139 hashSetList.setEnabled(
false);
144 JCheckBox getCheckbox() {
145 return hashSetCheckbox;
149 JLabel getAdditionalLabel() {
153 @NbBundle.Messages({
"HashSetFilterPanel.error.text=At least one hash set name must be selected."})
155 String checkForError() {
156 if (hashSetCheckbox.isSelected() && hashSetList.getSelectedValuesList().isEmpty()) {
157 return Bundle.HashSetFilterPanel_error_text();
168 AbstractFilter getFilter() {
169 if (hashSetCheckbox.isSelected()) {
170 return new SearchFiltering.HashSetFilter(hashSetList.getSelectedValuesList());