From 10f262ec9a6a025b63fa30540bf00cb02c81831f Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Mon, 20 Apr 2015 16:51:33 -0400 Subject: [PATCH] Add local/remote ingest job event filter to hash lookup and keyword search option panels --- .../autopsy/events/AutopsyEvent.java | 2 +- .../hashdatabase/HashLookupSettingsPanel.java | 15 +++++++------ .../DropdownListSearchPanel.java | 6 ++---- .../keywordsearch/GlobalEditListPanel.java | 21 ++++++++----------- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/events/AutopsyEvent.java b/Core/src/org/sleuthkit/autopsy/events/AutopsyEvent.java index 4141d0d0d9..73739ed8a5 100644 --- a/Core/src/org/sleuthkit/autopsy/events/AutopsyEvent.java +++ b/Core/src/org/sleuthkit/autopsy/events/AutopsyEvent.java @@ -66,7 +66,7 @@ public class AutopsyEvent extends PropertyChangeEvent implements Serializable { * @param sourceType The source type of the event, local or remote. */ @Override - public Object getSource() { + public SourceType getSource() { return sourceType; } diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettingsPanel.java index 3bc20c4da4..c5eadbaaf2 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettingsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettingsPanel.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011 - 2013 Basis Technology Corp. + * Copyright 2011 - 2015 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -38,6 +38,7 @@ import javax.swing.table.TableCellRenderer; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.corecomponents.OptionsPanel; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.events.AutopsyEvent; import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb; @@ -56,8 +57,8 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan .getMessage(HashLookupSettingsPanel.class, "HashDbConfigPanel.errorGettingPathText"); private static final String ERROR_GETTING_INDEX_STATUS_TEXT = NbBundle .getMessage(HashLookupSettingsPanel.class, "HashDbConfigPanel.errorGettingIndexStatusText"); - private HashDbManager hashSetManager = HashDbManager.getInstance(); - private HashSetTableModel hashSetTableModel = new HashSetTableModel(); + private final HashDbManager hashSetManager = HashDbManager.getInstance(); + private final HashSetTableModel hashSetTableModel = new HashSetTableModel(); public HashLookupSettingsPanel() { initComponents(); @@ -69,7 +70,7 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan IngestManager.getInstance().addIngestJobEventListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { - if (isIngestJobEvent(evt)) { + if (isLocalIngestJobEvent(evt)) { EventQueue.invokeLater(new Runnable() { @Override public void run() { @@ -227,10 +228,8 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan return shortenedPath; } - private boolean isIngestJobEvent(PropertyChangeEvent evt) { - return evt.getPropertyName().equals(IngestManager.IngestJobEvent.STARTED.toString()) - || evt.getPropertyName().equals(IngestManager.IngestJobEvent.COMPLETED.toString()) - || evt.getPropertyName().equals(IngestManager.IngestJobEvent.CANCELLED.toString()); + private boolean isLocalIngestJobEvent(PropertyChangeEvent evt) { + return evt instanceof AutopsyEvent && ((AutopsyEvent)evt).getSource() == AutopsyEvent.SourceType.Local; } @Override diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownListSearchPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownListSearchPanel.java index 6157599b40..f12128ef02 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownListSearchPanel.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/DropdownListSearchPanel.java @@ -39,6 +39,7 @@ import javax.swing.table.TableColumn; import org.openide.util.NbBundle; import org.openide.util.actions.SystemAction; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.events.AutopsyEvent; import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.ingest.IngestManager.IngestJobEvent; @@ -119,10 +120,7 @@ class DropdownListSearchPanel extends KeywordSearchPanel { IngestManager.getInstance().addIngestJobEventListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { - String changed = evt.getPropertyName(); - if (changed.equals(IngestJobEvent.STARTED.toString()) - || changed.equals(IngestJobEvent.COMPLETED.toString()) - || changed.equals(IngestJobEvent.CANCELLED.toString())) { + if (evt instanceof AutopsyEvent && ((AutopsyEvent) evt).getSource() == AutopsyEvent.SourceType.Local) { EventQueue.invokeLater(new Runnable() { @Override public void run() { diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalEditListPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalEditListPanel.java index 7edab44ab8..b41d50f526 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalEditListPanel.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/GlobalEditListPanel.java @@ -42,6 +42,7 @@ import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableColumn; import org.sleuthkit.autopsy.corecomponents.OptionsPanel; +import org.sleuthkit.autopsy.events.AutopsyEvent; import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.ingest.IngestManager.IngestJobEvent; @@ -93,7 +94,7 @@ class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionLis lsm.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { - if (lsm.isSelectionEmpty() || currentKeywordList.isLocked() || IngestManager.getInstance().isIngestRunning() ) { + if (lsm.isSelectionEmpty() || currentKeywordList.isLocked() || IngestManager.getInstance().isIngestRunning()) { deleteWordButton.setEnabled(false); } else { deleteWordButton.setEnabled(true); @@ -129,16 +130,13 @@ class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionLis IngestManager.getInstance().addIngestJobEventListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { - String changed = evt.getPropertyName(); - if (changed.equals(IngestJobEvent.STARTED.toString()) - || changed.equals(IngestJobEvent.COMPLETED.toString()) - || changed.equals(IngestJobEvent.CANCELLED.toString())) { + if (evt instanceof AutopsyEvent && ((AutopsyEvent) evt).getSource() == AutopsyEvent.SourceType.Local) { EventQueue.invokeLater(new Runnable() { @Override public void run() { setButtonStates(); } - }); + }); } } }); @@ -147,14 +145,14 @@ class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionLis void setButtonStates() { boolean isIngestRunning = IngestManager.getInstance().isIngestRunning(); boolean isListSelected = currentKeywordList != null; - + // items that only need a selected list boolean canEditList = ((isListSelected == true) && (isIngestRunning == false)); ingestMessagesCheckbox.setEnabled(canEditList); ingestMessagesCheckbox.setSelected(currentKeywordList != null && currentKeywordList.getIngestMessages()); listOptionsLabel.setEnabled(canEditList); listOptionsSeparator.setEnabled(canEditList); - + // items that need an unlocked list w/out ingest running boolean isListLocked = ((isListSelected == false) || (currentKeywordList.isLocked())); boolean canAddWord = isListSelected && !isIngestRunning && !isListLocked; @@ -164,8 +162,7 @@ class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionLis keywordOptionsLabel.setEnabled(canAddWord); keywordOptionsSeparator.setEnabled(canAddWord); deleteListButton.setEnabled(canAddWord); - - + // items that need a non-empty list if ((currentKeywordList == null) || (currentKeywordList.getKeywords().isEmpty())) { saveListButton.setEnabled(false); @@ -446,7 +443,7 @@ class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionLis private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed final String FEATURE_NAME = NbBundle.getMessage(this.getClass(), - "KeywordSearchEditListPanel.exportButtonAction.featureName.text"); + "KeywordSearchEditListPanel.exportButtonAction.featureName.text"); JFileChooser chooser = new JFileChooser(); final String EXTENSION = "xml"; //NON-NLS @@ -474,7 +471,7 @@ class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionLis if (selFile.exists()) { shouldWrite = KeywordSearchUtil.displayConfirmDialog(FEATURE_NAME, NbBundle.getMessage(this.getClass(), "KeywordSearchEditListPanel.exportButtonActionPerformed.fileExistPrompt", - selFile.getName()), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN); + selFile.getName()), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN); } if (!shouldWrite) { return;