19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.awt.EventQueue;
22 import java.beans.PropertyChangeEvent;
23 import java.beans.PropertyChangeListener;
24 import java.util.logging.Level;
25 import org.netbeans.spi.options.OptionsPanelController;
34 @SuppressWarnings(
"PMD.SingularField")
35 class KeywordSearchGlobalSearchSettingsPanel extends javax.swing.JPanel implements OptionsPanel {
37 private final Logger logger = Logger.getLogger(KeywordSearchGlobalSearchSettingsPanel.class.getName());
42 KeywordSearchGlobalSearchSettingsPanel() {
44 customizeComponents();
47 private void activateWidgets() {
48 skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
49 showSnippetsCB.setSelected(KeywordSearchSettings.getShowSnippets());
50 boolean ingestRunning = IngestManager.getInstance().isIngestRunning();
51 ingestWarningLabel.setVisible(ingestRunning);
52 skipNSRLCheckBox.setEnabled(!ingestRunning);
53 setTimeSettingEnabled(!ingestRunning);
55 final UpdateFrequency curFreq = KeywordSearchSettings.getUpdateFrequency();
58 timeRadioButton1.setSelected(
true);
61 timeRadioButton2.setSelected(
true);
64 timeRadioButton3.setSelected(
true);
67 timeRadioButton4.setSelected(
true);
70 timeRadioButton5.setSelected(
true);
75 timeRadioButton3.setSelected(
true);
85 @SuppressWarnings(
"unchecked")
87 private
void initComponents() {
89 timeGroup =
new javax.swing.ButtonGroup();
90 skipNSRLCheckBox =
new javax.swing.JCheckBox();
91 filesIndexedLabel =
new javax.swing.JLabel();
92 filesIndexedValue =
new javax.swing.JLabel();
93 chunksLabel =
new javax.swing.JLabel();
94 chunksValLabel =
new javax.swing.JLabel();
95 settingsLabel =
new javax.swing.JLabel();
96 informationLabel =
new javax.swing.JLabel();
97 settingsSeparator =
new javax.swing.JSeparator();
98 informationSeparator =
new javax.swing.JSeparator();
99 frequencyLabel =
new javax.swing.JLabel();
100 timeRadioButton1 =
new javax.swing.JRadioButton();
101 timeRadioButton2 =
new javax.swing.JRadioButton();
102 timeRadioButton3 =
new javax.swing.JRadioButton();
103 timeRadioButton4 =
new javax.swing.JRadioButton();
104 showSnippetsCB =
new javax.swing.JCheckBox();
105 timeRadioButton5 =
new javax.swing.JRadioButton();
106 ingestWarningLabel =
new javax.swing.JLabel();
108 skipNSRLCheckBox.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.text"));
109 skipNSRLCheckBox.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.toolTipText"));
110 skipNSRLCheckBox.addActionListener(
new java.awt.event.ActionListener() {
111 public void actionPerformed(java.awt.event.ActionEvent evt) {
112 skipNSRLCheckBoxActionPerformed(evt);
116 filesIndexedLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedLabel.text"));
118 filesIndexedValue.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedValue.text"));
120 chunksLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.chunksLabel.text"));
122 chunksValLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.chunksValLabel.text"));
124 settingsLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.settingsLabel.text"));
126 informationLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.informationLabel.text"));
128 frequencyLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.frequencyLabel.text"));
130 timeRadioButton1.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.text"));
131 timeRadioButton1.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.toolTipText"));
132 timeRadioButton1.addActionListener(
new java.awt.event.ActionListener() {
133 public void actionPerformed(java.awt.event.ActionEvent evt) {
134 timeRadioButton1ActionPerformed(evt);
138 timeRadioButton2.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.text"));
139 timeRadioButton2.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.toolTipText"));
140 timeRadioButton2.addActionListener(
new java.awt.event.ActionListener() {
141 public void actionPerformed(java.awt.event.ActionEvent evt) {
142 timeRadioButton2ActionPerformed(evt);
146 timeRadioButton3.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.text"));
147 timeRadioButton3.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.toolTipText"));
148 timeRadioButton3.addActionListener(
new java.awt.event.ActionListener() {
149 public void actionPerformed(java.awt.event.ActionEvent evt) {
150 timeRadioButton3ActionPerformed(evt);
154 timeRadioButton4.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.text_1"));
155 timeRadioButton4.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.toolTipText"));
156 timeRadioButton4.addActionListener(
new java.awt.event.ActionListener() {
157 public void actionPerformed(java.awt.event.ActionEvent evt) {
158 timeRadioButton4ActionPerformed(evt);
162 showSnippetsCB.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.showSnippetsCB.text"));
163 showSnippetsCB.addActionListener(
new java.awt.event.ActionListener() {
164 public void actionPerformed(java.awt.event.ActionEvent evt) {
165 showSnippetsCBActionPerformed(evt);
169 timeRadioButton5.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.text"));
170 timeRadioButton5.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.toolTipText"));
171 timeRadioButton5.addActionListener(
new java.awt.event.ActionListener() {
172 public void actionPerformed(java.awt.event.ActionEvent evt) {
173 timeRadioButton5ActionPerformed(evt);
177 ingestWarningLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png")));
178 ingestWarningLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class,
"KeywordSearchGlobalSearchSettingsPanel.ingestWarningLabel.text"));
180 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
181 this.setLayout(layout);
182 layout.setHorizontalGroup(
183 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
184 .addGroup(layout.createSequentialGroup()
186 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
187 .addGroup(layout.createSequentialGroup()
188 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
189 .addGroup(layout.createSequentialGroup()
190 .addComponent(settingsLabel)
191 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
192 .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE))
193 .addGroup(layout.createSequentialGroup()
194 .addComponent(informationLabel)
195 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
196 .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE))
197 .addGroup(layout.createSequentialGroup()
199 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
200 .addComponent(skipNSRLCheckBox)
201 .addComponent(showSnippetsCB)
202 .addGroup(layout.createSequentialGroup()
203 .addComponent(filesIndexedLabel)
205 .addComponent(filesIndexedValue))
206 .addComponent(frequencyLabel)
207 .addGroup(layout.createSequentialGroup()
209 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
210 .addComponent(timeRadioButton2)
211 .addComponent(timeRadioButton1)
212 .addComponent(timeRadioButton3)
213 .addComponent(timeRadioButton4)
214 .addComponent(timeRadioButton5)))
215 .addGroup(layout.createSequentialGroup()
216 .addComponent(chunksLabel)
218 .addComponent(chunksValLabel)))))
219 .addGap(0, 0, Short.MAX_VALUE))
220 .addComponent(ingestWarningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
224 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {chunksLabel, filesIndexedLabel});
226 layout.setVerticalGroup(
227 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
228 .addGroup(layout.createSequentialGroup()
230 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
231 .addComponent(settingsLabel)
232 .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE))
233 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
234 .addComponent(skipNSRLCheckBox)
235 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
236 .addComponent(showSnippetsCB)
237 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
238 .addComponent(frequencyLabel)
239 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
240 .addComponent(timeRadioButton1)
241 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
242 .addComponent(timeRadioButton2)
243 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
244 .addComponent(timeRadioButton3)
245 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
246 .addComponent(timeRadioButton4)
247 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
248 .addComponent(timeRadioButton5)
249 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
250 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
251 .addComponent(informationLabel)
252 .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE))
253 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
254 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
255 .addComponent(filesIndexedLabel)
256 .addComponent(filesIndexedValue))
257 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
258 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
259 .addComponent(chunksLabel)
260 .addComponent(chunksValLabel))
261 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
262 .addComponent(ingestWarningLabel)
263 .addContainerGap(66, Short.MAX_VALUE))
267 private void timeRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {
268 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
271 private void skipNSRLCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
272 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
275 private void showSnippetsCBActionPerformed(java.awt.event.ActionEvent evt) {
276 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
279 private void timeRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
280 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
283 private void timeRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
284 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
287 private void timeRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {
288 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
291 private void timeRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {
292 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
296 private javax.swing.JLabel chunksLabel;
297 private javax.swing.JLabel chunksValLabel;
298 private javax.swing.JLabel filesIndexedLabel;
299 private javax.swing.JLabel filesIndexedValue;
300 private javax.swing.JLabel frequencyLabel;
301 private javax.swing.JLabel informationLabel;
302 private javax.swing.JSeparator informationSeparator;
303 private javax.swing.JLabel ingestWarningLabel;
304 private javax.swing.JLabel settingsLabel;
305 private javax.swing.JSeparator settingsSeparator;
306 private javax.swing.JCheckBox showSnippetsCB;
307 private javax.swing.JCheckBox skipNSRLCheckBox;
308 private javax.swing.ButtonGroup timeGroup;
309 private javax.swing.JRadioButton timeRadioButton1;
310 private javax.swing.JRadioButton timeRadioButton2;
311 private javax.swing.JRadioButton timeRadioButton3;
312 private javax.swing.JRadioButton timeRadioButton4;
313 private javax.swing.JRadioButton timeRadioButton5;
317 public void store() {
318 KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
319 KeywordSearchSettings.setUpdateFrequency(getSelectedTimeValue());
320 KeywordSearchSettings.setShowSnippets(showSnippetsCB.isSelected());
328 private void setTimeSettingEnabled(
boolean enabled) {
329 timeRadioButton1.setEnabled(enabled);
330 timeRadioButton2.setEnabled(enabled);
331 timeRadioButton3.setEnabled(enabled);
332 timeRadioButton4.setEnabled(enabled);
333 timeRadioButton5.setEnabled(enabled);
334 frequencyLabel.setEnabled(enabled);
337 private UpdateFrequency getSelectedTimeValue() {
338 if (timeRadioButton1.isSelected()) {
339 return UpdateFrequency.FAST;
340 }
else if (timeRadioButton2.isSelected()) {
341 return UpdateFrequency.AVG;
342 }
else if (timeRadioButton3.isSelected()) {
343 return UpdateFrequency.SLOW;
344 }
else if (timeRadioButton4.isSelected()) {
345 return UpdateFrequency.SLOWEST;
346 }
else if (timeRadioButton5.isSelected()) {
347 return UpdateFrequency.NONE;
349 return UpdateFrequency.DEFAULT;
352 private void customizeComponents() {
354 timeGroup.add(timeRadioButton1);
355 timeGroup.add(timeRadioButton2);
356 timeGroup.add(timeRadioButton3);
357 timeGroup.add(timeRadioButton4);
358 timeGroup.add(timeRadioButton5);
360 this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
363 filesIndexedValue.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedFiles()));
364 chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
365 }
catch (KeywordSearchModuleException | NoOpenCoreException ex) {
366 logger.log(Level.WARNING,
"Could not get number of indexed files/chunks");
369 KeywordSearch.addNumIndexedFilesChangeListener(
370 new PropertyChangeListener() {
372 public void propertyChange(PropertyChangeEvent evt) {
373 String changed = evt.getPropertyName();
374 Object newValue = evt.getNewValue();
376 if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
377 int newFilesIndexed = ((Integer) newValue);
378 filesIndexedValue.setText(Integer.toString(newFilesIndexed));
380 chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
381 }
catch (KeywordSearchModuleException | NoOpenCoreException ex) {
382 logger.log(Level.WARNING,
"Could not get number of indexed chunks");
390 IngestManager.getInstance().addIngestJobEventListener(
new PropertyChangeListener() {
392 public void propertyChange(PropertyChangeEvent evt) {
393 Object source = evt.getSource();
394 if (source instanceof String && ((String) source).equals(
"LOCAL")) {
395 EventQueue.invokeLater(() -> {