19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.awt.Component;
22 import java.beans.PropertyChangeEvent;
23 import java.beans.PropertyChangeListener;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
28 import javax.swing.JLabel;
29 import javax.swing.JTable;
30 import javax.swing.ListSelectionModel;
31 import javax.swing.table.AbstractTableModel;
32 import javax.swing.table.DefaultTableCellRenderer;
33 import javax.swing.table.TableColumn;
43 @SuppressWarnings(
"PMD.SingularField")
47 private final List<String> keywordListNames =
new ArrayList<>();
48 private final Map<String, Boolean> keywordListStates =
new HashMap<>();
49 private final XmlKeywordSearchList keywordListsManager = XmlKeywordSearchList.getCurrent();
52 initializeKeywordListSettings(initialSettings);
54 customizeComponents();
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));
69 customizeKeywordListsTable();
72 keywordListsManager.addPropertyChangeListener(
this);
73 languagesLabel.setText(
"<html>" +
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesLabel.text") +
"</html>");
77 listsTable.setModel(tableModel);
78 listsTable.setTableHeader(null);
79 listsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
80 final int width = listsScrollPane.getPreferredSize().width;
81 listsTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
83 for (
int i = 0; i < listsTable.getColumnCount(); i++) {
84 column = listsTable.getColumnModel().getColumn(i);
86 column.setPreferredWidth(((
int) (width * 0.07)));
88 column.setPreferredWidth(((
int) (width * 0.92)));
94 List<SCRIPT> scripts = KeywordSearchSettings.getStringExtractScripts();
95 StringBuilder langs =
new StringBuilder();
96 langs.append(
"<html>");
97 for (
int i = 0; i < scripts.size(); i++) {
98 langs.append(scripts.get(i).toString());
99 if (i + 1 < scripts.size()) {
103 langs.append(
"</html>");
104 String langsS = langs.toString();
105 this.languagesValLabel.setText(langsS);
106 this.languagesValLabel.setToolTipText(langsS);
110 String utf8 = KeywordSearchSettings.getStringExtractOption(StringsExtractOptions.EXTRACT_UTF8.toString());
111 String utf16 = KeywordSearchSettings.getStringExtractOption(StringsExtractOptions.EXTRACT_UTF16.toString());
112 ArrayList<String> encodingsList =
new ArrayList<>();
113 if (utf8 == null || Boolean.parseBoolean(utf8)) {
114 encodingsList.add(
"UTF8");
116 if (utf16 == null || Boolean.parseBoolean(utf16)) {
117 encodingsList.add(
"UTF16");
119 String encodings = encodingsList.toString();
120 encodings = encodings.substring(1, encodings.length() - 1);
121 keywordSearchEncodings.setText(encodings);
126 if (event.getPropertyName().equals(XmlKeywordSearchList.ListsEvt.LIST_ADDED.name())
127 || event.getPropertyName().equals(XmlKeywordSearchList.ListsEvt.LIST_DELETED.name())
128 || event.getPropertyName().equals(XmlKeywordSearchList.ListsEvt.LIST_UPDATED.name())
129 || event.getPropertyName().equals(XmlKeywordSearchList.LanguagesEvent.LANGUAGES_CHANGED.name())) {
135 updateKeywordListSettings();
138 tableModel.fireTableDataChanged();
143 List<KeywordList> keywordLists = keywordListsManager.getListsL();
144 List<String> currentListNames =
new ArrayList<>();
146 currentListNames.add(list.getName());
150 for (String listName : keywordListNames) {
151 if (!currentListNames.contains(listName)) {
152 keywordListStates.remove(listName);
157 keywordListNames.clear();
158 for (String currentListName : currentListNames) {
159 keywordListNames.add(currentListName);
160 if (!keywordListStates.containsKey(currentListName)) {
161 keywordListStates.put(currentListName, Boolean.TRUE);
168 List<String> enabledListNames =
new ArrayList<>();
169 List<String> disabledListNames =
new ArrayList<>();
170 for (String listName : keywordListNames) {
171 if (keywordListStates.get(listName)) {
172 enabledListNames.add(listName);
174 disabledListNames.add(listName);
177 return new KeywordSearchJobSettings(enabledListNames, disabledListNames);
180 void reset(KeywordSearchJobSettings newSettings) {
181 initializeKeywordListSettings(newSettings);
184 tableModel.fireTableDataChanged();
202 if (columnIndex == 0) {
203 return keywordListStates.get(listName);
211 return columnIndex == 0;
215 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
217 if (columnIndex == 0) {
218 keywordListStates.put(listName, (Boolean) aValue);
224 return getValueAt(0, c).getClass();
233 @SuppressWarnings(
"unchecked")
235 private
void initComponents() {
237 listsScrollPane =
new javax.swing.JScrollPane();
238 listsTable =
new javax.swing.JTable();
239 titleLabel =
new javax.swing.JLabel();
240 languagesLabel =
new javax.swing.JLabel();
241 languagesValLabel =
new javax.swing.JLabel();
242 encodingsLabel =
new javax.swing.JLabel();
243 keywordSearchEncodings =
new javax.swing.JLabel();
245 setPreferredSize(
new java.awt.Dimension(300, 170));
247 listsScrollPane.setBorder(javax.swing.BorderFactory.createEtchedBorder());
248 listsScrollPane.setPreferredSize(
new java.awt.Dimension(300, 100));
250 listsTable.setBackground(
new java.awt.Color(240, 240, 240));
251 listsTable.setModel(
new javax.swing.table.DefaultTableModel(
259 listsTable.setShowHorizontalLines(
false);
260 listsTable.setShowVerticalLines(
false);
261 listsScrollPane.setViewportView(listsTable);
267 languagesLabel.setToolTipText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesLabel.toolTipText"));
268 languagesLabel.setPreferredSize(
new java.awt.Dimension(294, 35));
269 languagesLabel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
271 languagesValLabel.setText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesValLabel.text"));
272 languagesValLabel.setToolTipText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesValLabel.toolTipText"));
276 keywordSearchEncodings.setText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.keywordSearchEncodings.text"));
278 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
279 this.setLayout(layout);
280 layout.setHorizontalGroup(
281 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
282 .addGroup(layout.createSequentialGroup()
284 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
285 .addGroup(layout.createSequentialGroup()
286 .addComponent(listsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
288 .addGroup(layout.createSequentialGroup()
290 .addComponent(languagesValLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE)
291 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
292 .addComponent(languagesLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
293 .addGroup(layout.createSequentialGroup()
294 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
295 .addComponent(titleLabel)
296 .addGroup(layout.createSequentialGroup()
297 .addComponent(encodingsLabel)
298 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
299 .addComponent(keywordSearchEncodings)))
300 .addGap(0, 0, Short.MAX_VALUE))))
302 layout.setVerticalGroup(
303 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
304 .addGroup(layout.createSequentialGroup()
306 .addComponent(titleLabel)
307 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
308 .addComponent(listsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 41, Short.MAX_VALUE)
309 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
310 .addComponent(languagesLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
311 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
312 .addComponent(languagesValLabel)
313 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
314 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
315 .addComponent(encodingsLabel)
316 .addComponent(keywordSearchEncodings))
void customizeKeywordListsTable()
boolean isCellEditable(int rowIndex, int columnIndex)
void customizeComponents()
void updateKeywordListSettings()
void propertyChange(PropertyChangeEvent event)
javax.swing.JLabel encodingsLabel
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
javax.swing.JLabel languagesLabel
final List< String > keywordListNames
IngestModuleIngestJobSettings getSettings()
Object getValueAt(int rowIndex, int columnIndex)
Class<?> getColumnClass(int c)