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

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