Search in sources :

Example 6 with ILaunchConfigurationType

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

the class ProfileLaunchShortcut method createConfiguration.

/**
 * Create a launch configuration based on a binary, and optionally
 * save it to the underlying resource.
 *
 * @param bin a representation of a binary
 * @param save true if the configuration should be saved to the
 * underlying resource, and false if it should not be saved.
 * @return a launch configuration generated for the binary.
 * @since 1.2
 */
protected ILaunchConfiguration createConfiguration(IBinary bin, boolean save) {
    ILaunchConfiguration config = null;
    try {
        String projectName = bin.getResource().getProjectRelativePath().toString();
        ILaunchConfigurationType configType = getLaunchConfigType();
        ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(bin.getElementName()));
        wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectName);
        wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName());
        wc.setMappedResources(new IResource[] { bin.getResource(), bin.getResource().getProject() });
        wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
        setDefaultProfileAttributes(wc);
        if (save) {
            config = wc.doSave();
        } else {
            config = wc;
        }
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return config;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 7 with ILaunchConfigurationType

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

the class ErlangLaunchDelegate method isErlangInternalLaunch.

public static boolean isErlangInternalLaunch(final ILaunch aLaunch) {
    try {
        final ILaunchConfiguration cfg = aLaunch.getLaunchConfiguration();
        final ILaunchConfigurationType type = cfg.getType();
        final String id = type.getIdentifier();
        return IErlangLaunchDelegateConstants.CONFIGURATION_TYPE_INTERNAL.equals(id);
    } catch (final CoreException e) {
        ErlLogger.warn(e);
        return false;
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType)

Example 8 with ILaunchConfigurationType

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

the class PortalSourcePathComputerDelegate method addSourceContainers.

private void addSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor, final List<ISourceContainer> sourceContainers, IProject project) {
    String projectName = project.getName();
    try {
        ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
        ILaunchConfigurationType launchConfigurationType = manager.getLaunchConfigurationType("org.eclipse.jdt.launching.localJavaApplication");
        ILaunchConfigurationWorkingCopy sourceLookupConfig = launchConfigurationType.newInstance(null, configuration.getName());
        sourceLookupConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
        ISourceContainer[] computedSourceContainers = super.computeSourceContainers(sourceLookupConfig, monitor);
        Stream.of(computedSourceContainers).filter(computedSourceContainer -> !sourceContainers.contains(computedSourceContainer)).forEach(sourceContainers::add);
    } catch (CoreException e) {
        LiferayServerCore.logError("Unable to add source container for project " + projectName, e);
    }
}
Also used : JavaSourcePathComputer(org.eclipse.jdt.launching.sourcelookup.containers.JavaSourcePathComputer) DebugPlugin(org.eclipse.debug.core.DebugPlugin) IServer(org.eclipse.wst.server.core.IServer) LiferayServerCore(com.liferay.ide.server.core.LiferayServerCore) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ArrayList(java.util.ArrayList) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) LiferayCore(com.liferay.ide.core.LiferayCore) ServerUtil(org.eclipse.wst.server.core.ServerUtil) List(java.util.List) Stream(java.util.stream.Stream) IProject(org.eclipse.core.resources.IProject) ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer) IWorkspaceProject(com.liferay.ide.core.IWorkspaceProject) IJavaLaunchConfigurationConstants(org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer)

Example 9 with ILaunchConfigurationType

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

the class MavenUIProjectBuilder method runMavenGoal.

