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 boolean ingestRunning = IngestManager.getInstance().isIngestRunning();
54 ingestWarningLabel.setVisible(ingestRunning);
55 skipNSRLCheckBox.setEnabled(!ingestRunning);
56 setTimeSettingEnabled(!ingestRunning);
58 final UpdateFrequency curFreq = KeywordSearchSettings.getUpdateFrequency();
61 timeRadioButton1.setSelected(
true);
64 timeRadioButton2.setSelected(
true);
67 timeRadioButton3.setSelected(
true);
70 timeRadioButton4.setSelected(
true);
73 timeRadioButton5.setSelected(
true);
78 timeRadioButton3.setSelected(
true);
88 @SuppressWarnings(
"unchecked")
90 private
void initComponents() {
92 timeGroup =
new javax.swing.ButtonGroup();
93 skipNSRLCheckBox =
new javax.swing.JCheckBox();
94 filesIndexedLabel =
new javax.swing.JLabel();
95 filesIndexedValue =
new javax.swing.JLabel();
96 chunksLabel =
new javax.swing.JLabel();
97 chunksValLabel =
new javax.swing.JLabel();
98 settingsLabel =
new javax.swing.JLabel();
99 informationLabel =
new javax.swing.JLabel();
100 settingsSeparator =
new javax.swing.JSeparator();
101 informationSeparator =
new javax.swing.JSeparator();
102 frequencyLabel =
new javax.swing.JLabel();
103 timeRadioButton1 =
new javax.swing.JRadioButton();
104 timeRadioButton2 =
new javax.swing.JRadioButton();
105 timeRadioButton3 =
new javax.swing.JRadioButton();
106 timeRadioButton4 =
new javax.swing.JRadioButton();
107 showSnippetsCB =
new javax.swing.JCheckBox();
108 timeRadioButton5 =
new javax.swing.JRadioButton();
109 ingestWarningLabel =
new javax.swing.JLabel();
111 skipNSRLCheckBox.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.text"));
112 skipNSRLCheckBox.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.toolTipText"));
113 skipNSRLCheckBox.addActionListener(
new java.awt.event.ActionListener() {
114 public void actionPerformed(java.awt.event.ActionEvent evt) {
115 skipNSRLCheckBoxActionPerformed(evt);
119 filesIndexedLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedLabel.text"));
121 filesIndexedValue.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedValue.text"));
123 chunksLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.chunksLabel.text"));
125 chunksValLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.chunksValLabel.text"));
127 settingsLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.settingsLabel.text"));
129 informationLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.informationLabel.text"));
131 frequencyLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.frequencyLabel.text"));
133 timeRadioButton1.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.text"));
134 timeRadioButton1.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.toolTipText"));
135 timeRadioButton1.addActionListener(
new java.awt.event.ActionListener() {
136 public void actionPerformed(java.awt.event.ActionEvent evt) {
137 timeRadioButton1ActionPerformed(evt);
141 timeRadioButton2.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.text"));
142 timeRadioButton2.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.toolTipText"));
143 timeRadioButton2.addActionListener(
new java.awt.event.ActionListener() {
144 public void actionPerformed(java.awt.event.ActionEvent evt) {
145 timeRadioButton2ActionPerformed(evt);
149 timeRadioButton3.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.text"));
150 timeRadioButton3.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.toolTipText"));
151 timeRadioButton3.addActionListener(
new java.awt.event.ActionListener() {
152 public void actionPerformed(java.awt.event.ActionEvent evt) {
153 timeRadioButton3ActionPerformed(evt);
157 timeRadioButton4.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.text_1"));
158 timeRadioButton4.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.toolTipText"));
159 timeRadioButton4.addActionListener(
new java.awt.event.ActionListener() {
160 public void actionPerformed(java.awt.event.ActionEvent evt) {
161 timeRadioButton4ActionPerformed(evt);
165 showSnippetsCB.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.showSnippetsCB.text"));
166 showSnippetsCB.addActionListener(
new java.awt.event.ActionListener() {
167 public void actionPerformed(java.awt.event.ActionEvent evt) {
168 showSnippetsCBActionPerformed(evt);
172 timeRadioButton5.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.text"));
173 timeRadioButton5.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.toolTipText"));
174 timeRadioButton5.addActionListener(
new java.awt.event.ActionListener() {
175 public void actionPerformed(java.awt.event.ActionEvent evt) {
176 timeRadioButton5ActionPerformed(evt);
180 ingestWarningLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png")));
181 ingestWarningLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.ingestWarningLabel.text"));
183 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
184 this.setLayout(layout);
185 layout.setHorizontalGroup(
186 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
187 .addGroup(layout.createSequentialGroup()
189 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
190 .addGroup(layout.createSequentialGroup()
192 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
193 .addComponent(skipNSRLCheckBox)
194 .addComponent(showSnippetsCB))
195 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
196 .addGroup(layout.createSequentialGroup()
197 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
198 .addComponent(ingestWarningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
199 .addGroup(layout.createSequentialGroup()
200 .addComponent(informationLabel)
201 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
202 .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE))
203 .addGroup(layout.createSequentialGroup()
205 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
206 .addGroup(layout.createSequentialGroup()
207 .addComponent(filesIndexedLabel)
209 .addComponent(filesIndexedValue))
210 .addComponent(frequencyLabel)
211 .addGroup(layout.createSequentialGroup()
212 .addComponent(chunksLabel)
214 .addComponent(chunksValLabel))
215 .addGroup(layout.createSequentialGroup()
217 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
218 .addComponent(timeRadioButton2)
219 .addComponent(timeRadioButton1)
220 .addComponent(timeRadioButton3)
221 .addComponent(timeRadioButton4)
222 .addComponent(timeRadioButton5))))))
223 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
224 .addGroup(layout.createSequentialGroup()
225 .addComponent(settingsLabel)
226 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
227 .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE)
228 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
231 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {chunksLabel, filesIndexedLabel});
233 layout.setVerticalGroup(
234 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
235 .addGroup(layout.createSequentialGroup()
237 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
238 .addComponent(settingsLabel)
239 .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE))
240 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
241 .addComponent(skipNSRLCheckBox)
242 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
243 .addComponent(showSnippetsCB)
244 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
245 .addComponent(frequencyLabel)
246 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
247 .addComponent(timeRadioButton1)
248 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
249 .addComponent(timeRadioButton2)
250 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
251 .addComponent(timeRadioButton3)
252 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
253 .addComponent(timeRadioButton4)
254 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
255 .addComponent(timeRadioButton5)
256 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
257 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
258 .addComponent(informationLabel)
259 .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE))
260 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
261 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
262 .addComponent(filesIndexedLabel)
263 .addComponent(filesIndexedValue))
264 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
265 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
266 .addComponent(chunksLabel)
267 .addComponent(chunksValLabel))
268 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
269 .addComponent(ingestWarningLabel)
270 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
274 private void timeRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {
275 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
278 private void skipNSRLCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
279 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
282 private void showSnippetsCBActionPerformed(java.awt.event.ActionEvent evt) {
283 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
286 private void timeRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
287 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
290 private void timeRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
291 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
294 private void timeRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {
295 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
298 private void timeRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {
299 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
303 private javax.swing.JLabel chunksLabel;
304 private javax.swing.JLabel chunksValLabel;
305 private javax.swing.JLabel filesIndexedLabel;
306 private javax.swing.JLabel filesIndexedValue;
307 private javax.swing.JLabel frequencyLabel;
308 private javax.swing.JLabel informationLabel;
309 private javax.swing.JSeparator informationSeparator;
310 private javax.swing.JLabel ingestWarningLabel;
311 private javax.swing.JLabel settingsLabel;
312 private javax.swing.JSeparator settingsSeparator;
313 private javax.swing.JCheckBox showSnippetsCB;
314 private javax.swing.JCheckBox skipNSRLCheckBox;
315 private javax.swing.ButtonGroup timeGroup;
316 private javax.swing.JRadioButton timeRadioButton1;
317 private javax.swing.JRadioButton timeRadioButton2;
318 private javax.swing.JRadioButton timeRadioButton3;
319 private javax.swing.JRadioButton timeRadioButton4;
320 private javax.swing.JRadioButton timeRadioButton5;
324 public void store() {
325 KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
326 KeywordSearchSettings.setUpdateFrequency(getSelectedTimeValue());
327 KeywordSearchSettings.setShowSnippets(showSnippetsCB.isSelected());
335 private void setTimeSettingEnabled(
boolean enabled) {
336 timeRadioButton1.setEnabled(enabled);
337 timeRadioButton2.setEnabled(enabled);
338 timeRadioButton3.setEnabled(enabled);
339 timeRadioButton4.setEnabled(enabled);
340 timeRadioButton5.setEnabled(enabled);
341 frequencyLabel.setEnabled(enabled);
344 private UpdateFrequency getSelectedTimeValue() {
345 if (timeRadioButton1.isSelected()) {
346 return UpdateFrequency.FAST;
347 }
else if (timeRadioButton2.isSelected()) {
348 return UpdateFrequency.AVG;
349 }
else if (timeRadioButton3.isSelected()) {
350 return UpdateFrequency.SLOW;
351 }
else if (timeRadioButton4.isSelected()) {
352 return UpdateFrequency.SLOWEST;
353 }
else if (timeRadioButton5.isSelected()) {
354 return UpdateFrequency.NONE;
356 return UpdateFrequency.DEFAULT;
359 @NbBundle.Messages({
"KeywordSearchGlobalSearchSettingsPanel.customizeComponents.windowsOCR=Enable Optical Character Recognition (OCR) (Requires Windows 64-bit)",
360 "KeywordSearchGlobalSearchSettingsPanel.customizeComponents.windowsLimitedOCR=Only process images which are over 100KB in size or extracted from a document. (Beta) (Requires Windows 64-bit)"})
361 private void customizeComponents() {
363 timeGroup.add(timeRadioButton1);
364 timeGroup.add(timeRadioButton2);
365 timeGroup.add(timeRadioButton3);
366 timeGroup.add(timeRadioButton4);
367 timeGroup.add(timeRadioButton5);
369 this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
372 filesIndexedValue.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedFiles()));
373 chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
374 }
catch (KeywordSearchModuleException | NoOpenCoreException ex) {
375 logger.log(Level.WARNING,
"Could not get number of indexed files/chunks");
378 KeywordSearch.addNumIndexedFilesChangeListener(
379 new PropertyChangeListener() {
381 public void propertyChange(PropertyChangeEvent evt) {
382 String changed = evt.getPropertyName();
383 Object newValue = evt.getNewValue();
385 if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
386 int newFilesIndexed = ((Integer) newValue);
387 filesIndexedValue.setText(Integer.toString(newFilesIndexed));
389 chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
390 }
catch (KeywordSearchModuleException | NoOpenCoreException ex) {
391 logger.log(Level.WARNING,
"Could not get number of indexed chunks");
399 IngestManager.getInstance().addIngestJobEventListener(
new PropertyChangeListener() {
401 public void propertyChange(PropertyChangeEvent evt) {
402 Object source = evt.getSource();
403 if (source instanceof String && ((String) source).equals(
"LOCAL")) {
404 EventQueue.invokeLater(() -> {