19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.logging.Level;
24 import org.netbeans.spi.options.OptionsPanelController;
33 class KeywordSearchGlobalSearchSettingsPanel
extends javax.swing.JPanel implements OptionsPanel {
35 private final Logger logger = Logger.getLogger(KeywordSearchGlobalSearchSettingsPanel.class.getName());
40 KeywordSearchGlobalSearchSettingsPanel() {
42 customizeComponents();
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);
52 final UpdateFrequency curFreq = KeywordSearchSettings.getUpdateFrequency();
55 timeRadioButton1.setSelected(
true);
58 timeRadioButton2.setSelected(
true);
61 timeRadioButton3.setSelected(
true);
64 timeRadioButton4.setSelected(
true);
67 timeRadioButton5.setSelected(
true);
72 timeRadioButton3.setSelected(
true);
82 @SuppressWarnings(
"unchecked")
84 private
void initComponents() {
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();
104 skipNSRLCheckBox.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.text"));
105 skipNSRLCheckBox.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.toolTipText"));
106 skipNSRLCheckBox.addActionListener(
new java.awt.event.ActionListener() {
107 public void actionPerformed(java.awt.event.ActionEvent evt) {
108 skipNSRLCheckBoxActionPerformed(evt);
112 filesIndexedLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedLabel.text"));
114 filesIndexedValue.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedValue.text"));
116 chunksLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.chunksLabel.text"));
118 chunksValLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.chunksValLabel.text"));
120 settingsLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.settingsLabel.text"));
122 informationLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.informationLabel.text"));
124 frequencyLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.frequencyLabel.text"));
126 timeRadioButton1.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.text"));
127 timeRadioButton1.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.toolTipText"));
128 timeRadioButton1.addActionListener(
new java.awt.event.ActionListener() {
129 public void actionPerformed(java.awt.event.ActionEvent evt) {
130 timeRadioButton1ActionPerformed(evt);
134 timeRadioButton2.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.text"));
135 timeRadioButton2.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.toolTipText"));
136 timeRadioButton2.addActionListener(
new java.awt.event.ActionListener() {
137 public void actionPerformed(java.awt.event.ActionEvent evt) {
138 timeRadioButton2ActionPerformed(evt);
142 timeRadioButton3.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.text"));
143 timeRadioButton3.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.toolTipText"));
144 timeRadioButton3.addActionListener(
new java.awt.event.ActionListener() {
145 public void actionPerformed(java.awt.event.ActionEvent evt) {
146 timeRadioButton3ActionPerformed(evt);
150 timeRadioButton4.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.text_1"));
151 timeRadioButton4.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.toolTipText"));
152 timeRadioButton4.addActionListener(
new java.awt.event.ActionListener() {
153 public void actionPerformed(java.awt.event.ActionEvent evt) {
154 timeRadioButton4ActionPerformed(evt);
158 showSnippetsCB.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.showSnippetsCB.text"));
159 showSnippetsCB.addActionListener(
new java.awt.event.ActionListener() {
160 public void actionPerformed(java.awt.event.ActionEvent evt) {
161 showSnippetsCBActionPerformed(evt);
165 timeRadioButton5.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.text"));
166 timeRadioButton5.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.toolTipText"));
167 timeRadioButton5.addActionListener(
new java.awt.event.ActionListener() {
168 public void actionPerformed(java.awt.event.ActionEvent evt) {
169 timeRadioButton5ActionPerformed(evt);
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()
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()
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()
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)
209 .addComponent(chunksValLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)))))
210 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
212 layout.setVerticalGroup(
213 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
214 .addGroup(layout.createSequentialGroup()
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))
251 private void timeRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {
252 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
255 private void skipNSRLCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
256 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
259 private void showSnippetsCBActionPerformed(java.awt.event.ActionEvent evt) {
260 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
263 private void timeRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
264 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
267 private void timeRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
268 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
271 private void timeRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {
272 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
275 private void timeRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {
276 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
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;
300 public void store() {
301 KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
302 KeywordSearchSettings.setUpdateFrequency(getSelectedTimeValue());
303 KeywordSearchSettings.setShowSnippets(showSnippetsCB.isSelected());
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);
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;
332 return UpdateFrequency.DEFAULT;
335 private void customizeComponents() {
337 timeGroup.add(timeRadioButton1);
338 timeGroup.add(timeRadioButton2);
339 timeGroup.add(timeRadioButton3);
340 timeGroup.add(timeRadioButton4);
341 timeGroup.add(timeRadioButton5);
343 this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
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");
352 KeywordSearch.addNumIndexedFilesChangeListener(
353 new PropertyChangeListener() {
355 public void propertyChange(PropertyChangeEvent evt) {
356 String changed = evt.getPropertyName();
357 Object newValue = evt.getNewValue();
359 if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
360 int newFilesIndexed = ((Integer) newValue).intValue();
361 filesIndexedValue.setText(Integer.toString(newFilesIndexed));
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");