1414package org .eclipse .jdt .internal .debug .ui ;
1515
1616import org .eclipse .core .runtime .IStatus ;
17+ import org .eclipse .debug .core .DebugEvent ;
1718import org .eclipse .debug .core .DebugException ;
19+ import org .eclipse .debug .core .DebugPlugin ;
20+ import org .eclipse .debug .core .IDebugEventSetListener ;
1821import org .eclipse .debug .core .ILaunch ;
1922import org .eclipse .debug .core .ILaunchConfiguration ;
2023import org .eclipse .debug .core .model .IDebugTarget ;
2124import org .eclipse .debug .ui .DebugUITools ;
25+ import org .eclipse .jdt .internal .debug .core .model .JDIThread ;
2226import org .eclipse .jface .dialogs .IDialogConstants ;
2327import org .eclipse .jface .preference .IPreferenceStore ;
2428import org .eclipse .osgi .util .NLS ;
2933import org .eclipse .swt .layout .GridData ;
3034import org .eclipse .swt .widgets .Button ;
3135import org .eclipse .swt .widgets .Composite ;
36+ import org .eclipse .swt .widgets .Display ;
3237import org .eclipse .swt .widgets .Shell ;
3338
3439/**
3540 * An error dialog reporting a problem with a debug
3641 * target which gives the user the option to continue
3742 * or terminate/disconnect or restart the target.
3843 */
39- public class HotCodeReplaceErrorDialog extends ErrorDialogWithToggle {
44+ public class HotCodeReplaceErrorDialog extends ErrorDialogWithToggle implements IDebugEventSetListener {
4045
4146 protected IDebugTarget target ;
4247 // The IDs of the buttons. Set to the sum of the other possible IDs generated by
@@ -53,6 +58,7 @@ public class HotCodeReplaceErrorDialog extends ErrorDialogWithToggle {
5358 public HotCodeReplaceErrorDialog (Shell parentShell , String dialogTitle , String message , IStatus status , String preferenceKey , String toggleMessage , String toggleMessage2 , IPreferenceStore store , IDebugTarget target ) {
5459 super (parentShell , dialogTitle , message , status , preferenceKey , toggleMessage , toggleMessage2 , store );
5560 this .target = target ;
61+ DebugPlugin .getDefault ().addDebugEventListener (this );
5662 }
5763
5864 /* (non-Javadoc)
@@ -149,4 +155,16 @@ public void run() {
149155 super .buttonPressed (id , target );
150156 }
151157 }
158+
159+ @ Override
160+ public void handleDebugEvents (DebugEvent [] events ) {
161+ for (DebugEvent event : events ) {
162+ if (event .getSource () instanceof JDIThread de ) {
163+ if (de .isTerminated ()) {
164+ Display .getDefault ().asyncExec (() -> this .close ());
165+ }
166+ }
167+ }
168+
169+ }
152170}
0 commit comments