1 11 package org.eclipse.debug.internal.ui.launchConfigurations; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.debug.core.ILaunchConfiguration; 16 import org.eclipse.debug.core.ILaunchManager; 17 import org.eclipse.debug.core.IStatusHandler; 18 import org.eclipse.debug.internal.ui.DebugUIPlugin; 19 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 20 import org.eclipse.debug.ui.DebugUITools; 21 import org.eclipse.jface.dialogs.IDialogConstants; 22 import org.eclipse.jface.dialogs.MessageDialogWithToggle; 23 import org.eclipse.jface.preference.IPreferenceStore; 24 import org.eclipse.swt.widgets.Shell; 25 26 27 public class DebugModePromptStatusHandler implements IStatusHandler { 28 29 32 public Object handleStatus(IStatus status, Object source) throws CoreException { 33 if (source instanceof ILaunchConfiguration) { 34 ILaunchConfiguration config = (ILaunchConfiguration)source; 35 if (DebugUITools.isPrivate(config)) { 36 return Boolean.FALSE; 37 } 38 } 39 40 IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); 41 ILaunchConfiguration configuration = (ILaunchConfiguration)source; 42 String pref = store.getString(IInternalDebugUIConstants.PREF_RELAUNCH_IN_DEBUG_MODE); 43 if (pref != null) { 44 if (pref.equals(MessageDialogWithToggle.NEVER)) { 45 return Boolean.FALSE; 46 } else if (pref.equals(MessageDialogWithToggle.ALWAYS)) { 47 relaunchInDebugMode(configuration); 48 return Boolean.TRUE; 49 } 50 } 51 52 Shell activeShell = DebugUIPlugin.getShell(); 53 String title = LaunchConfigurationsMessages.DebugModePromptStatusHandler_0; 54 String message = LaunchConfigurationsMessages.DebugModePromptStatusHandler_1; 55 56 MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(activeShell, title, message, null, false, store, IInternalDebugUIConstants.PREF_RELAUNCH_IN_DEBUG_MODE); 57 int buttonId = dialog.getReturnCode(); 58 if (buttonId == IDialogConstants.YES_ID) { 59 relaunchInDebugMode(configuration); 60 return Boolean.TRUE; } else if (buttonId == IDialogConstants.NO_ID) { 62 return Boolean.FALSE; } else { return Boolean.TRUE; } 66 } 67 70 private void relaunchInDebugMode(ILaunchConfiguration configuration) { 71 DebugUITools.launch(configuration, ILaunchManager.DEBUG_MODE); 72 } 73 } 74 | Popular Tags |