Bug fixes for Case changes, etc.

This commit is contained in:
Richard Cordovano 2017-01-24 13:54:12 -05:00
parent efb48b4d5c
commit ec108b0b06
6 changed files with 89 additions and 16 deletions

View File

@ -40,14 +40,16 @@ final public class ExitAction implements ActionListener {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
new Thread(() -> { if (IngestRunningCheck.checkAndConfirmProceed()) {
try { new Thread(() -> {
Case.closeCurrentCase(); try {
} catch (CaseActionException ex) { Case.closeCurrentCase();
Logger.getLogger(ExitAction.class.getName()).log(Level.SEVERE, "Error closing the current case on exit", ex); //NON-NLS } catch (CaseActionException ex) {
} finally { Logger.getLogger(ExitAction.class.getName()).log(Level.SEVERE, "Error closing the current case on exit", ex); //NON-NLS
LifecycleManager.getDefault().exit(); } finally {
} LifecycleManager.getDefault().exit();
}).start(); }
}).start();
}
} }
} }

View File

@ -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() {
}
}

View File

@ -48,7 +48,7 @@ import org.sleuthkit.autopsy.coreutils.Logger;
public final class OpenLogFolderAction implements ActionListener { public final class OpenLogFolderAction implements ActionListener {
private static final Logger logger = Logger.getLogger(OpenLogFolderAction.class.getName()); private static final Logger logger = Logger.getLogger(OpenLogFolderAction.class.getName());
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
File logDir; File logDir;

View File

@ -43,13 +43,21 @@ import org.sleuthkit.autopsy.coreutils.Logger;
* *
* This action should only be invoked in the event dispatch thread (EDT). * 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) @ActionReference(path = "Menu/Tools", position = 1850, separatorBefore = 1849)
@ActionID(id = "org.sleuthkit.autopsy.actions.OpenOutputFolderAction", category = "Help") @ActionID(id = "org.sleuthkit.autopsy.actions.OpenOutputFolderAction", category = "Help")
public final class OpenOutputFolderAction extends CallableSystemAction { public final class OpenOutputFolderAction extends CallableSystemAction {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final Logger logger = Logger.getLogger(OpenOutputFolderAction.class.getName()); 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 @Override
public void performAction() { public void performAction() {

View File

@ -52,6 +52,8 @@ import org.sleuthkit.datamodel.Image;
/** /**
* An action that invokes the Add Data Source wizard. * 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") @ActionID(category = "Tools", id = "org.sleuthkit.autopsy.casemodule.AddImageAction")
@ActionRegistration(displayName = "#CTL_AddImage", lazy = false) @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 @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); iterator = new AddImageWizardIterator(this);
wizardDescriptor = new WizardDescriptor(iterator); wizardDescriptor = new WizardDescriptor(iterator);
wizardDescriptor.setTitle(NbBundle.getMessage(this.getClass(), "AddImageAction.wizard.title")); 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); dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
Dimension d = dialog.getSize(); Dimension d = dialog.getSize();
dialog.setSize(SIZE); 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.setVisible(true);
dialog.toFront(); dialog.toFront();

View File

@ -58,6 +58,7 @@ import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.openide.util.actions.CallableSystemAction; import org.openide.util.actions.CallableSystemAction;
import org.openide.windows.WindowManager; import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.actions.OpenOutputFolderAction;
import org.sleuthkit.autopsy.casemodule.CaseMetadata.CaseMetadataException; import org.sleuthkit.autopsy.casemodule.CaseMetadata.CaseMetadataException;
import org.sleuthkit.autopsy.casemodule.events.AddingDataSourceEvent; import org.sleuthkit.autopsy.casemodule.events.AddingDataSourceEvent;
import org.sleuthkit.autopsy.casemodule.events.AddingDataSourceFailedEvent; import org.sleuthkit.autopsy.casemodule.events.AddingDataSourceFailedEvent;
@ -1279,7 +1280,8 @@ public class Case {
CallableSystemAction.get(CasePropertiesAction.class).setEnabled(true); CallableSystemAction.get(CasePropertiesAction.class).setEnabled(true);
CallableSystemAction.get(CaseDeleteAction.class).setEnabled(true); CallableSystemAction.get(CaseDeleteAction.class).setEnabled(true);
CallableSystemAction.get(OpenTimelineAction.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 * Add the case to the recent cases tracker that supplies a list
* of recent cases to the recent cases menu item and the * 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(CasePropertiesAction.class).setEnabled(false);
CallableSystemAction.get(CaseDeleteAction.class).setEnabled(false); CallableSystemAction.get(CaseDeleteAction.class).setEnabled(false);
CallableSystemAction.get(OpenTimelineAction.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 * Clear the notifications in the notfier component in the lower
* right hand corner of the main application window. * right hand corner of the main application window.