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 @SuppressWarnings(
"PMD.SingularField")
34 class KeywordSearchGlobalSearchSettingsPanel extends javax.swing.JPanel implements OptionsPanel {
36 private final Logger logger = Logger.getLogger(KeywordSearchGlobalSearchSettingsPanel.class.getName());
41 KeywordSearchGlobalSearchSettingsPanel() {
43 customizeComponents();
46 private void activateWidgets() {
47 skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
48 showSnippetsCB.setSelected(KeywordSearchSettings.getShowSnippets());
49 boolean enable = !IngestManager.getInstance().isIngestRunning();
50 skipNSRLCheckBox.setEnabled(enable);
51 setTimeSettingEnabled(enable);
53 final UpdateFrequency curFreq = KeywordSearchSettings.getUpdateFrequency();
56 timeRadioButton1.setSelected(
true);
59 timeRadioButton2.setSelected(
true);
62 timeRadioButton3.setSelected(
true);
65 timeRadioButton4.setSelected(
true);
68 timeRadioButton5.setSelected(
true);
73 timeRadioButton3.setSelected(
true);
83 @SuppressWarnings(
"unchecked")
85 private
void initComponents() {
87 timeGroup =
new javax.swing.ButtonGroup();
88 skipNSRLCheckBox =
new javax.swing.JCheckBox();
89 filesIndexedLabel =
new javax.swing.JLabel();
90 filesIndexedValue =
new javax.swing.JLabel();
91 chunksLabel =
new javax.swing.JLabel();
92 chunksValLabel =
new javax.swing.JLabel();
93 settingsLabel =
new javax.swing.JLabel();
94 informationLabel =
new javax.swing.JLabel();
95 settingsSeparator =
new javax.swing.JSeparator();
96 informationSeparator =
new javax.swing.JSeparator();
97 frequencyLabel =
new javax.swing.JLabel();
98 timeRadioButton1 =
new javax.swing.JRadioButton();
99 timeRadioButton2 =
new javax.swing.JRadioButton();
100 timeRadioButton3 =
new javax.swing.JRadioButton();
101 timeRadioButton4 =
new javax.swing.JRadioButton();
102 showSnippetsCB =
new javax.swing.JCheckBox();
103 timeRadioButton5 =
new javax.swing.JRadioButton();
105 skipNSRLCheckBox.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.text"));
106 skipNSRLCheckBox.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.toolTipText"));
107 skipNSRLCheckBox.addActionListener(
new java.awt.event.ActionListener() {
108 public void actionPerformed(java.awt.event.ActionEvent evt) {
109 skipNSRLCheckBoxActionPerformed(evt);
113 filesIndexedLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedLabel.text"));
115 filesIndexedValue.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedValue.text"));
117 chunksLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.chunksLabel.text"));
119 chunksValLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.chunksValLabel.text"));
121 settingsLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.settingsLabel.text"));
123 informationLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.informationLabel.text"));
125 frequencyLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.frequencyLabel.text"));
127 timeRadioButton1.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.text"));
128 timeRadioButton1.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.toolTipText"));
129 timeRadioButton1.addActionListener(
new java.awt.event.ActionListener() {
130 public void actionPerformed(java.awt.event.ActionEvent evt) {
131 timeRadioButton1ActionPerformed(evt);
135 timeRadioButton2.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.text"));
136 timeRadioButton2.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.toolTipText"));
137 timeRadioButton2.addActionListener(
new java.awt.event.ActionListener() {
138 public void actionPerformed(java.awt.event.ActionEvent evt) {
139 timeRadioButton2ActionPerformed(evt);
143 timeRadioButton3.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.text"));
144 timeRadioButton3.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.toolTipText"));
145 timeRadioButton3.addActionListener(
new java.awt.event.ActionListener() {
146 public void actionPerformed(java.awt.event.ActionEvent evt) {
147 timeRadioButton3ActionPerformed(evt);
151 timeRadioButton4.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.text_1"));
152 timeRadioButton4.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.toolTipText"));
153 timeRadioButton4.addActionListener(
new java.awt.event.ActionListener() {
154 public void actionPerformed(java.awt.event.ActionEvent evt) {
155 timeRadioButton4ActionPerformed(evt);
159 showSnippetsCB.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.showSnippetsCB.text"));
160 showSnippetsCB.addActionListener(
new java.awt.event.ActionListener() {
161 public void actionPerformed(java.awt.event.ActionEvent evt) {
162 showSnippetsCBActionPerformed(evt);
166 timeRadioButton5.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.text"));
167 timeRadioButton5.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.toolTipText"));
168 timeRadioButton5.addActionListener(
new java.awt.event.ActionListener() {
169 public void actionPerformed(java.awt.event.ActionEvent evt) {
170 timeRadioButton5ActionPerformed(evt);
174 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
175 this.setLayout(layout);
176 layout.setHorizontalGroup(
177 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
178 .addGroup(layout.createSequentialGroup()
180 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
181 .addGroup(layout.createSequentialGroup()
182 .addComponent(settingsLabel)
183 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
184 .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE))
185 .addGroup(layout.createSequentialGroup()
186 .addComponent(informationLabel)
187 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
188 .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE))
189 .addGroup(layout.createSequentialGroup()
191 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
192 .addComponent(skipNSRLCheckBox)
193 .addComponent(showSnippetsCB)
194 .addGroup(layout.createSequentialGroup()
195 .addComponent(filesIndexedLabel)
197 .addComponent(filesIndexedValue))
198 .addComponent(frequencyLabel)
199 .addGroup(layout.createSequentialGroup()
201 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
202 .addComponent(timeRadioButton2)
203 .addComponent(timeRadioButton1)
204 .addComponent(timeRadioButton3)
205 .addComponent(timeRadioButton4)
206 .addComponent(timeRadioButton5)))
207 .addGroup(layout.createSequentialGroup()
208 .addComponent(chunksLabel)
210 .addComponent(chunksValLabel)))))
211 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
214 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {chunksLabel, filesIndexedLabel});
216 layout.setVerticalGroup(
217 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
218 .addGroup(layout.createSequentialGroup()
220 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
221 .addComponent(settingsLabel)
222 .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE))
223 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
224 .addComponent(skipNSRLCheckBox)
225 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
226 .addComponent(showSnippetsCB)
227 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
228 .addComponent(frequencyLabel)
229 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
230 .addComponent(timeRadioButton1)
231 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
232 .addComponent(timeRadioButton2)
233 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
234 .addComponent(timeRadioButton3)
235 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
236 .addComponent(timeRadioButton4)
237 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
238 .addComponent(timeRadioButton5)
239 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
240 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
241 .addComponent(informationLabel)
242 .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE))
243 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
244 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
245 .addComponent(filesIndexedLabel)
246 .addComponent(filesIndexedValue))
247 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
248 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
249 .addComponent(chunksLabel)
250 .addComponent(chunksValLabel))
251 .addContainerGap(93, Short.MAX_VALUE))
255 private void timeRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {
256 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
259 private void skipNSRLCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
260 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
263 private void showSnippetsCBActionPerformed(java.awt.event.ActionEvent evt) {
264 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
267 private void timeRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
268 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
271 private void timeRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
272 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
275 private void timeRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {
276 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
279 private void timeRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {
280 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
284 private javax.swing.JLabel chunksLabel;
285 private javax.swing.JLabel chunksValLabel;
286 private javax.swing.JLabel filesIndexedLabel;
287 private javax.swing.JLabel filesIndexedValue;
288 private javax.swing.JLabel frequencyLabel;
289 private javax.swing.JLabel informationLabel;
290 private javax.swing.JSeparator informationSeparator;
291 private javax.swing.JLabel settingsLabel;
292 private javax.swing.JSeparator settingsSeparator;
293 private javax.swing.JCheckBox showSnippetsCB;
294 private javax.swing.JCheckBox skipNSRLCheckBox;
295 private javax.swing.ButtonGroup timeGroup;
296 private javax.swing.JRadioButton timeRadioButton1;
297 private javax.swing.JRadioButton timeRadioButton2;
298 private javax.swing.JRadioButton timeRadioButton3;
299 private javax.swing.JRadioButton timeRadioButton4;
300 private javax.swing.JRadioButton timeRadioButton5;
304 public void store() {
305 KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
306 KeywordSearchSettings.setUpdateFrequency(getSelectedTimeValue());
307 KeywordSearchSettings.setShowSnippets(showSnippetsCB.isSelected());
315 private void setTimeSettingEnabled(
boolean enabled) {
316 timeRadioButton1.setEnabled(enabled);
317 timeRadioButton2.setEnabled(enabled);
318 timeRadioButton3.setEnabled(enabled);
319 timeRadioButton4.setEnabled(enabled);
320 timeRadioButton5.setEnabled(enabled);
321 frequencyLabel.setEnabled(enabled);
324 private UpdateFrequency getSelectedTimeValue() {
325 if (timeRadioButton1.isSelected()) {
326 return UpdateFrequency.FAST;
327 }
else if (timeRadioButton2.isSelected()) {
328 return UpdateFrequency.AVG;
329 }
else if (timeRadioButton3.isSelected()) {
330 return UpdateFrequency.SLOW;
331 }
else if (timeRadioButton4.isSelected()) {
332 return UpdateFrequency.SLOWEST;
333 }
else if (timeRadioButton5.isSelected()) {
334 return UpdateFrequency.NONE;
336 return UpdateFrequency.DEFAULT;
339 private void customizeComponents() {
341 timeGroup.add(timeRadioButton1);
342 timeGroup.add(timeRadioButton2);
343 timeGroup.add(timeRadioButton3);
344 timeGroup.add(timeRadioButton4);
345 timeGroup.add(timeRadioButton5);
347 this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
350 filesIndexedValue.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedFiles()));
351 chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
352 }
catch (KeywordSearchModuleException | NoOpenCoreException ex) {
353 logger.log(Level.WARNING,
"Could not get number of indexed files/chunks");
356 KeywordSearch.addNumIndexedFilesChangeListener(
357 new PropertyChangeListener() {
359 public void propertyChange(PropertyChangeEvent evt) {
360 String changed = evt.getPropertyName();
361 Object newValue = evt.getNewValue();
363 if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
364 int newFilesIndexed = ((Integer) newValue);
365 filesIndexedValue.setText(Integer.toString(newFilesIndexed));
367 chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
368 }
catch (KeywordSearchModuleException | NoOpenCoreException ex) {
369 logger.log(Level.WARNING,
"Could not get number of indexed chunks");