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 javax.swing.JFileChooser;
26 import javax.swing.JOptionPane;
27 import javax.swing.SwingUtilities;
28 import javax.swing.filechooser.FileFilter;
29 import javax.swing.filechooser.FileNameExtensionFilter;
30 import org.openide.util.NbBundle;
31 import org.openide.util.lookup.ServiceProvider;
32 import org.openide.windows.WindowManager;
35 import org.openide.DialogDescriptor;
36 import org.openide.DialogDisplayer;
37 import org.openide.NotifyDescriptor;
39 import java.util.logging.Level;
40 import org.openide.util.HelpCtx;
41 import org.openide.util.actions.CallableSystemAction;
47 @ServiceProvider(service = CaseOpenAction.class)
48 public final class
CaseOpenAction extends CallableSystemAction implements ActionListener {
51 private static final String PROP_BASECASE =
"LBL_BaseCase_PATH";
52 private static final long serialVersionUID = 1L;
53 private final JFileChooser fileChooser =
new JFileChooser();
61 fileChooser.setDragEnabled(
false);
62 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
63 fileChooser.setMultiSelectionEnabled(
false);
64 fileChooser.setFileFilter(caseMetadataFileFilter);
84 NotifyDescriptor descriptor =
new NotifyDescriptor.Confirmation(
85 NbBundle.getMessage(
this.getClass(),
"CloseCaseWhileIngesting.Warning"),
86 NbBundle.getMessage(
this.getClass(),
"CloseCaseWhileIngesting.Warning.title"),
87 NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.WARNING_MESSAGE);
88 descriptor.setValue(NotifyDescriptor.NO_OPTION);
89 Object res = DialogDisplayer.getDefault().notify(descriptor);
90 if (res != null && res == DialogDescriptor.YES_OPTION) {
91 Case currentCase = null;
95 }
catch (IllegalStateException ignored) {
100 logger.log(Level.SEVERE, String.format(
"Error closing case at %s while ingest was running", (null != currentCase ? currentCase.
getCaseDirectory() :
"?")), ex);
111 int retval = fileChooser.showOpenDialog(WindowManager.getDefault().getMainWindow());
112 if (retval == JFileChooser.APPROVE_OPTION) {
122 final String path = fileChooser.getSelectedFile().getPath();
123 String dirPath = fileChooser.getSelectedFile().getParent();
125 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
130 logger.log(Level.SEVERE, String.format(
"Error opening case with metadata file path %s", path), ex);
131 SwingUtilities.invokeLater(() -> {
132 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
133 JOptionPane.showMessageDialog(
134 WindowManager.getDefault().getMainWindow(),
136 NbBundle.getMessage(this.getClass(),
"CaseOpenAction.msgDlg.cantOpenCase.title"),
137 JOptionPane.ERROR_MESSAGE);
153 return NbBundle.getMessage(
CaseOpenAction.class,
"CTL_OpenAction");
158 return HelpCtx.DEFAULT_HELP;
static synchronized IngestManager getInstance()
void actionPerformed(ActionEvent e)
String getCaseDirectory()
boolean isIngestRunning()
final FileFilter caseMetadataFileFilter
static synchronized void setConfigSetting(String moduleName, String settingName, String settingVal)
static String getConfigSetting(String moduleName, String settingName)
static void open(String caseMetadataFilePath)
static final String MAIN_SETTINGS
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
static StartupWindowProvider getInstance()
static boolean isCaseOpen()