Search in sources :

Example 31 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType in project pivot by apache.

the class PivotScriptApplicationLaunchShortcut method createLaunchConfiguration.

protected ILaunchConfiguration createLaunchConfiguration(IFile file) {
    ILaunchConfiguration launchConfiguration = null;
    try {
        String fileProjectName = file.getProject().getName();
        String fileName = file.getName();
        ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
        ILaunchConfigurationType configurationType = launchManager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
        String name = launchManager.generateUniqueLaunchConfigurationNameFrom(fileName);
        ILaunchConfigurationWorkingCopy workingLaunchConfiguration = configurationType.newInstance(null, name);
        workingLaunchConfiguration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, PivotPlugin.MAIN_TYPE_NAME);
        workingLaunchConfiguration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, fileProjectName);
        workingLaunchConfiguration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, getProgramArguments(file));
        workingLaunchConfiguration.setMappedResources(new IResource[] { file });
        launchConfiguration = workingLaunchConfiguration.doSave();
    } catch (CoreException exception) {
        MessageDialog.openError(PivotPlugin.getActiveWorkbenchShell(), exception.getMessage(), exception.getStatus().getMessage());
    }
    return launchConfiguration;
}
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 32 with ILaunchConfigurationType

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

the class AutomatedTestLaunchShortcut method createLaunchConfiguration.

protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(WorkflowProject workflowProject, WorkflowPackage workflowPackage, boolean isLegacyLaunch, String testName, List<String> testCases, boolean debug) throws CoreException {
    ILaunchConfigurationType configType;
    if (debug) {
        configType = getLaunchManager().getLaunchConfigurationType(DEBUG_TYPE_ID);
    } else {
        configType = getLaunchManager().getLaunchConfigurationType(TYPE_ID);
    }
    ILaunchConfigurationWorkingCopy wc = configType.newInstance(workflowProject.getSourceProject(), getLaunchManager().generateLaunchConfigurationName(testName));
    wc.setAttribute(AutomatedTestLaunchConfiguration.WORKFLOW_PROJECT, workflowProject.getName());
    if (workflowPackage == null || workflowPackage.equals(workflowProject.getDefaultPackage()))
        wc.removeAttribute(AutomatedTestLaunchConfiguration.WORKFLOW_PACKAGE);
    else
        wc.setAttribute(AutomatedTestLaunchConfiguration.WORKFLOW_PACKAGE, workflowPackage.getName());
    wc.setAttribute(AutomatedTestLaunchConfiguration.IS_LEGACY_LAUNCH, isLegacyLaunch);
    wc.setAttribute(AutomatedTestCase.FUNCTION_TEST + "_" + AutomatedTestLaunchConfiguration.RESULTS_PATH, workflowProject.getTestResultsPath(AutomatedTestCase.FUNCTION_TEST));
    wc.setAttribute(AutomatedTestCase.LOAD_TEST + "_" + AutomatedTestLaunchConfiguration.RESULTS_PATH, workflowProject.getTestResultsPath(AutomatedTestCase.LOAD_TEST));
    wc.setAttribute(AutomatedTestCase.FUNCTION_TEST + "_" + AutomatedTestLaunchConfiguration.TEST_CASES, testCases);
    wc.setAttribute(AutomatedTestCase.LOAD_TEST + "_" + AutomatedTestLaunchConfiguration.TEST_CASES, testCases);
    return wc;
}
Also used : ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 33 with ILaunchConfigurationType

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

the class CucumberLaunchShortcut method performLaunch.

