Autopsy  4.7.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.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.logging.Level;
24 import org.netbeans.spi.options.OptionsPanelController;
29 
33 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
34 class KeywordSearchGlobalSearchSettingsPanel extends javax.swing.JPanel implements OptionsPanel {
35 
36  private final Logger logger = Logger.getLogger(KeywordSearchGlobalSearchSettingsPanel.class.getName());
37 
41  KeywordSearchGlobalSearchSettingsPanel() {
42  initComponents();
43  customizeComponents();
44  }
45 
46  private void activateWidgets() {
47  skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
48  showSnippetsCB.setSelected(KeywordSearchSettings.getShowSnippets());
49  boolean enable = !IngestManager.getInstance().isIngestRunning();
50  skipNSRLCheckBox.setEnabled(enable);
51  setTimeSettingEnabled(enable);
52 
53  final UpdateFrequency curFreq = KeywordSearchSettings.getUpdateFrequency();
54  switch (curFreq) {
55  case FAST:
56  timeRadioButton1.setSelected(true);
57  break;
58  case AVG:
59  timeRadioButton2.setSelected(true);
60  break;
61  case SLOW:
62  timeRadioButton3.setSelected(true);
63  break;
64  case SLOWEST:
65  timeRadioButton4.setSelected(true);
66  break;
67  case NONE:
68  timeRadioButton5.setSelected(true);
69  break;
70  case DEFAULT:
71  default:
72  // default value
73  timeRadioButton3.setSelected(true);
74  break;
75  }
76  }
77 
83  @SuppressWarnings("unchecked")
84  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
85  private void initComponents() {
86 
87  timeGroup = new javax.swing.ButtonGroup();
88  skipNSRLCheckBox = new javax.swing.JCheckBox();
89  filesIndexedLabel = new javax.swing.JLabel();
90  filesIndexedValue = new javax.swing.JLabel();
91  chunksLabel = new javax.swing.JLabel();
92  chunksValLabel = new javax.swing.JLabel();
93  settingsLabel = new javax.swing.JLabel();
94  informationLabel = new javax.swing.JLabel();
95  settingsSeparator = new javax.swing.JSeparator();
96  informationSeparator = new javax.swing.JSeparator();
97  frequencyLabel = new javax.swing.JLabel();
98  timeRadioButton1 = new javax.swing.JRadioButton();
99  timeRadioButton2 = new javax.swing.JRadioButton();
100  timeRadioButton3 = new javax.swing.JRadioButton();
101  timeRadioButton4 = new javax.swing.JRadioButton();
102  showSnippetsCB = new javax.swing.JCheckBox();
103  timeRadioButton5 = new javax.swing.JRadioButton();
104 
105  skipNSRLCheckBox.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.text")); // NOI18N
106  skipNSRLCheckBox.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.toolTipText")); // NOI18N
107  skipNSRLCheckBox.addActionListener(new java.awt.event.ActionListener() {
108  public void actionPerformed(java.awt.event.ActionEvent evt) {
109  skipNSRLCheckBoxActionPerformed(evt);
110  }
111  });
112 
113  filesIndexedLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.filesIndexedLabel.text")); // NOI18N
114 
115  filesIndexedValue.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.filesIndexedValue.text")); // NOI18N
116 
117  chunksLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.chunksLabel.text")); // NOI18N
118 
119  chunksValLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.chunksValLabel.text")); // NOI18N
120 
121  settingsLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.settingsLabel.text")); // NOI18N
122 
123  informationLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.informationLabel.text")); // NOI18N
124 
125  frequencyLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.frequencyLabel.text")); // NOI18N
126 
127  timeRadioButton1.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.text")); // NOI18N
128  timeRadioButton1.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.toolTipText")); // NOI18N
129  timeRadioButton1.addActionListener(new java.awt.event.ActionListener() {
130  public void actionPerformed(java.awt.event.ActionEvent evt) {
131  timeRadioButton1ActionPerformed(evt);
132  }
133  });
134 
135  timeRadioButton2.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.text")); // NOI18N
136  timeRadioButton2.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.toolTipText")); // NOI18N
137  timeRadioButton2.addActionListener(new java.awt.event.ActionListener() {
138  public void actionPerformed(java.awt.event.ActionEvent evt) {
139  timeRadioButton2ActionPerformed(evt);
140  }
141  });
142 
143  timeRadioButton3.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.text")); // NOI18N
144  timeRadioButton3.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.toolTipText")); // NOI18N
145  timeRadioButton3.addActionListener(new java.awt.event.ActionListener() {
146  public void actionPerformed(java.awt.event.ActionEvent evt) {
147  timeRadioButton3ActionPerformed(evt);
148  }
149  });
150 
151  timeRadioButton4.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.text_1")); // NOI18N
152  timeRadioButton4.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.toolTipText")); // NOI18N
153  timeRadioButton4.addActionListener(new java.awt.event.ActionListener() {
154  public void actionPerformed(java.awt.event.ActionEvent evt) {
155  timeRadioButton4ActionPerformed(evt);
156  }
157  });
158 
159  showSnippetsCB.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.showSnippetsCB.text")); // NOI18N
160  showSnippetsCB.addActionListener(new java.awt.event.ActionListener() {
161  public void actionPerformed(java.awt.event.ActionEvent evt) {
162  showSnippetsCBActionPerformed(evt);
163  }
164  });
165 
166  timeRadioButton5.setText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.text")); // NOI18N
167  timeRadioButton5.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, "KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.toolTipText")); // NOI18N
168  timeRadioButton5.addActionListener(new java.awt.event.ActionListener() {
169  public void actionPerformed(java.awt.event.ActionEvent evt) {
170  timeRadioButton5ActionPerformed(evt);
171  }
172  });
173 
174  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
175  this.setLayout(layout);
176  layout.setHorizontalGroup(
177  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
178  .addGroup(layout.createSequentialGroup()
179  .addContainerGap()
180  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
181  .addGroup(layout.createSequentialGroup()
182  .addComponent(settingsLabel)
183  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
184  .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE))
185  .addGroup(layout.createSequentialGroup()
186  .addComponent(informationLabel)
187  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
188  .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE))
189  .addGroup(layout.createSequentialGroup()
190  .addGap(10, 10, 10)
191  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
192  .addComponent(skipNSRLCheckBox)
193  .addComponent(showSnippetsCB)
194  .addGroup(layout.createSequentialGroup()
195  .addComponent(filesIndexedLabel)
196  .addGap(18, 18, 18)
197  .addComponent(filesIndexedValue))
198  .addComponent(frequencyLabel)
199  .addGroup(layout.createSequentialGroup()
200  .addGap(10, 10, 10)
201  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
202  .addComponent(timeRadioButton2)
203  .addComponent(timeRadioButton1)
204  .addComponent(timeRadioButton3)
205  .addComponent(timeRadioButton4)
206  .addComponent(timeRadioButton5)))
207  .addGroup(layout.createSequentialGroup()
208  .addComponent(chunksLabel)
209  .addGap(18, 18, 18)
210  .addComponent(chunksValLabel)))))
211  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
212  );
213 
214  layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {chunksLabel, filesIndexedLabel});
215 
216  layout.setVerticalGroup(
217  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
218  .addGroup(layout.createSequentialGroup()
219  .addContainerGap()
220  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
221  .addComponent(settingsLabel)
222  .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE))
223  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
224  .addComponent(skipNSRLCheckBox)
225  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
226  .addComponent(showSnippetsCB)
227  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
228  .addComponent(frequencyLabel)
229  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
230  .addComponent(timeRadioButton1)
231  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
232  .addComponent(timeRadioButton2)
233  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
234  .addComponent(timeRadioButton3)
235  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
236  .addComponent(timeRadioButton4)
237  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
238  .addComponent(timeRadioButton5)
239  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
240  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
241  .addComponent(informationLabel)
242  .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE))
243  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
244  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
245  .addComponent(filesIndexedLabel)
246  .addComponent(filesIndexedValue))
247  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
248  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
249  .addComponent(chunksLabel)
250  .addComponent(chunksValLabel))
251  .addContainerGap(93, Short.MAX_VALUE))
252  );
253  }// </editor-fold>//GEN-END:initComponents
254 
255  private void timeRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton5ActionPerformed
256  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
257  }//GEN-LAST:event_timeRadioButton5ActionPerformed
258 
259  private void skipNSRLCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skipNSRLCheckBoxActionPerformed
260  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
261  }//GEN-LAST:event_skipNSRLCheckBoxActionPerformed
262 
263  private void showSnippetsCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showSnippetsCBActionPerformed
264  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
265  }//GEN-LAST:event_showSnippetsCBActionPerformed
266 
267  private void timeRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton1ActionPerformed
268  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
269  }//GEN-LAST:event_timeRadioButton1ActionPerformed
270 
271  private void timeRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton2ActionPerformed
272  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
273  }//GEN-LAST:event_timeRadioButton2ActionPerformed
274 
275  private void timeRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton3ActionPerformed
276  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
277  }//GEN-LAST:event_timeRadioButton3ActionPerformed
278 
279  private void timeRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton4ActionPerformed
280  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
281  }//GEN-LAST:event_timeRadioButton4ActionPerformed
282 
283  // Variables declaration - do not modify//GEN-BEGIN:variables
284  private javax.swing.JLabel chunksLabel;
285  private javax.swing.JLabel chunksValLabel;
286  private javax.swing.JLabel filesIndexedLabel;
287  private javax.swing.JLabel filesIndexedValue;
288  private javax.swing.JLabel frequencyLabel;
289  private javax.swing.JLabel informationLabel;
290  private javax.swing.JSeparator informationSeparator;
291  private javax.swing.JLabel settingsLabel;
292  private javax.swing.JSeparator settingsSeparator;
293  private javax.swing.JCheckBox showSnippetsCB;
294  private javax.swing.JCheckBox skipNSRLCheckBox;
295  private javax.swing.ButtonGroup timeGroup;
296  private javax.swing.JRadioButton timeRadioButton1;
297  private javax.swing.JRadioButton timeRadioButton2;
298  private javax.swing.JRadioButton timeRadioButton3;
299  private javax.swing.JRadioButton timeRadioButton4;
300  private javax.swing.JRadioButton timeRadioButton5;
301  // End of variables declaration//GEN-END:variables
302 
303  @Override
304  public void store() {
305  KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
306  KeywordSearchSettings.setUpdateFrequency(getSelectedTimeValue());
307  KeywordSearchSettings.setShowSnippets(showSnippetsCB.isSelected());
308  }
309 
310  @Override
311  public void load() {
312  activateWidgets();
313  }
314 
315  private void setTimeSettingEnabled(boolean enabled) {
316  timeRadioButton1.setEnabled(enabled);
317  timeRadioButton2.setEnabled(enabled);
318  timeRadioButton3.setEnabled(enabled);
319  timeRadioButton4.setEnabled(enabled);
320  timeRadioButton5.setEnabled(enabled);
321  frequencyLabel.setEnabled(enabled);
322  }
323 
324  private UpdateFrequency getSelectedTimeValue() {
325  if (timeRadioButton1.isSelected()) {
326  return UpdateFrequency.FAST;
327  } else if (timeRadioButton2.isSelected()) {
328  return UpdateFrequency.AVG;
329  } else if (timeRadioButton3.isSelected()) {
330  return UpdateFrequency.SLOW;
331  } else if (timeRadioButton4.isSelected()) {
332  return UpdateFrequency.SLOWEST;
333  } else if (timeRadioButton5.isSelected()) {
334  return UpdateFrequency.NONE;
335  }
336  return UpdateFrequency.DEFAULT;
337  }
338 
339  private void customizeComponents() {
340 
341  timeGroup.add(timeRadioButton1);
342  timeGroup.add(timeRadioButton2);
343  timeGroup.add(timeRadioButton3);
344  timeGroup.add(timeRadioButton4);
345  timeGroup.add(timeRadioButton5);
346 
347  this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
348 
349  try {
350  filesIndexedValue.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedFiles()));
351  chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
352  } catch (KeywordSearchModuleException | NoOpenCoreException ex) {
353  logger.log(Level.WARNING, "Could not get number of indexed files/chunks"); //NON-NLS
354  }
355 
356  KeywordSearch.addNumIndexedFilesChangeListener(
357  new PropertyChangeListener() {
358  @Override
359  public void propertyChange(PropertyChangeEvent evt) {
360  String changed = evt.getPropertyName();
361  Object newValue = evt.getNewValue();
362 
363  if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
364  int newFilesIndexed = ((Integer) newValue);
365  filesIndexedValue.setText(Integer.toString(newFilesIndexed));
366  try {
367  chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
368  } catch (KeywordSearchModuleException | NoOpenCoreException ex) {
369  logger.log(Level.WARNING, "Could not get number of indexed chunks"); //NON-NLS
370 
371  }
372  }
373  }
374  });
375  }
376 }

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