20 package org.sleuthkit.autopsy.casemodule;
22 import java.awt.Component;
23 import java.awt.Dialog;
25 import java.text.MessageFormat;
26 import java.util.logging.Level;
27 import javax.swing.JComponent;
28 import org.openide.DialogDescriptor;
29 import org.openide.DialogDisplayer;
30 import org.openide.NotifyDescriptor;
31 import org.openide.WizardDescriptor;
32 import org.openide.util.HelpCtx;
33 import org.openide.util.NbBundle;
34 import org.openide.util.actions.CallableSystemAction;
35 import org.openide.util.actions.SystemAction;
41 final class NewCaseWizardAction
extends CallableSystemAction {
43 private WizardDescriptor.Panel<WizardDescriptor>[] panels;
45 private static final Logger logger = Logger.
getLogger(NewCaseWizardAction.class.getName());
48 public void performAction() {
50 if (Case.existsCurrentCase()) {
52 String closeCurrentCase = NbBundle
53 .getMessage(this.getClass(),
"NewCaseWizardAction.closeCurCase.confMsg.msg");
54 NotifyDescriptor d =
new NotifyDescriptor.Confirmation(closeCurrentCase,
55 NbBundle.getMessage(
this.getClass(),
56 "NewCaseWizardAction.closeCurCase.confMsg.title"),
57 NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.WARNING_MESSAGE);
58 d.setValue(NotifyDescriptor.NO_OPTION);
60 Object res = DialogDisplayer.getDefault().notify(d);
61 if (res != null && res == DialogDescriptor.YES_OPTION) {
63 Case.getCurrentCase().closeCase();
65 }
catch (Exception ex) {
66 Logger.getLogger(NewCaseWizardAction.class.getName()).log(Level.WARNING,
"Error closing case.", ex);
77 private void newCaseAction() {
78 WizardDescriptor wizardDescriptor =
new WizardDescriptor(getPanels());
80 wizardDescriptor.setTitleFormat(
new MessageFormat(
"{0}"));
81 wizardDescriptor.setTitle(NbBundle.getMessage(
this.getClass(),
"NewCaseWizardAction.newCase.windowTitle.text"));
82 Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
83 dialog.setVisible(
true);
87 boolean finished = wizardDescriptor.getValue() == WizardDescriptor.FINISH_OPTION;
88 boolean isCancelled = wizardDescriptor.getValue() == WizardDescriptor.CANCEL_OPTION;
94 AddImageAction addImageAction = SystemAction.get(AddImageAction.class);
95 addImageAction.actionPerformed(null);
100 String createdDirectory = (String) wizardDescriptor.getProperty(
"createdDirectory");
101 if(createdDirectory != null) {
102 logger.log(Level.INFO,
"Deleting a created case directory due to isCancelled set, dir: " + createdDirectory);
103 Case.deleteCaseDirectory(
new File(createdDirectory));
106 if (Case.existsCurrentCase()) {
108 CaseCloseAction closeCase = SystemAction.get(CaseCloseAction.class);
109 closeCase.actionPerformed(null);
119 @SuppressWarnings({
"unchecked",
"rawtypes"})
120 private WizardDescriptor.Panel<WizardDescriptor>[] getPanels() {
121 if (panels == null) {
122 panels =
new WizardDescriptor.Panel[]{
123 new NewCaseWizardPanel1(),
124 new NewCaseWizardPanel2()
126 String[] steps =
new String[panels.length];
127 for (
int i = 0; i < panels.length; i++) {
128 Component c = panels[i].getComponent();
132 steps[i] = c.getName();
133 if (c instanceof JComponent) {
134 JComponent jc = (JComponent) c;
136 jc.putClientProperty(
"WizardPanel_contentSelectedIndex",
new Integer(i));
138 jc.putClientProperty(
"WizardPanel_contentData", steps);
140 jc.putClientProperty(
"WizardPanel_autoWizardStyle", Boolean.TRUE);
142 jc.putClientProperty(
"WizardPanel_contentDisplayed", Boolean.TRUE);
144 jc.putClientProperty(
"WizardPanel_contentNumbered", Boolean.TRUE);
152 public String getName() {
153 return NbBundle.getMessage(this.getClass(),
"NewCaseWizardAction.getName.text");
157 public String iconResource() {
162 public HelpCtx getHelpCtx() {
163 return HelpCtx.DEFAULT_HELP;
167 protected boolean asynchronous() {
static Logger getLogger(String name)