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.setFont(ingestWarningLabel.getFont().deriveFont(ingestWarningLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
 
  178         ingestWarningLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png"))); 
 
  179         ingestWarningLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.ingestWarningLabel.text")); 
 
  181         javax.swing.GroupLayout layout = 
new javax.swing.GroupLayout(
this);
 
  182         this.setLayout(layout);
 
  183         layout.setHorizontalGroup(
 
  184             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  185             .addGroup(layout.createSequentialGroup()
 
  187                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  188                     .addGroup(layout.createSequentialGroup()
 
  189                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  190                             .addGroup(layout.createSequentialGroup()
 
  191                                 .addComponent(settingsLabel)
 
  192                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  193                                 .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  194                             .addGroup(layout.createSequentialGroup()
 
  195                                 .addComponent(informationLabel)
 
  196                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  197                                 .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  198                             .addGroup(layout.createSequentialGroup()
 
  200                                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  201                                     .addComponent(skipNSRLCheckBox)
 
  202                                     .addComponent(showSnippetsCB)
 
  203                                     .addGroup(layout.createSequentialGroup()
 
  204                                         .addComponent(filesIndexedLabel)
 
  206                                         .addComponent(filesIndexedValue))
 
  207                                     .addComponent(frequencyLabel)
 
  208                                     .addGroup(layout.createSequentialGroup()
 
  210                                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  211                                             .addComponent(timeRadioButton2)
 
  212                                             .addComponent(timeRadioButton1)
 
  213                                             .addComponent(timeRadioButton3)
 
  214                                             .addComponent(timeRadioButton4)
 
  215                                             .addComponent(timeRadioButton5)))
 
  216                                     .addGroup(layout.createSequentialGroup()
 
  217                                         .addComponent(chunksLabel)
 
  219                                         .addComponent(chunksValLabel)))))
 
  220                         .addGap(0, 0, Short.MAX_VALUE))
 
  221                     .addComponent(ingestWarningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  225         layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, 
new java.awt.Component[] {chunksLabel, filesIndexedLabel});
 
  227         layout.setVerticalGroup(
 
  228             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  229             .addGroup(layout.createSequentialGroup()
 
  231                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
 
  232                     .addComponent(settingsLabel)
 
  233                     .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  234                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  235                 .addComponent(skipNSRLCheckBox)
 
  236                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  237                 .addComponent(showSnippetsCB)
 
  238                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  239                 .addComponent(frequencyLabel)
 
  240                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  241                 .addComponent(timeRadioButton1)
 
  242                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  243                 .addComponent(timeRadioButton2)
 
  244                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  245                 .addComponent(timeRadioButton3)
 
  246                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  247                 .addComponent(timeRadioButton4)
 
  248                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  249                 .addComponent(timeRadioButton5)
 
  250                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  251                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
 
  252                     .addComponent(informationLabel)
 
  253                     .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  254                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  255                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  256                     .addComponent(filesIndexedLabel)
 
  257                     .addComponent(filesIndexedValue))
 
  258                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  259                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  260                     .addComponent(chunksLabel)
 
  261                     .addComponent(chunksValLabel))
 
  262                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  263                 .addComponent(ingestWarningLabel)
 
  264                 .addContainerGap(66, Short.MAX_VALUE))
 
  268     private void timeRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {
 
  269         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
  272     private void skipNSRLCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
 
  273         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
  276     private void showSnippetsCBActionPerformed(java.awt.event.ActionEvent evt) {
 
  277         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
  280     private void timeRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
 
  281         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
  284     private void timeRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
 
  285         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
  288     private void timeRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {
 
  289         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
  292     private void timeRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {
 
  293         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
  297     private javax.swing.JLabel chunksLabel;
 
  298     private javax.swing.JLabel chunksValLabel;
 
  299     private javax.swing.JLabel filesIndexedLabel;
 
  300     private javax.swing.JLabel filesIndexedValue;
 
  301     private javax.swing.JLabel frequencyLabel;
 
  302     private javax.swing.JLabel informationLabel;
 
  303     private javax.swing.JSeparator informationSeparator;
 
  304     private javax.swing.JLabel ingestWarningLabel;
 
  305     private javax.swing.JLabel settingsLabel;
 
  306     private javax.swing.JSeparator settingsSeparator;
 
  307     private javax.swing.JCheckBox showSnippetsCB;
 
  308     private javax.swing.JCheckBox skipNSRLCheckBox;
 
  309     private javax.swing.ButtonGroup timeGroup;
 
  310     private javax.swing.JRadioButton timeRadioButton1;
 
  311     private javax.swing.JRadioButton timeRadioButton2;
 
  312     private javax.swing.JRadioButton timeRadioButton3;
 
  313     private javax.swing.JRadioButton timeRadioButton4;
 
  314     private javax.swing.JRadioButton timeRadioButton5;
 
  318     public void store() {
 
  319         KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
 
  320         KeywordSearchSettings.setUpdateFrequency(getSelectedTimeValue());
 
  321         KeywordSearchSettings.setShowSnippets(showSnippetsCB.isSelected());
 
  329     private void setTimeSettingEnabled(
boolean enabled) {
 
  330         timeRadioButton1.setEnabled(enabled);
 
  331         timeRadioButton2.setEnabled(enabled);
 
  332         timeRadioButton3.setEnabled(enabled);
 
  333         timeRadioButton4.setEnabled(enabled);
 
  334         timeRadioButton5.setEnabled(enabled);
 
  335         frequencyLabel.setEnabled(enabled);
 
  338     private UpdateFrequency getSelectedTimeValue() {
 
  339         if (timeRadioButton1.isSelected()) {
 
  340             return UpdateFrequency.FAST;
 
  341         } 
else if (timeRadioButton2.isSelected()) {
 
  342             return UpdateFrequency.AVG;
 
  343         } 
else if (timeRadioButton3.isSelected()) {
 
  344             return UpdateFrequency.SLOW;
 
  345         } 
else if (timeRadioButton4.isSelected()) {
 
  346             return UpdateFrequency.SLOWEST;
 
  347         } 
else if (timeRadioButton5.isSelected()) {
 
  348             return UpdateFrequency.NONE;
 
  350         return UpdateFrequency.DEFAULT;
 
  353     private void customizeComponents() {
 
  355         timeGroup.add(timeRadioButton1);
 
  356         timeGroup.add(timeRadioButton2);
 
  357         timeGroup.add(timeRadioButton3);
 
  358         timeGroup.add(timeRadioButton4);
 
  359         timeGroup.add(timeRadioButton5);
 
  361         this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
 
  364             filesIndexedValue.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedFiles()));
 
  365             chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
 
  366         } 
catch (KeywordSearchModuleException | NoOpenCoreException ex) {
 
  367             logger.log(Level.WARNING, 
"Could not get number of indexed files/chunks"); 
 
  370         KeywordSearch.addNumIndexedFilesChangeListener(
 
  371                 new PropertyChangeListener() {
 
  373             public void propertyChange(PropertyChangeEvent evt) {
 
  374                 String changed = evt.getPropertyName();
 
  375                 Object newValue = evt.getNewValue();
 
  377                 if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
 
  378                     int newFilesIndexed = ((Integer) newValue);
 
  379                     filesIndexedValue.setText(Integer.toString(newFilesIndexed));
 
  381                         chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
 
  382                     } 
catch (KeywordSearchModuleException | NoOpenCoreException ex) {
 
  383                         logger.log(Level.WARNING, 
"Could not get number of indexed chunks"); 
 
  391         IngestManager.getInstance().addIngestJobEventListener(
new PropertyChangeListener() {
 
  393             public void propertyChange(PropertyChangeEvent evt) {
 
  394                 Object source = evt.getSource();
 
  395                 if (source instanceof String && ((String) source).equals(
"LOCAL")) { 
 
  396                     EventQueue.invokeLater(() -> {