Autopsy  4.11.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.setFont(ingestWarningLabel.getFont().deriveFont(ingestWarningLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
178  ingestWarningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png"))); // NOI18N
179  ingestWarningLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.ingestWarningLabel.text")); // NOI18N
180 
181  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
182  this.setLayout(layout);
183  layout.setHorizontalGroup(
184  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
185  .addGroup(layout.createSequentialGroup()
186  .addContainerGap()
187  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
188  .addGroup(layout.createSequentialGroup()
189  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
190  .addGroup(layout.createSequentialGroup()
191  .addComponent(settingsLabel)
192  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
193  .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE))
194  .addGroup(layout.createSequentialGroup()
195  .addComponent(informationLabel)
196  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
197  .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE))
198  .addGroup(layout.createSequentialGroup()
199  .addGap(10, 10, 10)
200  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
201  .addComponent(skipNSRLCheckBox)
202  .addComponent(showSnippetsCB)
203  .addGroup(layout.createSequentialGroup()
204  .addComponent(filesIndexedLabel)
205  .addGap(18, 18, 18)
206  .addComponent(filesIndexedValue))
207  .addComponent(frequencyLabel)
208  .addGroup(layout.createSequentialGroup()
209  .addGap(10, 10, 10)
210  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
211  .addComponent(timeRadioButton2)
212  .addComponent(timeRadioButton1)
213  .addComponent(timeRadioButton3)
214  .addComponent(timeRadioButton4)
215  .addComponent(timeRadioButton5)))
216  .addGroup(layout.createSequentialGroup()
217  .addComponent(chunksLabel)
218  .addGap(18, 18, 18)
219  .addComponent(chunksValLabel)))))
220  .addGap(0, 0, Short.MAX_VALUE))
221  .addComponent(ingestWarningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
222  .addContainerGap())
223  );
224 
225  layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {chunksLabel, filesIndexedLabel});
226 
227  layout.setVerticalGroup(
228  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
229  .addGroup(layout.createSequentialGroup()
230  .addContainerGap()
231  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
232  .addComponent(settingsLabel)
233  .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE))
234  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
235  .addComponent(skipNSRLCheckBox)
236  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
237  .addComponent(showSnippetsCB)
238  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
239  .addComponent(frequencyLabel)
240  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
241  .addComponent(timeRadioButton1)
242  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
243  .addComponent(timeRadioButton2)
244  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
245  .addComponent(timeRadioButton3)
246  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
247  .addComponent(timeRadioButton4)
248  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
249  .addComponent(timeRadioButton5)
250  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
251  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
252  .addComponent(informationLabel)
253  .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE))
254  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
255  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
256  .addComponent(filesIndexedLabel)
257  .addComponent(filesIndexedValue))
258  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
259  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
260  .addComponent(chunksLabel)
261  .addComponent(chunksValLabel))
262  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
263  .addComponent(ingestWarningLabel)
264  .addContainerGap(66, Short.MAX_VALUE))
265  );
266  }// </editor-fold>//GEN-END:initComponents
267 
268  private void timeRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton5ActionPerformed
269  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
270  }//GEN-LAST:event_timeRadioButton5ActionPerformed
271 
272  private void skipNSRLCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skipNSRLCheckBoxActionPerformed
273  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
274  }//GEN-LAST:event_skipNSRLCheckBoxActionPerformed
275 
276  private void showSnippetsCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showSnippetsCBActionPerformed
277  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
278  }//GEN-LAST:event_showSnippetsCBActionPerformed
279 
280  private void timeRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton1ActionPerformed
281  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
282  }//GEN-LAST:event_timeRadioButton1ActionPerformed
283 
284  private void timeRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton2ActionPerformed
285  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
286  }//GEN-LAST:event_timeRadioButton2ActionPerformed
287 
288  private void timeRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton3ActionPerformed
289  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
290  }//GEN-LAST:event_timeRadioButton3ActionPerformed
291 
292  private void timeRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton4ActionPerformed
293  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
294  }//GEN-LAST:event_timeRadioButton4ActionPerformed
295 
296  // Variables declaration - do not modify//GEN-BEGIN:variables
297  private javax.swing.JLabel chunksLabel;
298  private javax.swing.JLabel chunksValLabel;
299  private javax.swing.JLabel filesIndexedLabel;
300  private javax.swing.JLabel filesIndexedValue;
301  private javax.swing.JLabel frequencyLabel;
302  private javax.swing.JLabel informationLabel;
303  private javax.swing.JSeparator informationSeparator;
304  private javax.swing.JLabel ingestWarningLabel;
305  private javax.swing.JLabel settingsLabel;
306  private javax.swing.JSeparator settingsSeparator;
307  private javax.swing.JCheckBox showSnippetsCB;
308  private javax.swing.JCheckBox skipNSRLCheckBox;
309  private javax.swing.ButtonGroup timeGroup;
310  private javax.swing.JRadioButton timeRadioButton1;
311  private javax.swing.JRadioButton timeRadioButton2;
312  private javax.swing.JRadioButton timeRadioButton3;
313  private javax.swing.JRadioButton timeRadioButton4;
314  private javax.swing.JRadioButton timeRadioButton5;
315  // End of variables declaration//GEN-END:variables
316 
317  @Override
318  public void store() {
319  KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
320  KeywordSearchSettings.setUpdateFrequency(getSelectedTimeValue());
321  KeywordSearchSettings.setShowSnippets(showSnippetsCB.isSelected());
322  }
323 
324  @Override
325  public void load() {
326  activateWidgets();
327  }
328 
329  private void setTimeSettingEnabled(boolean enabled) {
330  timeRadioButton1.setEnabled(enabled);
331  timeRadioButton2.setEnabled(enabled);
332  timeRadioButton3.setEnabled(enabled);
333  timeRadioButton4.setEnabled(enabled);
334  timeRadioButton5.setEnabled(enabled);
335  frequencyLabel.setEnabled(enabled);
336  }
337 
338  private UpdateFrequency getSelectedTimeValue() {
339  if (timeRadioButton1.isSelected()) {
340  return UpdateFrequency.FAST;
341  } else if (timeRadioButton2.isSelected()) {
342  return UpdateFrequency.AVG;
343  } else if (timeRadioButton3.isSelected()) {
344  return UpdateFrequency.SLOW;
345  } else if (timeRadioButton4.isSelected()) {
346  return UpdateFrequency.SLOWEST;
347  } else if (timeRadioButton5.isSelected()) {
348  return UpdateFrequency.NONE;
349  }
350  return UpdateFrequency.DEFAULT;
351  }
352 
353  private void customizeComponents() {
354 
355  timeGroup.add(timeRadioButton1);
356  timeGroup.add(timeRadioButton2);
357  timeGroup.add(timeRadioButton3);
358  timeGroup.add(timeRadioButton4);
359  timeGroup.add(timeRadioButton5);
360 
361  this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
362 
363  try {
364  filesIndexedValue.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedFiles()));
365  chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
366  } catch (KeywordSearchModuleException | NoOpenCoreException ex) {
367  logger.log(Level.WARNING, "Could not get number of indexed files/chunks"); //NON-NLS
368  }
369 
370  KeywordSearch.addNumIndexedFilesChangeListener(
371  new PropertyChangeListener() {
372  @Override
373  public void propertyChange(PropertyChangeEvent evt) {
374  String changed = evt.getPropertyName();
375  Object newValue = evt.getNewValue();
376 
377  if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
378  int newFilesIndexed = ((Integer) newValue);
379  filesIndexedValue.setText(Integer.toString(newFilesIndexed));
380  try {
381  chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
382  } catch (KeywordSearchModuleException | NoOpenCoreException ex) {
383  logger.log(Level.WARNING, "Could not get number of indexed chunks"); //NON-NLS
384 
385  }
386  }
387  }
388  });
389 
390  //allow panel to toggle its enabled status while it is open based on ingest events
391  IngestManager.getInstance().addIngestJobEventListener(new PropertyChangeListener() {
392  @Override
393  public void propertyChange(PropertyChangeEvent evt) {
394  Object source = evt.getSource();
395  if (source instanceof String && ((String) source).equals("LOCAL")) { //NON-NLS
396  EventQueue.invokeLater(() -> {
397  activateWidgets();
398  });
399  }
400  }
401  });
402  }
403 }

Copyright © 2012-2018 Basis Technology. Generated on: Fri Jun 21 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.