Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/model/LaunchConfigurationDelegate.java38
-rw-r--r--org.eclipse.debug.ui/plugin.xml18
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java1
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DebugModePromptStatusHandler.java61
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java6
6 files changed, 127 insertions, 1 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/LaunchConfigurationDelegate.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/LaunchConfigurationDelegate.java
index 48cbbfe85..1b4c11469 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/LaunchConfigurationDelegate.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/LaunchConfigurationDelegate.java
@@ -12,8 +12,14 @@ package org.eclipse.debug.core.model;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.IStatusHandler;
/**
* Default implementation of a launch configuration delegate.
@@ -24,6 +30,18 @@ import org.eclipse.debug.core.ILaunchConfiguration;
* @since 3.0
*/
public abstract class LaunchConfigurationDelegate implements ILaunchConfigurationDelegate2 {
+
+ /**
+ * Status code for which a UI prompter is registered.
+ */
+ protected static final IStatus promptStatus = new Status(IStatus.INFO, "org.eclipse.debug.ui", 200, "", null); //$NON-NLS-1$//$NON-NLS-2$
+
+ /**
+ * Status code for which a prompter is registered to ask the user if they
+ * want to launch in debug mode when breakpoints are present.
+ */
+ protected static final IStatus switchToDebugPromptStatus = new Status(IStatus.INFO, "org.eclipse.debug.core", 201, "", null); //$NON-NLS-1$//$NON-NLS-2$
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate2#getLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
*/
@@ -43,9 +61,29 @@ public abstract class LaunchConfigurationDelegate implements ILaunchConfiguratio
return true;
}
/* (non-Javadoc)
+ *
+ * If launching in run mode, and the configuration supports debug mode, check
+ * if there are any breakpoints in the workspace, and ask the user if they'd
+ * rather launch in debug mode.
+ *
* @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate2#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
*/
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
+ if (mode.equals(ILaunchManager.RUN_MODE) && configuration.supportsMode(ILaunchManager.DEBUG_MODE)) {
+ IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
+ IBreakpoint[] breakpoints = breakpointManager.getBreakpoints();
+ if (breakpoints.length > 0) {
+ IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus);
+ if (prompter != null) {
+ boolean lauchInDebugModeInstead = ((Boolean)prompter.handleStatus(switchToDebugPromptStatus, configuration)).booleanValue();
+ if (lauchInDebugModeInstead) {
+ return false; //kill this launch
+ }
+ }
+
+ }
+ }
+
return true;
}
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index a481f3c4c..0a6c78757 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -1191,6 +1191,12 @@
class="org.eclipse.debug.internal.ui.sourcelookup.ResolveDuplicatesHandler"
id="org.eclipse.debug.ui.statusHandler.selectSourceDialog">
</statusHandler>
+ <statusHandler
+ plugin="org.eclipse.debug.core"
+ code="201"
+ class="org.eclipse.debug.internal.ui.launchConfigurations.DebugModePromptStatusHandler"
+ id="org.eclipse.debug.ui.statusHandler.debugModePromptStatusHandler">
+ </statusHandler>
</extension>
<extension
point="org.eclipse.debug.ui.launchGroups">
@@ -1686,6 +1692,18 @@
icon="icons/full/obj16/prj_obj.gif"
id="org.eclipse.debug.ui.containerPresentation.workspace">
</sourceContainerPresentation>
+<!-- <sourceContainerPresentation
+ browserClass="org.eclipse.debug.internal.ui.sourcelookup.browsers.ArchiveSourceContainerBrowser"
+ containerTypeID="org.eclipse.debug.core.containerType.archive"
+ icon="icons/full/obj16/jar_obj.gif"
+ id="org.eclipse.debug.ui.containerPresentation.archive">
+ </sourceContainerPresentation> -->
+ <sourceContainerPresentation
+ browserClass="org.eclipse.debug.internal.ui.sourcelookup.browsers.ExternalArchiveSourceContainerBrowser"
+ containerTypeID="org.eclipse.debug.core.containerType.externalArchive"
+ icon="icons/full/obj16/jar_obj.gif"
+ id="org.eclipse.debug.ui.containerPresentation.externalArchive">
+ </sourceContainerPresentation>
<sourceContainerPresentation
containerTypeID="org.eclipse.debug.core.containerType.default"
icon="icons/full/obj16/prj_obj.gif"
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
index 722796762..fda960f6d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
@@ -345,6 +345,7 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener {
prefs.setDefault(IDebugUIConstants.PREF_WAIT_FOR_BUILD, AlwaysNeverDialog.PROMPT);
prefs.setDefault(IDebugUIConstants.PREF_REUSE_EDITOR, true);
prefs.setDefault(IDebugUIConstants.PREF_SKIP_BREAKPOINTS_DURING_RUN_TO_LINE, false);
+ prefs.setDefault(IDebugUIConstants.PREF_RELAUNCH_IN_DEBUG_MODE, AlwaysNeverDialog.PROMPT);
//ConsolePreferencePage
prefs.setDefault(IDebugPreferenceConstants.CONSOLE_WRAP, false);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DebugModePromptStatusHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DebugModePromptStatusHandler.java
new file mode 100644
index 000000000..1309bb9f2
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DebugModePromptStatusHandler.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.launchConfigurations;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.IStatusHandler;
+import org.eclipse.debug.internal.ui.AlwaysNeverDialog;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class DebugModePromptStatusHandler implements IStatusHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object)
+ */
+ public Object handleStatus(IStatus status, Object source) throws CoreException {
+ Shell activeShell = DebugUIPlugin.getShell();
+ String title = LaunchConfigurationsMessages.getString("DebugModePromptStatusHandler.0"); //$NON-NLS-1$
+ String message = LaunchConfigurationsMessages.getString("DebugModePromptStatusHandler.1"); //$NON-NLS-1$
+ IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore();
+
+ ILaunchConfiguration configuration = (ILaunchConfiguration)source;
+
+ String pref = store.getString(IDebugUIConstants.PREF_RELAUNCH_IN_DEBUG_MODE);
+ if (pref != null) {
+ if (pref.equals(AlwaysNeverDialog.NEVER)) {
+ return new Boolean(false);
+ } else if (pref.equals(AlwaysNeverDialog.ALWAYS)) {
+ relaunchInDebugMode(configuration);
+ return new Boolean(true);
+ }
+ }
+
+ boolean switchToDebug = AlwaysNeverDialog.openQuestion(activeShell, title, message, IDebugUIConstants.PREF_RELAUNCH_IN_DEBUG_MODE, store);
+ if (switchToDebug) {
+ relaunchInDebugMode(configuration);
+ }
+ return new Boolean(switchToDebug);
+ }
+ /**
+ * @param configuration
+ */
+ private void relaunchInDebugMode(ILaunchConfiguration configuration) {
+ DebugUITools.launch(configuration, ILaunchManager.DEBUG_MODE);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
index 6d08e06fe..6d136f3b4 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
@@ -127,4 +127,6 @@ PerspectiveManager.13=This kind of launch is configured to switch to the {0} per
PerspectiveManager.15=This kind of launch is associated with the {0} perspective. Do you want to switch to this perspective now?
NewEnvironmentVariableDialog.1=New Environment Variable
-NewEnvironmentVariableDialog.4=Varia&bles... \ No newline at end of file
+NewEnvironmentVariableDialog.4=Varia&bles...
+DebugModePromptStatusHandler.0=Breakpoints in Workspace
+DebugModePromptStatusHandler.1=There are breakpoints in the workspace. Would you rather launch in debug mode?
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
index d85f74bef..eacf54229 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
@@ -168,6 +168,12 @@ public interface IDebugUIConstants {
* @since 2.0
*/
public static final String PREF_AUTO_REMOVE_OLD_LAUNCHES= PLUGIN_ID + ".auto_remove_old_launches"; //$NON-NLS-1$
+
+ /**
+ * Preference specifiying that all launches should be DEBUG_MODE if breakpoints exist in the workspace
+ * @since 3.0
+ */
+ public static final String PREF_RELAUNCH_IN_DEBUG_MODE = PLUGIN_ID + ".relaunch_in_debug_mode"; //$NON-NLS-1$
/**
* Boolean preference controlling whether the debugger re-uses non-dirty editors

Back to the top