Search in sources :

Example 61 with ILaunchConfigurationType

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

the class RunnerUiUtils method getRunnerId.

/**
 * Read the N4JS runner ID from the given Eclipse launch configuration. Will throw exceptions if 'failFast' is
 * <code>true</code>, otherwise will return <code>null</code> in case of error.
 */
public static String getRunnerId(ILaunchConfiguration launchConfig, boolean failFast) {
    try {
        // 1) simple case: runnerId already defined in launchConfig
        final String id = launchConfig.getAttribute(RunConfiguration.RUNNER_ID, (String) null);
        if (id != null)
            return id;
        // 2) tricky case: not set yet, so have to go via the ILaunchConfigurationType or the launchConfig
        final ILaunchConfigurationType launchConfigType = launchConfig.getType();
        return getRunnerId(launchConfigType, failFast);
    } catch (CoreException e) {
        if (failFast)
            throw new WrappedException(e);
        return null;
    }
}
Also used : WrappedException(org.eclipse.emf.common.util.WrappedException) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType)

Example 62 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType in project liferay-ide by liferay.

the class LaunchHelper method createLaunchConfiguration.

public ILaunchConfigurationWorkingCopy createLaunchConfiguration() throws CoreException {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(launchConfigTypeId);
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    String name = launchManager.generateLaunchConfigurationName(getNewLaunchConfigurationName());
    ILaunchConfigurationWorkingCopy launchConfig = type.newInstance(null, name);
    launchConfig.setAttribute("org.eclipse.debug.ui.ATTR_CAPTURE_IN_CONSOLE", isLaunchCaptureInConsole());
    launchConfig.setAttribute("org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND", isLaunchInBackground());
    launchConfig.setAttribute("org.eclipse.debug.ui.ATTR_PRIVATE", isLaunchIsPrivate());
    IRuntimeClasspathEntry[] classpath = getClasspath(launchConfig);
    List<String> mementos = new ArrayList<>(classpath.length);
    for (int i = 0; i < classpath.length; i++) {
        IRuntimeClasspathEntry entry = classpath[i];
        mementos.add(entry.getMemento());
    }
    launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, Boolean.FALSE);
    launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, mementos);
    if (getMainClass() != null) {
        launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, getMainClass());
    }
    if (ListUtil.isNotEmpty(launchArgs)) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < launchArgs.length; i++) {
            sb.append("\"");
            sb.append(launchArgs[i]);
            sb.append("\" ");
        }
        launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, sb.toString());
    }
    return launchConfig;
}
Also used : ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ArrayList(java.util.ArrayList) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IRuntimeClasspathEntry(org.eclipse.jdt.launching.IRuntimeClasspathEntry)

Example 63 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType in project liferay-ide by liferay.

the class MavenProjectBuilder method _execMavenLaunch.

private boolean _execMavenLaunch(IProject project, String goal, IMavenProjectFacade facade, IProgressMonitor monitor) throws CoreException {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(_launchConfigurationTypeId);
    IPath basedirLocation = project.getLocation();
    String newName = launchManager.generateLaunchConfigurationName(basedirLocation.lastSegment());
    ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(null, newName);
    workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Dmaven.multiModuleProjectDirectory");
    workingCopy.setAttribute(_attrPomDir, basedirLocation.toString());
    workingCopy.setAttribute(_attrGoals, goal);
    // workingCopy.setAttribute( ATTR_UPDATE_SNAPSHOTS, Boolean.TRUE );
    workingCopy.setAttribute(_attrWorkspaceResolution, Boolean.TRUE);
    workingCopy.setAttribute(_attrSkipTests, Boolean.TRUE);
    if (facade != null) {
        ResolverConfiguration configuration = facade.getResolverConfiguration();
        String selectedProfiles = configuration.getSelectedProfiles();
        if ((selectedProfiles != null) && (selectedProfiles.length() > 0)) {
            workingCopy.setAttribute(_attrProfiles, selectedProfiles);
        }
        new LaunchHelper().launch(workingCopy, "run", monitor);
        return true;
    } else {
        return false;
    }
}
Also used : ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) IPath(org.eclipse.core.runtime.IPath) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) LaunchHelper(com.liferay.ide.core.util.LaunchHelper) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 64 with ILaunchConfigurationType

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

the class PivotApplicationLaunchShortcut method getExistingLaunchConfiguration.

private ILaunchConfiguration getExistingLaunchConfiguration(IType type) {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
    ILaunchConfiguration existingLaunchConfiguration = null;
    try {
        String applicationProjectName = type.getJavaProject().getElementName();
        String applicationTypeName = type.getFullyQualifiedName();
        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(applicationProjectName) && programArguments.equals(applicationTypeName)) {
                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 65 with ILaunchConfigurationType

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

the class WebLogicServerConfigurator method launchNewServerCreation.

@SuppressWarnings({ "deprecation", "rawtypes", "unchecked" })
public String launchNewServerCreation(Shell shell) {
    String serverHome = getServerSettings().getHome();
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType programType = manager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE);
    try {
        ILaunchConfiguration cfg = programType.newInstance(null, "WebLogic Domain Config Wizard");
        ILaunchConfigurationWorkingCopy wc = cfg.getWorkingCopy();
        wc.setAttribute(IExternalToolConstants.ATTR_LOCATION, serverHome + "/common/bin/config.cmd");
        wc.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, serverHome + "/common/bin");
        Map envVars = new HashMap();
        envVars.put("MW_HOME", serverHome.substring(0, serverHome.lastIndexOf(System.getProperty("file.separator"))));
        wc.setAttribute("org.eclipse.debug.core.environmentVariables", envVars);
        cfg = wc.doSave();
        ILaunch launch = cfg.launch(ILaunchManager.RUN_MODE, null, false, false);
        StringBuilder errors = new StringBuilder("");
        for (IProcess process : launch.getProcesses()) errors.append(process.getStreamsProxy().getErrorStreamMonitor().getContents() + "\n");
        cfg.delete();
        if (errors.toString().trim().length() > 0)
            throw new IOException(errors.toString().trim());
        return null;
    } catch (Exception ex) {
        PluginMessages.uiError(shell, ex, "Create Domain", getServerSettings().getProject());
        return null;
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) HashMap(java.util.HashMap) ILaunch(org.eclipse.debug.core.ILaunch) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map) IProcess(org.eclipse.debug.core.model.IProcess) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

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