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.JDialog;
28 import javax.swing.JFileChooser;
29 import javax.swing.JOptionPane;
30 import javax.swing.SwingWorker;
31 import javax.swing.filechooser.FileFilter;
32 import javax.swing.filechooser.FileNameExtensionFilter;
33 import org.openide.awt.ActionID;
34 import org.openide.awt.ActionReference;
35 import org.openide.awt.ActionRegistration;
36 import org.openide.util.HelpCtx;
37 import org.openide.util.NbBundle;
38 import org.openide.util.actions.CallableSystemAction;
39 import org.openide.util.lookup.ServiceProvider;
40 import org.openide.windows.WindowManager;
54 @ActionID(category =
"Case",
id =
"org.sleuthkit.autopsy.casemodule.CaseOpenAction")
55 @ActionReference(path =
"Menu/Case", position = 102)
56 @ActionRegistration(displayName =
"#CTL_CaseOpenAction", lazy =
false)
57 @NbBundle.Messages({
"CTL_CaseOpenAction=Open Case"})
58 @ServiceProvider(service = CaseOpenAction.class)
59 public final class CaseOpenAction extends CallableSystemAction implements ActionListener {
62 private static final String
DISPLAY_NAME = Bundle.CTL_CaseOpenAction();
77 fileChooser.setDragEnabled(
false);
78 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
79 fileChooser.setMultiSelectionEnabled(
false);
80 fileChooser.setFileFilter(caseMetadataFileFilter);
91 void openCaseSelectionWindow() {
92 String optionsDlgTitle = NbBundle.getMessage(
Case.class,
"CloseCaseWhileIngesting.Warning.title");
93 String optionsDlgMessage = NbBundle.getMessage(
Case.class,
"CloseCaseWhileIngesting.Warning");
99 int retval = fileChooser.showOpenDialog(WindowManager.getDefault().getMainWindow());
100 if (retval == JFileChooser.APPROVE_OPTION) {
109 if (multiUserCaseWindow != null) {
110 multiUserCaseWindow.setVisible(
false);
117 final String path = fileChooser.getSelectedFile().getPath();
118 String dirPath = fileChooser.getSelectedFile().getParent();
119 ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_BASECASE, dirPath.substring(0, dirPath.lastIndexOf(File.separator)));
120 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
121 new SwingWorker<Void, Void>() {
124 protected Void doInBackground() throws Exception {
125 Case.openAsCurrentCase(path);
130 protected void done() {
133 }
catch (InterruptedException | ExecutionException ex) {
134 if (ex instanceof InterruptedException || (null != ex.getCause() && !(ex.getCause() instanceof CaseActionCancelledException))) {
135 LOGGER.log(Level.SEVERE, String.format(
"Error opening case with metadata file path %s", path), ex);
136 JOptionPane.showMessageDialog(
137 WindowManager.getDefault().getMainWindow(),
138 ex.getCause().getMessage(),
139 NbBundle.getMessage(this.getClass(),
"CaseOpenAction.msgDlg.cantOpenCase.title"),
140 JOptionPane.ERROR_MESSAGE);
142 StartupWindowProvider.getInstance().open();
144 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
161 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
163 if (multiUserCaseWindow == null) {
164 multiUserCaseWindow = MultiUserCasesDialog.getInstance();
166 multiUserCaseWindow.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
167 multiUserCaseWindow.setVisible(
true);
169 WindowManager.getDefault().getMainWindow().setCursor(null);
171 openCaseSelectionWindow();
187 return HelpCtx.DEFAULT_HELP;
static final String PROP_BASECASE
void actionPerformed(ActionEvent e)
static boolean checkAndConfirmProceed(String optionsDlgTitle, String optionsDlgMessage)
static boolean getIsMultiUserModeEnabled()
final JFileChooser fileChooser
final FileFilter caseMetadataFileFilter
static final String DISPLAY_NAME
static JDialog multiUserCaseWindow
static String getConfigSetting(String moduleName, String settingName)
static final String MAIN_SETTINGS
synchronized static Logger getLogger(String name)
static final Logger LOGGER
static StartupWindowProvider getInstance()
static final long serialVersionUID