private void performLaunch(List<CucumberTest> tests, IFolder folder) throws CoreException {
    IProject project = tests.get(0).getProject();
    String launchName;
    if (folder == null)
        launchName = project.getName();
    else
        launchName = folder.getName();
    List<String> testCases = new ArrayList<>();
    for (CucumberTest test : tests) {
        String testPath = test.getPath();
        if (folder != null)
            testPath = testPath.substring(folder.getProjectRelativePath().toString().length() + 1);
        testCases.add(testPath);
    }
    ILaunchConfigurationWorkingCopy workingCopy = createLaunchConfiguration(project, folder, launchName, testCases);
    ILaunchConfiguration config = null;
    ILaunchConfigurationType configType = workingCopy.getType();
    ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(configType);
    for (ILaunchConfiguration launchConfig : configs) {
        String projectAttr = launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
        String folderMatch = (folder == null) ? "" : folder.getProjectRelativePath().toString();
        String folderAttr = launchConfig.getAttribute(CucumberLaunchConfiguration.FOLDER, "");
        if (!project.getName().equals(projectAttr) || !folderMatch.equals(folderAttr))
            continue;
        config = launchConfig;
    }
    if (config == null) {
        // no existing found - create a new one
        config = workingCopy.doSave();
    } else {
        workingCopy = config.getWorkingCopy();
        workingCopy.setAttribute(CucumberLaunchConfiguration.FEATURES, testCases);
        config = workingCopy.doSave();
    }
    IStructuredSelection selection = new StructuredSelection(config);
    DebugUITools.openLaunchConfigurationDialogOnGroup(getShell(), selection, GROUP_ID);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CucumberTest(com.centurylink.mdw.plugin.designer.model.CucumberTest) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IProject(org.eclipse.core.resources.IProject)

Example 34 with ILaunchConfigurationType

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

the class ProcessLaunchConfiguration method findExistingDebugLaunchConfig.

private ILaunchConfiguration findExistingDebugLaunchConfig(ILaunchConfigurationWorkingCopy workingCopy) throws CoreException {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType configType = workingCopy.getType();
    ILaunchConfiguration[] configs = launchManager.getLaunchConfigurations(configType);
    String wcDebugProj = workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
    String wcVmConnector = workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, "");
    Map<?, ?> wcConnectAttrMap = workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, new HashMap<String, String>());
    for (ILaunchConfiguration launchConfig : configs) {
        String debugProj = launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
        if (!debugProj.equals(wcDebugProj))
            continue;
        String vmConnector = launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, "");
        if (!vmConnector.equals(wcVmConnector))
            continue;
        Map<?, ?> connectAttrMap = launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, new HashMap<String, String>());
        boolean mapMatches = true;
        for (Map.Entry<?, ?> connectAttr : connectAttrMap.entrySet()) {
            if (!"timeout".equals(connectAttr.getKey()) && !connectAttr.getValue().equals(wcConnectAttrMap.get(connectAttr.getKey()))) {
                mapMatches = false;
                continue;
            }
        }
        if (!mapMatches)
            continue;
        return launchConfig;
    }
    return null;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) HashMap(java.util.HashMap) Map(java.util.Map)

Example 35 with ILaunchConfigurationType

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

the class ProcessLaunchConfiguration method createDebugLaunchConfig.

private ILaunchConfigurationWorkingCopy createDebugLaunchConfig(WorkflowProject workflowProject, ILaunchConfiguration launchConfig) throws CoreException {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType configType = launchManager.getLaunchConfigurationType("com.centurylink.mdw.plugin.launch.JavaDebug");
    ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, launchManager.generateLaunchConfigurationName(workflowProject.getLabel()));
    wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, workflowProject.getSourceProject().getName()));
    wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, "org.eclipse.jdt.launching.socketAttachConnector"));
    Map<String, String> argDefaults = new HashMap<>();
    argDefaults.put("hostname", workflowProject.isRemote() ? workflowProject.getServerSettings().getHome() : "localhost");
    argDefaults.put("port", ProcessLaunchConfiguration.DEFAULT_DEBUG_PORT);
    argDefaults.put("timeout", "20000");
    wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, argDefaults));
    wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, false);
    return wc;
}
Also used : ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) HashMap(java.util.HashMap) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

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