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 final Logger logger = Logger.getLogger(KeywordSearchGlobalSearchSettingsPanel.class.getName());
44 KeywordSearchGlobalSearchSettingsPanel() {
46 customizeComponents();
49 private void activateWidgets() {
50 skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
51 showSnippetsCB.setSelected(KeywordSearchSettings.getShowSnippets());
52 ocrCheckBox.setSelected(KeywordSearchSettings.getOcrOption());
53 boolean ingestRunning = IngestManager.getInstance().isIngestRunning();
54 ingestWarningLabel.setVisible(ingestRunning);
55 skipNSRLCheckBox.setEnabled(!ingestRunning);
56 ocrCheckBox.setEnabled(!ingestRunning);
57 setTimeSettingEnabled(!ingestRunning);
59 final UpdateFrequency curFreq = KeywordSearchSettings.getUpdateFrequency();
62 timeRadioButton1.setSelected(
true);
65 timeRadioButton2.setSelected(
true);
68 timeRadioButton3.setSelected(
true);
71 timeRadioButton4.setSelected(
true);
74 timeRadioButton5.setSelected(
true);
79 timeRadioButton3.setSelected(
true);
89 @SuppressWarnings(
"unchecked")
91 private
void initComponents() {
93 timeGroup =
new javax.swing.ButtonGroup();
94 skipNSRLCheckBox =
new javax.swing.JCheckBox();
95 filesIndexedLabel =
new javax.swing.JLabel();
96 filesIndexedValue =
new javax.swing.JLabel();
97 chunksLabel =
new javax.swing.JLabel();
98 chunksValLabel =
new javax.swing.JLabel();
99 settingsLabel =
new javax.swing.JLabel();
100 informationLabel =
new javax.swing.JLabel();
101 settingsSeparator =
new javax.swing.JSeparator();
102 informationSeparator =
new javax.swing.JSeparator();
103 frequencyLabel =
new javax.swing.JLabel();
104 timeRadioButton1 =
new javax.swing.JRadioButton();
105 timeRadioButton2 =
new javax.swing.JRadioButton();
106 timeRadioButton3 =
new javax.swing.JRadioButton();
107 timeRadioButton4 =
new javax.swing.JRadioButton();
108 showSnippetsCB =
new javax.swing.JCheckBox();
109 timeRadioButton5 =
new javax.swing.JRadioButton();
110 ingestWarningLabel =
new javax.swing.JLabel();
111 ocrCheckBox =
new javax.swing.JCheckBox();
113 skipNSRLCheckBox.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.text"));
114 skipNSRLCheckBox.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.toolTipText"));
115 skipNSRLCheckBox.addActionListener(
new java.awt.event.ActionListener() {
116 public void actionPerformed(java.awt.event.ActionEvent evt) {
117 skipNSRLCheckBoxActionPerformed(evt);
121 filesIndexedLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedLabel.text"));
123 filesIndexedValue.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedValue.text"));
125 chunksLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.chunksLabel.text"));
127 chunksValLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.chunksValLabel.text"));
129 settingsLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.settingsLabel.text"));
131 informationLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.informationLabel.text"));
133 frequencyLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.frequencyLabel.text"));
135 timeRadioButton1.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.text"));
136 timeRadioButton1.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.toolTipText"));
137 timeRadioButton1.addActionListener(
new java.awt.event.ActionListener() {
138 public void actionPerformed(java.awt.event.ActionEvent evt) {
139 timeRadioButton1ActionPerformed(evt);
143 timeRadioButton2.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.text"));
144 timeRadioButton2.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.toolTipText"));
145 timeRadioButton2.addActionListener(
new java.awt.event.ActionListener() {
146 public void actionPerformed(java.awt.event.ActionEvent evt) {
147 timeRadioButton2ActionPerformed(evt);
151 timeRadioButton3.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.text"));
152 timeRadioButton3.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.toolTipText"));
153 timeRadioButton3.addActionListener(
new java.awt.event.ActionListener() {
154 public void actionPerformed(java.awt.event.ActionEvent evt) {
155 timeRadioButton3ActionPerformed(evt);
159 timeRadioButton4.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.text_1"));
160 timeRadioButton4.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.toolTipText"));
161 timeRadioButton4.addActionListener(
new java.awt.event.ActionListener() {
162 public void actionPerformed(java.awt.event.ActionEvent evt) {
163 timeRadioButton4ActionPerformed(evt);
167 showSnippetsCB.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.showSnippetsCB.text"));
168 showSnippetsCB.addActionListener(
new java.awt.event.ActionListener() {
169 public void actionPerformed(java.awt.event.ActionEvent evt) {
170 showSnippetsCBActionPerformed(evt);
174 timeRadioButton5.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.text"));
175 timeRadioButton5.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.toolTipText"));
176 timeRadioButton5.addActionListener(
new java.awt.event.ActionListener() {
177 public void actionPerformed(java.awt.event.ActionEvent evt) {
178 timeRadioButton5ActionPerformed(evt);
182 ingestWarningLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png")));
183 ingestWarningLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.ingestWarningLabel.text"));
185 ocrCheckBox.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.ocrCheckBox.text"));
186 ocrCheckBox.addActionListener(
new java.awt.event.ActionListener() {
187 public void actionPerformed(java.awt.event.ActionEvent evt) {
188 ocrCheckBoxActionPerformed(evt);
192 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
193 this.setLayout(layout);
194 layout.setHorizontalGroup(
195 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
196 .addGroup(layout.createSequentialGroup()
198 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
199 .addComponent(ingestWarningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
200 .addGroup(layout.createSequentialGroup()
201 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
202 .addGroup(layout.createSequentialGroup()
203 .addComponent(settingsLabel)
204 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
205 .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE))
206 .addGroup(layout.createSequentialGroup()
208 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
209 .addComponent(skipNSRLCheckBox)
210 .addComponent(showSnippetsCB)
211 .addComponent(ocrCheckBox)))
212 .addGroup(layout.createSequentialGroup()
213 .addComponent(informationLabel)
214 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
215 .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE))
216 .addGroup(layout.createSequentialGroup()
218 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
219 .addGroup(layout.createSequentialGroup()
220 .addComponent(filesIndexedLabel)
222 .addComponent(filesIndexedValue))
223 .addComponent(frequencyLabel)
224 .addGroup(layout.createSequentialGroup()
226 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
227 .addComponent(timeRadioButton2)
228 .addComponent(timeRadioButton1)
229 .addComponent(timeRadioButton3)
230 .addComponent(timeRadioButton4)
231 .addComponent(timeRadioButton5)))
232 .addGroup(layout.createSequentialGroup()
233 .addComponent(chunksLabel)
235 .addComponent(chunksValLabel)))))
236 .addGap(0, 0, Short.MAX_VALUE)))
240 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {chunksLabel, filesIndexedLabel});
242 layout.setVerticalGroup(
243 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
244 .addGroup(layout.createSequentialGroup()
246 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
247 .addComponent(settingsLabel)
248 .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE))
249 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
250 .addComponent(skipNSRLCheckBox)
251 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
252 .addComponent(showSnippetsCB)
253 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
254 .addComponent(ocrCheckBox)
255 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
256 .addComponent(frequencyLabel)
257 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
258 .addComponent(timeRadioButton1)
259 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
260 .addComponent(timeRadioButton2)
261 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
262 .addComponent(timeRadioButton3)
263 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
264 .addComponent(timeRadioButton4)
265 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
266 .addComponent(timeRadioButton5)
267 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
268 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
269 .addComponent(informationLabel)
270 .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE))
271 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
272 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
273 .addComponent(filesIndexedLabel)
274 .addComponent(filesIndexedValue))
275 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
276 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
277 .addComponent(chunksLabel)
278 .addComponent(chunksValLabel))
279 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
280 .addComponent(ingestWarningLabel)
281 .addContainerGap(43, Short.MAX_VALUE))
285 private void timeRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {
286 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
289 private void skipNSRLCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
290 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
293 private void showSnippetsCBActionPerformed(java.awt.event.ActionEvent evt) {
294 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
297 private void timeRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
298 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
301 private void timeRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
302 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
305 private void timeRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {
306 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
309 private void timeRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {
310 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
313 private void ocrCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
314 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
318 private javax.swing.JLabel chunksLabel;
319 private javax.swing.JLabel chunksValLabel;
320 private javax.swing.JLabel filesIndexedLabel;
321 private javax.swing.JLabel filesIndexedValue;
322 private javax.swing.JLabel frequencyLabel;
323 private javax.swing.JLabel informationLabel;
324 private javax.swing.JSeparator informationSeparator;
325 private javax.swing.JLabel ingestWarningLabel;
326 private javax.swing.JCheckBox ocrCheckBox;
327 private javax.swing.JLabel settingsLabel;
328 private javax.swing.JSeparator settingsSeparator;
329 private javax.swing.JCheckBox showSnippetsCB;
330 private javax.swing.JCheckBox skipNSRLCheckBox;
331 private javax.swing.ButtonGroup timeGroup;
332 private javax.swing.JRadioButton timeRadioButton1;
333 private javax.swing.JRadioButton timeRadioButton2;
334 private javax.swing.JRadioButton timeRadioButton3;
335 private javax.swing.JRadioButton timeRadioButton4;
336 private javax.swing.JRadioButton timeRadioButton5;
340 public void store() {
341 KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
342 KeywordSearchSettings.setUpdateFrequency(getSelectedTimeValue());
343 KeywordSearchSettings.setShowSnippets(showSnippetsCB.isSelected());
344 KeywordSearchSettings.setOcrOption(ocrCheckBox.isSelected());
352 private void setTimeSettingEnabled(
boolean enabled) {
353 timeRadioButton1.setEnabled(enabled);
354 timeRadioButton2.setEnabled(enabled);
355 timeRadioButton3.setEnabled(enabled);
356 timeRadioButton4.setEnabled(enabled);
357 timeRadioButton5.setEnabled(enabled);
358 frequencyLabel.setEnabled(enabled);
361 private UpdateFrequency getSelectedTimeValue() {
362 if (timeRadioButton1.isSelected()) {
363 return UpdateFrequency.FAST;
364 }
else if (timeRadioButton2.isSelected()) {
365 return UpdateFrequency.AVG;
366 }
else if (timeRadioButton3.isSelected()) {
367 return UpdateFrequency.SLOW;
368 }
else if (timeRadioButton4.isSelected()) {
369 return UpdateFrequency.SLOWEST;
370 }
else if (timeRadioButton5.isSelected()) {
371 return UpdateFrequency.NONE;
373 return UpdateFrequency.DEFAULT;
376 @NbBundle.Messages({
"KeywordSearchGlobalSearchSettingsPanel.customizeComponents.windowsOCR=Enable Optical Character Recognition (OCR) (Requires Windows 64-bit)"})
377 private void customizeComponents() {
379 timeGroup.add(timeRadioButton1);
380 timeGroup.add(timeRadioButton2);
381 timeGroup.add(timeRadioButton3);
382 timeGroup.add(timeRadioButton4);
383 timeGroup.add(timeRadioButton5);
385 this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
388 filesIndexedValue.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedFiles()));
389 chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
390 }
catch (KeywordSearchModuleException | NoOpenCoreException ex) {
391 logger.log(Level.WARNING,
"Could not get number of indexed files/chunks");
394 if (!PlatformUtil.isWindowsOS() || !PlatformUtil.is64BitOS()) {
395 ocrCheckBox.setText(Bundle.KeywordSearchGlobalSearchSettingsPanel_customizeComponents_windowsOCR());
396 ocrCheckBox.setSelected(
false);
397 ocrCheckBox.setEnabled(
false);
400 KeywordSearch.addNumIndexedFilesChangeListener(
401 new PropertyChangeListener() {
403 public void propertyChange(PropertyChangeEvent evt) {
404 String changed = evt.getPropertyName();
405 Object newValue = evt.getNewValue();
407 if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
408 int newFilesIndexed = ((Integer) newValue);
409 filesIndexedValue.setText(Integer.toString(newFilesIndexed));
411 chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
412 }
catch (KeywordSearchModuleException | NoOpenCoreException ex) {
413 logger.log(Level.WARNING,
"Could not get number of indexed chunks");
421 IngestManager.getInstance().addIngestJobEventListener(
new PropertyChangeListener() {
423 public void propertyChange(PropertyChangeEvent evt) {
424 Object source = evt.getSource();
425 if (source instanceof String && ((String) source).equals(
"LOCAL")) {
426 EventQueue.invokeLater(() -> {