Autopsy  4.6.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-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  .addGroup(layout.createSequentialGroup()
194  .addComponent(filesIndexedLabel)
195  .addGap(18, 18, 18)
196  .addComponent(filesIndexedValue))
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)))))
210  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
211  );
212 
213  layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {chunksLabel, filesIndexedLabel});
214 
215  layout.setVerticalGroup(
216  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
217  .addGroup(layout.createSequentialGroup()
218  .addContainerGap()
219  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
220  .addComponent(settingsLabel)
221  .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE))
222  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
223  .addComponent(skipNSRLCheckBox)
224  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
225  .addComponent(showSnippetsCB)
226  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
227  .addComponent(frequencyLabel)
228  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
229  .addComponent(timeRadioButton1)
230  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
231  .addComponent(timeRadioButton2)
232  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
233  .addComponent(timeRadioButton3)
234  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
235  .addComponent(timeRadioButton4)
236  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
237  .addComponent(timeRadioButton5)
238  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
239  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
240  .addComponent(informationLabel)
241  .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE))
242  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
243  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
244  .addComponent(filesIndexedLabel)
245  .addComponent(filesIndexedValue))
246  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
247  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
248  .addComponent(chunksLabel)
249  .addComponent(chunksValLabel))
250  .addContainerGap(93, Short.MAX_VALUE))
251  );
252  }// </editor-fold>//GEN-END:initComponents
253 
254  private void timeRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton5ActionPerformed
255  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
256  }//GEN-LAST:event_timeRadioButton5ActionPerformed
257 
258  private void skipNSRLCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skipNSRLCheckBoxActionPerformed
259  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
260  }//GEN-LAST:event_skipNSRLCheckBoxActionPerformed
261 
262  private void showSnippetsCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showSnippetsCBActionPerformed
263  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
264  }//GEN-LAST:event_showSnippetsCBActionPerformed
265 
266  private void timeRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton1ActionPerformed
267  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
268  }//GEN-LAST:event_timeRadioButton1ActionPerformed
269 
270  private void timeRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton2ActionPerformed
271  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
272  }//GEN-LAST:event_timeRadioButton2ActionPerformed
273 
274  private void timeRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton3ActionPerformed
275  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
276  }//GEN-LAST:event_timeRadioButton3ActionPerformed
277 
278  private void timeRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeRadioButton4ActionPerformed
279  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
280  }//GEN-LAST:event_timeRadioButton4ActionPerformed
281 
282  // Variables declaration - do not modify//GEN-BEGIN:variables
283  private javax.swing.JLabel chunksLabel;
284  private javax.swing.JLabel chunksValLabel;
285  private javax.swing.JLabel filesIndexedLabel;
286  private javax.swing.JLabel filesIndexedValue;
287  private javax.swing.JLabel frequencyLabel;
288  private javax.swing.JLabel informationLabel;
289  private javax.swing.JSeparator informationSeparator;
290  private javax.swing.JLabel settingsLabel;
291  private javax.swing.JSeparator settingsSeparator;
292  private javax.swing.JCheckBox showSnippetsCB;
293  private javax.swing.JCheckBox skipNSRLCheckBox;
294  private javax.swing.ButtonGroup timeGroup;
295  private javax.swing.JRadioButton timeRadioButton1;
296  private javax.swing.JRadioButton timeRadioButton2;
297  private javax.swing.JRadioButton timeRadioButton3;
298  private javax.swing.JRadioButton timeRadioButton4;
299  private javax.swing.JRadioButton timeRadioButton5;
300  // End of variables declaration//GEN-END:variables
301 
302  @Override
303  public void store() {
304  KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
305  KeywordSearchSettings.setUpdateFrequency(getSelectedTimeValue());
306  KeywordSearchSettings.setShowSnippets(showSnippetsCB.isSelected());
307  }
308 
309  @Override
310  public void load() {
311  activateWidgets();
312  }
313 
314  private void setTimeSettingEnabled(boolean enabled) {
315  timeRadioButton1.setEnabled(enabled);
316  timeRadioButton2.setEnabled(enabled);
317  timeRadioButton3.setEnabled(enabled);
318  timeRadioButton4.setEnabled(enabled);
319  timeRadioButton5.setEnabled(enabled);
320  frequencyLabel.setEnabled(enabled);
321  }
322 
323  private UpdateFrequency getSelectedTimeValue() {
324  if (timeRadioButton1.isSelected()) {
325  return UpdateFrequency.FAST;
326  } else if (timeRadioButton2.isSelected()) {
327  return UpdateFrequency.AVG;
328  } else if (timeRadioButton3.isSelected()) {
329  return UpdateFrequency.SLOW;
330  } else if (timeRadioButton4.isSelected()) {
331  return UpdateFrequency.SLOWEST;
332  } else if (timeRadioButton5.isSelected()) {
333  return UpdateFrequency.NONE;
334  }
335  return UpdateFrequency.DEFAULT;
336  }
337 
338  private void customizeComponents() {
339 
340  timeGroup.add(timeRadioButton1);
341  timeGroup.add(timeRadioButton2);
342  timeGroup.add(timeRadioButton3);
343  timeGroup.add(timeRadioButton4);
344  timeGroup.add(timeRadioButton5);
345 
346  this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
347 
348  try {
349  filesIndexedValue.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedFiles()));
350  chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
351  } catch (KeywordSearchModuleException | NoOpenCoreException ex) {
352  logger.log(Level.WARNING, "Could not get number of indexed files/chunks"); //NON-NLS
353  }
354 
355  KeywordSearch.addNumIndexedFilesChangeListener(
356  new PropertyChangeListener() {
357  @Override
358  public void propertyChange(PropertyChangeEvent evt) {
359  String changed = evt.getPropertyName();
360  Object newValue = evt.getNewValue();
361 
362  if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
363  int newFilesIndexed = ((Integer) newValue).intValue();
364  filesIndexedValue.setText(Integer.toString(newFilesIndexed));
365  try {
366  chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
367  } catch (KeywordSearchModuleException | NoOpenCoreException ex) {
368  logger.log(Level.WARNING, "Could not get number of indexed chunks"); //NON-NLS
369 
370  }
371  }
372  }
373  });
374  }
375 }

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