public IStatus runMavenGoal(IMavenProjectFacade projectFacade, String goal, String mode, IProgressMonitor monitor) throws CoreException {
    IStatus retval = Status.OK_STATUS;
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(MavenLaunchConstants.LAUNCH_CONFIGURATION_TYPE_ID);
    IPath basedirLocation = getProject().getLocation();
    String newName = launchManager.generateLaunchConfigurationName(basedirLocation.lastSegment());
    ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(null, newName);
    workingCopy.setAttribute(MavenLaunchConstants.ATTR_POM_DIR, basedirLocation.toString());
    workingCopy.setAttribute(MavenLaunchConstants.ATTR_GOALS, goal);
    workingCopy.setAttribute(MavenLaunchConstants.ATTR_UPDATE_SNAPSHOTS, Boolean.TRUE);
    workingCopy.setAttribute(MavenLaunchConstants.ATTR_WORKSPACE_RESOLUTION, Boolean.TRUE);
    workingCopy.setAttribute(MavenLaunchConstants.ATTR_SKIP_TESTS, Boolean.TRUE);
    if (projectFacade != null) {
        ResolverConfiguration configuration = projectFacade.getResolverConfiguration();
        String selectedProfiles = configuration.getSelectedProfiles();
        if ((selectedProfiles != null) && (selectedProfiles.length() > 0)) {
            workingCopy.setAttribute(MavenLaunchConstants.ATTR_PROFILES, selectedProfiles);
        }
        /*
			 * <?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration
			 * type="org.eclipse.m2e.Maven2LaunchConfigurationType"> <booleanAttribute
			 * key="M2_DEBUG_OUTPUT" value="false"/> <booleanAttribute
			 * key="M2_NON_RECURSIVE" value="false"/> <booleanAttribute key="M2_OFFLINE"
			 * value="false"/> <stringAttribute key="M2_PROFILES" value="v6.2.0"/>
			 * <listAttribute key="M2_PROPERTIES"/> <stringAttribute key="M2_RUNTIME"
			 * value="EMBEDDED"/> <intAttribute key="M2_THREADS" value="1"/>
			 * <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY"
			 * value="D:/dev java/workspaces/runtime-eclipse-ide-juno-sr2/WorldDatabase/WorldDatabase-portlet"
			 * /> </launchConfiguration>
			 */
        UIJob launchJob = new UIJob("maven launch") {

            @Override
            public IStatus runInUIThread(IProgressMonitor monitor) {
                DebugUITools.launch(workingCopy, mode);
                return Status.OK_STATUS;
            }
        };
        boolean[] launchTerminated = new boolean[1];
        ILaunchListener[] listener = new ILaunchListener[1];
        listener[0] = new LaunchAdapter() {

            public void launchChanged(ILaunch launch) {
                if (launch.getLaunchConfiguration().equals(workingCopy)) {
                    Thread t = new Thread() {

                        @Override
                        public void run() {
                            while ((launch.getProcesses().length > 0) && !launch.getProcesses()[0].isTerminated()) {
                                try {
                                    sleep(100);
                                } catch (InterruptedException ie) {
                                }
                            }
                            launchTerminated[0] = true;
                            ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
                            launchManager.removeLaunchListener(listener[0]);
                        }
                    };
                    t.start();
                }
            }
        };
        launchManager = DebugPlugin.getDefault().getLaunchManager();
        launchManager.addLaunchListener(listener[0]);
        launchJob.schedule();
        while ((Display.getCurrent() == null) && !launchTerminated[0]) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ie) {
            }
        }
    }
    return retval;
}
Also used : ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunch(org.eclipse.debug.core.ILaunch) UIJob(org.eclipse.ui.progress.UIJob) LaunchAdapter(com.liferay.ide.core.adapter.LaunchAdapter) ILaunchListener(org.eclipse.debug.core.ILaunchListener)

Example 10 with ILaunchConfigurationType

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

the class ServerManagerTests method getLaunchConfig.

private ILaunchConfigurationWorkingCopy getLaunchConfig(IPath workingDir, String execFileName, String command) throws CoreException {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType configType = launchManager.getLaunchConfigurationType("org.eclipse.ui.externaltools.ProgramLaunchConfigurationType");
    ILaunchConfigurationWorkingCopy config = configType.newInstance(null, launchManager.generateLaunchConfigurationName("tomcat-server"));
    config.setAttribute("org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND", true);
    config.setAttribute("org.eclipse.debug.ui.ATTR_CAPTURE_IN_CONSOLE", true);
    config.setAttribute("org.eclipse.debug.ui.ATTR_PRIVATE", true);
    String execPath = workingDir.append(execFileName).toOSString();
    new File(execPath).setExecutable(true);
    config.setAttribute("org.eclipse.ui.externaltools.ATTR_LOCATION", execPath);
    config.setAttribute("org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY", workingDir.toOSString());
    config.setAttribute("org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS", command);
    return config;
}
Also used : ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) File(java.io.File)

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