19 package org.sleuthkit.autopsy.modules.hashdatabase;
 
   22 import java.awt.event.KeyEvent;
 
   23 import java.beans.PropertyChangeEvent;
 
   24 import java.beans.PropertyChangeListener;
 
   26 import java.util.ArrayList;
 
   27 import java.util.List;
 
   28 import java.util.logging.Level;
 
   29 import javax.swing.JComponent;
 
   30 import javax.swing.JOptionPane;
 
   31 import javax.swing.JTable;
 
   32 import javax.swing.ListSelectionModel;
 
   33 import javax.swing.event.ListSelectionEvent;
 
   34 import javax.swing.event.ListSelectionListener;
 
   35 import javax.swing.table.AbstractTableModel;
 
   36 import javax.swing.table.TableCellRenderer;
 
   38 import org.openide.util.NbBundle;
 
   71             public void propertyChange(PropertyChangeEvent evt) {
 
   73                     EventQueue.invokeLater(
new Runnable() {
 
   85         setName(NbBundle.getMessage(
this.getClass(), 
"HashDbConfigPanel.setName.hashSetConfig"));
 
   90         hashSetTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
 
   91         hashSetTable.getSelectionModel().addListSelectionListener(
new ListSelectionListener() {
 
   93             public void valueChanged(ListSelectionEvent e) {
 
   94                 if (!e.getValueIsAdjusting()) {
 
  122         indexButton.setText(NbBundle.getMessage(
this.getClass(), 
"HashDbConfigPanel.indexButtonText.index"));
 
  163             if (db.isIndexing()) {
 
  165                         NbBundle.getMessage(
this.getClass(), 
"HashDbConfigPanel.indexButtonText.indexing"));
 
  167                         NbBundle.getMessage(
this.getClass(), 
"HashDbConfigPanel.indexStatusText.indexGen"));
 
  170             } 
else if (db.hasIndex()) {
 
  171                 if (db.hasIndexOnly()) {
 
  173                             NbBundle.getMessage(
this.getClass(), 
"HashDbConfigPanel.indexStatusText.indexOnly"));
 
  176                             NbBundle.getMessage(
this.getClass(), 
"HashDbConfigPanel.indexStatusText.indexed"));
 
  179                 if (db.canBeReIndexed()) {
 
  181                             NbBundle.getMessage(
this.getClass(), 
"HashDbConfigPanel.indexButtonText.reIndex"));
 
  184                     indexButton.setText(NbBundle.getMessage(
this.getClass(), 
"HashDbConfigPanel.indexButtonText.index"));
 
  189                         NbBundle.getMessage(
this.getClass(), 
"HashDbConfigPanel.indexStatusText.noIndex"));
 
  191                 indexButton.setText(NbBundle.getMessage(
this.getClass(), 
"HashDbConfigPanel.indexButtonText.index"));
 
  198             indexButton.setText(NbBundle.getMessage(
this.getClass(), 
"HashDbConfigPanel.indexButtonText.index"));
 
  203         if (ingestIsRunning) {
 
  223         String shortenedPath = path;
 
  224         if (shortenedPath.length() > 50) {
 
  225             shortenedPath = shortenedPath.substring(0, 10 + shortenedPath.substring(10).indexOf(File.separator) + 1) + 
"..." + shortenedPath.substring((shortenedPath.length() - 20) + shortenedPath.substring(shortenedPath.length() - 20).indexOf(File.separator));
 
  227         return shortenedPath;
 
  239         List<HashDb> unindexed = 
new ArrayList<>();
 
  242                 if (!hashSet.hasIndex()) {
 
  243                     unindexed.add(hashSet);
 
  251         if (unindexed.size() == 1) {
 
  253         } 
else if (unindexed.size() > 1) {
 
  257         hashSetManager.save();
 
  263         hashSetTableModel.refreshModel();
 
  281     void removeThese(List<HashDb> toRemove) {
 
  282         for (
HashDb hashDb : toRemove) {
 
  283             hashSetManager.removeHashDatabaseInternal(hashDb);
 
  285         hashSetTableModel.refreshModel();
 
  299         for (
HashDb hdb : unindexed) {
 
  300             total += 
"\n" + hdb.getHashSetName();
 
  303             message = NbBundle.getMessage(this.getClass(), 
"HashDbConfigPanel.dbsNotIndexedMsg", total);
 
  305             message = NbBundle.getMessage(this.getClass(), 
"HashDbConfigPanel.dbNotIndexedMsg", total);
 
  307         int res = JOptionPane.showConfirmDialog(
this, message,
 
  308                 NbBundle.getMessage(
this.getClass(),
 
  309                 "HashDbConfigPanel.unindexedDbsMsg"),
 
  310                 JOptionPane.YES_NO_OPTION);
 
  311         if (res == JOptionPane.YES_OPTION) {
 
  312             ModalNoButtons indexingDialog = 
new ModalNoButtons(
this, 
new Frame(), unindexed);
 
  313             indexingDialog.setLocationRelativeTo(null);
 
  314             indexingDialog.setVisible(
true);
 
  315             indexingDialog.setModal(
true);
 
  316             hashSetTableModel.refreshModel();
 
  318         if (res == JOptionPane.NO_OPTION) {
 
  319             JOptionPane.showMessageDialog(
this, NbBundle.getMessage(
this.getClass(),
 
  320                     "HashDbConfigPanel.allUnindexedDbsRmFromListMsg"));
 
  321             removeThese(unindexed);
 
  337             JComponent cellRenderer = (JComponent) super.prepareRenderer(renderer, row, column);
 
  338             cellRenderer.setToolTipText((String) getValueAt(row, column));
 
  344                 cellRenderer.setForeground(Color.black);
 
  346                 cellRenderer.setForeground(Color.red);
 
  353             return hashSetTableModel.getHashSetAt(getSelectionModel().getMinSelectionIndex());
 
  358                 getSelectionModel().setSelectionInterval(index, index);
 
  382             return hashSets.size();
 
  387             return NbBundle.getMessage(this.getClass(), 
"HashDbConfigPanel.nameColLbl");
 
  392             return hashSets.get(rowIndex).getHashSetName();
 
  397                 return hashSets.get(rowIndex).hasIndex();
 
  410         public void setValueAt(Object aValue, 
int rowIndex, 
int columnIndex) {
 
  411             throw new UnsupportedOperationException(
 
  412                     NbBundle.getMessage(
this.getClass(), 
"HashDbConfigPanel.editingCellsNotSupportedMsg"));
 
  420         HashDb getHashSetAt(
int index) {
 
  421             if (!hashSets.isEmpty() && index >= 0 && index < hashSets.size()) {
 
  422                 return hashSets.get(index);
 
  428         int getIndexByName(String name) {
 
  429             for (
int i = 0; i < hashSets.size(); ++i) {
 
  430                 if (hashSets.get(i).getHashSetName().equals(name)) {
 
  437         void refreshModel() {
 
  438             hashSets = HashDbManager.getInstance().getAllHashSets();
 
  442         void refreshDisplay() {
 
  443             fireTableDataChanged();
 
  455         jLabel2 = 
new javax.swing.JLabel();
 
  456         jLabel4 = 
new javax.swing.JLabel();
 
  457         jLabel6 = 
new javax.swing.JLabel();
 
  458         jButton3 = 
new javax.swing.JButton();
 
  460         jPanel1 = 
new javax.swing.JPanel();
 
  491         jButton3.setFont(
new java.awt.Font(
"Tahoma", 0, 14)); 
 
  494         setMinimumSize(
new java.awt.Dimension(700, 430));
 
  495         setPreferredSize(
new java.awt.Dimension(700, 430));
 
  497         jPanel1.setPreferredSize(
new java.awt.Dimension(671, 430));
 
  499         ingestWarningLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png"))); 
 
  502         hashSetTable.setModel(
new javax.swing.table.DefaultTableModel(
 
  512         hashSetTable.addKeyListener(
new java.awt.event.KeyAdapter() {
 
  513             public void keyPressed(java.awt.event.KeyEvent evt) {
 
  519         deleteDatabaseButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/delete16.png"))); 
 
  525             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  530         importDatabaseButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/import16.png"))); 
 
  536             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  561         indexButton.addActionListener(
new java.awt.event.ActionListener() {
 
  562             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  569             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  578         createDatabaseButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/new16.png"))); 
 
  584             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  593         javax.swing.GroupLayout jPanel1Layout = 
new javax.swing.GroupLayout(
jPanel1);
 
  594         jPanel1.setLayout(jPanel1Layout);
 
  595         jPanel1Layout.setHorizontalGroup(
 
  596             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  597             .addGroup(jPanel1Layout.createSequentialGroup()
 
  599                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  600                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  601                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
false)
 
  602                             .addGroup(jPanel1Layout.createSequentialGroup()
 
  603                                 .addComponent(
createDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  604                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 
  605                                 .addComponent(
importDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  606                             .addComponent(
jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  607                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  608                             .addGroup(jPanel1Layout.createSequentialGroup()
 
  610                                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  611                                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  613                                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  616                                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
 
  618                                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  619                                             .addGroup(jPanel1Layout.createSequentialGroup()
 
  620                                                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  622                                                     .addComponent(
indexButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  624                                                     .addComponent(
indexLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  627                                                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  628                                                     .addComponent(
hashDbTypeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 
  629                                                     .addComponent(
hashDbLocationLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 
  630                                                     .addComponent(
indexPathLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 
  631                                                     .addComponent(
hashDbIndexStatusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
 
  632                                             .addGroup(jPanel1Layout.createSequentialGroup()
 
  636                                                 .addGap(0, 0, Short.MAX_VALUE))))
 
  637                                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  639                                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  640                                         .addComponent(
optionsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE))))
 
  641                             .addGroup(jPanel1Layout.createSequentialGroup()
 
  644                                 .addGap(0, 0, Short.MAX_VALUE))))
 
  645                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  646                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  648                             .addComponent(
deleteDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  649                         .addGap(0, 0, Short.MAX_VALUE)))
 
  652         jPanel1Layout.setVerticalGroup(
 
  653             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  654             .addGroup(jPanel1Layout.createSequentialGroup()
 
  658                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  659                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  660                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  662                             .addGroup(jPanel1Layout.createSequentialGroup()
 
  664                                 .addComponent(
informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 3, javax.swing.GroupLayout.PREFERRED_SIZE)))
 
  666                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  669                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  670                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  673                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  674                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  677                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  678                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  681                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  682                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  685                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  688                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
 
  690                             .addComponent(
optionsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  695                     .addComponent(
jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 304, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  696                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  697                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  698                     .addComponent(
importDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  699                     .addComponent(
createDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  700                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  701                 .addComponent(
deleteDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  702                 .addContainerGap(33, Short.MAX_VALUE))
 
  707         javax.swing.GroupLayout layout = 
new javax.swing.GroupLayout(
this);
 
  708         this.setLayout(layout);
 
  709         layout.setHorizontalGroup(
 
  710             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  711             .addGroup(layout.createSequentialGroup()
 
  713                 .addComponent(
jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 690, Short.MAX_VALUE))
 
  715         layout.setVerticalGroup(
 
  716             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  717             .addGroup(layout.createSequentialGroup()
 
  719                 .addComponent(
jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 410, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  720                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  726         assert hashDb != null;
 
  732             public void propertyChange(PropertyChangeEvent evt) {
 
  735                     if (selectedHashDb != null && hashDb != null && hashDb.equals(selectedHashDb)) {
 
  738                     hashSetTableModel.refreshDisplay();
 
  748         ModalNoButtons indexDialog = 
new ModalNoButtons(
this, 
new Frame(), hashDb);
 
  749         indexDialog.setLocationRelativeTo(null);
 
  750         indexDialog.setVisible(
true);
 
  751         indexDialog.setModal(
true);
 
  755         if (JOptionPane.showConfirmDialog(null,
 
  756                 NbBundle.getMessage(
this.getClass(),
 
  757                 "HashDbConfigPanel.deleteDbActionConfirmMsg"),
 
  758                 NbBundle.getMessage(
this.getClass(), 
"HashDbConfigPanel.deleteDbActionMsg"),
 
  759                 JOptionPane.YES_NO_OPTION,
 
  760                 JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
 
  762             if (hashDb != null) {
 
  763                 hashSetManager.removeHashDatabaseInternal(hashDb);
 
  764                 hashSetTableModel.refreshModel();
 
  770         if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
 
  772             if (hashDb != null) {
 
  773                 hashSetManager.removeHashDatabaseInternal(hashDb);
 
  774                 hashSetTableModel.refreshModel();
 
  781         if (hashDb != null) {
 
  787         HashDb hashDb = 
new HashDbImportDatabaseDialog().getHashDatabase();
 
  788         if (null != hashDb) {
 
  789             hashSetTableModel.refreshModel();
 
  795         HashDb hashDb = 
new HashDbCreateDatabaseDialog().getHashDatabase();
 
  796         if (null != hashDb) {
 
  797             hashSetTableModel.refreshModel();
 
HashDbManager hashSetManager
 
void importDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt)
 
boolean getSendIngestMessages()
 
javax.swing.JLabel indexLabel
 
static synchronized IngestManager getInstance()
 
boolean isCellEditable(int rowIndex, int columnIndex)
 
javax.swing.JLabel hashDbIndexStatusLabel
 
javax.swing.JLabel jLabel6
 
void setValueAt(Object aValue, int rowIndex, int columnIndex)
 
javax.swing.JLabel optionsLabel
 
boolean getSearchDuringIngest()
 
javax.swing.JLabel hashDatabasesLabel
 
javax.swing.JLabel ingestWarningLabel
 
javax.swing.JLabel typeLabel
 
javax.swing.JLabel indexPathLabel
 
void updateComponentsForSelection(HashDb db)
 
javax.swing.JButton createDatabaseButton
 
void createDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt)
 
static String shortenPath(String path)
 
boolean indexExists(int rowIndex)
 
boolean isIngestRunning()
 
HashLookupSettingsPanel()
 
javax.swing.JButton jButton3
 
javax.swing.JScrollPane jScrollPane1
 
void updateComponentsForNoSelection()
 
boolean isIngestJobEvent(PropertyChangeEvent evt)
 
javax.swing.JLabel hashDbLocationLabel
 
javax.swing.JLabel nameLabel
 
javax.swing.JLabel locationLabel
 
javax.swing.JButton indexButton
 
javax.swing.JLabel informationLabel
 
void addPropertyChangeListener(PropertyChangeListener pcl)
 
void sendIngestMessagesCheckBoxActionPerformed(java.awt.event.ActionEvent evt)
 
Component prepareRenderer(TableCellRenderer renderer, int row, int column)
 
static final String ERROR_GETTING_INDEX_STATUS_TEXT
 
void indexButtonActionPerformed(java.awt.event.ActionEvent evt)
 
void customizeComponents()
 
void addIngestJobEventListener(final PropertyChangeListener listener)
 
static final String NO_SELECTION_TEXT
 
javax.swing.JLabel jLabel2
 
javax.swing.JScrollPane jScrollPane2
 
static synchronized HashDbManager getInstance()
 
javax.swing.JLabel indexPathLabelLabel
 
void hashSetTableKeyPressed(java.awt.event.KeyEvent evt)
 
void selectRowByName(String name)
 
javax.swing.JTable hashSetTable
 
javax.swing.JLabel hashDbNameLabel
 
String getColumnName(int column)
 
static final String ERROR_GETTING_PATH_TEXT
 
javax.swing.JLabel jLabel4
 
synchronized List< HashDb > getAllHashSets()
 
javax.swing.JButton deleteDatabaseButton
 
Object getValueAt(int rowIndex, int columnIndex)
 
Class<?> getColumnClass(int c)
 
void setSelection(int index)
 
javax.swing.JSeparator optionsSeparator
 
synchronized void loadLastSavedConfiguration()
 
void showInvalidIndex(boolean plural, List< HashDb > unindexed)
 
javax.swing.JLabel hashDbTypeLabel
 
HashSetTableModel hashSetTableModel
 
KnownFilesType getKnownFilesType()
 
void deleteDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt)
 
javax.swing.JSeparator informationSeparator
 
javax.swing.JButton importDatabaseButton
 
javax.swing.JPanel jPanel1
 
static Logger getLogger(String name)
 
javax.swing.JCheckBox sendIngestMessagesCheckBox