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 .addGroup(layout.createSequentialGroup()
194 .addComponent(filesIndexedLabel)
196 .addComponent(filesIndexedValue))
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)))))
210 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
213 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {chunksLabel, filesIndexedLabel});
215 layout.setVerticalGroup(
216 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
217 .addGroup(layout.createSequentialGroup()
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))
254 private void timeRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {
255 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
258 private void skipNSRLCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
259 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
262 private void showSnippetsCBActionPerformed(java.awt.event.ActionEvent evt) {
263 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
266 private void timeRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
267 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
270 private void timeRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
271 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
274 private void timeRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {
275 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
278 private void timeRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {
279 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
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;
303 public void store() {
304 KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
305 KeywordSearchSettings.setUpdateFrequency(getSelectedTimeValue());
306 KeywordSearchSettings.setShowSnippets(showSnippetsCB.isSelected());
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);
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;
335 return UpdateFrequency.DEFAULT;
338 private void customizeComponents() {
340 timeGroup.add(timeRadioButton1);
341 timeGroup.add(timeRadioButton2);
342 timeGroup.add(timeRadioButton3);
343 timeGroup.add(timeRadioButton4);
344 timeGroup.add(timeRadioButton5);
346 this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
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");
355 KeywordSearch.addNumIndexedFilesChangeListener(
356 new PropertyChangeListener() {
358 public void propertyChange(PropertyChangeEvent evt) {
359 String changed = evt.getPropertyName();
360 Object newValue = evt.getNewValue();
362 if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
363 int newFilesIndexed = ((Integer) newValue).intValue();
364 filesIndexedValue.setText(Integer.toString(newFilesIndexed));
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");