Search in sources :

Example 36 with ILaunchConfigurationType

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

the class ProcessLaunchShortcut method findExistingLaunchConfiguration.

protected ILaunchConfiguration findExistingLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, WorkflowProject workflowProject, boolean debug) throws CoreException {
    String wcWorkflowProj = workingCopy.getAttribute(ProcessLaunchConfiguration.WORKFLOW_PROJECT, "");
    String wcProcessName = workingCopy.getAttribute(ProcessLaunchConfiguration.PROCESS_NAME, "");
    String wcProcessVersion = workingCopy.getAttribute(ProcessLaunchConfiguration.PROCESS_VERSION, "");
    ILaunchConfigurationType configType = workingCopy.getType();
    ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(configType);
    for (ILaunchConfiguration launchConfig : configs) {
        String workflowProj = launchConfig.getAttribute(ProcessLaunchConfiguration.WORKFLOW_PROJECT, "");
        if (!wcWorkflowProj.equals(workflowProj))
            continue;
        String processName = launchConfig.getAttribute(ProcessLaunchConfiguration.PROCESS_NAME, "");
        if (!wcProcessName.equals(processName))
            continue;
        String processVersion = launchConfig.getAttribute(ProcessLaunchConfiguration.PROCESS_VERSION, "");
        if (!wcProcessVersion.equals(processVersion)) {
            // match without process version; just update version attribute
            // if not matching
            ILaunchConfigurationWorkingCopy updatedWc = launchConfig.getWorkingCopy();
            updatedWc.setAttribute(ProcessLaunchConfiguration.PROCESS_VERSION, wcProcessVersion);
            launchConfig = updatedWc.doSave();
        }
        if (debug) {
            // launch config has matched; just update debug attributes if
            // blank
            String debugProj = launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
            String vmConnector = launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, "");
            Map<?, ?> connectAttrMap = launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, new HashMap<String, String>());
            ILaunchConfigurationWorkingCopy updatedWc = null;
            if (debugProj.isEmpty()) {
                updatedWc = launchConfig.getWorkingCopy();
                updatedWc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, workflowProject.getSourceProject().getName());
            }
            if (vmConnector.isEmpty()) {
                if (updatedWc == null)
                    updatedWc = launchConfig.getWorkingCopy();
                updatedWc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, "org.eclipse.jdt.launching.socketAttachConnector");
            }
            if (connectAttrMap.isEmpty()) {
                if (updatedWc == null)
                    updatedWc = launchConfig.getWorkingCopy();
                updatedWc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, getDefaultConnectArgs(workflowProject));
            }
            if (updatedWc != null)
                launchConfig = updatedWc.doSave();
        }
        return launchConfig;
    }
    return null;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 37 with ILaunchConfigurationType

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

the class ExternalEventLaunchShortcut method createLaunchConfiguration.

protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(ExternalEvent externalEvent) throws CoreException {
    WorkflowProject workflowProject = externalEvent.getProject();
    String launchConfigName = getUniqueLaunchConfigName(externalEvent);
    ILaunchConfigurationType configType = getLaunchManager().getLaunchConfigurationType(EXTERNAL_EVENT_LAUNCH_CONFIG_TYPE);
    ILaunchConfigurationWorkingCopy wc = configType.newInstance(workflowProject.getSourceProject(), launchConfigName);
    wc.setAttribute(ExternalEventLaunchConfiguration.WORKFLOW_PROJECT, workflowProject.getName());
    wc.setAttribute(ExternalEventLaunchConfiguration.EVENT_NAME, externalEvent.getName());
    return wc;
}
Also used : ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 38 with ILaunchConfigurationType

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

the class ExternalEventLaunchShortcut method getUniqueLaunchConfigName.

protected String getUniqueLaunchConfigName(ExternalEvent externalEvent) throws CoreException {
    String name = externalEvent.getName();
    ILaunchConfigurationType configType = getLaunchManager().getLaunchConfigurationType(EXTERNAL_EVENT_LAUNCH_CONFIG_TYPE);
    ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(configType);
    for (ILaunchConfiguration launchConfig : configs) {
        if (launchConfig.getName().equals(name)) {
            name = externalEvent.getName() + " (" + externalEvent.getProject().getName() + ")";
            break;
        }
    }
    return getLaunchManager().generateLaunchConfigurationName(name);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType)

Example 39 with ILaunchConfigurationType

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

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

Aggregations

ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)86 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)57 ILaunchManager (org.eclipse.debug.core.ILaunchManager)52 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)48 CoreException (org.eclipse.core.runtime.CoreException)41 ArrayList (java.util.ArrayList)20 IPath (org.eclipse.core.runtime.IPath)8 HashMap (java.util.HashMap)6 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 Map (java.util.Map)5 IProject (org.eclipse.core.resources.IProject)5 List (java.util.List)4 IResource (org.eclipse.core.resources.IResource)4 IStatus (org.eclipse.core.runtime.IStatus)4 IOException (java.io.IOException)3 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)2 LaunchHelper (com.liferay.ide.core.util.LaunchHelper)2