diff --git a/Core/src/org/sleuthkit/autopsy/actions/ExitAction.java b/Core/src/org/sleuthkit/autopsy/actions/ExitAction.java index ea8b3c8857..d4e1e7e379 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/ExitAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/ExitAction.java @@ -40,14 +40,16 @@ final public class ExitAction implements ActionListener { @Override public void actionPerformed(ActionEvent e) { - new Thread(() -> { - try { - Case.closeCurrentCase(); - } catch (CaseActionException ex) { - Logger.getLogger(ExitAction.class.getName()).log(Level.SEVERE, "Error closing the current case on exit", ex); //NON-NLS - } finally { - LifecycleManager.getDefault().exit(); - } - }).start(); + if (IngestRunningCheck.checkAndConfirmProceed()) { + new Thread(() -> { + try { + Case.closeCurrentCase(); + } catch (CaseActionException ex) { + Logger.getLogger(ExitAction.class.getName()).log(Level.SEVERE, "Error closing the current case on exit", ex); //NON-NLS + } finally { + LifecycleManager.getDefault().exit(); + } + }).start(); + } } } diff --git a/Core/src/org/sleuthkit/autopsy/actions/IngestRunningCheck.java b/Core/src/org/sleuthkit/autopsy/actions/IngestRunningCheck.java new file mode 100644 index 0000000000..64f319f61f --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/actions/IngestRunningCheck.java @@ -0,0 +1,54 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.sleuthkit.autopsy.actions; + +import org.openide.DialogDescriptor; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; +import org.openide.util.NbBundle.Messages; +import org.sleuthkit.autopsy.ingest.IngestManager; + +/** + * A helper for actions that checks to see if ingest is running. If it is, + * prompts the user to confirm they want to proceed with whatever operation was + * initiated (e.g., closing the case). + */ +public class IngestRunningCheck { + + /** + * Checks to see if ingest is running. If it is, prompts the user to confirm + * they want to proceed with whatever operation was initiated (e.g., closing + * the case). + * + * @return True to proceed, false otherwise. + */ + @Messages({ + "IngestRunningCheck.confirmationDialog.title=Ingest is Running", + "IngestRunningCheck.confirmationDialog.message=Ingest is running, are you sure you want to proceed?" + + }) + public static boolean checkAndConfirmProceed() { + if (IngestManager.getInstance().isIngestRunning()) { + NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation( + Bundle.IngestRunningCheck_confirmationDialog_message(), + Bundle.IngestRunningCheck_confirmationDialog_title(), + NotifyDescriptor.YES_NO_OPTION, + NotifyDescriptor.WARNING_MESSAGE); + descriptor.setValue(NotifyDescriptor.NO_OPTION); + Object response = DialogDisplayer.getDefault().notify(descriptor); + return (DialogDescriptor.YES_OPTION == response); + } else { + return true; + } + } + + /** + * Private contructor to prevent instantiation of a utility class. + */ + private IngestRunningCheck() { + } + +} diff --git a/Core/src/org/sleuthkit/autopsy/actions/OpenLogFolderAction.java b/Core/src/org/sleuthkit/autopsy/actions/OpenLogFolderAction.java index 7197c9a7aa..62a23b46b0 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/OpenLogFolderAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/OpenLogFolderAction.java @@ -48,7 +48,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; public final class OpenLogFolderAction implements ActionListener { private static final Logger logger = Logger.getLogger(OpenLogFolderAction.class.getName()); - + @Override public void actionPerformed(ActionEvent e) { File logDir; diff --git a/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java b/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java index 4294170070..451bb2b1c3 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java @@ -43,13 +43,21 @@ import org.sleuthkit.autopsy.coreutils.Logger; * * This action should only be invoked in the event dispatch thread (EDT). */ -@ActionRegistration(displayName = "#CTL_OpenOutputFolder", iconInMenu = true, lazy = true) +@ActionRegistration(displayName = "#CTL_OpenOutputFolder", iconInMenu = true, lazy = false) @ActionReference(path = "Menu/Tools", position = 1850, separatorBefore = 1849) @ActionID(id = "org.sleuthkit.autopsy.actions.OpenOutputFolderAction", category = "Help") public final class OpenOutputFolderAction extends CallableSystemAction { private static final long serialVersionUID = 1L; private static final Logger logger = Logger.getLogger(OpenOutputFolderAction.class.getName()); + + public OpenOutputFolderAction() { + /* + * Initially disabled. The Case class enables this action when a case is + * opened and disables it when a case is closed. + */ + this.setEnabled(false); + } @Override public void performAction() { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageAction.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageAction.java index 76d678dec3..b5c91d449b 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageAction.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageAction.java @@ -52,6 +52,8 @@ import org.sleuthkit.datamodel.Image; /** * An action that invokes the Add Data Source wizard. + * + * This action should only be invoked in the event dispatch thread (EDT). */ @ActionID(category = "Tools", id = "org.sleuthkit.autopsy.casemodule.AddImageAction") @ActionRegistration(displayName = "#CTL_AddImage", lazy = false) @@ -103,7 +105,11 @@ public final class AddImageAction extends CallableSystemAction implements Presen } }); - this.setEnabled(false); // disable this action class + /* + * Disable this action until a case is opened. Currently, the Case class + * enables the action. + */ + this.setEnabled(false); } @Override @@ -118,7 +124,7 @@ public final class AddImageAction extends CallableSystemAction implements Presen } } - WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); iterator = new AddImageWizardIterator(this); wizardDescriptor = new WizardDescriptor(iterator); wizardDescriptor.setTitle(NbBundle.getMessage(this.getClass(), "AddImageAction.wizard.title")); @@ -131,7 +137,7 @@ public final class AddImageAction extends CallableSystemAction implements Presen dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor); Dimension d = dialog.getSize(); dialog.setSize(SIZE); - WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); dialog.setVisible(true); dialog.toFront(); diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index 50e3b21d90..5392e202cf 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -58,6 +58,7 @@ import org.openide.util.NbBundle; import org.openide.util.NbBundle.Messages; import org.openide.util.actions.CallableSystemAction; import org.openide.windows.WindowManager; +import org.sleuthkit.autopsy.actions.OpenOutputFolderAction; import org.sleuthkit.autopsy.casemodule.CaseMetadata.CaseMetadataException; import org.sleuthkit.autopsy.casemodule.events.AddingDataSourceEvent; import org.sleuthkit.autopsy.casemodule.events.AddingDataSourceFailedEvent; @@ -1279,7 +1280,8 @@ public class Case { CallableSystemAction.get(CasePropertiesAction.class).setEnabled(true); CallableSystemAction.get(CaseDeleteAction.class).setEnabled(true); CallableSystemAction.get(OpenTimelineAction.class).setEnabled(true); - + CallableSystemAction.get(OpenOutputFolderAction.class).setEnabled(false); + /* * Add the case to the recent cases tracker that supplies a list * of recent cases to the recent cases menu item and the @@ -1325,7 +1327,8 @@ public class Case { CallableSystemAction.get(CasePropertiesAction.class).setEnabled(false); CallableSystemAction.get(CaseDeleteAction.class).setEnabled(false); CallableSystemAction.get(OpenTimelineAction.class).setEnabled(false); - + CallableSystemAction.get(OpenOutputFolderAction.class).setEnabled(false); + /* * Clear the notifications in the notfier component in the lower * right hand corner of the main application window.