Search in sources :

Example 46 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType in project tdi-studio-se by Talend.

the class JavaProcessor method saveLaunchConfigurationWithParam.

// generate the ILaunchConfiguration with the parameter string.
@Override
public Object saveLaunchConfigurationWithParam(String parameterStr) throws CoreException {
    /*
         * When launch debug progress, just share all libraries between farther job and child jobs
         */
    // computeLibrariesPath(this.getProcess().getNeededLibraries(true));
    ILaunchConfiguration config = null;
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    String projectName = this.getCodeProject().getName();
    ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
    if (type != null) {
        ILaunchConfigurationWorkingCopy wc = type.newInstance(null, launchManager.generateUniqueLaunchConfigurationNameFrom(this.getCodePath().lastSegment()));
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, this.getMainClass());
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_STOP_IN_MAIN, true);
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, CTX_ARG + context.getName() + parameterStr);
        config = wc.doSave();
    }
    return config;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 47 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType in project dbeaver by dbeaver.

the class DebugCore method createConfiguration.

public static ILaunchConfigurationWorkingCopy createConfiguration(IContainer container, String typeName, String name) throws CoreException {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(typeName);
    ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(container, name);
    return workingCopy;
}
Also used : ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 48 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType 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 49 with ILaunchConfigurationType

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

the class BaseResourceAwareLaunchShortcut method findLaunchConfiguration.

/**
 * Locate a configuration to launch for the given type. If one cannot be
 * found, create one.
 *
 * @param resource
 *            The {@code docker-compose.yml} to look up launch for.
 *
 * @return A re-useable config or <code>null</code> if none was found.
 */
protected ILaunchConfiguration findLaunchConfiguration(final String configTypeId, final IResource resource, final Predicate<ILaunchConfiguration> predicate) {
    final ILaunchConfigurationType configType = LaunchConfigurationUtils.getLaunchConfigType(configTypeId);
    final List<ILaunchConfiguration> candidateConfigs = new ArrayList<>();
    try {
        final ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configType);
        Stream.of(configs).filter(predicate).forEach(config -> candidateConfigs.add(config));
    } catch (CoreException e) {
        Activator.log(e);
    }
    // If there are no existing configurations associated with the
    // given resource,
    // create one. If there is exactly one configuration associated with the
    // given resource, return it. Otherwise, if there is more than one
    // configuration associated with the given resource, prompt the user to
    // choose
    // one.
    int candidateCount = candidateConfigs.size();
    if (candidateCount < 1) {
        return createConfiguration(resource);
    } else if (candidateCount == 1) {
        return candidateConfigs.get(0);
    } else {
        // anything.
        return chooseConfiguration(candidateConfigs);
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ArrayList(java.util.ArrayList)

Example 50 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType 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)

Aggregations

ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)91 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)62 ILaunchManager (org.eclipse.debug.core.ILaunchManager)54 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)50 CoreException (org.eclipse.core.runtime.CoreException)43 ArrayList (java.util.ArrayList)19 HashMap (java.util.HashMap)8 IPath (org.eclipse.core.runtime.IPath)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)6 Path (org.eclipse.core.runtime.Path)6 ILaunch (org.eclipse.debug.core.ILaunch)6 File (java.io.File)5 IOException (java.io.IOException)5 Map (java.util.Map)5 IProject (org.eclipse.core.resources.IProject)5 IResource (org.eclipse.core.resources.IResource)4 IStatus (org.eclipse.core.runtime.IStatus)4 List (java.util.List)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)2