Search in sources :

Example 31 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project mdw-designer by CenturyLinkCloud.

the class GherkinTestCaseLaunch method getLaunchConfiguration.

/**
 * Actually returns a working copy since we don't save this launch config.
 */
public ILaunchConfiguration getLaunchConfiguration() throws CoreException {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(CUCUMBER_LAUNCH_TYPE);
    ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, "mdwCucumberLaunch_" + getTestCase().getCaseName());
    List<String> resPaths = new ArrayList<>();
    resPaths.add("/" + workflowProject.getName());
    workingCopy.setAttribute(CucumberLaunchConfiguration.ATTR_MAPPED_RESOURCE_PATHS, resPaths);
    List<String> resTypes = new ArrayList<>();
    resTypes.add(CucumberLaunchConfiguration.RESOURCE_TYPE_PROJECT);
    workingCopy.setAttribute(CucumberLaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES, resTypes);
    workingCopy.setAttribute(CucumberLaunchConfiguration.ATTR_USE_START_ON_FIRST_THREAD, true);
    workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, workflowProject.getName());
    // TODO user-specified arguments (especially glue)
    StringBuilder args = new StringBuilder(CucumberLaunchConfiguration.DEFAULT_ARGS);
    // glue
    if (workflowProject.isFilePersist()) {
        for (WorkflowPackage gluePackage : getGluePackages()) args.append(" --glue \"").append(gluePackage.getFolder().getProjectRelativePath()).append("\"");
    }
    // legacy glue
    File oldGlueFile = new File(workflowProject.getOldTestCasesDir() + "/steps.groovy");
    if (oldGlueFile.exists())
        args.append(" --glue \"").append(oldGlueFile.toString().replace('\\', '/')).append("\"");
    // feature
    if (getTestCase().isLegacy()) {
        String oldTestSuiteLoc = workflowProject.getOldTestCasesDir().toString().replace('\\', '/');
        args.append(" \"").append(oldTestSuiteLoc).append("/").append(getTestCase().getCaseName()).append("\"");
    } else {
        args.append(" \"").append(workflowProject.getAssetFolder().getProjectRelativePath()).append("/").append(getTestCase().getPrefix().replace('.', '/')).append("/").append(getTestCase().getName()).append(RuleSetVO.getFileExtension(RuleSetVO.FEATURE)).append("\"");
    }
    workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args.toString());
    String vmArgs = "-Dmdw.test.case=" + getTestCase().getCaseName();
    if (getTestCase().isLegacy())
        vmArgs += " -Dmdw.test.cases.dir=\"" + workflowProject.getOldTestCasesDir().toString().replace('\\', '/') + "\"";
    else
        vmArgs += " -Dmdw.test.case.file=\"" + getTestCase().getCaseFile().toString().replace('\\', '/') + "\"";
    vmArgs += " -Dmdw.test.case.user=" + workflowProject.getUser().getUsername();
    vmArgs += " -Dmdw.test.server.url=" + workflowProject.getServiceUrl();
    if (stubbing) {
        vmArgs += " -Dmdw.test.server.stub=true";
        vmArgs += " -Dmdw.test.server.stubPort=" + workflowProject.getServerSettings().getStubServerPort();
    }
    if (workflowProject.isOldNamespaces())
        vmArgs += " -Dmdw.test.old.namespaces=true";
    if (singleServer)
        vmArgs += " -Dmdw.test.pin.to.server=true";
    if (createReplace)
        vmArgs += " -Dmdw.test.create.replace=true";
    vmArgs += " -Dmdw.test.results.dir=\"" + getTestCase().getResultDirectory().toString().replace('\\', '/') + "\"";
    if (workflowProject.isFilePersist())
        vmArgs += " -Dmdw.test.workflow.dir=\"" + workflowProject.getAssetDir().toString().replace('\\', '/') + "\"";
    else
        vmArgs += " -Dmdw.test.jdbc.url=" + workflowProject.getMdwDataSource().getJdbcUrlWithCredentials();
    if (verbose)
        vmArgs += " -Dmdw.test.verbose=true";
    if (this.getMasterRequestId() != null)
        vmArgs += " -Dmdw.test.masterRequestId=" + this.getMasterRequestId();
    workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs);
    return workingCopy;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ArrayList(java.util.ArrayList) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) File(java.io.File)

