19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.awt.EventQueue;
22 import java.beans.PropertyChangeEvent;
23 import java.beans.PropertyChangeListener;
24 import java.util.logging.Level;
25 import org.netbeans.spi.options.OptionsPanelController;
26 import org.openide.util.NbBundle;
36 @SuppressWarnings(
"PMD.SingularField")
37 class KeywordSearchGlobalSearchSettingsPanel extends javax.swing.JPanel implements OptionsPanel {
39 private static final long serialVersionUID = 1L;
40 private final Logger logger = Logger.getLogger(KeywordSearchGlobalSearchSettingsPanel.class.getName());
45 KeywordSearchGlobalSearchSettingsPanel() {
47 customizeComponents();
50 private void activateWidgets() {
51 skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
52 showSnippetsCB.setSelected(KeywordSearchSettings.getShowSnippets());
53 ocrCheckBox.setSelected(KeywordSearchSettings.getOcrOption());
54 limitedOcrCheckbox.setSelected(KeywordSearchSettings.getLimitedOcrOption());
55 boolean ingestRunning = IngestManager.getInstance().isIngestRunning();
56 ingestWarningLabel.setVisible(ingestRunning);
57 skipNSRLCheckBox.setEnabled(!ingestRunning);
58 ocrCheckBox.setEnabled(!ingestRunning);
59 limitedOcrCheckbox.setEnabled(ocrCheckBox.isSelected() && !ingestRunning);
60 setTimeSettingEnabled(!ingestRunning);
62 final UpdateFrequency curFreq = KeywordSearchSettings.getUpdateFrequency();
65 timeRadioButton1.setSelected(
true);
68 timeRadioButton2.setSelected(
true);
71 timeRadioButton3.setSelected(
true);
74 timeRadioButton4.setSelected(
true);
77 timeRadioButton5.setSelected(
true);
82 timeRadioButton3.setSelected(
true);
92 @SuppressWarnings(
"unchecked")
94 private
void initComponents() {
96 timeGroup =
new javax.swing.ButtonGroup();
97 skipNSRLCheckBox =
new javax.swing.JCheckBox();
98 filesIndexedLabel =
new javax.swing.JLabel();
99 filesIndexedValue =
new javax.swing.JLabel();
100 chunksLabel =
new javax.swing.JLabel();
101 chunksValLabel =
new javax.swing.JLabel();
102 settingsLabel =
new javax.swing.JLabel();
103 informationLabel =
new javax.swing.JLabel();
104 settingsSeparator =
new javax.swing.JSeparator();
105 informationSeparator =
new javax.swing.JSeparator();
106 frequencyLabel =
new javax.swing.JLabel();
107 timeRadioButton1 =
new javax.swing.JRadioButton();
108 timeRadioButton2 =
new javax.swing.JRadioButton();
109 timeRadioButton3 =
new javax.swing.JRadioButton();
110 timeRadioButton4 =
new javax.swing.JRadioButton();
111 showSnippetsCB =
new javax.swing.JCheckBox();
112 timeRadioButton5 =
new javax.swing.JRadioButton();
113 ingestWarningLabel =
new javax.swing.JLabel();
114 ocrCheckBox =
new javax.swing.JCheckBox();
115 limitedOcrCheckbox =
new javax.swing.JCheckBox();
117 skipNSRLCheckBox.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.text"));
118 skipNSRLCheckBox.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.toolTipText"));
119 skipNSRLCheckBox.addActionListener(
new java.awt.event.ActionListener() {
120 public void actionPerformed(java.awt.event.ActionEvent evt) {
121 skipNSRLCheckBoxActionPerformed(evt);
125 filesIndexedLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedLabel.text"));
127 filesIndexedValue.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedValue.text"));
129 chunksLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.chunksLabel.text"));
131 chunksValLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.chunksValLabel.text"));
133 settingsLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.settingsLabel.text"));
135 informationLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.informationLabel.text"));
137 frequencyLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.frequencyLabel.text"));
139 timeRadioButton1.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.text"));
140 timeRadioButton1.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.toolTipText"));
141 timeRadioButton1.addActionListener(
new java.awt.event.ActionListener() {
142 public void actionPerformed(java.awt.event.ActionEvent evt) {
143 timeRadioButton1ActionPerformed(evt);
147 timeRadioButton2.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.text"));
148 timeRadioButton2.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.toolTipText"));
149 timeRadioButton2.addActionListener(
new java.awt.event.ActionListener() {
150 public void actionPerformed(java.awt.event.ActionEvent evt) {
151 timeRadioButton2ActionPerformed(evt);
155 timeRadioButton3.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.text"));
156 timeRadioButton3.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.toolTipText"));
157 timeRadioButton3.addActionListener(
new java.awt.event.ActionListener() {
158 public void actionPerformed(java.awt.event.ActionEvent evt) {
159 timeRadioButton3ActionPerformed(evt);
163 timeRadioButton4.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.text_1"));
164 timeRadioButton4.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.toolTipText"));
165 timeRadioButton4.addActionListener(
new java.awt.event.ActionListener() {
166 public void actionPerformed(java.awt.event.ActionEvent evt) {
167 timeRadioButton4ActionPerformed(evt);
171 showSnippetsCB.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.showSnippetsCB.text"));
172 showSnippetsCB.addActionListener(
new java.awt.event.ActionListener() {
173 public void actionPerformed(java.awt.event.ActionEvent evt) {
174 showSnippetsCBActionPerformed(evt);
178 timeRadioButton5.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.text"));
179 timeRadioButton5.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.toolTipText"));
180 timeRadioButton5.addActionListener(
new java.awt.event.ActionListener() {
181 public void actionPerformed(java.awt.event.ActionEvent evt) {
182 timeRadioButton5ActionPerformed(evt);
186 ingestWarningLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png")));
187 ingestWarningLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.ingestWarningLabel.text"));
189 ocrCheckBox.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.ocrCheckBox.text"));
190 ocrCheckBox.addActionListener(
new java.awt.event.ActionListener() {
191 public void actionPerformed(java.awt.event.ActionEvent evt) {
192 ocrCheckBoxActionPerformed(evt);
196 limitedOcrCheckbox.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.limitedOcrCheckbox.text"));
197 limitedOcrCheckbox.addActionListener(
new java.awt.event.ActionListener() {
198 public void actionPerformed(java.awt.event.ActionEvent evt) {
199 limitedOcrCheckboxActionPerformed(evt);
203 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
204 this.setLayout(layout);
205 layout.setHorizontalGroup(
206 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
207 .addGroup(layout.createSequentialGroup()
209 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
210 .addComponent(ingestWarningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
211 .addGroup(layout.createSequentialGroup()
212 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
213 .addGroup(layout.createSequentialGroup()
214 .addComponent(settingsLabel)
215 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
216 .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE))
217 .addGroup(layout.createSequentialGroup()
218 .addComponent(informationLabel)
219 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
220 .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE))
221 .addGroup(layout.createSequentialGroup()
223 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
224 .addComponent(skipNSRLCheckBox)
225 .addComponent(showSnippetsCB)
226 .addComponent(ocrCheckBox)
227 .addGroup(layout.createSequentialGroup()
228 .addComponent(filesIndexedLabel)
230 .addComponent(filesIndexedValue))
231 .addComponent(frequencyLabel)
232 .addGroup(layout.createSequentialGroup()
234 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
235 .addComponent(timeRadioButton2)
236 .addComponent(timeRadioButton1)
237 .addComponent(timeRadioButton3)
238 .addComponent(timeRadioButton4)
239 .addComponent(timeRadioButton5)))
240 .addGroup(layout.createSequentialGroup()
241 .addComponent(chunksLabel)
243 .addComponent(chunksValLabel))
244 .addGroup(layout.createSequentialGroup()
246 .addComponent(limitedOcrCheckbox)))))
247 .addGap(0, 0, Short.MAX_VALUE)))
251 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {chunksLabel, filesIndexedLabel});
253 layout.setVerticalGroup(
254 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
255 .addGroup(layout.createSequentialGroup()
257 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
258 .addComponent(settingsLabel)
259 .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE))
260 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
261 .addComponent(skipNSRLCheckBox)
262 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
263 .addComponent(showSnippetsCB)
264 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
265 .addComponent(ocrCheckBox)
267 .addComponent(limitedOcrCheckbox)
268 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
269 .addComponent(frequencyLabel)
270 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
271 .addComponent(timeRadioButton1)
272 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
273 .addComponent(timeRadioButton2)
274 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
275 .addComponent(timeRadioButton3)
276 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
277 .addComponent(timeRadioButton4)
278 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
279 .addComponent(timeRadioButton5)
280 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
281 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
282 .addComponent(informationLabel)
283 .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE))
284 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
285 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
286 .addComponent(filesIndexedLabel)
287 .addComponent(filesIndexedValue))
288 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
289 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
290 .addComponent(chunksLabel)
291 .addComponent(chunksValLabel))
292 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
293 .addComponent(ingestWarningLabel)
294 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
298 private void timeRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {
299 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
302 private void skipNSRLCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
303 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
306 private void showSnippetsCBActionPerformed(java.awt.event.ActionEvent evt) {
307 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
310 private void timeRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
311 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
314 private void timeRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
315 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
318 private void timeRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {
319 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
322 private void timeRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {
323 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
326 private void ocrCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
327 limitedOcrCheckbox.setEnabled(ocrCheckBox.isSelected());
328 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
331 private void limitedOcrCheckboxActionPerformed(java.awt.event.ActionEvent evt) {
332 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
336 private javax.swing.JLabel chunksLabel;
337 private javax.swing.JLabel chunksValLabel;
338 private javax.swing.JLabel filesIndexedLabel;
339 private javax.swing.JLabel filesIndexedValue;
340 private javax.swing.JLabel frequencyLabel;
341 private javax.swing.JLabel informationLabel;
342 private javax.swing.JSeparator informationSeparator;
343 private javax.swing.JLabel ingestWarningLabel;
344 private javax.swing.JCheckBox limitedOcrCheckbox;
345 private javax.swing.JCheckBox ocrCheckBox;
346 private javax.swing.JLabel settingsLabel;
347 private javax.swing.JSeparator settingsSeparator;
348 private javax.swing.JCheckBox showSnippetsCB;
349 private javax.swing.JCheckBox skipNSRLCheckBox;
350 private javax.swing.ButtonGroup timeGroup;
351 private javax.swing.JRadioButton timeRadioButton1;
352 private javax.swing.JRadioButton timeRadioButton2;
353 private javax.swing.JRadioButton timeRadioButton3;
354 private javax.swing.JRadioButton timeRadioButton4;
355 private javax.swing.JRadioButton timeRadioButton5;
359 public void store() {
360 KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
361 KeywordSearchSettings.setUpdateFrequency(getSelectedTimeValue());
362 KeywordSearchSettings.setShowSnippets(showSnippetsCB.isSelected());
363 KeywordSearchSettings.setOcrOption(ocrCheckBox.isSelected());
364 KeywordSearchSettings.setLimitedOcrOption(limitedOcrCheckbox.isSelected());
372 private void setTimeSettingEnabled(
boolean enabled) {
373 timeRadioButton1.setEnabled(enabled);
374 timeRadioButton2.setEnabled(enabled);
375 timeRadioButton3.setEnabled(enabled);
376 timeRadioButton4.setEnabled(enabled);
377 timeRadioButton5.setEnabled(enabled);
378 frequencyLabel.setEnabled(enabled);
381 private UpdateFrequency getSelectedTimeValue() {
382 if (timeRadioButton1.isSelected()) {
383 return UpdateFrequency.FAST;
384 }
else if (timeRadioButton2.isSelected()) {
385 return UpdateFrequency.AVG;
386 }
else if (timeRadioButton3.isSelected()) {
387 return UpdateFrequency.SLOW;
388 }
else if (timeRadioButton4.isSelected()) {
389 return UpdateFrequency.SLOWEST;
390 }
else if (timeRadioButton5.isSelected()) {
391 return UpdateFrequency.NONE;
393 return UpdateFrequency.DEFAULT;
396 @NbBundle.Messages({
"KeywordSearchGlobalSearchSettingsPanel.customizeComponents.windowsOCR=Enable Optical Character Recognition (OCR) (Requires Windows 64-bit)",
397 "KeywordSearchGlobalSearchSettingsPanel.customizeComponents.windowsLimitedOCR=Only process images which are over 100KB in size or extracted from a document. (Beta) (Requires Windows 64-bit)"})
398 private void customizeComponents() {
400 timeGroup.add(timeRadioButton1);
401 timeGroup.add(timeRadioButton2);
402 timeGroup.add(timeRadioButton3);
403 timeGroup.add(timeRadioButton4);
404 timeGroup.add(timeRadioButton5);
406 this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
409 filesIndexedValue.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedFiles()));
410 chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
411 }
catch (KeywordSearchModuleException | NoOpenCoreException ex) {
412 logger.log(Level.WARNING,
"Could not get number of indexed files/chunks");
415 if (!PlatformUtil.isWindowsOS() || !PlatformUtil.is64BitOS()) {
416 ocrCheckBox.setText(Bundle.KeywordSearchGlobalSearchSettingsPanel_customizeComponents_windowsOCR());
417 ocrCheckBox.setSelected(
false);
418 ocrCheckBox.setEnabled(
false);
419 limitedOcrCheckbox.setSelected(
false);
420 limitedOcrCheckbox.setEnabled(
false);
421 limitedOcrCheckbox.setText(Bundle.KeywordSearchGlobalSearchSettingsPanel_customizeComponents_windowsLimitedOCR());
424 KeywordSearch.addNumIndexedFilesChangeListener(
425 new PropertyChangeListener() {
427 public void propertyChange(PropertyChangeEvent evt) {
428 String changed = evt.getPropertyName();
429 Object newValue = evt.getNewValue();
431 if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
432 int newFilesIndexed = ((Integer) newValue);
433 filesIndexedValue.setText(Integer.toString(newFilesIndexed));
435 chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
436 }
catch (KeywordSearchModuleException | NoOpenCoreException ex) {
437 logger.log(Level.WARNING,
"Could not get number of indexed chunks");
445 IngestManager.getInstance().addIngestJobEventListener(
new PropertyChangeListener() {
447 public void propertyChange(PropertyChangeEvent evt) {
448 Object source = evt.getSource();
449 if (source instanceof String && ((String) source).equals(
"LOCAL")) {
450 EventQueue.invokeLater(() -> {