use of org.eclipse.cdt.launch.AbstractCLaunchDelegate in project linuxtools by eclipse.
the class ProviderFramework method getConfigurationDelegateFromId.
/**
* Get a launch configuration delegate that is associated with the specified id.
* This looks through extensions of the extension point
* <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code> that
* have a specific delegate attribute.
*
* @param id a unique identifier
* @return a launch configuration delegate that implements
* <code>AbstractCLaunchDelegate</code> , or <code>null</code> if
* none could be found.
* @since 1.2
*/
public static AbstractCLaunchDelegate getConfigurationDelegateFromId(String id) {
IConfigurationElement[] configs = getConfigurationElements();
for (IConfigurationElement config : configs) {
if (config.getName().equals("provider")) {
// $NON-NLS-1$
// $NON-NLS-1$
String currentId = config.getAttribute("id");
// $NON-NLS-1$
String tabgroup = config.getAttribute("delegate");
if (currentId != null && tabgroup != null && currentId.equals(id)) {
try {
Object obj = config.createExecutableExtension(// $NON-NLS-1$
"delegate");
if (obj instanceof AbstractCLaunchDelegate) {
return (AbstractCLaunchDelegate) obj;
}
} catch (CoreException e) {
// continue, perhaps another configuration will succeed
}
}
}
}
return null;
}
use of org.eclipse.cdt.launch.AbstractCLaunchDelegate in project linuxtools by eclipse.
the class ExtensionPointTest method testDelegate.
@Test
public void testDelegate() {
// $NON-NLS-1$
AbstractCLaunchDelegate delegate = ProviderFramework.getConfigurationDelegateFromId(PLUGIN_ID + "1");
assertTrue(delegate instanceof StubbyLaunchConfigurationDelegate);
}
use of org.eclipse.cdt.launch.AbstractCLaunchDelegate in project linuxtools by eclipse.
the class ProviderLaunchConfigurationDelegate method launch.
@Override
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
if (config != null) {
// get provider id from configuration.
String providerId = config.getAttribute(ProviderProfileConstants.PROVIDER_CONFIG_ATT, // $NON-NLS-1$
"");
String providerToolName = config.getAttribute(ProviderProfileConstants.PROVIDER_CONFIG_TOOLNAME_ATT, // $NON-NLS-1$
"");
if (providerId == null || providerId.isEmpty()) {
// $NON-NLS-1$
String cProjectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
if (cProjectName != null && !cProjectName.isEmpty()) {
// We have a previously created C/C++ run/debug configuration and now Linux Tools
// profiling framework has been added. Find a suitable default provider id to use
// and perform initialization prior to profiling.
String defaultType = null;
String[] categories = ProviderFramework.getProviderCategories();
if (categories.length == 0) {
infoDialog(Messages.ProviderNoProfilers_title_0, Messages.ProviderNoProfilers_msg_0);
return;
}
for (String category : categories) {
// Give precedence to timing category if present
if (category.equals("timing")) {
// $NON-NLS-1$
// $NON-NLS-1$
defaultType = "timing";
}
}
// if default category still not set, take first one found
if (defaultType == null)
defaultType = categories[0];
providerId = ProviderFramework.getProviderIdToRun(null, defaultType);
ProfileLaunchConfigurationTabGroup tabGroupConfig = ProviderFramework.getTabGroupProviderFromId(providerId);
if (tabGroupConfig == null) {
infoDialog(Messages.ProviderNoProfilers_title_0, Messages.ProviderNoProfilers_msg_0);
return;
}
AbstractLaunchConfigurationTab[] tabs = tabGroupConfig.getProfileTabs();
// Set up defaults according to profiling tabs. We must use a working copy
// to do this which we save at the end to the original copy.
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
for (ILaunchConfigurationTab tab : tabs) {
tab.setDefaults(wc);
}
config = wc.doSave();
}
}
// get delegate associated with provider id.
AbstractCLaunchDelegate delegate = ProviderFramework.getConfigurationDelegateFromId(providerId);
// launch delegate
if (delegate != null) {
try {
delegate.launch(config, mode, launch, monitor);
} catch (CoreException e) {
errorDialog(Messages.ProviderLaunchError_msg_0, e.getMessage());
}
} else {
String message = providerToolName.isEmpty() ? NLS.bind(Messages.ProviderProfilerMissing_msg_0, providerId) : NLS.bind(Messages.ProviderProfilerMissing_msg_1, providerToolName);
infoDialog(Messages.ProviderProfilerMissing_title_0, message);
}
}
}
Aggregations