Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jtag
diff options
context:
space:
mode:
authorMarc Khouzam2010-06-22 11:18:20 -0400
committerMarc Khouzam2010-06-22 11:18:20 -0400
commit888641771eaaa175672176f2e63815b647450cfa (patch)
treecd2ba669fbdd8c4c570268d5a97698b1651d312d /jtag
parent6468bb856d834ccc43a6be27edacfc0018f57486 (diff)
downloadorg.eclipse.cdt-888641771eaaa175672176f2e63815b647450cfa.tar.gz
org.eclipse.cdt-888641771eaaa175672176f2e63815b647450cfa.tar.xz
org.eclipse.cdt-888641771eaaa175672176f2e63815b647450cfa.zip
Bug 315490: Update JTag launch to set the default launch delegate more efficiently.
Diffstat (limited to 'jtag')
-rw-r--r--jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/internal/ui/GDBJtagDSFCMainTab.java22
-rw-r--r--jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/Activator.java33
2 files changed, 33 insertions, 22 deletions
diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/internal/ui/GDBJtagDSFCMainTab.java b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/internal/ui/GDBJtagDSFCMainTab.java
index 1a54d185b4..f2529a50af 100644
--- a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/internal/ui/GDBJtagDSFCMainTab.java
+++ b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/internal/ui/GDBJtagDSFCMainTab.java
@@ -10,12 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.internal.ui;
-import java.util.HashSet;
-
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.CMainTab;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchDelegate;
/**
* @since 7.0
@@ -25,21 +20,4 @@ public class GDBJtagDSFCMainTab extends CMainTab {
public GDBJtagDSFCMainTab() {
super(CMainTab.DONT_CHECK_PROGRAM | CMainTab.INCLUDE_BUILD_SETTINGS);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.dsf.gdb.internal.ui.launching.CMainTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
- */
- @Override
- public void setDefaults(ILaunchConfigurationWorkingCopy config) {
- super.setDefaults(config);
- HashSet<String> set = new HashSet<String>();
- set.add(getLaunchConfigurationDialog().getMode());
- try {
- ILaunchDelegate preferredDelegate = config.getPreferredDelegate(set);
- if (preferredDelegate == null) {
- config.setPreferredLaunchDelegate(set, "org.eclipse.cdt.debug.gdbjtag.core.dsfLaunchDelegate"); //$NON-NLS-1$
- }
- } catch (CoreException e) {}
- }
-
}
diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/Activator.java b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/Activator.java
index 499e3dbcdb..d169ad8cfd 100644
--- a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/Activator.java
+++ b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/src/org/eclipse/cdt/debug/gdbjtag/ui/Activator.java
@@ -11,8 +11,15 @@
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.ui;
+import java.util.HashSet;
+
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchDelegate;
+import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -24,6 +31,10 @@ public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.cdt.debug.gdbjtag.ui";
+ private static final String HARDWARE_LAUNCH_TYPE = "org.eclipse.cdt.debug.gdbjtag.launchConfigurationType"; //$NON-NLS-1$
+
+ private static final String PREFERRED_DEBUG_HARDWARE_LAUNCH_DELEGATE = "org.eclipse.cdt.debug.gdbjtag.core.dsfLaunchDelegate"; //$NON-NLS-1$
+
// The shared instance
private static Activator plugin;
@@ -40,6 +51,7 @@ public class Activator extends AbstractUIPlugin {
*/
public void start(BundleContext context) throws Exception {
super.start(context);
+ setDefaultLaunchDelegates();
}
/*
@@ -88,4 +100,25 @@ public class Activator extends AbstractUIPlugin {
static void log(Throwable e) {
log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
}
+
+ private void setDefaultLaunchDelegates() {
+ // Set the default launch delegates as early as possible, and do it only once (Bug 312997)
+ ILaunchManager launchMgr = DebugPlugin.getDefault().getLaunchManager();
+
+ HashSet<String> debugSet = new HashSet<String>();
+ debugSet.add(ILaunchManager.DEBUG_MODE);
+
+ ILaunchConfigurationType remoteCfg = launchMgr.getLaunchConfigurationType(HARDWARE_LAUNCH_TYPE);
+ try {
+ if (remoteCfg.getPreferredDelegate(debugSet) == null) {
+ ILaunchDelegate[] delegates = remoteCfg.getDelegates(debugSet);
+ for (ILaunchDelegate delegate : delegates) {
+ if (PREFERRED_DEBUG_HARDWARE_LAUNCH_DELEGATE.equals(delegate.getId())) {
+ remoteCfg.setPreferredDelegate(debugSet, delegate);
+ break;
+ }
+ }
+ }
+ } catch (CoreException e) {}
+ }
}

Back to the top