19 package org.sleuthkit.autopsy.casemodule;
21 import java.awt.Cursor;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
25 import java.util.concurrent.ExecutionException;
26 import java.util.logging.Level;
27 import javax.swing.JFileChooser;
28 import javax.swing.JOptionPane;
29 import javax.swing.SwingWorker;
30 import javax.swing.filechooser.FileFilter;
31 import javax.swing.filechooser.FileNameExtensionFilter;
32 import org.openide.awt.ActionID;
33 import org.openide.awt.ActionReference;
34 import org.openide.awt.ActionRegistration;
35 import org.openide.util.HelpCtx;
36 import org.openide.util.NbBundle;
37 import org.openide.util.actions.CallableSystemAction;
38 import org.openide.util.lookup.ServiceProvider;
39 import org.openide.windows.WindowManager;
53 @ActionID(category =
"Case",
id =
"org.sleuthkit.autopsy.casemodule.CaseOpenAction")
54 @ActionReference(path =
"Menu/Case", position = 102)
55 @ActionRegistration(displayName =
"#CTL_CaseOpenAction", lazy =
false)
56 @NbBundle.Messages({
"CTL_CaseOpenAction=Open Case"})
57 @ServiceProvider(service = CaseOpenAction.class)
58 public final class CaseOpenAction extends CallableSystemAction implements ActionListener {
61 private static final String
DISPLAY_NAME = Bundle.CTL_CaseOpenAction();
81 void openCaseSelectionWindow() {
82 JFileChooser fileChooser =
new JFileChooser();
83 fileChooser.setDragEnabled(
false);
84 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
85 fileChooser.setMultiSelectionEnabled(
false);
86 fileChooser.setFileFilter(caseMetadataFileFilter);
91 String optionsDlgTitle = NbBundle.getMessage(Case.class,
"CloseCaseWhileIngesting.Warning.title");
92 String optionsDlgMessage = NbBundle.getMessage(Case.class,
"CloseCaseWhileIngesting.Warning");
93 if (IngestRunningCheck.checkAndConfirmProceed(optionsDlgTitle, optionsDlgMessage)) {
98 int retval = fileChooser.showOpenDialog(WindowManager.getDefault().getMainWindow());
99 if (retval == JFileChooser.APPROVE_OPTION) {
103 StartupWindowProvider.getInstance().close();
108 OpenMultiUserCaseDialog.getInstance().setVisible(
false);
114 final String path = fileChooser.getSelectedFile().getPath();
115 String dirPath = fileChooser.getSelectedFile().getParent();
116 ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_BASECASE, dirPath.substring(0, dirPath.lastIndexOf(File.separator)));
117 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
118 new SwingWorker<Void, Void>() {
121 protected Void doInBackground() throws Exception {
122 Case.openAsCurrentCase(path);
127 protected void done() {
130 }
catch (InterruptedException | ExecutionException ex) {
131 if (ex instanceof InterruptedException || (null != ex.getCause() && !(ex.getCause() instanceof CaseActionCancelledException))) {
132 LOGGER.log(Level.SEVERE, String.format(
"Error opening case with metadata file path %s", path), ex);
133 JOptionPane.showMessageDialog(
134 WindowManager.getDefault().getMainWindow(),
135 ex.getCause().getMessage(),
136 NbBundle.getMessage(this.getClass(),
"CaseOpenAction.msgDlg.cantOpenCase.title"),
137 JOptionPane.ERROR_MESSAGE);
139 StartupWindowProvider.getInstance().open();
141 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
158 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
160 OpenMultiUserCaseDialog multiUserCaseWindow = OpenMultiUserCaseDialog.getInstance();
161 multiUserCaseWindow.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
162 multiUserCaseWindow.setVisible(
true);
164 WindowManager.getDefault().getMainWindow().setCursor(null);
166 openCaseSelectionWindow();
182 return HelpCtx.DEFAULT_HELP;
static final String PROP_BASECASE
void actionPerformed(ActionEvent e)
static boolean getIsMultiUserModeEnabled()
final FileFilter caseMetadataFileFilter
static final String DISPLAY_NAME
static String getConfigSetting(String moduleName, String settingName)
static final String MAIN_SETTINGS
synchronized static Logger getLogger(String name)
static final Logger LOGGER
static final long serialVersionUID