19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
27 import javax.swing.JTable;
28 import javax.swing.ListSelectionModel;
29 import javax.swing.table.AbstractTableModel;
30 import javax.swing.table.TableColumn;
41 @SuppressWarnings(
"PMD.SingularField")
44 private static final long serialVersionUID = 1L;
46 private final List<String> keywordListNames =
new ArrayList<>();
47 private final Map<String, Boolean> keywordListStates =
new HashMap<>();
48 private final XmlKeywordSearchList keywordListsManager = XmlKeywordSearchList.getCurrent();
53 customizeComponents();
54 initializeKeywordListSettings(initialSettings);
58 keywordListNames.clear();
59 keywordListStates.clear();
60 List<KeywordList> keywordLists = keywordListsManager.getListsL();
62 String listName = list.getName();
63 keywordListNames.add(listName);
64 keywordListStates.put(listName, settings.keywordListIsEnabled(listName));
68 limitedOcrCheckbox.setSelected(settings.isLimitedOCREnabled());
69 ocrOnlyCheckbox.setSelected(settings.isOCROnly());
70 solrCheckbox.setSelected(settings.isIndexToSolrEnabled());
81 ocrCheckBox.setEnabled(platformSupported);
82 limitedOcrCheckbox.setEnabled(platformSupported && ocrEnabled);
83 ocrOnlyCheckbox.setEnabled(platformSupported && ocrEnabled);
87 customizeKeywordListsTable();
90 keywordListsManager.addPropertyChangeListener(
this);
91 languagesLabel.setText(
"<html>" +
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesLabel.text") +
"</html>");
94 listsTable.setShowHorizontalLines(
false);
95 listsTable.setShowVerticalLines(
false);
99 listsTable.setModel(tableModel);
100 listsTable.setTableHeader(null);
101 listsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
102 final int width = listsScrollPane.getPreferredSize().width;
103 listsTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
105 for (
int i = 0; i < listsTable.getColumnCount(); i++) {
106 column = listsTable.getColumnModel().getColumn(i);
108 column.setPreferredWidth(((
int) (width * 0.07)));
110 column.setPreferredWidth(((
int) (width * 0.92)));
116 List<SCRIPT> scripts = KeywordSearchSettings.getStringExtractScripts();
117 StringBuilder langs =
new StringBuilder();
118 langs.append(
"<html>");
119 for (
int i = 0; i < scripts.size(); i++) {
120 langs.append(scripts.get(i).toString());
121 if (i + 1 < scripts.size()) {
125 langs.append(
"</html>");
126 String langsS = langs.toString();
127 this.languagesValLabel.setText(langsS);
128 this.languagesValLabel.setToolTipText(langsS);
132 String utf8 = KeywordSearchSettings.getStringExtractOption(StringsExtractOptions.EXTRACT_UTF8.toString());
133 String utf16 = KeywordSearchSettings.getStringExtractOption(StringsExtractOptions.EXTRACT_UTF16.toString());
134 ArrayList<String> encodingsList =
new ArrayList<>();
135 if (utf8 == null || Boolean.parseBoolean(utf8)) {
136 encodingsList.add(
"UTF8");
138 if (utf16 == null || Boolean.parseBoolean(utf16)) {
139 encodingsList.add(
"UTF16");
141 String encodings = encodingsList.toString();
142 encodings = encodings.substring(1, encodings.length() - 1);
143 keywordSearchEncodings.setText(encodings);
148 if (event.getPropertyName().equals(XmlKeywordSearchList.ListsEvt.LIST_ADDED.name())
149 || event.getPropertyName().equals(XmlKeywordSearchList.ListsEvt.LIST_DELETED.name())
150 || event.getPropertyName().equals(XmlKeywordSearchList.ListsEvt.LIST_UPDATED.name())
151 || event.getPropertyName().equals(XmlKeywordSearchList.LanguagesEvent.LANGUAGES_CHANGED.name())) {
157 updateKeywordListSettings();
160 tableModel.fireTableDataChanged();
165 List<KeywordList> keywordLists = keywordListsManager.getListsL();
166 List<String> currentListNames =
new ArrayList<>();
168 currentListNames.add(list.getName());
172 for (String listName : keywordListNames) {
173 if (!currentListNames.contains(listName)) {
174 keywordListStates.remove(listName);
179 keywordListNames.clear();
180 for (String currentListName : currentListNames) {
181 keywordListNames.add(currentListName);
182 if (!keywordListStates.containsKey(currentListName)) {
183 keywordListStates.put(currentListName, Boolean.TRUE);
190 List<String> enabledListNames =
new ArrayList<>();
191 List<String> disabledListNames =
new ArrayList<>();
192 for (String listName : keywordListNames) {
193 if (keywordListStates.get(listName)) {
194 enabledListNames.add(listName);
196 disabledListNames.add(listName);
200 this.ocrCheckBox.isSelected(), this.limitedOcrCheckbox.isSelected(), this.ocrOnlyCheckbox.isSelected(), this.solrCheckbox.isSelected());
204 initializeKeywordListSettings(newSettings);
207 tableModel.fireTableDataChanged();
225 if (columnIndex == 0) {
226 return keywordListStates.get(listName);
234 return columnIndex == 0;
238 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
240 if (columnIndex == 0) {
241 keywordListStates.put(listName, (Boolean) aValue);
247 return getValueAt(0, c).getClass();
256 @SuppressWarnings(
"unchecked")
258 private
void initComponents() {
259 java.awt.GridBagConstraints gridBagConstraints;
261 listsScrollPane =
new javax.swing.JScrollPane();
262 listsTable =
new javax.swing.JTable();
263 titleLabel =
new javax.swing.JLabel();
264 languagesLabel =
new javax.swing.JLabel();
265 languagesValLabel =
new javax.swing.JLabel();
266 encodingsLabel =
new javax.swing.JLabel();
267 keywordSearchEncodings =
new javax.swing.JLabel();
268 ocrCheckBox =
new javax.swing.JCheckBox();
269 limitedOcrCheckbox =
new javax.swing.JCheckBox();
270 ocrOnlyCheckbox =
new javax.swing.JCheckBox();
271 solrCheckbox =
new javax.swing.JCheckBox();
273 setMinimumSize(
new java.awt.Dimension(250, 250));
274 setPreferredSize(
new java.awt.Dimension(250, 250));
275 setLayout(
new java.awt.GridBagLayout());
277 listsScrollPane.setBorder(javax.swing.BorderFactory.createEtchedBorder());
278 listsScrollPane.setMinimumSize(
new java.awt.Dimension(250, 48));
279 listsScrollPane.setPreferredSize(
new java.awt.Dimension(250, 48));
281 listsTable.setBackground(
new java.awt.Color(240, 240, 240));
282 listsTable.setModel(
new javax.swing.table.DefaultTableModel(
290 listsTable.setMaximumSize(
new java.awt.Dimension(32767, 32767));
291 listsTable.setMinimumSize(
new java.awt.Dimension(20, 200));
292 listsTable.setPreferredSize(null);
293 listsScrollPane.setViewportView(listsTable);
296 gridBagConstraints =
new java.awt.GridBagConstraints();
297 gridBagConstraints.gridx = 0;
298 gridBagConstraints.gridy = 1;
299 gridBagConstraints.gridwidth = 2;
300 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
301 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
302 gridBagConstraints.weightx = 1.0;
303 gridBagConstraints.weighty = 1.0;
304 gridBagConstraints.insets =
new java.awt.Insets(2, 10, 0, 0);
305 add(listsScrollPane, gridBagConstraints);
308 gridBagConstraints =
new java.awt.GridBagConstraints();
309 gridBagConstraints.gridx = 0;
310 gridBagConstraints.gridy = 0;
311 gridBagConstraints.gridwidth = 2;
312 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
313 gridBagConstraints.insets =
new java.awt.Insets(2, 10, 0, 0);
314 add(titleLabel, gridBagConstraints);
317 languagesLabel.setToolTipText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesLabel.toolTipText"));
318 languagesLabel.setPreferredSize(
new java.awt.Dimension(294, 35));
319 languagesLabel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
320 gridBagConstraints =
new java.awt.GridBagConstraints();
321 gridBagConstraints.gridx = 0;
322 gridBagConstraints.gridy = 2;
323 gridBagConstraints.gridwidth = 2;
324 gridBagConstraints.ipadx = 25;
325 gridBagConstraints.ipady = -22;
326 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
327 gridBagConstraints.insets =
new java.awt.Insets(2, 10, 0, 0);
328 add(languagesLabel, gridBagConstraints);
330 languagesValLabel.setText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesValLabel.text"));
331 languagesValLabel.setToolTipText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesValLabel.toolTipText"));
332 gridBagConstraints =
new java.awt.GridBagConstraints();
333 gridBagConstraints.gridx = 0;
334 gridBagConstraints.gridy = 3;
335 gridBagConstraints.gridwidth = 2;
336 gridBagConstraints.ipadx = 270;
337 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
338 gridBagConstraints.insets =
new java.awt.Insets(2, 10, 0, 0);
339 add(languagesValLabel, gridBagConstraints);
342 gridBagConstraints =
new java.awt.GridBagConstraints();
343 gridBagConstraints.gridx = 0;
344 gridBagConstraints.gridy = 4;
345 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
346 gridBagConstraints.insets =
new java.awt.Insets(5, 10, 0, 0);
347 add(encodingsLabel, gridBagConstraints);
349 keywordSearchEncodings.setText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.keywordSearchEncodings.text"));
350 gridBagConstraints =
new java.awt.GridBagConstraints();
351 gridBagConstraints.gridx = 1;
352 gridBagConstraints.gridy = 4;
353 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
354 gridBagConstraints.insets =
new java.awt.Insets(5, 10, 0, 0);
355 add(keywordSearchEncodings, gridBagConstraints);
358 ocrCheckBox.addActionListener(
new java.awt.event.ActionListener() {
359 public void actionPerformed(java.awt.event.ActionEvent evt) {
360 ocrCheckBoxActionPerformed(evt);
363 gridBagConstraints =
new java.awt.GridBagConstraints();
364 gridBagConstraints.gridx = 0;
365 gridBagConstraints.gridy = 5;
366 gridBagConstraints.gridwidth = 2;
367 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
368 gridBagConstraints.insets =
new java.awt.Insets(2, 10, 0, 0);
369 add(ocrCheckBox, gridBagConstraints);
371 limitedOcrCheckbox.setText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.limitedOcrCheckbox.text"));
372 limitedOcrCheckbox.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
373 limitedOcrCheckbox.addActionListener(
new java.awt.event.ActionListener() {
374 public void actionPerformed(java.awt.event.ActionEvent evt) {
375 limitedOcrCheckboxActionPerformed(evt);
378 gridBagConstraints =
new java.awt.GridBagConstraints();
379 gridBagConstraints.gridx = 0;
380 gridBagConstraints.gridy = 7;
381 gridBagConstraints.gridwidth = 2;
382 gridBagConstraints.ipadx = 216;
383 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
384 gridBagConstraints.insets =
new java.awt.Insets(0, 31, 0, 0);
385 add(limitedOcrCheckbox, gridBagConstraints);
388 ocrOnlyCheckbox.addActionListener(
new java.awt.event.ActionListener() {
389 public void actionPerformed(java.awt.event.ActionEvent evt) {
390 ocrOnlyCheckboxActionPerformed(evt);
393 gridBagConstraints =
new java.awt.GridBagConstraints();
394 gridBagConstraints.gridx = 0;
395 gridBagConstraints.gridy = 6;
396 gridBagConstraints.gridwidth = 2;
397 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
398 gridBagConstraints.insets =
new java.awt.Insets(0, 31, 0, 0);
399 add(ocrOnlyCheckbox, gridBagConstraints);
401 solrCheckbox.setSelected(
true);
403 gridBagConstraints =
new java.awt.GridBagConstraints();
404 gridBagConstraints.gridx = 0;
405 gridBagConstraints.gridy = 8;
406 gridBagConstraints.gridwidth = 2;
407 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
408 gridBagConstraints.insets =
new java.awt.Insets(2, 10, 0, 0);
409 add(solrCheckbox, gridBagConstraints);
413 handleOcrEnabled(ocrCheckBox.isSelected());
void customizeKeywordListsTable()
boolean isCellEditable(int rowIndex, int columnIndex)
void customizeComponents()
void updateKeywordListSettings()
javax.swing.JCheckBox limitedOcrCheckbox
void ocrCheckBoxActionPerformed(java.awt.event.ActionEvent evt)
void propertyChange(PropertyChangeEvent event)
javax.swing.JLabel encodingsLabel
void handleOcrEnabled(boolean ocrEnabled)
void limitedOcrCheckboxActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JCheckBox solrCheckbox
javax.swing.JCheckBox ocrCheckBox
javax.swing.JCheckBox ocrOnlyCheckbox
void initializeKeywordListSettings(KeywordSearchJobSettings settings)
javax.swing.JLabel keywordSearchEncodings
javax.swing.JScrollPane listsScrollPane
javax.swing.JLabel languagesValLabel
void setValueAt(Object aValue, int rowIndex, int columnIndex)
javax.swing.JLabel titleLabel
javax.swing.JTable listsTable
void ocrOnlyCheckboxActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JLabel languagesLabel
final List< String > keywordListNames
IngestModuleIngestJobSettings getSettings()
Object getValueAt(int rowIndex, int columnIndex)
Class<?> getColumnClass(int c)