Search in sources :

Example 46 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 47 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 48 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 49 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)

Example 50 with ILaunchManager

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

the class SystemTapScriptLaunch method forceRemove.

public void forceRemove() {
    removeConsole();
    runStopped = true;
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    manager.removeLaunch(this);
}
Also used : ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Aggregations

ILaunchManager (org.eclipse.debug.core.ILaunchManager)78 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)53 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)41 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)37 CoreException (org.eclipse.core.runtime.CoreException)28 ArrayList (java.util.ArrayList)15 ILaunch (org.eclipse.debug.core.ILaunch)14 IPath (org.eclipse.core.runtime.IPath)9 File (java.io.File)7 HashMap (java.util.HashMap)6 Path (org.eclipse.core.runtime.Path)6 IProject (org.eclipse.core.resources.IProject)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 IOException (java.io.IOException)4 Map (java.util.Map)4 IStatus (org.eclipse.core.runtime.IStatus)4 LinkedList (java.util.LinkedList)3 Status (org.eclipse.core.runtime.Status)3 IProcess (org.eclipse.debug.core.model.IProcess)3 IProcess2 (org.talend.core.model.process.IProcess2)3