19 package org.sleuthkit.autopsy.apputils;
22 import java.io.IOException;
23 import java.nio.charset.Charset;
24 import java.util.logging.Level;
25 import javax.swing.SwingUtilities;
26 import org.apache.commons.io.FileUtils;
27 import org.openide.LifecycleManager;
28 import org.openide.awt.ActionID;
29 import org.openide.awt.ActionReference;
30 import org.openide.awt.ActionReferences;
31 import org.openide.awt.ActionRegistration;
32 import org.openide.util.HelpCtx;
33 import org.openide.util.NbBundle;
34 import org.openide.util.actions.CallableSystemAction;
45 @ActionID(category =
"Tools",
id =
"org.sleuthkit.autopsy.apputils.ResetWindowsAction")
46 @ActionReferences(value = {
47 @ActionReference(path =
"Menu/Window", position = 205)})
48 @ActionRegistration(displayName =
"#CTL_ResetWindowsAction", lazy =
false)
49 @NbBundle.Messages({
"CTL_ResetWindowsAction=Reset Windows"})
52 private static final String DISPLAY_NAME = Bundle.CTL_ResetWindowsAction();
53 private static final long serialVersionUID = 1L;
55 private final static String WINDOWS2LOCAL =
"Windows2Local";
56 private final static String CASE_TO_REOPEN_FILE =
"caseToOpen.txt";
63 @NbBundle.Messages({
"ResetWindowAction.confirm.text=In order to perform the resetting of window locations the software will close and restart. "
64 +
"If a case is currently open, it will be closed. If ingest or a search is currently running, it will be terminated. "
65 +
"Are you sure you want to restart the software to reset all window locations?",
66 "ResetWindowAction.caseCloseFailure.text=Unable to close the current case, "
67 +
"the software will restart and the windows locations will reset the next time the software is closed.",
68 "ResetWindowAction.caseSaveMetadata.text=Unable to save current case path, "
69 +
"the software will restart and the windows locations will reset but the current case will not be opened upon restart."})
73 SwingUtilities.invokeLater(() -> {
77 Runtime.getRuntime().addShutdownHook(
new Thread() {
82 }
catch (IOException ex) {
85 logger.log(Level.SEVERE,
"Unable to delete config directory, window locations will not be reset. To manually reset the windows please delete the following directory while the software is closed. " +
PlatformUtil.
getUserConfigDirectory() + File.separator +
"Windows2Local", ex);
93 Charset encoding = null;
94 FileUtils.writeStringToFile(caseToOpenFile, caseMetadataFilePath, encoding);
98 LifecycleManager.getDefault().markForRestart();
100 LifecycleManager.getDefault().exit();
102 logger.log(Level.WARNING, Bundle.ResetWindowAction_caseCloseFailure_text(), ex);
104 }
catch (IOException ex) {
105 logger.log(Level.WARNING, Bundle.ResetWindowAction_caseSaveMetadata_text(), ex);
124 super.setEnabled(value);
134 return HelpCtx.DEFAULT_HELP;
static void closeCurrentCase()
void setEnabled(boolean value)
static String getCaseToReopenFilePath()
static boolean confirm(String message)
static void show(String message, MessageType messageType)
CaseMetadata getMetadata()
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
static boolean isCaseOpen()