19 package org.sleuthkit.autopsy.casemodule;
21 import java.awt.event.ActionEvent;
22 import java.beans.PropertyChangeEvent;
23 import java.util.concurrent.ExecutionException;
24 import java.util.logging.Level;
25 import javax.swing.Action;
26 import javax.swing.JOptionPane;
27 import javax.swing.SwingWorker;
28 import org.openide.DialogDescriptor;
29 import org.openide.DialogDisplayer;
30 import org.openide.NotifyDescriptor;
31 import org.openide.util.HelpCtx;
32 import org.openide.util.NbBundle;
33 import org.openide.util.NbBundle.Messages;
34 import org.openide.util.actions.CallableSystemAction;
44 final class CaseDeleteAction
extends CallableSystemAction {
46 private static final long serialVersionUID = 1L;
47 private static final Logger logger = Logger.
getLogger(CaseDeleteAction.class.getName());
50 putValue(Action.NAME, NbBundle.getMessage(CaseDeleteAction.class,
"CTL_CaseDeleteAction"));
51 this.setEnabled(
false);
52 Case.addEventSubscriber(Case.Events.CURRENT_CASE.toString(), (PropertyChangeEvent evt) -> {
53 setEnabled(null != evt.getNewValue() && UserPreferences.getMode() != UserPreferences.SelectedMode.REVIEW);
59 "Case.deleteCaseConfirmationDialog.title=Delete Current Case?",
60 "Case.deleteCaseConfirmationDialog.message=Are you sure you want to close and delete the current case?",
61 "Case.deleteCaseFailureMessageBox.title=Failed to Delete Case",
62 "# {0} - exception message",
"Case.deleteCaseFailureMessageBox.message=Error deleting case: {0}",})
63 public void actionPerformed(ActionEvent e) {
65 Case currentCase = Case.getCurrentCase();
66 String caseName = currentCase.getName();
67 String caseDirectory = currentCase.getCaseDirectory();
73 Object response = DialogDisplayer.getDefault().notify(
new NotifyDescriptor(
74 Bundle.Case_deleteCaseConfirmationDialog_message(),
75 Bundle.Case_deleteCaseConfirmationDialog_title(),
76 NotifyDescriptor.YES_NO_OPTION,
77 NotifyDescriptor.WARNING_MESSAGE,
79 NotifyDescriptor.NO_OPTION));
80 if (null != response && DialogDescriptor.YES_OPTION == response) {
82 new SwingWorker<Void, Void>() {
85 protected Void doInBackground() throws Exception {
86 Case.deleteCurrentCase();
91 protected void done() {
94 }
catch (InterruptedException | ExecutionException ex) {
95 logger.log(Level.SEVERE, String.format(
"Failed to delete case %s at %s", caseName, caseDirectory), ex);
96 JOptionPane.showMessageDialog(
98 Bundle.Case_deleteCaseFailureMessageBox_message(ex.getLocalizedMessage()),
99 Bundle.Case_deleteCaseFailureMessageBox_title(),
100 JOptionPane.ERROR_MESSAGE);
105 StartupWindowProvider.getInstance().open();
109 }
catch (IllegalStateException ex) {
110 logger.log(Level.SEVERE,
"Case delete action called with no current case", ex);
115 public void performAction() {
119 public String getName() {
120 return NbBundle.getMessage(CaseDeleteAction.class,
"CTL_CaseDeleteAction");
124 public HelpCtx getHelpCtx() {
125 return HelpCtx.DEFAULT_HELP;
synchronized static Logger getLogger(String name)