Search in sources :

Example 16 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project bndtools by bndtools.

the class AbstractLaunchShortcut method createConfiguration.

protected ILaunchConfigurationWorkingCopy createConfiguration(IPath targetPath, IProject targetProject) throws CoreException {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType configType = manager.getLaunchConfigurationType(launchId);
    ILaunchConfigurationWorkingCopy wc;
    wc = configType.newInstance(null, manager.generateLaunchConfigurationName(targetPath.lastSegment()));
    wc.setAttribute(LaunchConstants.ATTR_LAUNCH_TARGET, targetPath.toString());
    wc.setAttribute(LaunchConstants.ATTR_CLEAN, LaunchConstants.DEFAULT_CLEAN);
    wc.setAttribute(LaunchConstants.ATTR_DYNAMIC_BUNDLES, LaunchConstants.DEFAULT_DYNAMIC_BUNDLES);
    if (targetProject != null) {
        IJavaProject javaProject = JavaCore.create(targetProject);
        if (javaProject.exists()) {
            wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, targetProject.getName());
        }
    }
    return wc;
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 17 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project linuxtools by eclipse.

the class ClearLaunchConfigurationsRule method before.

@Override
protected void before() throws Throwable {
    final ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    final ILaunchConfigurationType launchConfigType = LaunchConfigurationUtils.getLaunchConfigType(launchConfigTypeId);
    Stream.of(manager.getLaunchConfigurations(launchConfigType)).forEach(launchConfig -> {
        try {
            launchConfig.delete();
        } catch (Exception e) {
            fail("Failed to remove a launch configuration  '" + launchConfig.getName() + "' of type '" + this.launchConfigTypeId + "'");
        }
    });
}
Also used : ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Example 18 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project linuxtools by eclipse.

the class LaunchConfigurationUtils method updateLaunchConfigurations.

/**
 * Updates all {@link ILaunchConfiguration} of the given {@code type} where
 * there is an attribute with the given {@code attributeName} of the given
 * {@code oldValue}, and sets the {@code newValue} instead.
 *
 * @param type
 *            the type of {@link ILaunchConfiguration} to find
 * @param attributeName
 *            the name of the attribute to look-up
 * @param oldValue
 *            the old value to match
 * @param newValue
 *            the new value to set
 */
public static void updateLaunchConfigurations(final String type, final String attributeName, final String oldValue, final String newValue) {
    final ILaunchConfigurationType configType = LaunchConfigurationUtils.getLaunchConfigType(type);
    final ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    try {
        for (ILaunchConfiguration config : manager.getLaunchConfigurations(configType)) {
            try {
                if (// $NON-NLS-1$
                config.getAttribute(attributeName, "").equals(oldValue)) {
                    final ILaunchConfigurationWorkingCopy workingCopy = config.getWorkingCopy();
                    workingCopy.setAttribute(attributeName, newValue);
                    workingCopy.doSave();
                }
            } catch (CoreException e) {
                Activator.logErrorMessage(LaunchMessages.getFormattedString(// $NON-NLS-1$
                "UpdateLaunchConfiguration.named.error", config.getName()), e);
            }
        }
    } catch (CoreException e) {
        Activator.logErrorMessage(// $NON-NLS-1$
        LaunchMessages.getString(// $NON-NLS-1$
        "UpdateLaunchConfiguration.error"), e);
        Activator.logErrorMessage("Failed to retrieve launch configurations after connection name changed", e);
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 19 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project linuxtools by eclipse.

the class LaunchConfigurationUtils method getLaunchConfigurationWorkingCopy.

/**
 * Returns the {@link ILaunchConfigurationWorkingCopy} with the given type
 * and <strong>IDockerImage's name</strong>.
 *
 * @param type
 *            the configuration type
 * @param imageName
 *            the associated {@link IDockerImage} name
 * @param createIfNotFound
 *            flag to indicate if a new {@link ILaunchConfiguration} should
 *            be created if none was found.
 * @return the ILaunchConfigurationWorkingCopy for the matching
 *         {@link ILaunchConfiguration} or a new instance if none was found.
 * @throws CoreException
 */
private static ILaunchConfigurationWorkingCopy getLaunchConfigurationWorkingCopy(final ILaunchConfigurationType type, final String imageName) throws CoreException {
    final ILaunchConfiguration existingLaunchConfiguration = getLaunchConfigurationByImageName(type, imageName);
    if (existingLaunchConfiguration != null) {
        return existingLaunchConfiguration.getWorkingCopy();
    }
    final ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    final String configurationName = manager.generateLaunchConfigurationName(imageName);
    return type.newInstance(null, configurationName);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Example 20 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project linuxtools by eclipse.

the class SystemTapScriptLaunch method setConsole.

public void setConsole(ScriptConsole console) {
    if (this.console == console) {
        return;
    }
    // If another launch is using the same console, remove that launch since
    // ScriptConsole prevents two identical stap scripts from being be run at once.
    this.console = console;
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    for (ILaunch launch : manager.getLaunches()) {
        if (launch.equals(this)) {
            continue;
        }
        if (launch instanceof SystemTapScriptLaunch) {
            SystemTapScriptLaunch olaunch = (SystemTapScriptLaunch) launch;
            if (olaunch.console == null || olaunch.console.equals(console)) {
                olaunch.forceRemove();
            }
        }
    }
    console.addScriptConsoleObserver(this);
}
Also used : ILaunch(org.eclipse.debug.core.ILaunch) ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Aggregations

ILaunchManager (org.eclipse.debug.core.ILaunchManager)26 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)14 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)13 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)10 CoreException (org.eclipse.core.runtime.CoreException)8 ArrayList (java.util.ArrayList)7 ILaunch (org.eclipse.debug.core.ILaunch)6 File (java.io.File)4 IPath (org.eclipse.core.runtime.IPath)4 Path (org.eclipse.core.runtime.Path)4 LinkedList (java.util.LinkedList)3 IProcess2 (org.talend.core.model.process.IProcess2)3 Map (java.util.Map)2 IStatus (org.eclipse.core.runtime.IStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Status (org.eclipse.core.runtime.Status)2 IVMInstall (org.eclipse.jdt.launching.IVMInstall)2 IRemoteCommandLauncher (org.eclipse.linuxtools.profiling.launch.IRemoteCommandLauncher)2 ProcessItem (org.talend.core.model.properties.ProcessItem)2 Project (org.talend.core.model.properties.Project)2