19package org.sleuthkit.autopsy.apputils;
22import java.io.IOException;
23import java.nio.charset.Charset;
24import java.util.logging.Level;
25import javax.swing.SwingUtilities;
26import org.apache.commons.io.FileUtils;
27import org.openide.LifecycleManager;
28import org.openide.awt.ActionID;
29import org.openide.awt.ActionReference;
30import org.openide.awt.ActionReferences;
31import org.openide.awt.ActionRegistration;
32import org.openide.util.HelpCtx;
33import org.openide.util.NbBundle;
34import org.openide.util.actions.CallableSystemAction;
35import org.sleuthkit.autopsy.casemodule.Case;
36import org.sleuthkit.autopsy.casemodule.CaseActionException;
37import org.sleuthkit.autopsy.coreutils.Logger;
38import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
39import org.sleuthkit.autopsy.coreutils.PlatformUtil;
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();
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 final String CASE_TO_REOPEN_FILE
static String getCaseToReopenFilePath()
void setEnabled(boolean value)
static final Logger logger
static final String WINDOWS2LOCAL
static final String DISPLAY_NAME
static final long serialVersionUID
static void closeCurrentCase()
CaseMetadata getMetadata()
static Case getCurrentCase()
static boolean isCaseOpen()
synchronized static Logger getLogger(String name)
static void show(String message, MessageType messageType)
static boolean confirm(String message)