1616
1717/**
1818 * class ExportThreadsAction
19+ *
1920 * @author Jeka
2021 */
2122package com .intellij .java .debugger .impl .actions ;
2223
23- import java .io .BufferedWriter ;
24- import java .io .File ;
25- import java .io .FileWriter ;
26- import java .io .IOException ;
27-
28- import com .intellij .java .debugger .impl .DebuggerManagerEx ;
2924import com .intellij .java .debugger .impl .DebuggerContextImpl ;
25+ import com .intellij .java .debugger .impl .DebuggerManagerEx ;
3026import com .intellij .java .debugger .impl .DebuggerSession ;
3127import com .intellij .java .debugger .impl .ui .ExportDialog ;
3228import consulo .platform .base .localize .ActionLocalize ;
29+ import consulo .project .Project ;
3330import consulo .ui .ex .action .AnAction ;
3431import consulo .ui .ex .action .AnActionEvent ;
3532import consulo .ui .ex .action .Presentation ;
36- import consulo .project .Project ;
3733import consulo .ui .ex .awt .Messages ;
3834import consulo .ui .ex .awt .UIUtil ;
3935import consulo .util .lang .StringUtil ;
40- import consulo .virtualFileSystem .VirtualFile ;
4136import consulo .util .lang .SystemProperties ;
37+ import consulo .virtualFileSystem .VirtualFile ;
4238import jakarta .annotation .Nonnull ;
4339
44- public class ExportThreadsAction extends AnAction implements AnAction .TransparentUpdate
45- {
46- @ Override
47- public void actionPerformed (@ Nonnull AnActionEvent e )
48- {
49- Project project = e .getData (Project .KEY );
50- if (project == null )
51- {
52- return ;
53- }
54- DebuggerContextImpl context = (DebuggerManagerEx .getInstanceEx (project )).getContext ();
40+ import java .io .BufferedWriter ;
41+ import java .io .File ;
42+ import java .io .FileWriter ;
43+ import java .io .IOException ;
44+
45+ public class ExportThreadsAction extends AnAction {
46+ @ Override
47+ public void actionPerformed (@ Nonnull AnActionEvent e ) {
48+ Project project = e .getData (Project .KEY );
49+ if (project == null ) {
50+ return ;
51+ }
52+ DebuggerContextImpl context = (DebuggerManagerEx .getInstanceEx (project )).getContext ();
5553
56- if (context .getDebuggerSession () != null )
57- {
58- String destinationDirectory = "" ;
59- final VirtualFile baseDir = project .getBaseDir ();
60- if (baseDir != null )
61- {
62- destinationDirectory = baseDir .getPresentableUrl ();
63- }
54+ if (context .getDebuggerSession () != null ) {
55+ String destinationDirectory = "" ;
56+ final VirtualFile baseDir = project .getBaseDir ();
57+ if (baseDir != null ) {
58+ destinationDirectory = baseDir .getPresentableUrl ();
59+ }
6460
65- ExportDialog dialog = new ExportDialog (context .getDebugProcess (), destinationDirectory );
66- dialog .show ();
67- if (dialog .isOK ())
68- {
69- try
70- {
71- File file = new File (dialog .getFilePath ());
72- try (BufferedWriter writer = new BufferedWriter (new FileWriter (file )))
73- {
74- String text = StringUtil .convertLineSeparators (dialog .getTextToSave (), SystemProperties .getLineSeparator ());
75- writer .write (text );
76- }
77- }
78- catch (IOException ex )
79- {
80- Messages .showMessageDialog (project , ex .getMessage (), ActionLocalize .actionExportthreadsText ().get (), UIUtil .getErrorIcon ());
81- }
82- }
83- }
84- }
61+ ExportDialog dialog = new ExportDialog (context .getDebugProcess (), destinationDirectory );
62+ dialog .show ();
63+ if (dialog .isOK ()) {
64+ try {
65+ File file = new File (dialog .getFilePath ());
66+ try (BufferedWriter writer = new BufferedWriter (new FileWriter (file ))) {
67+ String text = StringUtil .convertLineSeparators (dialog .getTextToSave (), SystemProperties .getLineSeparator ());
68+ writer .write (text );
69+ }
70+ }
71+ catch (IOException ex ) {
72+ Messages .showMessageDialog (project , ex .getMessage (), ActionLocalize .actionExportthreadsText ().get (), UIUtil .getErrorIcon ());
73+ }
74+ }
75+ }
76+ }
8577
86- @ Override
87- public void update (@ Nonnull AnActionEvent event )
88- {
89- Presentation presentation = event .getPresentation ();
90- Project project = event .getData (Project .KEY );
91- if (project == null )
92- {
93- presentation .setEnabled (false );
94- return ;
95- }
96- DebuggerSession debuggerSession = (DebuggerManagerEx .getInstanceEx (project )).getContext ().getDebuggerSession ();
97- presentation .setEnabled (debuggerSession != null && debuggerSession .isPaused ());
98- }
78+ @ Override
79+ public void update (@ Nonnull AnActionEvent event ) {
80+ Presentation presentation = event .getPresentation ();
81+ Project project = event .getData (Project .KEY );
82+ if (project == null ) {
83+ presentation .setEnabled (false );
84+ return ;
85+ }
86+ DebuggerSession debuggerSession = (DebuggerManagerEx .getInstanceEx (project )).getContext ().getDebuggerSession ();
87+ presentation .setEnabled (debuggerSession != null && debuggerSession .isPaused ());
88+ }
9989}
0 commit comments