use of org.eclipse.debug.core.ILaunchConfiguration in project linuxtools by eclipse.
the class PerfOpenData method createDefaultConfiguration.
/**
* Create an ILaunchConfiguration instance given the project's name.
*
* @param projectName
* @return ILaunchConfiguration based on String projectName
*/
private ILaunchConfiguration createDefaultConfiguration(String projectName) {
ILaunchConfiguration config = null;
try {
ILaunchConfigurationType configType = getLaunchConfigType();
ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(projectName));
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
config = wc;
} catch (CoreException e) {
PerfCore.logException(e);
}
return config;
}
use of org.eclipse.debug.core.ILaunchConfiguration in project linuxtools by eclipse.
the class PerfOpenData method open.
@Override
public void open(IPath file) {
// get project name of where the file resides.
String projectName = null;
IFile location = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(file);
// If unable to get location from workspace, try getting from current file selection
if (location == null) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
ISelection selection = page.getSelection();
if (selection instanceof ITreeSelection) {
Object element = ((ITreeSelection) selection).getFirstElement();
if (element instanceof IFile) {
IFile eFile = (IFile) element;
IProject project = eFile.getProject();
projectName = project.getName();
URI fileURI = ((IFile) element).getLocationURI();
ILaunchConfiguration config = createDefaultConfiguration(projectName);
PerfCore.report(config, null, null, fileURI.getPath(), null);
String timestamp = DateFormat.getInstance().format(new Date(eFile.getLocalTimeStamp()));
// $NON-NLS-1$ //$NON-NLS-2$
PerfCore.refreshView(fileURI.toString() + " (" + timestamp + ")");
}
}
} else {
projectName = location.getProject().getName();
ILaunchConfiguration config = createDefaultConfiguration(projectName);
PerfCore.report(config, null, null, file.toOSString(), null);
String timestamp = DateFormat.getInstance().format(new Date(location.getLocalTimeStamp()));
// $NON-NLS-1$ //$NON-NLS-2$
PerfCore.refreshView(file.toOSString() + " (" + timestamp + ")");
}
}
use of org.eclipse.debug.core.ILaunchConfiguration in project linuxtools by eclipse.
the class AbstractEventConfigTab method initializeFrom.
@Override
public void initializeFrom(ILaunchConfiguration config) {
IProject previousProject = getOprofileProject();
IProject project = getProject(config);
setOprofileProject(project);
updateOprofileInfo();
String previousHost = null;
if (previousProject != null) {
if (previousProject.getLocationURI() != null) {
previousHost = previousProject.getLocationURI().getHost();
}
}
String host;
if (project != null) {
host = project.getLocationURI().getHost();
} else {
host = null;
}
// Any calculation based on project doesn't work as the very first time for local project they are both null.
if (previousProject == null || previousHost != host || host == null || counters == null) {
Control[] children = top.getChildren();
for (Control control : children) {
control.dispose();
}
OprofileCounter[] ctrs = getOprofileCounters(null);
if (getOprofileTimerMode() || (ctrs.length > 0 && ctrs[0].getValidEvents() == null)) {
Label timerModeLabel = new Label(top, SWT.LEFT);
// $NON-NLS-1$
timerModeLabel.setText(OprofileLaunchMessages.getString("tab.event.timermode.no.options"));
} else {
createVerticalSpacer(top, 1);
// default event checkbox
defaultEventCheck = new Button(top, SWT.CHECK);
// $NON-NLS-1$
defaultEventCheck.setText(OprofileLaunchMessages.getString("tab.event.defaultevent.button.text"));
defaultEventCheck.setLayoutData(new GridData());
defaultEventCheck.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> handleEnabledToggle()));
createVerticalSpacer(top, 1);
createCounterTabs(top);
}
}
if (!getOprofileTimerMode()) {
if (counters == null) {
// $NON-NLS-1$
OprofileCorePlugin.showErrorDialog("countersNotFound", null);
return;
}
for (int i = 0; i < counters.length; i++) {
counters[i].loadConfiguration(config);
}
for (CounterSubTab tab : counterSubTabs) {
tab.initializeTab(config);
tab.createEventsFilter();
}
try {
boolean enabledState = config.getAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, true);
defaultEventCheck.setSelection(enabledState);
setEnabledState(!enabledState);
} catch (CoreException e) {
e.printStackTrace();
}
}
}
use of org.eclipse.debug.core.ILaunchConfiguration in project linuxtools by eclipse.
the class ProfileLaunchShortcut method createConfiguration.
/**
* Create a launch configuration based on a binary, and optionally
* save it to the underlying resource.
*
* @param bin a representation of a binary
* @param save true if the configuration should be saved to the
* underlying resource, and false if it should not be saved.
* @return a launch configuration generated for the binary.
* @since 1.2
*/
protected ILaunchConfiguration createConfiguration(IBinary bin, boolean save) {
ILaunchConfiguration config = null;
try {
String projectName = bin.getResource().getProjectRelativePath().toString();
ILaunchConfigurationType configType = getLaunchConfigType();
ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(bin.getElementName()));
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectName);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName());
wc.setMappedResources(new IResource[] { bin.getResource(), bin.getResource().getProject() });
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
setDefaultProfileAttributes(wc);
if (save) {
config = wc.doSave();
} else {
config = wc;
}
} catch (CoreException e) {
e.printStackTrace();
}
return config;
}
use of org.eclipse.debug.core.ILaunchConfiguration in project linuxtools by eclipse.
the class ProfileLaunchShortcut method chooseConfiguration.
/**
* Show a selection dialog that allows the user to choose one of the specified
* launch configurations.
* @param configList The list of launch configurations to choose from.
* @param mode Currently unused.
* @return The chosen config, or <code>null</code> if the user cancelled the dialog.
*/
// TODO remove not used mode parameter for 4.0.
protected ILaunchConfiguration chooseConfiguration(List<ILaunchConfiguration> configList, String mode) {
IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
ElementListSelectionDialog dialog = new ElementListSelectionDialog(getActiveWorkbenchShell(), labelProvider);
dialog.setElements(configList.toArray());
dialog.setTitle(Messages.ProfileLaunchShortcut_Launch_Configuration_Selection);
dialog.setMessage(Messages.ProfileLaunchShortcut_Choose_a_launch_configuration);
dialog.setMultipleSelection(false);
int result = dialog.open();
labelProvider.dispose();
if (result == Window.OK) {
return (ILaunchConfiguration) dialog.getFirstResult();
}
return null;
}
Aggregations