Search in sources :

Example 6 with ILaunchConfiguration

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;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) LaunchAction(org.eclipse.debug.ui.actions.LaunchAction) CoreException(org.eclipse.core.runtime.CoreException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 7 with ILaunchConfiguration

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);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 8 with ILaunchConfiguration

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;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Example 9 with ILaunchConfiguration

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);
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IDockerContainerConfig(org.eclipse.linuxtools.docker.core.IDockerContainerConfig) CoreException(org.eclipse.core.runtime.CoreException) IDockerHostConfig(org.eclipse.linuxtools.docker.core.IDockerHostConfig) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage)

Example 10 with ILaunchConfiguration

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);
        }
    }
}
Also used : Arrays(java.util.Arrays) TabFolder(org.eclipse.swt.widgets.TabFolder) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) Image(org.eclipse.swt.graphics.Image) CoreException(org.eclipse.core.runtime.CoreException) PerfPlugin(org.eclipse.linuxtools.internal.perf.PerfPlugin) Table(org.eclipse.swt.widgets.Table) ArrayList(java.util.ArrayList) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IProject(org.eclipse.core.resources.IProject) AbstractLaunchConfigurationTab(org.eclipse.debug.ui.AbstractLaunchConfigurationTab) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) GridData(org.eclipse.swt.layout.GridData) PerfCore(org.eclipse.linuxtools.internal.perf.PerfCore) TabItem(org.eclipse.swt.widgets.TabItem) TableItem(org.eclipse.swt.widgets.TableItem) Text(org.eclipse.swt.widgets.Text) Button(org.eclipse.swt.widgets.Button) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) List(java.util.List) ICDTLaunchConfigurationConstants(org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants) Color(org.eclipse.swt.graphics.Color) SWT(org.eclipse.swt.SWT) Label(org.eclipse.swt.widgets.Label) Control(org.eclipse.swt.widgets.Control) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) TableItem(org.eclipse.swt.widgets.TableItem) Color(org.eclipse.swt.graphics.Color) ArrayList(java.util.ArrayList) TabFolder(org.eclipse.swt.widgets.TabFolder) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)266 CoreException (org.eclipse.core.runtime.CoreException)96 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)76 Test (org.junit.Test)72 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)50 ILaunchManager (org.eclipse.debug.core.ILaunchManager)40 ArrayList (java.util.ArrayList)37 ILaunch (org.eclipse.debug.core.ILaunch)35 IProject (org.eclipse.core.resources.IProject)20 IPath (org.eclipse.core.runtime.IPath)20 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)16 IEditorPart (org.eclipse.ui.IEditorPart)15 IStatus (org.eclipse.core.runtime.IStatus)14 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 IFile (org.eclipse.core.resources.IFile)13 IProcess (org.eclipse.debug.core.model.IProcess)13 CachegrindViewPart (org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart)13 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)11 Shell (org.eclipse.swt.widgets.Shell)10 ElementListSelectionDialog (org.eclipse.ui.dialogs.ElementListSelectionDialog)10