1 11 package org.eclipse.jdt.internal.debug.ui; 12 13 import com.ibm.icu.text.MessageFormat; 14 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.debug.core.DebugException; 17 import org.eclipse.debug.core.ILaunch; 18 import org.eclipse.debug.core.ILaunchConfiguration; 19 import org.eclipse.debug.core.model.IDebugTarget; 20 import org.eclipse.debug.ui.DebugUITools; 21 import org.eclipse.jface.dialogs.IDialogConstants; 22 import org.eclipse.jface.preference.IPreferenceStore; 23 import org.eclipse.swt.custom.BusyIndicator; 24 import org.eclipse.swt.widgets.Composite; 25 import org.eclipse.swt.widgets.Shell; 26 27 32 public class HotCodeReplaceErrorDialog extends ErrorDialogWithToggle { 33 34 protected IDebugTarget target; 35 protected int TERMINATE_ID= IDialogConstants.OK_ID + IDialogConstants.DETAILS_ID + IDialogConstants.CANCEL_ID; 38 protected int DISCONNECT_ID= TERMINATE_ID + 1; 39 protected int RESTART_ID= TERMINATE_ID + 2; 40 41 47 public HotCodeReplaceErrorDialog(Shell parentShell, String dialogTitle, String message, IStatus status, String preferenceKey, String toggleMessage, IPreferenceStore store, IDebugTarget target) { 48 super(parentShell, dialogTitle, message, status, preferenceKey, toggleMessage, store); 49 this.target = target; 50 } 51 52 55 protected void createButtonsForButtonBar(Composite parent) { 56 super.createButtonsForButtonBar(parent); 57 getButton(IDialogConstants.OK_ID).setText(DebugUIMessages.HotCodeReplaceErrorDialog_0); 58 boolean canTerminate= target.canTerminate(); 59 boolean canDisconnect= target.canDisconnect(); 60 if (canTerminate) { 61 createButton(parent, TERMINATE_ID, DebugUIMessages.HotCodeReplaceErrorDialog_1, false); 62 } 63 if (canDisconnect) { 64 createButton(parent, DISCONNECT_ID, DebugUIMessages.HotCodeReplaceErrorDialog_3, false); 65 } 66 if (canTerminate && !canDisconnect) { 67 createButton(parent, RESTART_ID, DebugUIMessages.HotCodeReplaceErrorDialog_7, false); 68 } 69 } 70 71 74 protected void buttonPressed(final int id) { 75 if (id == TERMINATE_ID || id == DISCONNECT_ID || id == RESTART_ID) { 76 final DebugException[] ex = new DebugException[1]; 77 final String [] operation = new String [1]; 78 ex[0] = null; 79 Runnable r = new Runnable () { 80 public void run() { 81 try { 82 if (id == TERMINATE_ID) { 83 operation[0]= DebugUIMessages.HotCodeReplaceErrorDialog_5; 84 target.terminate(); 85 } else if (id == DISCONNECT_ID){ 86 operation[0]= DebugUIMessages.HotCodeReplaceErrorDialog_6; 87 target.disconnect(); 88 } else { 89 operation[0]= DebugUIMessages.HotCodeReplaceErrorDialog_8; 90 ILaunch launch = target.getLaunch(); 91 launch.terminate(); 92 ILaunchConfiguration config = launch.getLaunchConfiguration(); 93 if (config != null && config.exists()) { 94 DebugUITools.launch(config, launch.getLaunchMode()); 95 } 96 } 97 } catch (DebugException e) { 98 ex[0] = e; 99 } 100 } 101 }; 102 BusyIndicator.showWhile(getShell().getDisplay(), r); 103 if (ex[0] != null) { 104 JDIDebugUIPlugin.statusDialog(MessageFormat.format(DebugUIMessages.HotCodeReplaceErrorDialog_2, operation), ex[0].getStatus()); 105 } 106 okPressed(); 107 } else { 108 super.buttonPressed(id); 109 } 110 } 111 } 112 | Popular Tags |