Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
HashLookupSettingsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011 - 2013 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.modules.hashdatabase;
20 
21 import java.awt.*;
22 import java.awt.event.KeyEvent;
23 import java.beans.PropertyChangeEvent;
24 import java.beans.PropertyChangeListener;
25 import java.io.File;
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;
37 
38 import org.openide.util.NbBundle;
46 
52 
53  private static final String NO_SELECTION_TEXT = NbBundle
54  .getMessage(HashLookupSettingsPanel.class, "HashDbConfigPanel.noSelectionText");
55  private static final String ERROR_GETTING_PATH_TEXT = NbBundle
56  .getMessage(HashLookupSettingsPanel.class, "HashDbConfigPanel.errorGettingPathText");
57  private static final String ERROR_GETTING_INDEX_STATUS_TEXT = NbBundle
58  .getMessage(HashLookupSettingsPanel.class, "HashDbConfigPanel.errorGettingIndexStatusText");
61 
66 
67  // Listen to the ingest modules to refresh the enabled/disabled state of
68  // the components in sync with file ingest.
69  IngestManager.getInstance().addIngestJobEventListener(new PropertyChangeListener() {
70  @Override
71  public void propertyChange(PropertyChangeEvent evt) {
72  if (isIngestJobEvent(evt)) {
73  EventQueue.invokeLater(new Runnable() {
74  @Override
75  public void run() {
77  }
78  });
79  }
80  }
81  });
82  }
83 
84  private void customizeComponents() {
85  setName(NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.setName.hashSetConfig"));
86  this.ingestWarningLabel.setVisible(false);
87  this.hashSetTable.setModel(hashSetTableModel);
88  this.hashSetTable.setTableHeader(null);
89  hashSetTable.getParent().setBackground(hashSetTable.getBackground());
90  hashSetTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
91  hashSetTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
92  @Override
93  public void valueChanged(ListSelectionEvent e) {
94  if (!e.getValueIsAdjusting()) {
96  }
97  }
98  });
99  }
100 
101  private void updateComponents() {
102  HashDb db = ((HashSetTable) hashSetTable).getSelection();
103  if (db != null) {
105  } else {
107  }
108  }
109 
111  boolean ingestIsRunning = IngestManager.getInstance().isIngestRunning();
112 
113  // Update descriptive labels.
114  hashDbNameLabel.setText(NO_SELECTION_TEXT);
115  hashDbTypeLabel.setText(NO_SELECTION_TEXT);
116  hashDbLocationLabel.setText(NO_SELECTION_TEXT);
117  indexPathLabel.setText(NO_SELECTION_TEXT);
118 
119  // Update indexing components.
120  hashDbIndexStatusLabel.setText(NO_SELECTION_TEXT);
121  hashDbIndexStatusLabel.setForeground(Color.black);
122  indexButton.setText(NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexButtonText.index"));
123  indexButton.setEnabled(false);
124 
125  // Update ingest options.
126  sendIngestMessagesCheckBox.setSelected(false);
127  sendIngestMessagesCheckBox.setEnabled(false);
128  optionsLabel.setEnabled(false);
129  optionsSeparator.setEnabled(false);
130 
131  // Update database action buttons.
132  createDatabaseButton.setEnabled(true);
133  importDatabaseButton.setEnabled(true);
134  deleteDatabaseButton.setEnabled(false);
135 
136  // Update ingest in progress warning label.
137  ingestWarningLabel.setVisible(ingestIsRunning);
138  }
139 
141  boolean ingestIsRunning = IngestManager.getInstance().isIngestRunning();
142 
143  // Update descriptive labels.
144  hashDbNameLabel.setText(db.getHashSetName());
146 
147  try {
149  } catch (TskCoreException ex) {
150  Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error getting database path of " + db.getHashSetName() + " hash database", ex); //NON-NLS
151  hashDbLocationLabel.setText(ERROR_GETTING_PATH_TEXT);
152  }
153 
154  try {
155  indexPathLabel.setText(shortenPath(db.getIndexPath()));
156  } catch (TskCoreException ex) {
157  Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error getting index path of " + db.getHashSetName() + " hash database", ex); //NON-NLS
158  indexPathLabel.setText(ERROR_GETTING_PATH_TEXT);
159  }
160 
161  // Update indexing components.
162  try {
163  if (db.isIndexing()) {
164  indexButton.setText(
165  NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexButtonText.indexing"));
166  hashDbIndexStatusLabel.setText(
167  NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexStatusText.indexGen"));
168  hashDbIndexStatusLabel.setForeground(Color.black);
169  indexButton.setEnabled(false);
170  } else if (db.hasIndex()) {
171  if (db.hasIndexOnly()) {
172  hashDbIndexStatusLabel.setText(
173  NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexStatusText.indexOnly"));
174  } else {
175  hashDbIndexStatusLabel.setText(
176  NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexStatusText.indexed"));
177  }
178  hashDbIndexStatusLabel.setForeground(Color.black);
179  if (db.canBeReIndexed()) {
180  indexButton.setText(
181  NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexButtonText.reIndex"));
182  indexButton.setEnabled(true);
183  } else {
184  indexButton.setText(NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexButtonText.index"));
185  indexButton.setEnabled(false);
186  }
187  } else {
188  hashDbIndexStatusLabel.setText(
189  NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexStatusText.noIndex"));
190  hashDbIndexStatusLabel.setForeground(Color.red);
191  indexButton.setText(NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexButtonText.index"));
192  indexButton.setEnabled(true);
193  }
194  } catch (TskCoreException ex) {
195  Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error getting index state of hash database", ex); //NON-NLS
196  hashDbIndexStatusLabel.setText(ERROR_GETTING_INDEX_STATUS_TEXT);
197  hashDbIndexStatusLabel.setForeground(Color.red);
198  indexButton.setText(NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexButtonText.index"));
199  indexButton.setEnabled(false);
200  }
201 
202  // Disable the indexing button if ingest is in progress.
203  if (ingestIsRunning) {
204  indexButton.setEnabled(false);
205  }
206 
207  // Update ingest option components.
209  sendIngestMessagesCheckBox.setEnabled(!ingestIsRunning && db.getSearchDuringIngest() && db.getKnownFilesType().equals(KnownFilesType.KNOWN_BAD));
210  optionsLabel.setEnabled(!ingestIsRunning);
211  optionsSeparator.setEnabled(!ingestIsRunning);
212 
213  // Update database action buttons.
214  createDatabaseButton.setEnabled(true);
215  importDatabaseButton.setEnabled(true);
216  deleteDatabaseButton.setEnabled(!ingestIsRunning);
217 
218  // Update ingest in progress warning label.
219  ingestWarningLabel.setVisible(ingestIsRunning);
220  }
221 
222  private static String shortenPath(String path) {
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));
226  }
227  return shortenedPath;
228  }
229 
230  private boolean isIngestJobEvent(PropertyChangeEvent evt) {
231  return evt.getPropertyName().equals(IngestManager.IngestJobEvent.STARTED.toString())
232  || evt.getPropertyName().equals(IngestManager.IngestJobEvent.COMPLETED.toString())
233  || evt.getPropertyName().equals(IngestManager.IngestJobEvent.CANCELLED.toString());
234  }
235 
236  @Override
237  public void saveSettings() {
238  //Checking for for any unindexed databases
239  List<HashDb> unindexed = new ArrayList<>();
240  for (HashDb hashSet : hashSetManager.getAllHashSets()) {
241  try {
242  if (!hashSet.hasIndex()) {
243  unindexed.add(hashSet);
244  }
245  } catch (TskCoreException ex) {
246  Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error getting index info for hash database", ex); //NON-NLS
247  }
248  }
249 
250  //If unindexed ones are found, show a popup box that will either index them, or remove them.
251  if (unindexed.size() == 1) {
252  showInvalidIndex(false, unindexed);
253  } else if (unindexed.size() > 1) {
254  showInvalidIndex(true, unindexed);
255  }
256 
257  hashSetManager.save();
258  }
259 
260  @Override
261  public void load() {
262  hashSetTable.clearSelection();
263  hashSetTableModel.refreshModel();
264  }
265 
266  @Override
267  public void store() {
268  saveSettings();
269  }
270 
271  public void cancel() {
272  /* Revert back to last settings only if the user could have
273  * made changes. Doing this while ingest is running causes
274  * hash dbs to be closed while they are still being used.
275  */
276  if (IngestManager.getInstance().isIngestRunning() == false) {
278  }
279  }
280 
281  void removeThese(List<HashDb> toRemove) {
282  for (HashDb hashDb : toRemove) {
283  hashSetManager.removeHashDatabaseInternal(hashDb);
284  }
285  hashSetTableModel.refreshModel();
286  }
287 
296  private void showInvalidIndex(boolean plural, List<HashDb> unindexed) {
297  String total = "";
298  String message;
299  for (HashDb hdb : unindexed) {
300  total += "\n" + hdb.getHashSetName();
301  }
302  if (plural) {
303  message = NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.dbsNotIndexedMsg", total);
304  } else {
305  message = NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.dbNotIndexedMsg", total);
306  }
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();
317  }
318  if (res == JOptionPane.NO_OPTION) {
319  JOptionPane.showMessageDialog(this, NbBundle.getMessage(this.getClass(),
320  "HashDbConfigPanel.allUnindexedDbsRmFromListMsg"));
321  removeThese(unindexed);
322  }
323  }
324 
325  boolean valid() {
326  return true;
327  }
328 
332  private class HashSetTable extends JTable {
333 
334  @Override
335  public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
336  // Use the hash set name as the cell text.
337  JComponent cellRenderer = (JComponent) super.prepareRenderer(renderer, row, column);
338  cellRenderer.setToolTipText((String) getValueAt(row, column));
339 
340  // Give the user a visual indication of any hash sets with a hash
341  // database that needs to be indexed by displaying the hash set name
342  // in red.
343  if (hashSetTableModel.indexExists(row)) {
344  cellRenderer.setForeground(Color.black);
345  } else {
346  cellRenderer.setForeground(Color.red);
347  }
348 
349  return cellRenderer;
350  }
351 
352  public HashDb getSelection() {
353  return hashSetTableModel.getHashSetAt(getSelectionModel().getMinSelectionIndex());
354  }
355 
356  public void setSelection(int index) {
357  if (index >= 0 && index < hashSetTable.getRowCount()) {
358  getSelectionModel().setSelectionInterval(index, index);
359  }
360  }
361 
362  public void selectRowByName(String name) {
363  setSelection(hashSetTableModel.getIndexByName(name));
364  }
365  }
366 
371  private class HashSetTableModel extends AbstractTableModel {
372 
373  List<HashDb> hashSets = HashDbManager.getInstance().getAllHashSets();
374 
375  @Override
376  public int getColumnCount() {
377  return 1;
378  }
379 
380  @Override
381  public int getRowCount() {
382  return hashSets.size();
383  }
384 
385  @Override
386  public String getColumnName(int column) {
387  return NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.nameColLbl");
388  }
389 
390  @Override
391  public Object getValueAt(int rowIndex, int columnIndex) {
392  return hashSets.get(rowIndex).getHashSetName();
393  }
394 
395  private boolean indexExists(int rowIndex) {
396  try {
397  return hashSets.get(rowIndex).hasIndex();
398  } catch (TskCoreException ex) {
399  Logger.getLogger(HashSetTableModel.class.getName()).log(Level.SEVERE, "Error getting index info for hash database", ex); //NON-NLS
400  return false;
401  }
402  }
403 
404  @Override
405  public boolean isCellEditable(int rowIndex, int columnIndex) {
406  return false;
407  }
408 
409  @Override
410  public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
411  throw new UnsupportedOperationException(
412  NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.editingCellsNotSupportedMsg"));
413  }
414 
415  @Override
416  public Class<?> getColumnClass(int c) {
417  return getValueAt(0, c).getClass();
418  }
419 
420  HashDb getHashSetAt(int index) {
421  if (!hashSets.isEmpty() && index >= 0 && index < hashSets.size()) {
422  return hashSets.get(index);
423  } else {
424  return null;
425  }
426  }
427 
428  int getIndexByName(String name) {
429  for (int i = 0; i < hashSets.size(); ++i) {
430  if (hashSets.get(i).getHashSetName().equals(name)) {
431  return i;
432  }
433  }
434  return -1;
435  }
436 
437  void refreshModel() {
438  hashSets = HashDbManager.getInstance().getAllHashSets();
439  refreshDisplay();
440  }
441 
442  void refreshDisplay() {
443  fireTableDataChanged();
444  }
445  }
446 
452  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
453  private void initComponents() {
454 
455  jLabel2 = new javax.swing.JLabel();
456  jLabel4 = new javax.swing.JLabel();
457  jLabel6 = new javax.swing.JLabel();
458  jButton3 = new javax.swing.JButton();
459  jScrollPane2 = new javax.swing.JScrollPane();
460  jPanel1 = new javax.swing.JPanel();
461  ingestWarningLabel = new javax.swing.JLabel();
462  jScrollPane1 = new javax.swing.JScrollPane();
463  hashSetTable = new HashSetTable();
464  deleteDatabaseButton = new javax.swing.JButton();
465  importDatabaseButton = new javax.swing.JButton();
466  hashDatabasesLabel = new javax.swing.JLabel();
467  nameLabel = new javax.swing.JLabel();
468  hashDbNameLabel = new javax.swing.JLabel();
469  hashDbLocationLabel = new javax.swing.JLabel();
470  locationLabel = new javax.swing.JLabel();
471  typeLabel = new javax.swing.JLabel();
472  hashDbTypeLabel = new javax.swing.JLabel();
473  hashDbIndexStatusLabel = new javax.swing.JLabel();
474  indexLabel = new javax.swing.JLabel();
475  indexButton = new javax.swing.JButton();
476  sendIngestMessagesCheckBox = new javax.swing.JCheckBox();
477  informationLabel = new javax.swing.JLabel();
478  optionsLabel = new javax.swing.JLabel();
479  informationSeparator = new javax.swing.JSeparator();
480  optionsSeparator = new javax.swing.JSeparator();
481  createDatabaseButton = new javax.swing.JButton();
482  indexPathLabelLabel = new javax.swing.JLabel();
483  indexPathLabel = new javax.swing.JLabel();
484 
485  org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.jLabel2.text")); // NOI18N
486 
487  org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.jLabel4.text")); // NOI18N
488 
489  org.openide.awt.Mnemonics.setLocalizedText(jLabel6, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.jLabel6.text")); // NOI18N
490 
491  jButton3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
492  org.openide.awt.Mnemonics.setLocalizedText(jButton3, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.jButton3.text")); // NOI18N
493 
494  setMinimumSize(new java.awt.Dimension(700, 430));
495  setPreferredSize(new java.awt.Dimension(700, 430));
496 
497  jPanel1.setPreferredSize(new java.awt.Dimension(671, 430));
498 
499  ingestWarningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png"))); // NOI18N
500  org.openide.awt.Mnemonics.setLocalizedText(ingestWarningLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.ingestWarningLabel.text")); // NOI18N
501 
502  hashSetTable.setModel(new javax.swing.table.DefaultTableModel(
503  new Object [][] {
504 
505  },
506  new String [] {
507 
508  }
509  ));
510  hashSetTable.setShowHorizontalLines(false);
511  hashSetTable.setShowVerticalLines(false);
512  hashSetTable.addKeyListener(new java.awt.event.KeyAdapter() {
513  public void keyPressed(java.awt.event.KeyEvent evt) {
515  }
516  });
517  jScrollPane1.setViewportView(hashSetTable);
518 
519  deleteDatabaseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/delete16.png"))); // NOI18N
520  org.openide.awt.Mnemonics.setLocalizedText(deleteDatabaseButton, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.deleteDatabaseButton.text")); // NOI18N
521  deleteDatabaseButton.setMaximumSize(new java.awt.Dimension(140, 25));
522  deleteDatabaseButton.setMinimumSize(new java.awt.Dimension(140, 25));
523  deleteDatabaseButton.setPreferredSize(new java.awt.Dimension(140, 25));
524  deleteDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
525  public void actionPerformed(java.awt.event.ActionEvent evt) {
527  }
528  });
529 
530  importDatabaseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/import16.png"))); // NOI18N
531  org.openide.awt.Mnemonics.setLocalizedText(importDatabaseButton, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.importDatabaseButton.text")); // NOI18N
532  importDatabaseButton.setMaximumSize(new java.awt.Dimension(140, 25));
533  importDatabaseButton.setMinimumSize(new java.awt.Dimension(140, 25));
534  importDatabaseButton.setPreferredSize(new java.awt.Dimension(140, 25));
535  importDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
536  public void actionPerformed(java.awt.event.ActionEvent evt) {
538  }
539  });
540 
541  org.openide.awt.Mnemonics.setLocalizedText(hashDatabasesLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.hashDatabasesLabel.text")); // NOI18N
542 
543  org.openide.awt.Mnemonics.setLocalizedText(nameLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.nameLabel.text")); // NOI18N
544 
545  org.openide.awt.Mnemonics.setLocalizedText(hashDbNameLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.hashDbNameLabel.text")); // NOI18N
546 
547  org.openide.awt.Mnemonics.setLocalizedText(hashDbLocationLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.hashDbLocationLabel.text")); // NOI18N
548 
549  org.openide.awt.Mnemonics.setLocalizedText(locationLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.locationLabel.text")); // NOI18N
550 
551  org.openide.awt.Mnemonics.setLocalizedText(typeLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.typeLabel.text")); // NOI18N
552 
553  org.openide.awt.Mnemonics.setLocalizedText(hashDbTypeLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.hashDbTypeLabel.text")); // NOI18N
554 
555  org.openide.awt.Mnemonics.setLocalizedText(hashDbIndexStatusLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.hashDbIndexStatusLabel.text")); // NOI18N
556 
557  org.openide.awt.Mnemonics.setLocalizedText(indexLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.indexLabel.text")); // NOI18N
558 
559  org.openide.awt.Mnemonics.setLocalizedText(indexButton, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.indexButton.text")); // NOI18N
560  indexButton.setEnabled(false);
561  indexButton.addActionListener(new java.awt.event.ActionListener() {
562  public void actionPerformed(java.awt.event.ActionEvent evt) {
564  }
565  });
566 
567  org.openide.awt.Mnemonics.setLocalizedText(sendIngestMessagesCheckBox, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.sendIngestMessagesCheckBox.text")); // NOI18N
568  sendIngestMessagesCheckBox.addActionListener(new java.awt.event.ActionListener() {
569  public void actionPerformed(java.awt.event.ActionEvent evt) {
571  }
572  });
573 
574  org.openide.awt.Mnemonics.setLocalizedText(informationLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.informationLabel.text")); // NOI18N
575 
576  org.openide.awt.Mnemonics.setLocalizedText(optionsLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.optionsLabel.text")); // NOI18N
577 
578  createDatabaseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/new16.png"))); // NOI18N
579  org.openide.awt.Mnemonics.setLocalizedText(createDatabaseButton, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.createDatabaseButton.text")); // NOI18N
580  createDatabaseButton.setMaximumSize(new java.awt.Dimension(140, 25));
581  createDatabaseButton.setMinimumSize(new java.awt.Dimension(140, 25));
582  createDatabaseButton.setPreferredSize(new java.awt.Dimension(140, 25));
583  createDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
584  public void actionPerformed(java.awt.event.ActionEvent evt) {
586  }
587  });
588 
589  org.openide.awt.Mnemonics.setLocalizedText(indexPathLabelLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.indexPathLabelLabel.text")); // NOI18N
590 
591  org.openide.awt.Mnemonics.setLocalizedText(indexPathLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.indexPathLabel.text")); // NOI18N
592 
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()
598  .addContainerGap()
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()
609  .addGap(10, 10, 10)
610  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
611  .addGroup(jPanel1Layout.createSequentialGroup()
612  .addComponent(informationLabel)
613  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
614  .addComponent(informationSeparator))
615  .addComponent(ingestWarningLabel)
616  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
617  .addGap(10, 10, 10)
618  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
619  .addGroup(jPanel1Layout.createSequentialGroup()
620  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
621  .addComponent(locationLabel)
622  .addComponent(indexButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
623  .addComponent(typeLabel)
624  .addComponent(indexLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
625  .addComponent(indexPathLabelLabel))
626  .addGap(10, 10, 10)
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()
633  .addComponent(nameLabel)
634  .addGap(53, 53, 53)
635  .addComponent(hashDbNameLabel)
636  .addGap(0, 0, Short.MAX_VALUE))))
637  .addGroup(jPanel1Layout.createSequentialGroup()
638  .addComponent(optionsLabel)
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()
642  .addGap(23, 23, 23)
643  .addComponent(sendIngestMessagesCheckBox)
644  .addGap(0, 0, Short.MAX_VALUE))))
645  .addGroup(jPanel1Layout.createSequentialGroup()
646  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
647  .addComponent(hashDatabasesLabel)
648  .addComponent(deleteDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))
649  .addGap(0, 0, Short.MAX_VALUE)))
650  .addContainerGap())
651  );
652  jPanel1Layout.setVerticalGroup(
653  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
654  .addGroup(jPanel1Layout.createSequentialGroup()
655  .addContainerGap()
656  .addComponent(hashDatabasesLabel)
657  .addGap(6, 6, 6)
658  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
659  .addGroup(jPanel1Layout.createSequentialGroup()
660  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
661  .addComponent(informationLabel)
662  .addGroup(jPanel1Layout.createSequentialGroup()
663  .addGap(7, 7, 7)
664  .addComponent(informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 3, javax.swing.GroupLayout.PREFERRED_SIZE)))
665  .addGap(7, 7, 7)
666  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
667  .addComponent(nameLabel)
668  .addComponent(hashDbNameLabel))
669  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
670  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
671  .addComponent(typeLabel)
672  .addComponent(hashDbTypeLabel))
673  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
674  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
675  .addComponent(locationLabel)
676  .addComponent(hashDbLocationLabel))
677  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
678  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
679  .addComponent(indexPathLabelLabel)
680  .addComponent(indexPathLabel))
681  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
682  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
683  .addComponent(indexLabel)
684  .addComponent(hashDbIndexStatusLabel))
685  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
686  .addComponent(indexButton)
687  .addGap(18, 18, 18)
688  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
689  .addComponent(optionsLabel)
690  .addComponent(optionsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE))
691  .addGap(18, 18, 18)
692  .addComponent(sendIngestMessagesCheckBox)
693  .addGap(18, 18, 18)
694  .addComponent(ingestWarningLabel))
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))
703  );
704 
705  jScrollPane2.setViewportView(jPanel1);
706 
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()
712  .addContainerGap()
713  .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 690, Short.MAX_VALUE))
714  );
715  layout.setVerticalGroup(
716  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
717  .addGroup(layout.createSequentialGroup()
718  .addContainerGap()
719  .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 410, javax.swing.GroupLayout.PREFERRED_SIZE)
720  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
721  );
722  }// </editor-fold>//GEN-END:initComponents
723 
724  private void indexButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_indexButtonActionPerformed
725  final HashDb hashDb = ((HashSetTable) hashSetTable).getSelection();
726  assert hashDb != null;
727 
728  // Add a listener for the INDEXING_DONE event. This listener will update
729  // the UI.
730  hashDb.addPropertyChangeListener(new PropertyChangeListener() {
731  @Override
732  public void propertyChange(PropertyChangeEvent evt) {
733  if (evt.getPropertyName().equals(HashDb.Event.INDEXING_DONE.toString())) {
734  HashDb selectedHashDb = ((HashSetTable) hashSetTable).getSelection();
735  if (selectedHashDb != null && hashDb != null && hashDb.equals(selectedHashDb)) {
737  }
738  hashSetTableModel.refreshDisplay();
739  }
740  }
741  });
742 
743  // Display a modal dialog box to kick off the indexing on a worker thread
744  // and try to persuade the user to wait for the indexing task to finish.
745  // TODO: If the user waits, this defeats the purpose of doing the indexing on a worker thread.
746  // But if the user cancels the dialog, other operations on the database
747  // may be attempted when it is not in a suitable state.
748  ModalNoButtons indexDialog = new ModalNoButtons(this, new Frame(), hashDb);
749  indexDialog.setLocationRelativeTo(null);
750  indexDialog.setVisible(true);
751  indexDialog.setModal(true);
752  }//GEN-LAST:event_indexButtonActionPerformed
753 
754  private void deleteDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteDatabaseButtonActionPerformed
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) {
761  HashDb hashDb = ((HashSetTable) hashSetTable).getSelection();
762  if (hashDb != null) {
763  hashSetManager.removeHashDatabaseInternal(hashDb);
764  hashSetTableModel.refreshModel();
765  }
766  }
767  }//GEN-LAST:event_deleteDatabaseButtonActionPerformed
768 
769  private void hashSetTableKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_hashSetTableKeyPressed
770  if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
771  HashDb hashDb = ((HashSetTable) hashSetTable).getSelection();
772  if (hashDb != null) {
773  hashSetManager.removeHashDatabaseInternal(hashDb);
774  hashSetTableModel.refreshModel();
775  }
776  }
777  }//GEN-LAST:event_hashSetTableKeyPressed
778 
779  private void sendIngestMessagesCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendIngestMessagesCheckBoxActionPerformed
780  HashDb hashDb = ((HashSetTable) hashSetTable).getSelection();
781  if (hashDb != null) {
782  hashDb.setSendIngestMessages(sendIngestMessagesCheckBox.isSelected());
783  }
784  }//GEN-LAST:event_sendIngestMessagesCheckBoxActionPerformed
785 
786  private void importDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importDatabaseButtonActionPerformed
787  HashDb hashDb = new HashDbImportDatabaseDialog().getHashDatabase();
788  if (null != hashDb) {
789  hashSetTableModel.refreshModel();
790  ((HashSetTable) hashSetTable).selectRowByName(hashDb.getHashSetName());
791  }
792  }//GEN-LAST:event_importDatabaseButtonActionPerformed
793 
794  private void createDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createDatabaseButtonActionPerformed
795  HashDb hashDb = new HashDbCreateDatabaseDialog().getHashDatabase();
796  if (null != hashDb) {
797  hashSetTableModel.refreshModel();
798  ((HashSetTable) hashSetTable).selectRowByName(hashDb.getHashSetName());
799  }
800  }//GEN-LAST:event_createDatabaseButtonActionPerformed
801  // Variables declaration - do not modify//GEN-BEGIN:variables
802  private javax.swing.JButton createDatabaseButton;
803  private javax.swing.JButton deleteDatabaseButton;
804  private javax.swing.JLabel hashDatabasesLabel;
805  private javax.swing.JLabel hashDbIndexStatusLabel;
806  private javax.swing.JLabel hashDbLocationLabel;
807  private javax.swing.JLabel hashDbNameLabel;
808  private javax.swing.JLabel hashDbTypeLabel;
809  private javax.swing.JTable hashSetTable;
810  private javax.swing.JButton importDatabaseButton;
811  private javax.swing.JButton indexButton;
812  private javax.swing.JLabel indexLabel;
813  private javax.swing.JLabel indexPathLabel;
814  private javax.swing.JLabel indexPathLabelLabel;
815  private javax.swing.JLabel informationLabel;
816  private javax.swing.JSeparator informationSeparator;
817  private javax.swing.JLabel ingestWarningLabel;
818  private javax.swing.JButton jButton3;
819  private javax.swing.JLabel jLabel2;
820  private javax.swing.JLabel jLabel4;
821  private javax.swing.JLabel jLabel6;
822  private javax.swing.JPanel jPanel1;
823  private javax.swing.JScrollPane jScrollPane1;
824  private javax.swing.JScrollPane jScrollPane2;
825  private javax.swing.JLabel locationLabel;
826  private javax.swing.JLabel nameLabel;
827  private javax.swing.JLabel optionsLabel;
828  private javax.swing.JSeparator optionsSeparator;
829  private javax.swing.JCheckBox sendIngestMessagesCheckBox;
830  private javax.swing.JLabel typeLabel;
831  // End of variables declaration//GEN-END:variables
832 }
static synchronized IngestManager getInstance()
Component prepareRenderer(TableCellRenderer renderer, int row, int column)
void addIngestJobEventListener(final PropertyChangeListener listener)
static Logger getLogger(String name)
Definition: Logger.java:131

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.