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 final List<String> keywordListNames =
new ArrayList<>();
45 private final Map<String, Boolean> keywordListStates =
new HashMap<>();
46 private final XmlKeywordSearchList keywordListsManager = XmlKeywordSearchList.getCurrent();
51 customizeComponents();
52 initializeKeywordListSettings(initialSettings);
56 keywordListNames.clear();
57 keywordListStates.clear();
58 List<KeywordList> keywordLists = keywordListsManager.getListsL();
60 String listName = list.getName();
61 keywordListNames.add(listName);
62 keywordListStates.put(listName, settings.keywordListIsEnabled(listName));
66 limitedOcrCheckbox.setSelected(settings.isLimitedOCREnabled());
67 ocrOnlyCheckbox.setSelected(settings.isOCROnly());
78 ocrCheckBox.setEnabled(platformSupported);
79 limitedOcrCheckbox.setEnabled(platformSupported && ocrEnabled);
80 ocrOnlyCheckbox.setEnabled(platformSupported && ocrEnabled);
84 customizeKeywordListsTable();
87 keywordListsManager.addPropertyChangeListener(
this);
88 languagesLabel.setText(
"<html>" +
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesLabel.text") +
"</html>");
91 listsTable.setShowHorizontalLines(
false);
92 listsTable.setShowVerticalLines(
false);
96 listsTable.setModel(tableModel);
97 listsTable.setTableHeader(null);
98 listsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
99 final int width = listsScrollPane.getPreferredSize().width;
100 listsTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
102 for (
int i = 0; i < listsTable.getColumnCount(); i++) {
103 column = listsTable.getColumnModel().getColumn(i);
105 column.setPreferredWidth(((
int) (width * 0.07)));
107 column.setPreferredWidth(((
int) (width * 0.92)));
113 List<SCRIPT> scripts = KeywordSearchSettings.getStringExtractScripts();
114 StringBuilder langs =
new StringBuilder();
115 langs.append(
"<html>");
116 for (
int i = 0; i < scripts.size(); i++) {
117 langs.append(scripts.get(i).toString());
118 if (i + 1 < scripts.size()) {
122 langs.append(
"</html>");
123 String langsS = langs.toString();
124 this.languagesValLabel.setText(langsS);
125 this.languagesValLabel.setToolTipText(langsS);
129 String utf8 = KeywordSearchSettings.getStringExtractOption(StringsExtractOptions.EXTRACT_UTF8.toString());
130 String utf16 = KeywordSearchSettings.getStringExtractOption(StringsExtractOptions.EXTRACT_UTF16.toString());
131 ArrayList<String> encodingsList =
new ArrayList<>();
132 if (utf8 == null || Boolean.parseBoolean(utf8)) {
133 encodingsList.add(
"UTF8");
135 if (utf16 == null || Boolean.parseBoolean(utf16)) {
136 encodingsList.add(
"UTF16");
138 String encodings = encodingsList.toString();
139 encodings = encodings.substring(1, encodings.length() - 1);
140 keywordSearchEncodings.setText(encodings);
145 if (event.getPropertyName().equals(XmlKeywordSearchList.ListsEvt.LIST_ADDED.name())
146 || event.getPropertyName().equals(XmlKeywordSearchList.ListsEvt.LIST_DELETED.name())
147 || event.getPropertyName().equals(XmlKeywordSearchList.ListsEvt.LIST_UPDATED.name())
148 || event.getPropertyName().equals(XmlKeywordSearchList.LanguagesEvent.LANGUAGES_CHANGED.name())) {
154 updateKeywordListSettings();
157 tableModel.fireTableDataChanged();
162 List<KeywordList> keywordLists = keywordListsManager.getListsL();
163 List<String> currentListNames =
new ArrayList<>();
165 currentListNames.add(list.getName());
169 for (String listName : keywordListNames) {
170 if (!currentListNames.contains(listName)) {
171 keywordListStates.remove(listName);
176 keywordListNames.clear();
177 for (String currentListName : currentListNames) {
178 keywordListNames.add(currentListName);
179 if (!keywordListStates.containsKey(currentListName)) {
180 keywordListStates.put(currentListName, Boolean.TRUE);
187 List<String> enabledListNames =
new ArrayList<>();
188 List<String> disabledListNames =
new ArrayList<>();
189 for (String listName : keywordListNames) {
190 if (keywordListStates.get(listName)) {
191 enabledListNames.add(listName);
193 disabledListNames.add(listName);
197 this.ocrCheckBox.isSelected(), this.limitedOcrCheckbox.isSelected(), this.ocrOnlyCheckbox.isSelected());
201 initializeKeywordListSettings(newSettings);
204 tableModel.fireTableDataChanged();
222 if (columnIndex == 0) {
223 return keywordListStates.get(listName);
231 return columnIndex == 0;
235 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
237 if (columnIndex == 0) {
238 keywordListStates.put(listName, (Boolean) aValue);
244 return getValueAt(0, c).getClass();
253 @SuppressWarnings(
"unchecked")
255 private
void initComponents() {
257 listsScrollPane =
new javax.swing.JScrollPane();
258 listsTable =
new javax.swing.JTable();
259 titleLabel =
new javax.swing.JLabel();
260 languagesLabel =
new javax.swing.JLabel();
261 languagesValLabel =
new javax.swing.JLabel();
262 encodingsLabel =
new javax.swing.JLabel();
263 keywordSearchEncodings =
new javax.swing.JLabel();
264 ocrCheckBox =
new javax.swing.JCheckBox();
265 limitedOcrCheckbox =
new javax.swing.JCheckBox();
266 ocrOnlyCheckbox =
new javax.swing.JCheckBox();
268 setPreferredSize(
new java.awt.Dimension(300, 170));
270 listsScrollPane.setBorder(javax.swing.BorderFactory.createEtchedBorder());
271 listsScrollPane.setPreferredSize(
new java.awt.Dimension(300, 100));
273 listsTable.setBackground(
new java.awt.Color(240, 240, 240));
274 listsTable.setModel(
new javax.swing.table.DefaultTableModel(
282 listsTable.setMaximumSize(
new java.awt.Dimension(32767, 32767));
283 listsTable.setMinimumSize(
new java.awt.Dimension(20, 200));
284 listsTable.setPreferredSize(null);
285 listsScrollPane.setViewportView(listsTable);
291 languagesLabel.setToolTipText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesLabel.toolTipText"));
292 languagesLabel.setPreferredSize(
new java.awt.Dimension(294, 35));
293 languagesLabel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
295 languagesValLabel.setText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesValLabel.text"));
296 languagesValLabel.setToolTipText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesValLabel.toolTipText"));
300 keywordSearchEncodings.setText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.keywordSearchEncodings.text"));
303 ocrCheckBox.addActionListener(
new java.awt.event.ActionListener() {
304 public void actionPerformed(java.awt.event.ActionEvent evt) {
305 ocrCheckBoxActionPerformed(evt);
309 limitedOcrCheckbox.setText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.limitedOcrCheckbox.text"));
310 limitedOcrCheckbox.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
311 limitedOcrCheckbox.addActionListener(
new java.awt.event.ActionListener() {
312 public void actionPerformed(java.awt.event.ActionEvent evt) {
313 limitedOcrCheckboxActionPerformed(evt);
318 ocrOnlyCheckbox.addActionListener(
new java.awt.event.ActionListener() {
319 public void actionPerformed(java.awt.event.ActionEvent evt) {
320 ocrOnlyCheckboxActionPerformed(evt);
324 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
325 this.setLayout(layout);
326 layout.setHorizontalGroup(
327 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
328 .addGroup(layout.createSequentialGroup()
330 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
331 .addComponent(languagesLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
332 .addGroup(layout.createSequentialGroup()
333 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
334 .addComponent(listsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 316, Short.MAX_VALUE)
335 .addComponent(titleLabel)
336 .addGroup(layout.createSequentialGroup()
337 .addComponent(encodingsLabel)
338 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
339 .addComponent(keywordSearchEncodings))
340 .addGroup(layout.createSequentialGroup()
342 .addComponent(languagesValLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE))
343 .addComponent(ocrCheckBox)
344 .addGroup(layout.createSequentialGroup()
346 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
347 .addComponent(ocrOnlyCheckbox)
348 .addComponent(limitedOcrCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 288, javax.swing.GroupLayout.PREFERRED_SIZE))))
349 .addContainerGap())))
351 layout.setVerticalGroup(
352 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
353 .addGroup(layout.createSequentialGroup()
355 .addComponent(titleLabel)
356 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
357 .addComponent(listsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
358 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
359 .addComponent(languagesLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
360 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
361 .addComponent(languagesValLabel)
362 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
363 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
364 .addComponent(encodingsLabel)
365 .addComponent(keywordSearchEncodings))
366 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
367 .addComponent(ocrCheckBox)
368 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
369 .addComponent(ocrOnlyCheckbox)
370 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
371 .addComponent(limitedOcrCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
377 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 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)