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;
39 @SuppressWarnings(
"PMD.SingularField")
43 private final List<String> keywordListNames =
new ArrayList<>();
44 private final Map<String, Boolean> keywordListStates =
new HashMap<>();
45 private final XmlKeywordSearchList keywordListsManager = XmlKeywordSearchList.getCurrent();
48 initializeKeywordListSettings(initialSettings);
50 customizeComponents();
54 keywordListNames.clear();
55 keywordListStates.clear();
56 List<KeywordList> keywordLists = keywordListsManager.getListsL();
58 String listName = list.getName();
59 keywordListNames.add(listName);
60 keywordListStates.put(listName, settings.keywordListIsEnabled(listName));
65 customizeKeywordListsTable();
68 keywordListsManager.addPropertyChangeListener(
this);
69 languagesLabel.setText(
"<html>" +
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesLabel.text") +
"</html>");
73 listsTable.setModel(tableModel);
74 listsTable.setTableHeader(null);
75 listsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
76 final int width = listsScrollPane.getPreferredSize().width;
77 listsTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
79 for (
int i = 0; i < listsTable.getColumnCount(); i++) {
80 column = listsTable.getColumnModel().getColumn(i);
82 column.setPreferredWidth(((
int) (width * 0.07)));
84 column.setPreferredWidth(((
int) (width * 0.92)));
90 List<SCRIPT> scripts = KeywordSearchSettings.getStringExtractScripts();
91 StringBuilder langs =
new StringBuilder();
92 langs.append(
"<html>");
93 for (
int i = 0; i < scripts.size(); i++) {
94 langs.append(scripts.get(i).toString());
95 if (i + 1 < scripts.size()) {
99 langs.append(
"</html>");
100 String langsS = langs.toString();
101 this.languagesValLabel.setText(langsS);
102 this.languagesValLabel.setToolTipText(langsS);
106 String utf8 = KeywordSearchSettings.getStringExtractOption(StringsExtractOptions.EXTRACT_UTF8.toString());
107 String utf16 = KeywordSearchSettings.getStringExtractOption(StringsExtractOptions.EXTRACT_UTF16.toString());
108 ArrayList<String> encodingsList =
new ArrayList<>();
109 if (utf8 == null || Boolean.parseBoolean(utf8)) {
110 encodingsList.add(
"UTF8");
112 if (utf16 == null || Boolean.parseBoolean(utf16)) {
113 encodingsList.add(
"UTF16");
115 String encodings = encodingsList.toString();
116 encodings = encodings.substring(1, encodings.length() - 1);
117 keywordSearchEncodings.setText(encodings);
122 if (event.getPropertyName().equals(XmlKeywordSearchList.ListsEvt.LIST_ADDED.name())
123 || event.getPropertyName().equals(XmlKeywordSearchList.ListsEvt.LIST_DELETED.name())
124 || event.getPropertyName().equals(XmlKeywordSearchList.ListsEvt.LIST_UPDATED.name())
125 || event.getPropertyName().equals(XmlKeywordSearchList.LanguagesEvent.LANGUAGES_CHANGED.name())) {
131 updateKeywordListSettings();
134 tableModel.fireTableDataChanged();
139 List<KeywordList> keywordLists = keywordListsManager.getListsL();
140 List<String> currentListNames =
new ArrayList<>();
142 currentListNames.add(list.getName());
146 for (String listName : keywordListNames) {
147 if (!currentListNames.contains(listName)) {
148 keywordListStates.remove(listName);
153 keywordListNames.clear();
154 for (String currentListName : currentListNames) {
155 keywordListNames.add(currentListName);
156 if (!keywordListStates.containsKey(currentListName)) {
157 keywordListStates.put(currentListName, Boolean.TRUE);
164 List<String> enabledListNames =
new ArrayList<>();
165 List<String> disabledListNames =
new ArrayList<>();
166 for (String listName : keywordListNames) {
167 if (keywordListStates.get(listName)) {
168 enabledListNames.add(listName);
170 disabledListNames.add(listName);
173 return new KeywordSearchJobSettings(enabledListNames, disabledListNames);
176 void reset(KeywordSearchJobSettings newSettings) {
177 initializeKeywordListSettings(newSettings);
180 tableModel.fireTableDataChanged();
198 if (columnIndex == 0) {
199 return keywordListStates.get(listName);
207 return columnIndex == 0;
211 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
213 if (columnIndex == 0) {
214 keywordListStates.put(listName, (Boolean) aValue);
220 return getValueAt(0, c).getClass();
229 @SuppressWarnings(
"unchecked")
231 private
void initComponents() {
233 listsScrollPane =
new javax.swing.JScrollPane();
234 listsTable =
new javax.swing.JTable();
235 titleLabel =
new javax.swing.JLabel();
236 languagesLabel =
new javax.swing.JLabel();
237 languagesValLabel =
new javax.swing.JLabel();
238 encodingsLabel =
new javax.swing.JLabel();
239 keywordSearchEncodings =
new javax.swing.JLabel();
241 setPreferredSize(
new java.awt.Dimension(300, 170));
243 listsScrollPane.setBorder(javax.swing.BorderFactory.createEtchedBorder());
244 listsScrollPane.setPreferredSize(
new java.awt.Dimension(300, 100));
246 listsTable.setBackground(
new java.awt.Color(240, 240, 240));
247 listsTable.setModel(
new javax.swing.table.DefaultTableModel(
255 listsTable.setShowHorizontalLines(
false);
256 listsTable.setShowVerticalLines(
false);
257 listsScrollPane.setViewportView(listsTable);
262 languagesLabel.setToolTipText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesLabel.toolTipText"));
263 languagesLabel.setPreferredSize(
new java.awt.Dimension(294, 35));
264 languagesLabel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
266 languagesValLabel.setText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesValLabel.text"));
267 languagesValLabel.setToolTipText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.languagesValLabel.toolTipText"));
271 keywordSearchEncodings.setText(
org.openide.util.NbBundle.getMessage(
KeywordSearchJobSettingsPanel.class,
"KeywordSearchJobSettingsPanel.keywordSearchEncodings.text"));
273 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
274 this.setLayout(layout);
275 layout.setHorizontalGroup(
276 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
277 .addGroup(layout.createSequentialGroup()
279 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
280 .addGroup(layout.createSequentialGroup()
281 .addComponent(listsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
283 .addGroup(layout.createSequentialGroup()
285 .addComponent(languagesValLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE)
286 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
287 .addComponent(languagesLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
288 .addGroup(layout.createSequentialGroup()
289 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
290 .addComponent(titleLabel)
291 .addGroup(layout.createSequentialGroup()
292 .addComponent(encodingsLabel)
293 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
294 .addComponent(keywordSearchEncodings)))
295 .addGap(0, 0, Short.MAX_VALUE))))
297 layout.setVerticalGroup(
298 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
299 .addGroup(layout.createSequentialGroup()
301 .addComponent(titleLabel)
302 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
303 .addComponent(listsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 41, Short.MAX_VALUE)
304 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
305 .addComponent(languagesLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
306 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
307 .addComponent(languagesValLabel)
308 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
309 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
310 .addComponent(encodingsLabel)
311 .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)