mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-07 16:26:11 +02:00
Bug 315490: Update JTag launch to set the default launch delegate more efficiently.
This commit is contained in:
parent
6468bb856d
commit
888641771e
2 changed files with 33 additions and 22 deletions
|
@ -10,12 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.gdbjtag.internal.ui;
|
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.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
|
* @since 7.0
|
||||||
|
@ -25,21 +20,4 @@ public class GDBJtagDSFCMainTab extends CMainTab {
|
||||||
public GDBJtagDSFCMainTab() {
|
public GDBJtagDSFCMainTab() {
|
||||||
super(CMainTab.DONT_CHECK_PROGRAM | CMainTab.INCLUDE_BUILD_SETTINGS);
|
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) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,15 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.gdbjtag.ui;
|
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.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
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.eclipse.ui.plugin.AbstractUIPlugin;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
@ -24,6 +31,10 @@ public class Activator extends AbstractUIPlugin {
|
||||||
// The plug-in ID
|
// The plug-in ID
|
||||||
public static final String PLUGIN_ID = "org.eclipse.cdt.debug.gdbjtag.ui";
|
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
|
// The shared instance
|
||||||
private static Activator plugin;
|
private static Activator plugin;
|
||||||
|
|
||||||
|
@ -40,6 +51,7 @@ public class Activator extends AbstractUIPlugin {
|
||||||
*/
|
*/
|
||||||
public void start(BundleContext context) throws Exception {
|
public void start(BundleContext context) throws Exception {
|
||||||
super.start(context);
|
super.start(context);
|
||||||
|
setDefaultLaunchDelegates();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -88,4 +100,25 @@ public class Activator extends AbstractUIPlugin {
|
||||||
static void log(Throwable e) {
|
static void log(Throwable e) {
|
||||||
log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, e.getMessage(), 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) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue