19 package org.sleuthkit.autopsy.keywordsearch;
 
   21 import java.beans.PropertyChangeEvent;
 
   22 import java.beans.PropertyChangeListener;
 
   23 import java.util.logging.Level;
 
   32 class KeywordSearchGlobalSearchSettingsPanel 
extends javax.swing.JPanel implements OptionsPanel {
 
   34     private final Logger logger = Logger.getLogger(KeywordSearchGlobalSearchSettingsPanel.class.getName());
 
   39     KeywordSearchGlobalSearchSettingsPanel() {
 
   41         customizeComponents();
 
   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);
 
   51         final UpdateFrequency curFreq = KeywordSearchSettings.getUpdateFrequency();
 
   54                 timeRadioButton1.setSelected(
true);
 
   57                 timeRadioButton2.setSelected(
true);
 
   60                 timeRadioButton3.setSelected(
true);
 
   63                 timeRadioButton4.setSelected(
true);
 
   66                 timeRadioButton5.setSelected(
true);
 
   71                 timeRadioButton3.setSelected(
true);
 
   81     @SuppressWarnings(
"unchecked")
 
   83     private 
void initComponents() {
 
   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();
 
  103         skipNSRLCheckBox.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.text")); 
 
  104         skipNSRLCheckBox.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.toolTipText")); 
 
  106         filesIndexedLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedLabel.text")); 
 
  108         filesIndexedValue.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedValue.text")); 
 
  109         filesIndexedValue.setMaximumSize(null);
 
  111         chunksLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.chunksLabel.text")); 
 
  113         chunksValLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.chunksValLabel.text")); 
 
  115         settingsLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.settingsLabel.text")); 
 
  117         informationLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.informationLabel.text")); 
 
  119         frequencyLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.frequencyLabel.text")); 
 
  121         timeRadioButton1.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.text")); 
 
  122         timeRadioButton1.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton1.toolTipText")); 
 
  124         timeRadioButton2.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.text")); 
 
  125         timeRadioButton2.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton2.toolTipText")); 
 
  127         timeRadioButton3.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.text")); 
 
  128         timeRadioButton3.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton3.toolTipText")); 
 
  130         timeRadioButton4.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.text_1")); 
 
  131         timeRadioButton4.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton4.toolTipText")); 
 
  133         showSnippetsCB.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.showSnippetsCB.text")); 
 
  135         timeRadioButton5.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.text")); 
 
  136         timeRadioButton5.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.timeRadioButton5.toolTipText")); 
 
  137         timeRadioButton5.addActionListener(
new java.awt.event.ActionListener() {
 
  138             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  139                 timeRadioButton5ActionPerformed(evt);
 
  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()
 
  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()
 
  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()
 
  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)
 
  179                                 .addComponent(chunksValLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)))))
 
  180                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  182         layout.setVerticalGroup(
 
  183             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  184             .addGroup(layout.createSequentialGroup()
 
  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))
 
  221     private void timeRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {
 
  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;
 
  246     public void store() {
 
  247         KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
 
  248         KeywordSearchSettings.setUpdateFrequency(getSelectedTimeValue());
 
  249         KeywordSearchSettings.setShowSnippets(showSnippetsCB.isSelected());
 
  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);
 
  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;
 
  278         return UpdateFrequency.DEFAULT;
 
  281     private void customizeComponents() {
 
  283         timeGroup.add(timeRadioButton1);
 
  284         timeGroup.add(timeRadioButton2);
 
  285         timeGroup.add(timeRadioButton3);
 
  286         timeGroup.add(timeRadioButton4);
 
  287         timeGroup.add(timeRadioButton5);
 
  289         this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
 
  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"); 
 
  298         KeywordSearch.addNumIndexedFilesChangeListener(
 
  299                 new PropertyChangeListener() {
 
  301             public void propertyChange(PropertyChangeEvent evt) {
 
  302                 String changed = evt.getPropertyName();
 
  303                 Object newValue = evt.getNewValue();
 
  305                 if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
 
  306                     int newFilesIndexed = ((Integer) newValue).intValue();
 
  307                     filesIndexedValue.setText(Integer.toString(newFilesIndexed));
 
  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");