19 package org.sleuthkit.autopsy.casemodule;
 
   21 import java.awt.event.ActionEvent;
 
   22 import java.util.concurrent.ExecutionException;
 
   23 import java.util.logging.Level;
 
   24 import javax.swing.Action;
 
   25 import javax.swing.JOptionPane;
 
   26 import javax.swing.SwingWorker;
 
   27 import org.openide.DialogDescriptor;
 
   28 import org.openide.DialogDisplayer;
 
   29 import org.openide.NotifyDescriptor;
 
   30 import org.openide.util.HelpCtx;
 
   31 import org.openide.util.NbBundle;
 
   32 import org.openide.util.NbBundle.Messages;
 
   33 import org.openide.util.actions.CallableSystemAction;
 
   42 final class CaseDeleteAction 
extends CallableSystemAction {
 
   44     private static final long serialVersionUID = 1L;
 
   45     private static final Logger logger = Logger.
getLogger(CaseDeleteAction.class.getName());
 
   48         putValue(Action.NAME, NbBundle.getMessage(CaseDeleteAction.class, 
"CTL_CaseDeleteAction"));
 
   49         this.setEnabled(
false);
 
   54         "Case.deleteCaseConfirmationDialog.title=Delete Current Case?",
 
   55         "Case.deleteCaseConfirmationDialog.message=Are you sure you want to close and delete the current case?",
 
   56         "Case.deleteCaseFailureMessageBox.title=Failed to Delete Case",
 
   57         "# {0} - exception message", 
"Case.deleteCaseFailureMessageBox.message=Error deleting case: {0}",})
 
   58     public void actionPerformed(ActionEvent e) {
 
   60             Case currentCase = Case.getCurrentCase();
 
   61             String caseName = currentCase.getName();
 
   62             String caseDirectory = currentCase.getCaseDirectory();
 
   68             Object response = DialogDisplayer.getDefault().notify(
new NotifyDescriptor(
 
   69                     Bundle.Case_deleteCaseConfirmationDialog_message(),
 
   70                     Bundle.Case_deleteCaseConfirmationDialog_title(),
 
   71                     NotifyDescriptor.YES_NO_OPTION,
 
   72                     NotifyDescriptor.WARNING_MESSAGE,
 
   74                     NotifyDescriptor.NO_OPTION));
 
   75             if (null != response && DialogDescriptor.YES_OPTION == response) {
 
   77                 new SwingWorker<Void, Void>() {
 
   80                     protected Void doInBackground() throws Exception {
 
   81                         Case.deleteCurrentCase();
 
   86                     protected void done() {
 
   89                         } 
catch (InterruptedException | ExecutionException ex) {
 
   90                             logger.log(Level.SEVERE, String.format(
"Failed to delete case %s at %s", caseName, caseDirectory), ex);
 
   91                             JOptionPane.showMessageDialog(
 
   93                                     Bundle.Case_deleteCaseFailureMessageBox_message(ex.getMessage()),
 
   94                                     Bundle.Case_deleteCaseFailureMessageBox_title(),
 
   95                                     JOptionPane.ERROR_MESSAGE);
 
  101                         CasePropertiesAction.closeCasePropertiesWindow();
 
  105         } 
catch (IllegalStateException ex) {
 
  106             logger.log(Level.SEVERE, 
"Case delete action called with no current case", ex);
 
  111     public void performAction() {
 
  115     public String getName() {
 
  116         return NbBundle.getMessage(CaseDeleteAction.class, 
"CTL_CaseDeleteAction");
 
  120     public HelpCtx getHelpCtx() {
 
  121         return HelpCtx.DEFAULT_HELP;
 
synchronized static Logger getLogger(String name)