Example 32 with ILaunchManager

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

the class AbstractLaunchShortcut method findLaunchConfig.

protected ILaunchConfiguration findLaunchConfig(IPath targetPath) throws CoreException {
    List<ILaunchConfiguration> candidateConfigs = new ArrayList<ILaunchConfiguration>();
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType configType = manager.getLaunchConfigurationType(launchId);
    ILaunchConfiguration[] configs = manager.getLaunchConfigurations(configType);
    for (int i = 0; i < configs.length; i++) {
        ILaunchConfiguration config = configs[i];
        String configTargetName = config.getAttribute(LaunchConstants.ATTR_LAUNCH_TARGET, (String) null);
        if (configTargetName != null && configTargetName.equals(targetPath.toString())) {
            candidateConfigs.add(config);
        }
    }
    // Return the latest (last in the list)
    return !candidateConfigs.isEmpty() ? candidateConfigs.get(candidateConfigs.size() - 1) : null;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ArrayList(java.util.ArrayList) ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Example 33 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project jop by jop-devel.

the class JOPizer method createJOPizeLaunchConfiguration.

private ILaunchConfiguration createJOPizeLaunchConfiguration(String programArguments) throws CoreException {
    String configName = "JOPize";
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
    ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
    for (ILaunchConfiguration config : configs) {
        if (config.getName().equals(configName)) {
            config.delete();
            break;
        }
    }
    ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, configName);
    IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall();
    Map attributes = workingCopy.getAttributes();
    attributes.put(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "com.jopdesign.build.JOPizer");
    attributes.put(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments);
    IPreferenceStore prefs = JOPUIPlugin.getDefault().getPreferenceStore();
    String jopHome = prefs.getString(IJOPLaunchConfigurationConstants.ATTR_JOP_HOME);
    IPath jopTools = new Path(jopHome).append(new Path("java/tools/dist/lib/jop-tools.jar"));
    IRuntimeClasspathEntry jopToolsEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(jopTools);
    jopToolsEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
    IPath jopClasses = new Path(jopHome).append(new Path("java/target/dist/lib/classes.zip"));
    IRuntimeClasspathEntry jopClassesEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(jopClasses);
    jopClassesEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
    // IClasspathEntry jreEntry = JavaRuntime.getDefaultJREContainerEntry();
    List<String> classpath = new ArrayList<String>();
    classpath.add(jopToolsEntry.getMemento());
    classpath.add(jopClassesEntry.getMemento());
    // classpath.add(jreEntry.get)
    attributes.put(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classpath);
    attributes.put(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
    attributes.put(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Dmgci=false");
    workingCopy.setAttributes(attributes);
    System.err.printf("> %s%n", workingCopy.toString());
    return workingCopy;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IRuntimeClasspathEntry(org.eclipse.jdt.launching.IRuntimeClasspathEntry) IVMInstall(org.eclipse.jdt.launching.IVMInstall) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Map(java.util.Map)

Example 34 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project arduino-eclipse-plugin by Sloeber.

the class LaunchShortcut method getLaunchConfigurations.

/**
 * Searches for all applicable launch configurations for this project.
 *
 * @return list with the launch configurations.
 */
private ArrayList<ILaunchConfiguration> getLaunchConfigurations() {
    ArrayList<ILaunchConfiguration> result = new ArrayList<>();
    try {
        ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
        ILaunchConfigurationType type = manager.getLaunchConfigurationType(LaunchConfiguration.LAUNCH_CONFIGURATION_TYPE_ID);
        ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
        for (int i = 0; i < configurations.length; i++) {
            ILaunchConfiguration config = configurations[i];
            if (!DebugUITools.isPrivate(config) && isGoodMatch(config)) {
                result.add(config);
            }
        }
    } catch (CoreException e) {
    // Stupid Exception
    }
    return result;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ArrayList(java.util.ArrayList) ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Example 35 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project erlide_eclipse by erlang.

the class ConsoleRemoveLaunchAction method run.

@Override
public synchronized void run() {
    final ILaunch launch = getLaunch();
    if (launch != null) {
        final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
        launchManager.removeLaunch(launch);
        ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[] { fConsole });
        fConsoleView = null;
        fLaunch = null;
    }
}
Also used : ILaunch(org.eclipse.debug.core.ILaunch) 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