19 package org.sleuthkit.autopsy.filesearch;
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.HashMap;
25 import java.util.HashSet;
26 import java.util.List;
29 import java.util.logging.Level;
30 import javax.swing.event.ListSelectionEvent;
41 @SuppressWarnings(
"PMD.SingularField")
45 private static final long serialVersionUID = 1L;
46 private final Map<Long, String> dataSourceMap =
new HashMap<>();
53 if (this.dataSourceList.getModel().getSize() > 1) {
54 this.dataSourceList.addListSelectionListener((ListSelectionEvent evt) -> {
55 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
62 this.dataSourceCheckBox.setEnabled(
false);
63 this.dataSourceList.setEnabled(
false);
73 List<String> dsList =
new ArrayList<>();
77 List<DataSource> dataSources = tskDb.getDataSources();
78 Collections.sort(dataSources, (DataSource ds1, DataSource ds2) -> ds1.getName().compareTo(ds2.getName()));
79 for (DataSource ds : dataSources) {
80 String dsName = ds.getName();
81 File dataSourceFullName =
new File(dsName);
82 String displayName = dataSourceFullName.getName();
83 dataSourceMap.put(ds.getId(), displayName);
84 dsList.add(displayName);
87 logger.log(Level.SEVERE,
"Unable to get current open case.", ex);
88 }
catch (TskCoreException ex) {
89 logger.log(Level.SEVERE,
"Failed to get data source info from database.", ex);
99 Set<Long> getDataSourcesSelected() {
100 Set<Long> dataSourceObjIdSet =
new HashSet<>();
101 for (Long key : dataSourceMap.keySet()) {
102 String value = dataSourceMap.get(key);
103 for (String dataSource : this.dataSourceList.getSelectedValuesList()) {
104 if (value.equals(dataSource)) {
105 dataSourceObjIdSet.add(key);
109 return dataSourceObjIdSet;
117 boolean isSelected() {
118 return this.dataSourceCheckBox.isSelected();
125 final void setComponentsEnabled() {
126 boolean enabled = this.isSelected();
127 this.dataSourceList.setEnabled(enabled);
128 this.dataSourceNoteLabel.setEnabled(enabled);
136 @SuppressWarnings(
"unchecked")
138 private
void initComponents() {
140 jScrollPane1 =
new javax.swing.JScrollPane();
141 dataSourceList =
new javax.swing.JList<>();
142 dataSourceCheckBox =
new javax.swing.JCheckBox();
143 dataSourceNoteLabel =
new javax.swing.JLabel();
145 setMinimumSize(
new java.awt.Dimension(150, 150));
146 setPreferredSize(
new java.awt.Dimension(150, 150));
148 dataSourceList.setModel(
new javax.swing.AbstractListModel<String>() {
149 List<String> strings = getDataSourceArray();
150 public int getSize() { return strings.size(); }
151 public String getElementAt(
int idx) {
return strings.get(idx); }
153 dataSourceList.setEnabled(
false);
154 dataSourceList.setMinimumSize(
new java.awt.Dimension(0, 200));
155 jScrollPane1.setViewportView(dataSourceList);
157 org.openide.awt.Mnemonics.setLocalizedText(dataSourceCheckBox,
org.openide.util.NbBundle.getMessage(
DataSourcePanel.class,
"DataSourcePanel.dataSourceCheckBox.text"));
158 dataSourceCheckBox.addActionListener(
new java.awt.event.ActionListener() {
159 public void actionPerformed(java.awt.event.ActionEvent evt) {
160 dataSourceCheckBoxActionPerformed(evt);
164 dataSourceNoteLabel.setFont(dataSourceNoteLabel.getFont().deriveFont(dataSourceNoteLabel.getFont().getSize()-1f));
165 org.openide.awt.Mnemonics.setLocalizedText(dataSourceNoteLabel,
org.openide.util.NbBundle.getMessage(DataSourcePanel.class,
"DataSourcePanel.dataSourceNoteLabel.text"));
166 dataSourceNoteLabel.setEnabled(
false);
168 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
169 this.setLayout(layout);
170 layout.setHorizontalGroup(
171 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
172 .addGroup(layout.createSequentialGroup()
173 .addComponent(dataSourceCheckBox)
174 .addGap(0, 0, Short.MAX_VALUE))
175 .addGroup(layout.createSequentialGroup()
177 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
178 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
179 .addGroup(layout.createSequentialGroup()
180 .addComponent(dataSourceNoteLabel)
181 .addGap(0, 0, Short.MAX_VALUE)))
184 layout.setVerticalGroup(
185 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
186 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
187 .addComponent(dataSourceCheckBox)
188 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
189 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
190 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
191 .addComponent(dataSourceNoteLabel)
195 dataSourceCheckBox.getAccessibleContext().setAccessibleName(
"");
199 setComponentsEnabled();
200 firePropertyChange(FileSearchPanel.EVENT.CHECKED.toString(), null, null);
201 this.dataSourceList.setSelectedIndices(
new int[0]);
javax.swing.JList< String > dataSourceList
void dataSourceCheckBoxActionPerformed(java.awt.event.ActionEvent evt)
List< String > getDataSourceArray()
javax.swing.JCheckBox dataSourceCheckBox
javax.swing.JScrollPane jScrollPane1
SleuthkitCase getSleuthkitCase()
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
javax.swing.JLabel dataSourceNoteLabel