Search in sources :

Example 96 with ILaunchConfiguration

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

the class PivotApplicationLaunchShortcut method createLaunchConfiguration.

protected ILaunchConfiguration createLaunchConfiguration(IType type) {
    ILaunchConfiguration launchConfiguration = null;
    try {
        String applicationProjectName = type.getJavaProject().getElementName();
        String applicationTypeName = type.getFullyQualifiedName();
        ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
        ILaunchConfigurationType configurationType = launchManager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
        String name = launchManager.generateUniqueLaunchConfigurationNameFrom(type.getElementName());
        ILaunchConfigurationWorkingCopy workingLaunchConfiguration = configurationType.newInstance(null, name);
        workingLaunchConfiguration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, PivotPlugin.MAIN_TYPE_NAME);
        workingLaunchConfiguration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, applicationProjectName);
        workingLaunchConfiguration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, applicationTypeName);
        workingLaunchConfiguration.setMappedResources(new IResource[] { type.getUnderlyingResource() });
        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 97 with ILaunchConfiguration

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

the class PivotScriptApplicationLaunchShortcut method getExistingLaunchConfiguration.

private ILaunchConfiguration getExistingLaunchConfiguration(IFile file) {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
    ILaunchConfiguration existingLaunchConfiguration = null;
    try {
        String fileProjectName = file.getProject().getName();
        ILaunchConfiguration[] launchConfigurations = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(launchConfigurationType);
        for (int i = 0; i < launchConfigurations.length; i++) {
            ILaunchConfiguration launchConfiguration = launchConfigurations[i];
            String mainTypeName = launchConfiguration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "");
            String projectName = launchConfiguration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
            String programArguments = launchConfiguration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "");
            if (mainTypeName.equals(PivotPlugin.MAIN_TYPE_NAME) && projectName.equals(fileProjectName) && programArguments.equals(getProgramArguments(file))) {
                existingLaunchConfiguration = launchConfiguration;
                break;
            }
        }
    } catch (CoreException exception) {
        MessageDialog.openError(PivotPlugin.getActiveWorkbenchShell(), exception.getMessage(), exception.getStatus().getMessage());
    }
    return existingLaunchConfiguration;
}
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)

Example 98 with ILaunchConfiguration

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

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

the class AutomatedTestLaunchShortcut method performLaunch.

/**
 * All test cases must be in the same package or legacy suite.
 */
private void performLaunch(List<AutomatedTestCase> cases, String mode) throws CoreException, JSONException {
    AutomatedTestCase firstCase = cases.get(0);
    WorkflowProject workflowProject = firstCase.getProject();
    WorkflowPackage workflowPackage = firstCase.getPackage();
    boolean isLegacyLaunch = firstCase.isLegacy();
    String testName;
    if (isLegacyLaunch)
        testName = workflowProject.getName() + LEGACY;
    else
        testName = workflowPackage.getName();
    List<String> testCases = new ArrayList<>();
    for (AutomatedTestCase testCase : cases) {
        if (testCase.getItems() != null) {
            testCases.addAll(workflowPackage.getTestCaseItems(testCase));
        } else if (testCase.isPostman())
            testCases.add(testCase.getItemPath());
        else
            testCases.add(testCase.getPath());
    }
    ILaunchConfigurationWorkingCopy workingCopy = createLaunchConfiguration(workflowProject, workflowPackage, isLegacyLaunch, testName, testCases, ILaunchManager.DEBUG_MODE.equals(mode));
    ILaunchConfiguration config = findExistingLaunchConfiguration(workingCopy);
    if (config == null) {
        // no existing found - create a new one
        config = workingCopy.doSave();
    } else {
        workingCopy = config.getWorkingCopy();
        String prefix;
        if (workingCopy.getAttribute(AutomatedTestLaunchConfiguration.IS_LOAD_TEST, false))
            prefix = AutomatedTestCase.LOAD_TEST;
        else
            prefix = AutomatedTestCase.FUNCTION_TEST;
        workingCopy.setAttribute(prefix + "_" + AutomatedTestLaunchConfiguration.TEST_CASES, testCases);
        config = workingCopy.doSave();
    }
    IStructuredSelection selection = new StructuredSelection(config);
    if (ILaunchManager.DEBUG_MODE.equals(mode)) {
        DebugUITools.openLaunchConfigurationDialogOnGroup(getShell(), selection, DEBUG_GROUP_ID);
    } else {
        DebugUITools.openLaunchConfigurationDialogOnGroup(getShell(), selection, GROUP_ID);
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 100 with ILaunchConfiguration

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

Aggregations

ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)275 CoreException (org.eclipse.core.runtime.CoreException)100 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)79 Test (org.junit.Test)72 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)51 ILaunchManager (org.eclipse.debug.core.ILaunchManager)41 ArrayList (java.util.ArrayList)37 ILaunch (org.eclipse.debug.core.ILaunch)37 IPath (org.eclipse.core.runtime.IPath)20 IProject (org.eclipse.core.resources.IProject)19 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)17 IStatus (org.eclipse.core.runtime.IStatus)16 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)16 IEditorPart (org.eclipse.ui.IEditorPart)15 IProcess (org.eclipse.debug.core.model.IProcess)14 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 IFile (org.eclipse.core.resources.IFile)13 Status (org.eclipse.core.runtime.Status)13 CachegrindViewPart (org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11