19 package org.sleuthkit.autopsy.actions;
21 import java.awt.Desktop;
22 import java.awt.event.ActionListener;
23 import java.io.BufferedWriter;
25 import java.io.FileWriter;
26 import java.io.IOException;
27 import java.nio.file.Path;
28 import java.nio.file.Paths;
29 import java.util.concurrent.ExecutionException;
30 import java.util.logging.Level;
31 import javax.swing.SwingWorker;
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.Messages;
37 import org.openide.util.actions.CallableSystemAction;
49 @ActionID(category =
"Help",
id =
"org.sleuthkit.autopsy.actions.ThreadDumpAction")
50 @ActionRegistration(displayName =
"#CTL_DumpThreadAction", lazy =
false)
51 @ActionReference(path =
"Menu/Help", position = 1750)
53 "CTL_DumpThreadAction=Thread Dump"
55 public final class ThreadDumpAction extends CallableSystemAction implements ActionListener {
57 private static final long serialVersionUID = 1L;
67 return Bundle.CTL_DumpThreadAction();
72 return HelpCtx.DEFAULT_HELP;
83 return createThreadDump();
91 Desktop.getDesktop().open(dumpFile);
92 }
catch (ExecutionException | InterruptedException ex) {
93 logger.log(Level.SEVERE,
"Failure occurred while creating thread dump file", ex);
94 }
catch (IOException ex) {
95 if (dumpFile != null) {
96 logger.log(Level.WARNING,
"Failed to open thread dump file in external viewer: " + dumpFile.getAbsolutePath(), ex);
98 logger.log(Level.SEVERE,
"Failed to create thread dump file.", ex);
113 File dumpFile = createFilePath().toFile();
114 try (BufferedWriter writer =
new BufferedWriter(
new FileWriter(dumpFile,
true))) {
115 writer.write(threadDump);
String getLogDirectoryPath()
static String generateThreadDump()
static String createTimeStamp()
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
static boolean isCaseOpen()