19 package org.sleuthkit.autopsy.casemodule;
21 import java.awt.event.ActionEvent;
23 import java.util.logging.Level;
25 import javax.swing.Action;
26 import javax.swing.JOptionPane;
27 import javax.swing.JPanel;
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.actions.CallableSystemAction;
36 import javax.swing.Action;
37 import javax.swing.JOptionPane;
38 import javax.swing.JPanel;
39 import org.openide.DialogDescriptor;
40 import org.openide.DialogDisplayer;
41 import org.openide.NotifyDescriptor;
42 import org.openide.util.HelpCtx;
43 import org.openide.util.NbBundle;
44 import org.openide.util.actions.CallableSystemAction;
46 import javax.swing.Action;
47 import javax.swing.JOptionPane;
48 import javax.swing.JPanel;
49 import org.openide.DialogDescriptor;
50 import org.openide.DialogDisplayer;
51 import org.openide.NotifyDescriptor;
52 import org.openide.util.HelpCtx;
53 import org.openide.util.NbBundle;
54 import org.openide.util.actions.CallableSystemAction;
62 final class CaseDeleteAction
extends CallableSystemAction {
64 private JPanel caller;
66 private static final Logger logger = Logger.getLogger(CaseDeleteAction.class.getName());
71 public CaseDeleteAction() {
72 putValue(Action.NAME, NbBundle.getMessage(CaseDeleteAction.class,
"CTL_CaseDeleteAction"));
73 this.setEnabled(
false);
82 public void actionPerformed(ActionEvent e) {
83 Case currentCase = Case.getCurrentCase();
84 File caseFolder =
new File(currentCase.getCaseDirectory());
85 String caseName = currentCase.getName();
86 if (!caseFolder.exists()) {
89 logger.log(Level.WARNING,
"Couldn't delete case.",
new Exception(
"The case directory doesn't exist."));
92 String closeCurrentCase = NbBundle.getMessage(this.getClass(),
"CaseDeleteAction.closeConfMsg.text", caseName, caseFolder.getPath());
93 NotifyDescriptor d =
new NotifyDescriptor.Confirmation(closeCurrentCase,
94 NbBundle.getMessage(
this.getClass(),
95 "CaseDeleteAction.closeConfMsg.title"),
96 NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.WARNING_MESSAGE);
97 d.setValue(NotifyDescriptor.NO_OPTION);
99 Object res = DialogDisplayer.getDefault().notify(d);
100 if (res != null && res == DialogDescriptor.YES_OPTION) {
101 boolean success =
false;
104 Case.getCurrentCase().deleteCase(caseFolder);
106 }
catch (CaseActionException ex) {
107 logger.log(Level.WARNING,
"Could not delete the case folder: " + caseFolder);
112 JOptionPane.showMessageDialog(caller,
113 NbBundle.getMessage(
this.getClass(),
114 "CaseDeleteAction.msgDlg.fileInUse.msg"),
115 NbBundle.getMessage(
this.getClass(),
116 "CaseDeleteAction.msgDlg.fileInUse.title"),
117 JOptionPane.ERROR_MESSAGE);
119 CasePropertiesAction.closeCasePropertiesWindow();
120 JOptionPane.showMessageDialog(caller, NbBundle.getMessage(
this.getClass(),
121 "CaseDeleteAction.msgDlg.caseDelete.msg",
133 public void performAction() {
143 public String getName() {
144 return NbBundle.getMessage(CaseDeleteAction.class,
"CTL_CaseDeleteAction");
153 public HelpCtx getHelpCtx() {
154 return HelpCtx.DEFAULT_HELP;