use of org.eclipse.debug.ui.ILaunchConfigurationTab 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);
}
}
}
use of org.eclipse.debug.ui.ILaunchConfigurationTab in project linuxtools by eclipse.
the class ProviderLaunchShortcut method setDefaultProfileAttributes.
@Override
protected void setDefaultProfileAttributes(ILaunchConfigurationWorkingCopy wc) {
// acquire a provider id to run.
final String providerId = ProviderFramework.getProviderIdToRun(wc, getProfilingType());
// get tool name from id.
final String providerToolName = ProviderFramework.getProviderToolNameFromId(providerId);
// get tab group associated with provider id.
final ProfileLaunchConfigurationTabGroup tabgroup = ProviderFramework.getTabGroupProviderFromId(providerId);
/**
* Certain tabs' setDefaults(ILaunchConfigurationWorkingCopy) may
* require a launch configuration dialog. Eg. CMainTab generates
* a name for the configuration based on generateName in setDefaults()
* so we can create a temporary launch configuration dialog here. With
* the exception of generateName(String), the other methods do not
* get called.
*/
ILaunchConfigurationDialog dialog = new ILaunchConfigurationDialog() {
@Override
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) {
throw new UnsupportedOperationException();
}
@Override
public void updateMessage() {
throw new UnsupportedOperationException();
}
@Override
public void updateButtons() {
throw new UnsupportedOperationException();
}
@Override
public void setName(String name) {
throw new UnsupportedOperationException();
}
@Override
public void setActiveTab(int index) {
throw new UnsupportedOperationException();
}
@Override
public void setActiveTab(ILaunchConfigurationTab tab) {
throw new UnsupportedOperationException();
}
@Override
public ILaunchConfigurationTab[] getTabs() {
return null;
}
@Override
public String getMode() {
return null;
}
@Override
public ILaunchConfigurationTab getActiveTab() {
return null;
}
@Override
public String generateName(String name) {
if (name == null) {
// $NON-NLS-1$
name = "";
}
String providerConfigutationName = generateProviderConfigurationName(name, providerToolName);
return getLaunchManager().generateLaunchConfigurationName(providerConfigutationName);
}
};
// $NON-NLS-1$
tabgroup.createTabs(dialog, "profile");
// set configuration to match default attributes for all tabs.
for (ILaunchConfigurationTab tab : tabgroup.getTabs()) {
tab.setLaunchConfigurationDialog(dialog);
tab.setDefaults(wc);
}
// get configuration shortcut associated with provider id.
ProfileLaunchShortcut shortcut = ProviderFramework.getLaunchShortcutProviderFromId(providerId);
// set attributes related to the specific profiling shortcut configuration.
shortcut.setDefaultProfileLaunchShortcutAttributes(wc);
wc.setAttribute(ProviderProfileConstants.PROVIDER_CONFIG_ATT, providerId);
// set tool name in configuration.
wc.setAttribute(ProviderProfileConstants.PROVIDER_CONFIG_TOOLNAME_ATT, providerToolName);
/**
* To avoid renaming an already renamed launch configuration, we can
* check the expected format of the name using regular expressions and
* skip on matches.
*/
String curConfigName = wc.getName();
// $NON-NLS-1$
Pattern configNamePattern = Pattern.compile(".+\\s\\[.+\\](\\s\\(\\d+\\))?$");
Matcher match = configNamePattern.matcher(curConfigName);
if (!match.find()) {
wc.rename(dialog.generateName(curConfigName));
}
}
use of org.eclipse.debug.ui.ILaunchConfigurationTab in project linuxtools by eclipse.
the class HelgrindLaunchShortcut method setDefaultProfileAttributes.
@Override
protected void setDefaultProfileAttributes(ILaunchConfigurationWorkingCopy wc) throws CoreException {
ValgrindOptionsTab tab = new ValgrindOptionsTab();
tab.setDefaults(wc);
ILaunchConfigurationTab defaultTab = ValgrindLaunchPlugin.getDefault().getToolPage(HelgrindPlugin.TOOL_ID);
defaultTab.setDefaults(wc);
}
use of org.eclipse.debug.ui.ILaunchConfigurationTab in project linuxtools by eclipse.
the class AbstractValgrindTest method setProfileAttributes.
@Override
protected void setProfileAttributes(ILaunchConfigurationWorkingCopy wc) throws CoreException {
ILaunchConfigurationTab tab = new ValgrindOptionsTab();
tab.setDefaults(wc);
tab = ValgrindLaunchPlugin.getDefault().getToolPage(getToolID());
tab.setDefaults(wc);
wc.setAttribute(LaunchConfigurationConstants.ATTR_TOOL, getToolID());
wc.setAttribute(LaunchConfigurationConstants.ATTR_FULLPATH_AFTER, false);
}
Aggregations