From fe3c6d028fabd799ab3a83385ce2cf2001adbf97 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Fri, 14 May 2010 01:50:46 +0000 Subject: [PATCH] Bug 281970: No longer show the Debugger, Refresh and Source tabs for a Run Configuration. Also, make sure a Run configuration can be used for Debug and vice versa. --- .../ICDTLaunchConfigurationConstants.java | 26 ++++++++++- debug/org.eclipse.cdt.debug.ui/plugin.xml | 7 +++ .../ui/launch/CApplicationLaunchShortcut.java | 21 ++++++--- .../LocalApplicationCDebuggerTab.java | 41 ++++++++++++++++- launch/org.eclipse.cdt.launch/plugin.xml | 33 ++++++++++++++ .../launch/ui/ApplicationCDebuggerTab.java | 44 ++++++++++++++++++- .../org/eclipse/cdt/launch/ui/CMainTab.java | 26 ++++++++--- 7 files changed, 182 insertions(+), 16 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java index dbbf7df6227..03013750f45 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 QNX Software Systems and others. + * Copyright (c) 2000, 2010 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -41,6 +41,30 @@ public interface ICDTLaunchConfigurationConstants { */ public static final String ID_LAUNCH_C_POST_MORTEM = "org.eclipse.cdt.launch.postmortemLaunchType"; //$NON-NLS-1$ + /** + * Specifies the default launch delegate for a Local Debug session + * @since 7.0 + */ + public static final String PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE = "org.eclipse.cdt.dsf.gdb.launch.localCLaunch"; //$NON-NLS-1$ + + /** + * Specifies the default launch delegate for an Attach Debug session + * @since 7.0 + */ + public static final String PREFERRED_DEBUG_ATTACH_LAUNCH_DELEGATE = "org.eclipse.cdt.dsf.gdb.launch.attachCLaunch"; //$NON-NLS-1$ + + /** + * Specifies the default launch delegate for a Post Mortem Debug session + * @since 7.0 + */ + public static final String PREFERRED_DEBUG_POSTMORTEM_LAUNCH_DELEGATE = "org.eclipse.cdt.dsf.gdb.launch.coreCLaunch"; //$NON-NLS-1$ + + /** + * Specifies the default launch delegate for a Run mode session + * @since 7.0 + */ + public static final String PREFERRED_RUN_LAUNCH_DELEGATE = "org.eclipse.cdt.cdi.launch.localCLaunch"; //$NON-NLS-1$ + /** * Identifier for the C/C++ program process type, which is annotated on processes created * by the C/C++ application launch delegate. diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 6dccc237add..69b7223759d 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -32,6 +32,13 @@ type="org.eclipse.cdt.launch.applicationLaunchType" class="org.eclipse.cdt.debug.internal.ui.launch.PlaceHolderLaunchConfigurationTabGroup" id="org.eclipse.cdt.launch.applicationLaunchTabGroup"> + + + + set = new HashSet(); - set.add(mode); + // Workaround for bug 262840 + try { + HashSet set = new HashSet(); + set.add(ILaunchManager.RUN_MODE); + ILaunchDelegate preferredDelegate = wc.getPreferredDelegate(set); + if (preferredDelegate == null) { + wc.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_RUN_LAUNCH_DELEGATE); + } + } catch (CoreException e) {} + + // We must also set the debug mode delegate because this configuration can be re-used + // in Debug mode. try { + HashSet set = new HashSet(); + set.add(ILaunchManager.DEBUG_MODE); ILaunchDelegate preferredDelegate = wc.getPreferredDelegate(set); if (preferredDelegate == null) { - wc.setPreferredLaunchDelegate(set, "org.eclipse.cdt.dsf.gdb.launch.localCLaunch"); + wc.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE); } } catch (CoreException e) {} // End workaround for bug 262840 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LocalApplicationCDebuggerTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LocalApplicationCDebuggerTab.java index 9e779f3747a..77d993dec4a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LocalApplicationCDebuggerTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LocalApplicationCDebuggerTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems and others. + * Copyright (c) 2008, 2010 Wind River Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,6 +11,9 @@ package org.eclipse.cdt.dsf.gdb.internal.ui.launching; import org.eclipse.cdt.dsf.gdb.service.SessionType; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; /** * Debugger tab to use for a local application launch configuration. @@ -19,7 +22,43 @@ import org.eclipse.cdt.dsf.gdb.service.SessionType; */ public class LocalApplicationCDebuggerTab extends CDebuggerTab { + /* + * When the launch configuration is created for Run mode, + * this Debugger tab is not created because it is not used + * for Run mode but only for Debug mode. + * When we then open the same configuration in Debug mode, the launch + * configuration already exists and initializeFrom() is called + * instead of setDefaults(). + * We therefore call setDefaults() ourselves and update the configuration. + * If we don't then the user will be required to press Apply to get the + * default settings saved. + * Bug 281970 + */ + private boolean fSetDefaultCalled; + public LocalApplicationCDebuggerTab() { super(SessionType.LOCAL, false); } + + @Override + public void setDefaults(ILaunchConfigurationWorkingCopy config) { + fSetDefaultCalled = true; + + super.setDefaults(config); + } + + @Override + public void initializeFrom(ILaunchConfiguration config) { + if (fSetDefaultCalled == false) { + try { + ILaunchConfigurationWorkingCopy wc; + wc = config.getWorkingCopy(); + setDefaults(wc); + wc.doSave(); + } catch (CoreException e) { + } + } + + super.initializeFrom(config); + } } diff --git a/launch/org.eclipse.cdt.launch/plugin.xml b/launch/org.eclipse.cdt.launch/plugin.xml index c761efe985c..895e9e16553 100644 --- a/launch/org.eclipse.cdt.launch/plugin.xml +++ b/launch/org.eclipse.cdt.launch/plugin.xml @@ -187,6 +187,39 @@ + + + + + + + + + + + + + + + + + diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/ApplicationCDebuggerTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/ApplicationCDebuggerTab.java index e5567beb20d..474537b8358 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/ApplicationCDebuggerTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/ApplicationCDebuggerTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems and others. + * Copyright (c) 2008, 2010 Wind River Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,13 +10,53 @@ *******************************************************************************/ package org.eclipse.cdt.launch.ui; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; + /** * CDebugger tab to use for an application launch configuration. * * @since 6.0 */ public class ApplicationCDebuggerTab extends CDebuggerTab { - public ApplicationCDebuggerTab() { + /* + * When the launch configuration is created for Run mode, + * this Debugger tab is not created because it is not used + * for Run mode but only for Debug mode. + * When we then open the same configuration in Debug mode, the launch + * configuration already exists and initializeFrom() is called + * instead of setDefaults(). + * We therefore call setDefaults() ourselves and update the configuration. + * If we don't then the user will be required to press Apply to get the + * default settings saved. + * Bug 281970 + */ + private boolean fSetDefaultCalled; + + public ApplicationCDebuggerTab() { super (false); } + + @Override + public void setDefaults(ILaunchConfigurationWorkingCopy config) { + fSetDefaultCalled = true; + + super.setDefaults(config); + } + + @Override + public void initializeFrom(ILaunchConfiguration config) { + if (fSetDefaultCalled == false) { + try { + ILaunchConfigurationWorkingCopy wc; + wc = config.getWorkingCopy(); + setDefaults(wc); + wc.doSave(); + } catch (CoreException e) { + } + } + + super.initializeFrom(config); + } } diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java index 66bb5f51a50..93a618d4155 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java @@ -35,6 +35,7 @@ import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchDelegate; +import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.dialogs.MessageDialog; @@ -534,19 +535,30 @@ public class CMainTab extends CAbstractMainTab { */ public void setDefaults(ILaunchConfigurationWorkingCopy config) { - // Workaround for bug 262840: select the standard CDT launcher by default. - HashSet set = new HashSet(); - set.add(getLaunchConfigurationDialog().getMode()); + // Workaround for bug 262840 try { + HashSet set = new HashSet(); + set.add(ILaunchManager.DEBUG_MODE); ILaunchDelegate preferredDelegate = config.getPreferredDelegate(set); if (preferredDelegate == null) { if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP)) { - config.setPreferredLaunchDelegate(set, "org.eclipse.cdt.dsf.gdb.launch.localCLaunch"); //$NON-NLS-1$ + config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE); } else if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH)) { - config.setPreferredLaunchDelegate(set, "org.eclipse.cdt.dsf.gdb.launch.attachCLaunch"); //$NON-NLS-1$ + config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_ATTACH_LAUNCH_DELEGATE); } else if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM)) { - config.setPreferredLaunchDelegate(set, "org.eclipse.cdt.dsf.gdb.launch.coreCLaunch"); //$NON-NLS-1$ - } + config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_POSTMORTEM_LAUNCH_DELEGATE); + } + } + } catch (CoreException e) {} + + // We must also set the preferred delegate for Run mode, because this configuration + // can be used in Run mode. + try { + HashSet set = new HashSet(); + set.add(ILaunchManager.RUN_MODE); + ILaunchDelegate preferredDelegate = config.getPreferredDelegate(set); + if (preferredDelegate == null) { + config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_RUN_LAUNCH_DELEGATE); } } catch (CoreException e) {}