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

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.