20 package org.sleuthkit.autopsy.casemodule;
22 import java.awt.event.ActionEvent;
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;
60 final class CaseDeleteAction
extends CallableSystemAction {
62 private JPanel caller;
64 private static final Logger logger = Logger.getLogger(CaseDeleteAction.class.getName());
69 public CaseDeleteAction() {
70 putValue(Action.NAME, NbBundle.getMessage(CaseDeleteAction.class,
"CTL_CaseDeleteAction"));
71 this.setEnabled(
false);
79 public void actionPerformed(ActionEvent e) {
80 Case currentCase = Case.getCurrentCase();
81 File configFile =
new File(currentCase.getConfigFilePath());
82 File caseFolder =
new File(configFile.getParent());
83 String caseName = currentCase.getName();
84 if(!caseFolder.exists()){
87 logger.log(Level.WARNING,
"Couldn't delete case.",
new Exception(
"The case directory doesn't exist."));
91 String closeCurrentCase = NbBundle.getMessage(this.getClass(),
"CaseDeleteAction.closeConfMsg.text", caseName, caseFolder.getPath());
92 NotifyDescriptor d =
new NotifyDescriptor.Confirmation(closeCurrentCase,
93 NbBundle.getMessage(
this.getClass(),
94 "CaseDeleteAction.closeConfMsg.title"),
95 NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.WARNING_MESSAGE);
96 d.setValue(NotifyDescriptor.NO_OPTION);
98 Object res = DialogDisplayer.getDefault().notify(d);
99 if(res != null && res == DialogDescriptor.YES_OPTION){
100 boolean success =
false;
103 Case.getCurrentCase().deleteCase(caseFolder);
105 }
catch (CaseActionException ex) {
106 logger.log(Level.WARNING,
"Could not delete the case folder: " + caseFolder);
111 JOptionPane.showMessageDialog(caller,
112 NbBundle.getMessage(
this.getClass(),
113 "CaseDeleteAction.msgDlg.fileInUse.msg"),
114 NbBundle.getMessage(
this.getClass(),
115 "CaseDeleteAction.msgDlg.fileInUse.title"),
116 JOptionPane.ERROR_MESSAGE);
119 CasePropertiesAction.closeCasePropertiesWindow();
120 JOptionPane.showMessageDialog(caller, NbBundle.getMessage(
this.getClass(),
121 "CaseDeleteAction.msgDlg.caseDelete.msg",
132 public void performAction() {
141 public String getName() {
142 return NbBundle.getMessage(CaseDeleteAction.class,
"CTL_CaseDeleteAction");
150 public HelpCtx getHelpCtx() {
151 return HelpCtx.DEFAULT_HELP;