Search in sources :

Example 1 with VMRunnerConfiguration

use of org.eclipse.jdt.launching.VMRunnerConfiguration in project ow by vtst.

the class EasyJavaProgramLaunchConfigurationDelegate method launch.

public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    Fixture fixture = getFixture(config);
    if (monitor == null)
        monitor = new NullProgressMonitor();
    monitor.beginTask(config.getName() + "...", 3);
    if (monitor.isCanceled())
        return;
    try {
        monitor.subTask(messages.getString("verifying_launch_attributes"));
        String mainTypeName = verifyMainTypeName(config);
        IVMRunner runner = getVMRunner(config, mode);
        File workingDir = verifyWorkingDirectory(config);
        String workingDirName = null;
        if (workingDir != null) {
            workingDirName = workingDir.getAbsolutePath();
        }
        // Environment variables
        String[] envp = getEnvironment(config);
        // VM-specific attributes
        @SuppressWarnings("unchecked") Map<String, Object> vmAttributesMap = getVMSpecificAttributesMap(config);
        // Classpath
        String[] classpath = getClasspath(config);
        // Create VM config
        VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);
        runConfig.setProgramArguments(getProgramArgumentsArray(config, fixture));
        runConfig.setEnvironment(envp);
        runConfig.setVMArguments(getVMArgumentsArray(config, fixture));
        runConfig.setWorkingDirectory(workingDirName);
        runConfig.setVMSpecificAttributesMap(vmAttributesMap);
        // Bootpath
        runConfig.setBootClassPath(getBootpath(config));
        // check for cancellation
        if (monitor.isCanceled()) {
            return;
        }
        // stop in main
        prepareStopInMain(config);
        // done the verification phase
        monitor.worked(1);
        monitor.subTask(messages.getString("creating_source_locator"));
        // set the source locator if required
        setDefaultSourceLocator(launch, config);
        monitor.worked(1);
        // Launch the configuration - 1 unit of work
        monitor.subTask(messages.getString("run_external_program"));
        runner.run(runConfig, launch, monitor);
        for (IProcess process : launch.getProcesses()) {
            addProcessListeners(config, fixture, new EasyLaunchConfigurationDelegateUtils.ProcessListernerAcceptorImpl(process));
        }
        // check for cancellation
        if (monitor.isCanceled())
            return;
    } finally {
        monitor.done();
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IVMRunner(org.eclipse.jdt.launching.IVMRunner) VMRunnerConfiguration(org.eclipse.jdt.launching.VMRunnerConfiguration) File(java.io.File) IProcess(org.eclipse.debug.core.model.IProcess)

Example 2 with VMRunnerConfiguration

use of org.eclipse.jdt.launching.VMRunnerConfiguration in project ow by vtst.

the class EasyJavaProgramLaunchConfigurationDelegate method launch.

public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    Fixture fixture = getFixture(config);
    if (monitor == null)
        monitor = new NullProgressMonitor();
    monitor.beginTask(config.getName() + "...", 3);
    if (monitor.isCanceled())
        return;
    try {
        monitor.subTask(messages.getString("verifying_launch_attributes"));
        String mainTypeName = verifyMainTypeName(config);
        IVMRunner runner = getVMRunner(config, mode);
        File workingDir = verifyWorkingDirectory(config);
        String workingDirName = null;
        if (workingDir != null) {
            workingDirName = workingDir.getAbsolutePath();
        }
        // Environment variables
        String[] envp = getEnvironment(config);
        // VM-specific attributes
        @SuppressWarnings("unchecked") Map<String, Object> vmAttributesMap = getVMSpecificAttributesMap(config);
        // Classpath
        String[] classpath = getClasspath(config);
        // Create VM config
        VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);
        runConfig.setProgramArguments(getProgramArgumentsArray(config, fixture));
        runConfig.setEnvironment(envp);
        runConfig.setVMArguments(getVMArgumentsArray(config, fixture));
        runConfig.setWorkingDirectory(workingDirName);
        runConfig.setVMSpecificAttributesMap(vmAttributesMap);
        // Bootpath
        runConfig.setBootClassPath(getBootpath(config));
        // check for cancellation
        if (monitor.isCanceled()) {
            return;
        }
        // stop in main
        prepareStopInMain(config);
        // done the verification phase
        monitor.worked(1);
        monitor.subTask(messages.getString("creating_source_locator"));
        // set the source locator if required
        setDefaultSourceLocator(launch, config);
        monitor.worked(1);
        // Launch the configuration - 1 unit of work
        monitor.subTask(messages.getString("run_external_program"));
        runner.run(runConfig, launch, monitor);
        for (IProcess process : launch.getProcesses()) {
            addProcessListeners(config, fixture, new EasyLaunchConfigurationDelegateUtils.ProcessListernerAcceptorImpl(process));
        }
        // check for cancellation
        if (monitor.isCanceled())
            return;
    } finally {
        monitor.done();
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IVMRunner(org.eclipse.jdt.launching.IVMRunner) VMRunnerConfiguration(org.eclipse.jdt.launching.VMRunnerConfiguration) File(java.io.File) IProcess(org.eclipse.debug.core.model.IProcess)

Aggregations

File (java.io.File)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 IProcess (org.eclipse.debug.core.model.IProcess)2 IVMRunner (org.eclipse.jdt.launching.IVMRunner)2 VMRunnerConfiguration (org.eclipse.jdt.launching.VMRunnerConfiguration)2