Autopsy  4.16.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
KeywordSearchGlobalSearchSettingsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2012-2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.keywordsearch;
20 
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;
30 
34 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
35 class KeywordSearchGlobalSearchSettingsPanel extends javax.swing.JPanel implements OptionsPanel {
36 
37  private final Logger logger = Logger.getLogger(KeywordSearchGlobalSearchSettingsPanel.class.getName());
38 
42  KeywordSearchGlobalSearchSettingsPanel() {
43  initComponents();
44  customizeComponents();
45  }
46 
47  private void activateWidgets() {
48  skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
49  showSnippetsCB.setSelected(KeywordSearchSettings.getShowSnippets());
50  boolean ingestRunning = IngestManager.getInstance().isIngestRunning();
51  ingestWarningLabel.setVisible(ingestRunning);
52  skipNSRLCheckBox.setEnabled(!ingestRunning);
53  setTimeSettingEnabled(!ingestRunning);
54 
55  final UpdateFrequency curFreq = KeywordSearchSettings.getUpdateFrequency();
56  switch (curFreq) {
57  case FAST:
58  timeRadioButton1.setSelected(true);
59  break;
60  case AVG:
61  timeRadioButton2.setSelected(true);
62  break;
63  case SLOW:
64  timeRadioButton3.setSelected(true);
65  break;
66  case SLOWEST:
67  timeRadioButton4.setSelected(true);
68  break;
69  case NONE:
70  timeRadioButton5.setSelected(true);
71  break;
72  case DEFAULT:
73  default:
74  // default value
75  timeRadioButton3.setSelected(true);
76  break;
77  }
78  }
79 
85  @SuppressWarnings("unchecked")
86  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
87  private void initComponents() {
88 
89  timeGroup = new javax.swing.ButtonGroup();
90  skipNSRLCheckBox = new javax.swing.JCheckBox();
91  filesIndexedLabel = new javax.swing.JLabel();
92  filesIndexedValue = new javax.swing.JLabel();
93  chunksLabel = new javax.swing.JLabel();
94  chunksValLabel = new javax.swing.JLabel();
95  settingsLabel = new javax.swing.JLabel();
96  informationLabel = new javax.swing.JLabel();
97  settingsSeparator = new javax.swing.JSeparator();
98  informationSeparator = new javax.swing.JSeparator();
99  frequencyLabel = new javax.swing.JLabel();
100  timeRadioButton1 = new javax.swing.JRadioButton();
101  timeRadioButton2 = new javax.swing.JRadioButton();
102  timeRadioButton3 = new javax.swing.JRadioButton();
103  timeRadioButton4 = new javax.swing.JRadioButton();
104  showSnippetsCB = new javax.swing.JCheckBox();
105  timeRadioButton5 = new javax.swing.JRadioButton();
106  ingestWarningLabel = new javax.swing.JLabel();
107 
108  skipNSRLCheckBox.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.text")); // NOI18N
109  skipNSRLCheckBox.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.toolTipText")); // NOI18N
110  skipNSRLCheckBox.addActionListener(new java.awt.event.ActionListener() {
111  public void actionPerformed(java.awt.event.ActionEvent evt) {
112  skipNSRLCheckBoxActionPerformed(evt);
113  }
114  });
115 
116  filesIndexedLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.filesIndexedLabel.text")); // NOI18N
117 
118  filesIndexedValue.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.filesIndexedValue.text")); // NOI18N
119 
120  chunksLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.chunksLabel.text")); // NOI18N
121 
122  chunksValLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.chunksValLabel.text")); // NOI18N
123 
124  settingsLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.settingsLabel.text")); // NOI18N
125 
126  informationLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.informationLabel.text")); // NOI18N
127 
128  frequencyLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.frequencyLabel.text")); // NOI18N
129 
130  timeRadioButton1.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.text")); // NOI18N
131  timeRadioButton1.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.toolTipText")); // NOI18N
132  timeRadioButton1.addActionListener(new java.awt.event.ActionListener() {
133  public void actionPerformed(java.awt.event.ActionEvent evt) {
134  timeRadioButton1ActionPerformed(evt);
135  }
136  });
137 
138  timeRadioButton2.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.text")); // NOI18N
139  timeRadioButton2.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.toolTipText")); // NOI18N
140  timeRadioButton2.addActionListener(new java.awt.event.ActionListener() {
141  public void actionPerformed(java.awt.event.ActionEvent evt) {
142  timeRadioButton2ActionPerformed(evt);
143  }
144  });
145 
146  timeRadioButton3.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.text")); // NOI18N
147  timeRadioButton3.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.toolTipText")); // NOI18N
148  timeRadioButton3.addActionListener(new java.awt.event.ActionListener() {
149  public void actionPerformed(java.awt.event.ActionEvent evt) {
150  timeRadioButton3ActionPerformed(evt);
151  }
152  });
153 
154  timeRadioButton4.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.text_1")); // NOI18N
155  timeRadioButton4.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.toolTipText")); // NOI18N
156  timeRadioButton4.addActionListener(new java.awt.event.ActionListener() {
157  public void actionPerformed(java.awt.event.ActionEvent evt) {
158  timeRadioButton4ActionPerformed(evt);
159  }
160  });
161 
162  showSnippetsCB.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.showSnippetsCB.text")); // NOI18N
163  showSnippetsCB.addActionListener(new java.awt.event.ActionListener() {
164  public void actionPerformed(java.awt.event.ActionEvent evt) {
165  showSnippetsCBActionPerformed(evt);
166  }
167  });
168 
169  timeRadioButton5.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.text")); // NOI18N
170  timeRadioButton5.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.toolTipText")); // NOI18N
171  timeRadioButton5.addActionListener(new java.awt.event.ActionListener() {
172  public void actionPerformed(java.awt.event.ActionEvent evt) {
173  timeRadioButton5ActionPerformed(evt);
174  }
175  });
176 
177  ingestWarningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png"))); // NOI18N
178  ingestWarningLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.ingestWarningLabel.text")); // NOI18N
179 
180  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
181  this.setLayout(layout);
182  layout.setHorizontalGroup(
183  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
184  .addGroup(layout.createSequentialGroup()
185  .addContainerGap()
186  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
187  .addGroup(layout.createSequentialGroup()
188  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
189  .addGroup(layout.createSequentialGroup()
190  .addComponent(settingsLabel)
191  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
192  .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE))
193  .addGroup(layout.createSequentialGroup()
194  .addComponent(informationLabel)
195  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
196  .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE))
197  .addGroup(layout.createSequentialGroup()
198  .addGap(10, 10, 10)
199  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
200  .addComponent(skipNSRLCheckBox)
201  .addComponent(showSnippetsCB)
202  .addGroup(layout.createSequentialGroup()
203  .addComponent(filesIndexedLabel)
204  .addGap(18, 18, 18)
205  .addComponent(filesIndexedValue))
206  .addComponent(frequencyLabel)
207  .addGroup(layout.createSequentialGroup()
208  .addGap(10, 10, 10)
209  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
210  .addComponent(timeRadioButton2)
211  .addComponent(timeRadioButton1)
212  .addComponent(timeRadioButton3)
213  .addComponent(timeRadioButton4)
214  .addComponent(timeRadioButton5)))
215  .addGroup(layout.createSequentialGroup()
216  .addComponent(chunksLabel)
217  .addGap(18, 18, 18)
218  .addComponent(chunksValLabel)))))
219  .addGap(0, 0, Short.MAX_VALUE))
220  .addComponent(ingestWarningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
221  .addContainerGap())
222  );
223 
224  layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {chunksLabel, filesIndexedLabel});
225 
226  layout.setVerticalGroup(
227  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
228  .addGroup(layout.createSequentialGroup()
229  .addContainerGap()
230  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
231  .addComponent(settingsLabel)
232  .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE))
233  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
234  .addComponent(skipNSRLCheckBox)
235  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
236  .addComponent(showSnippetsCB)
237  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
238  .addComponent(frequencyLabel)
239  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
240  .addComponent(timeRadioButton1)
241  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
242  .addComponent(timeRadioButton2)
243  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
244  .addComponent(timeRadioButton3)
245  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
246  .addComponent(timeRadioButton4)
247  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
248  .addComponent(timeRadioButton5)
249  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
250  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
251  .addComponent(informationLabel)
252  .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE))
253  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
254  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
255  .addComponent(filesIndexedLabel)
256  .addComponent(filesIndexedValue))
257  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
258  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
259  .addComponent(chunksLabel)
260  .addComponent(chunksValLabel))
261  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
262  .addComponent(ingestWarningLabel)
263  .addContainerGap(66, Short.MAX_VALUE))
264  );
265  }// </editor-fold>//GEN-END:initComponents
266 
267  private void timeRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton5ActionPerformed
268  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
269  }//GEN-LAST:event_timeRadioButton5ActionPerformed
270 
271  private void skipNSRLCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skipNSRLCheckBoxActionPerformed
272  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
273  }//GEN-LAST:event_skipNSRLCheckBoxActionPerformed
274 
275  private void showSnippetsCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showSnippetsCBActionPerformed
276  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
277  }//GEN-LAST:event_showSnippetsCBActionPerformed
278 
279  private void timeRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton1ActionPerformed
280  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
281  }//GEN-LAST:event_timeRadioButton1ActionPerformed
282 
283  private void timeRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton2ActionPerformed
284  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
285  }//GEN-LAST:event_timeRadioButton2ActionPerformed
286 
287  private void timeRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton3ActionPerformed
288  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
289  }//GEN-LAST:event_timeRadioButton3ActionPerformed
290 
291  private void timeRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton4ActionPerformed
292  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
293  }//GEN-LAST:event_timeRadioButton4ActionPerformed
294 
295  // Variables declaration - do not modify//GEN-BEGIN:variables
296  private javax.swing.JLabel chunksLabel;
297  private javax.swing.JLabel chunksValLabel;
298  private javax.swing.JLabel filesIndexedLabel;
299  private javax.swing.JLabel filesIndexedValue;
300  private javax.swing.JLabel frequencyLabel;
301  private javax.swing.JLabel informationLabel;
302  private javax.swing.JSeparator informationSeparator;
303  private javax.swing.JLabel ingestWarningLabel;
304  private javax.swing.JLabel settingsLabel;
305  private javax.swing.JSeparator settingsSeparator;
306  private javax.swing.JCheckBox showSnippetsCB;
307  private javax.swing.JCheckBox skipNSRLCheckBox;
308  private javax.swing.ButtonGroup timeGroup;
309  private javax.swing.JRadioButton timeRadioButton1;
310  private javax.swing.JRadioButton timeRadioButton2;
311  private javax.swing.JRadioButton timeRadioButton3;
312  private javax.swing.JRadioButton timeRadioButton4;
313  private javax.swing.JRadioButton timeRadioButton5;
314  // End of variables declaration//GEN-END:variables
315 
316  @Override
317  public void store() {
318  KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
319  KeywordSearchSettings.setUpdateFrequency(getSelectedTimeValue());
320  KeywordSearchSettings.setShowSnippets(showSnippetsCB.isSelected());
321  }
322 
323  @Override
324  public void load() {
325  activateWidgets();
326  }
327 
328  private void setTimeSettingEnabled(boolean enabled) {
329  timeRadioButton1.setEnabled(enabled);
330  timeRadioButton2.setEnabled(enabled);
331  timeRadioButton3.setEnabled(enabled);
332  timeRadioButton4.setEnabled(enabled);
333  timeRadioButton5.setEnabled(enabled);
334  frequencyLabel.setEnabled(enabled);
335  }
336 
337  private UpdateFrequency getSelectedTimeValue() {
338  if (timeRadioButton1.isSelected()) {
339  return UpdateFrequency.FAST;
340  } else if (timeRadioButton2.isSelected()) {
341  return UpdateFrequency.AVG;
342  } else if (timeRadioButton3.isSelected()) {
343  return UpdateFrequency.SLOW;
344  } else if (timeRadioButton4.isSelected()) {
345  return UpdateFrequency.SLOWEST;
346  } else if (timeRadioButton5.isSelected()) {
347  return UpdateFrequency.NONE;
348  }
349  return UpdateFrequency.DEFAULT;
350  }
351 
352  private void customizeComponents() {
353 
354  timeGroup.add(timeRadioButton1);
355  timeGroup.add(timeRadioButton2);
356  timeGroup.add(timeRadioButton3);
357  timeGroup.add(timeRadioButton4);
358  timeGroup.add(timeRadioButton5);
359 
360  this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
361 
362  try {
363  filesIndexedValue.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedFiles()));
364  chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
365  } catch (KeywordSearchModuleException | NoOpenCoreException ex) {
366  logger.log(Level.WARNING, "Could not get number of indexed files/chunks"); //NON-NLS
367  }
368 
369  KeywordSearch.addNumIndexedFilesChangeListener(
370  new PropertyChangeListener() {
371  @Override
372  public void propertyChange(PropertyChangeEvent evt) {
373  String changed = evt.getPropertyName();
374  Object newValue = evt.getNewValue();
375 
376  if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
377  int newFilesIndexed = ((Integer) newValue);
378  filesIndexedValue.setText(Integer.toString(newFilesIndexed));
379  try {
380  chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
381  } catch (KeywordSearchModuleException | NoOpenCoreException ex) {
382  logger.log(Level.WARNING, "Could not get number of indexed chunks"); //NON-NLS
383 
384  }
385  }
386  }
387  });
388 
389  //allow panel to toggle its enabled status while it is open based on ingest events
390  IngestManager.getInstance().addIngestJobEventListener(new PropertyChangeListener() {
391  @Override
392  public void propertyChange(PropertyChangeEvent evt) {
393  Object source = evt.getSource();
394  if (source instanceof String && ((String) source).equals("LOCAL")) { //NON-NLS
395  EventQueue.invokeLater(() -> {
396  activateWidgets();
397  });
398  }
399  }
400  });
401  }
402 }

Copyright © 2012-2020 Basis Technology. Generated on: Tue Sep 22 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.