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;
 
   26 import org.openide.util.NbBundle;
 
   34 @SuppressWarnings(
"PMD.SingularField") 
 
   35 class KeywordSearchGlobalSearchSettingsPanel extends javax.swing.JPanel implements OptionsPanel {
 
   37     private static final long serialVersionUID = 1L;
 
   38     private final Logger logger = Logger.getLogger(KeywordSearchGlobalSearchSettingsPanel.class.getName());
 
   43     KeywordSearchGlobalSearchSettingsPanel() {
 
   45         customizeComponents();
 
   48     private void activateWidgets() {
 
   49         skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
 
   50         showSnippetsCB.setSelected(KeywordSearchSettings.getShowSnippets());
 
   51         boolean ingestRunning = IngestManager.getInstance().isIngestRunning();
 
   52         ingestWarningLabel.setVisible(ingestRunning);
 
   53         skipNSRLCheckBox.setEnabled(!ingestRunning);
 
   61     @SuppressWarnings(
"unchecked")
 
   63     private 
void initComponents() {
 
   65         skipNSRLCheckBox = 
new javax.swing.JCheckBox();
 
   66         filesIndexedLabel = 
new javax.swing.JLabel();
 
   67         filesIndexedValue = 
new javax.swing.JLabel();
 
   68         chunksLabel = 
new javax.swing.JLabel();
 
   69         chunksValLabel = 
new javax.swing.JLabel();
 
   70         settingsLabel = 
new javax.swing.JLabel();
 
   71         informationLabel = 
new javax.swing.JLabel();
 
   72         settingsSeparator = 
new javax.swing.JSeparator();
 
   73         informationSeparator = 
new javax.swing.JSeparator();
 
   74         showSnippetsCB = 
new javax.swing.JCheckBox();
 
   75         ingestWarningLabel = 
new javax.swing.JLabel();
 
   77         skipNSRLCheckBox.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.text")); 
 
   78         skipNSRLCheckBox.setToolTipText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.skipNSRLCheckBox.toolTipText")); 
 
   79         skipNSRLCheckBox.addActionListener(
new java.awt.event.ActionListener() {
 
   80             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
   81                 skipNSRLCheckBoxActionPerformed(evt);
 
   85         filesIndexedLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedLabel.text")); 
 
   87         filesIndexedValue.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.filesIndexedValue.text")); 
 
   89         chunksLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.chunksLabel.text")); 
 
   91         chunksValLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.chunksValLabel.text")); 
 
   93         settingsLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.settingsLabel.text")); 
 
   95         informationLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.informationLabel.text")); 
 
   97         showSnippetsCB.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.showSnippetsCB.text")); 
 
   98         showSnippetsCB.addActionListener(
new java.awt.event.ActionListener() {
 
   99             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  100                 showSnippetsCBActionPerformed(evt);
 
  104         ingestWarningLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png"))); 
 
  105         ingestWarningLabel.setText(
org.openide.util.NbBundle.getMessage(KeywordSearchGlobalSearchSettingsPanel.class, 
"KeywordSearchGlobalSearchSettingsPanel.ingestWarningLabel.text")); 
 
  107         javax.swing.GroupLayout layout = 
new javax.swing.GroupLayout(
this);
 
  108         this.setLayout(layout);
 
  109         layout.setHorizontalGroup(
 
  110             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  111             .addGroup(layout.createSequentialGroup()
 
  113                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  114                     .addGroup(layout.createSequentialGroup()
 
  116                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  117                             .addComponent(skipNSRLCheckBox)
 
  118                             .addComponent(showSnippetsCB))
 
  119                         .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  120                     .addGroup(layout.createSequentialGroup()
 
  121                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  122                             .addComponent(ingestWarningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 
  123                             .addGroup(layout.createSequentialGroup()
 
  124                                 .addComponent(informationLabel)
 
  125                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  126                                 .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  127                             .addGroup(layout.createSequentialGroup()
 
  129                                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  130                                     .addGroup(layout.createSequentialGroup()
 
  131                                         .addComponent(filesIndexedLabel)
 
  133                                         .addComponent(filesIndexedValue))
 
  134                                     .addGroup(layout.createSequentialGroup()
 
  135                                         .addComponent(chunksLabel)
 
  137                                         .addComponent(chunksValLabel)))
 
  138                                 .addGap(132, 132, 132)))
 
  139                         .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  140                     .addGroup(layout.createSequentialGroup()
 
  141                         .addComponent(settingsLabel)
 
  142                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  143                         .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  144                         .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
 
  147         layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, 
new java.awt.Component[] {chunksLabel, filesIndexedLabel});
 
  149         layout.setVerticalGroup(
 
  150             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  151             .addGroup(layout.createSequentialGroup()
 
  153                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
 
  154                     .addComponent(settingsLabel)
 
  155                     .addComponent(settingsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  156                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  157                 .addComponent(skipNSRLCheckBox)
 
  158                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  159                 .addComponent(showSnippetsCB)
 
  160                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  161                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
 
  162                     .addComponent(informationLabel)
 
  163                     .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  164                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  165                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  166                     .addComponent(filesIndexedLabel)
 
  167                     .addComponent(filesIndexedValue))
 
  168                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  169                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  170                     .addComponent(chunksLabel)
 
  171                     .addComponent(chunksValLabel))
 
  172                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  173                 .addComponent(ingestWarningLabel)
 
  174                 .addContainerGap(151, Short.MAX_VALUE))
 
  178     private void skipNSRLCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
 
  179         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
  182     private void showSnippetsCBActionPerformed(java.awt.event.ActionEvent evt) {
 
  183         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
  187     private javax.swing.JLabel chunksLabel;
 
  188     private javax.swing.JLabel chunksValLabel;
 
  189     private javax.swing.JLabel filesIndexedLabel;
 
  190     private javax.swing.JLabel filesIndexedValue;
 
  191     private javax.swing.JLabel informationLabel;
 
  192     private javax.swing.JSeparator informationSeparator;
 
  193     private javax.swing.JLabel ingestWarningLabel;
 
  194     private javax.swing.JLabel settingsLabel;
 
  195     private javax.swing.JSeparator settingsSeparator;
 
  196     private javax.swing.JCheckBox showSnippetsCB;
 
  197     private javax.swing.JCheckBox skipNSRLCheckBox;
 
  201     public void store() {
 
  202         KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
 
  203         KeywordSearchSettings.setShowSnippets(showSnippetsCB.isSelected());
 
  211     @NbBundle.Messages({
"KeywordSearchGlobalSearchSettingsPanel.customizeComponents.windowsOCR=Enable Optical Character Recognition (OCR) (Requires Windows 64-bit)",
 
  212         "KeywordSearchGlobalSearchSettingsPanel.customizeComponents.windowsLimitedOCR=Only process images which are over 100KB in size or extracted from a document. (Beta) (Requires Windows 64-bit)"})
 
  213     private void customizeComponents() {
 
  215         this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
 
  218             filesIndexedValue.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedFiles()));
 
  219             chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
 
  220         } 
catch (KeywordSearchModuleException | NoOpenCoreException ex) {
 
  221             logger.log(Level.WARNING, 
"Could not get number of indexed files/chunks"); 
 
  224         KeywordSearch.addNumIndexedFilesChangeListener(
 
  225                 new PropertyChangeListener() {
 
  227             public void propertyChange(PropertyChangeEvent evt) {
 
  228                 String changed = evt.getPropertyName();
 
  229                 Object newValue = evt.getNewValue();
 
  231                 if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
 
  232                     int newFilesIndexed = ((Integer) newValue);
 
  233                     filesIndexedValue.setText(Integer.toString(newFilesIndexed));
 
  235                         chunksValLabel.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedChunks()));
 
  236                     } 
catch (KeywordSearchModuleException | NoOpenCoreException ex) {
 
  237                         logger.log(Level.WARNING, 
"Could not get number of indexed chunks"); 
 
  245         IngestManager.getInstance().addIngestJobEventListener(
new PropertyChangeListener() {
 
  247             public void propertyChange(PropertyChangeEvent evt) {
 
  248                 Object source = evt.getSource();
 
  249                 if (source instanceof String && ((String) source).equals(
"LOCAL")) { 
 
  250                     EventQueue.invokeLater(() -> {