use of org.eclipse.debug.core.ILaunchConfiguration in project tdi-studio-se by Talend.
the class TalendLaunchToolbarAction method addToMenu.
private int addToMenu(Menu menu, ILaunchConfiguration[] launchList, int accelerator, IRepositoryObject... allVersion) {
for (ILaunchConfiguration launch : launchList) {
try {
if (launch.getType().getIdentifier().equals(TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE) && isCurrentProject(launch)) {
if (checkItemExisted(launch, allVersion)) {
LaunchAction action = new LaunchAction(launch, getMode());
addToMenu(menu, action, accelerator);
accelerator++;
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
continue;
}
}
return accelerator;
}
use of org.eclipse.debug.core.ILaunchConfiguration in project linuxtools by eclipse.
the class ProviderLaunchShortcut method findLaunchConfiguration.
@Override
protected ILaunchConfiguration findLaunchConfiguration(IBinary bin, String mode) {
// create a default launch configuration based on the shortcut
ILaunchConfiguration config = createConfiguration(bin, false);
String providerId = null;
try {
providerId = ProviderFramework.getProviderIdToRun(config.getWorkingCopy(), type);
} catch (CoreException e1) {
e1.printStackTrace();
}
// check that there exists a provider for the given profiling type
if (providerId == null) {
// $NON-NLS-1$
handleFail(Messages.ProviderLaunchShortcut_0 + " " + type);
return null;
}
// true if a configuration exists for current project and program
boolean existsConfigForProject = false;
// true if a configuration exists for current project, program and
// the default provider
boolean existsConfigForTool = false;
try {
// $NON-NLS-1$
String projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
// $NON-NLS-1$
String programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(getLaunchConfigType());
for (ILaunchConfiguration currConfig : configs) {
// $NON-NLS-1$
String curProjectName = currConfig.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
// $NON-NLS-1$
String curProgramName = currConfig.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
// check that current configuration belongs to the current project/program
if (curProjectName.equals(projectName) && curProgramName.equals(programName)) {
existsConfigForProject = true;
// $NON-NLS-1$
String curProviderId = currConfig.getAttribute(ProviderProfileConstants.PROVIDER_CONFIG_ATT, "");
// check that current configuration has the same provider as the provider to run.
if (curProviderId.equals(providerId)) {
existsConfigForTool = true;
break;
}
}
}
} catch (CoreException e) {
// a configuration might be corrupted, skip prompting logic
// and fall back to default behavior
existsConfigForProject = true;
existsConfigForTool = true;
}
// the current project/program
if (!existsConfigForProject) {
createConfiguration(bin);
} else if (!existsConfigForTool) {
String provider = ProviderFramework.getProviderToolNameFromId(providerId);
String profileType = Character.toUpperCase(type.charAt(0)) + type.substring(1);
// prompt message
String promptMsg = MessageFormat.format(Messages.ProviderLaunchConfigurationPrompt_0, profileType, provider);
MessageBox prompt = new MessageBox(getActiveWorkbenchShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
prompt.setMessage(promptMsg);
// prompt user for configuration creation
if (prompt.open() == SWT.YES) {
return createConfiguration(bin);
}
}
return super.findLaunchConfiguration(bin, mode);
}
use of org.eclipse.debug.core.ILaunchConfiguration in project linuxtools by eclipse.
the class LaunchConfigurationUtils method getLaunchConfigurationByImageName.
/**
* Looks-up the {@link ILaunchConfiguration} with the given type and
* <strong>IDockerImage's name</strong>.
*
* @param type
* the configuration type
* @param imageName
* the associated {@link IDockerImage} name
* @return the first matching {@link ILaunchConfiguration} or
* <code>null</code> if none was found.
* @throws CoreException
*/
public static ILaunchConfiguration getLaunchConfigurationByImageName(final ILaunchConfigurationType type, final String imageName) throws CoreException {
final ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfiguration lastLaunchConfiguration = null;
// $NON-NLS-1$
String lastCreationDate = "";
for (ILaunchConfiguration launchConfiguration : manager.getLaunchConfigurations(type)) {
final String launchConfigImageName = launchConfiguration.getAttribute(IMAGE_NAME, // $NON-NLS-1$
"");
final String launchConfigCreationDate = launchConfiguration.getAttribute(CREATION_DATE, // $NON-NLS-1$
"");
if (launchConfigImageName.equals(imageName) && launchConfigCreationDate.compareTo(lastCreationDate) > 0) {
lastCreationDate = launchConfigCreationDate;
lastLaunchConfiguration = launchConfiguration;
}
}
return lastLaunchConfiguration;
}
use of org.eclipse.debug.core.ILaunchConfiguration in project linuxtools by eclipse.
the class RunDockerImageLaunchConfigurationDelegate method launch.
@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) {
try {
ILaunchConfiguration config = launch.getLaunchConfiguration();
final IDockerContainerConfig containerConfig = getDockerContainerConfig(config);
final IDockerHostConfig hostConfig = getDockerHostConfig(config);
final IDockerConnection connection = getDockerConnection(config);
if (connection == null)
return;
final IDockerImage image = getDockerImage(config, connection);
RunImageCommandHandler.runImage(image, containerConfig, hostConfig, config.getAttribute(IRunDockerImageLaunchConfigurationConstants.CONTAINER_NAME, (String) null), config.getAttribute(IRunDockerImageLaunchConfigurationConstants.AUTO_REMOVE, false));
} catch (CoreException e) {
Activator.log(e);
}
}
use of org.eclipse.debug.core.ILaunchConfiguration in project linuxtools by eclipse.
the class PerfEventsTab method createEventTabs.
private void createEventTabs(Composite top, ILaunchConfiguration config) {
// Maybe not the best place to load the event list but we'll see.
Map<String, List<String>> events = PerfCore.getEventList(config);
// the special counters should be last
ArrayList<String> tmpTabNames = new ArrayList<>(events.keySet());
final List<String> SPECIAL_EVENTS = Arrays.asList(new String[] { PerfPlugin.STRINGS_HWBREAKPOINTS, PerfPlugin.STRINGS_RAWHWEvents });
tmpTabNames.removeAll(SPECIAL_EVENTS);
tmpTabNames.addAll(SPECIAL_EVENTS);
String[] tabNames = tmpTabNames.toArray(new String[0]);
eventTabItems = new TabItem[tabNames.length];
eventTable = new Table[tabNames.length];
tabFolder = new TabFolder(top, SWT.NONE);
tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
// Initialize each tab.
for (int i = 0; i < tabNames.length; i++) {
eventTabItems[i] = new TabItem(tabFolder, SWT.NONE);
eventTabItems[i].setText(tabNames[i]);
// These are for the two special tabs for custom events.
if (tabNames[i].equals(PerfPlugin.STRINGS_HWBREAKPOINTS) || tabNames[i].equals(PerfPlugin.STRINGS_RAWHWEvents)) {
// Composite to contain it all
Composite c = new Composite(tabFolder, SWT.NONE);
c.setLayout(new GridLayout(2, false));
// A list to check off existing custom events (or show the new ones added)
Table table = new Table(c, SWT.CHECK | SWT.MULTI);
eventTable[i] = table;
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
table.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
updateLaunchConfigurationDialog();
}));
// Right side to enter new events and delete old ones
Composite right = new Composite(c, SWT.NONE);
right.setLayout(new GridLayout(2, false));
right.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, true));
// for adding
Label l = new Label(right, SWT.NONE);
l.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
Text t = new Text(right, SWT.SINGLE | SWT.BORDER);
t.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
if (tabNames[i].equals(PerfPlugin.STRINGS_HWBREAKPOINTS)) {
bpTabIndex = i;
bpText = t;
l.setText(Messages.PerfEventsTab_HardwareBreakpoint);
}
if (tabNames[i].equals(PerfPlugin.STRINGS_RAWHWEvents)) {
rawTabIndex = i;
rawText = t;
l.setText(Messages.PerfEventsTab_RawRegisterEncoding);
}
Button b = new Button(right, SWT.PUSH);
b.setText(Messages.PerfEventsTab_Add);
b.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
b.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
int index = tabFolder.getSelectionIndex();
if (rawTabIndex == index) {
new TableItem(eventTable[index], SWT.NONE).setText(rawText.getText());
} else if (bpTabIndex == index) {
new TableItem(eventTable[index], SWT.NONE).setText(bpText.getText());
}
updateLaunchConfigurationDialog();
}));
l = new Label(right, SWT.NONE);
l.setForeground(new Color(right.getDisplay(), 100, 100, 100));
if (tabNames[i].equals(PerfPlugin.STRINGS_HWBREAKPOINTS)) {
l.setText(Messages.PerfEventsTab_ForExample);
}
if (tabNames[i].equals(PerfPlugin.STRINGS_RAWHWEvents)) {
l.setText(Messages.PerfEventsTab_ForExampleR1A8);
}
l.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
// spacer label.
l = new Label(right, SWT.NONE);
l.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
// for removing
b = new Button(right, SWT.PUSH);
b.setText(Messages.PerfEventsTab_RemoveSelectedEvents);
b.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 2, 1));
b.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
eventTable[tabFolder.getSelectionIndex()].remove(eventTable[tabFolder.getSelectionIndex()].getSelectionIndices());
updateLaunchConfigurationDialog();
}));
l = new Label(right, SWT.NONE);
l.setForeground(new Color(right.getDisplay(), 100, 100, 100));
l.setText(Messages.PerfEventsTab_Note);
l.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 2, 1));
eventTabItems[i].setControl(c);
} else {
// This loads all the events 'perf list' gives into their respective tabs.
Table table = new Table(tabFolder, SWT.CHECK);
eventTable[i] = table;
List<String> eventList = events.get(tabNames[i]);
for (String event : eventList) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText(event);
}
table.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> updateLaunchConfigurationDialog()));
eventTabItems[i].setControl(table);
}
}
}
Aggregations