Java Code Examples for org.eclipse.debug.core.ILaunchManager#RUN_MODE

The following examples show how to use org.eclipse.debug.core.ILaunchManager#RUN_MODE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReportOSGiLaunchDelegate.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public IVMRunner getVMRunner( ILaunchConfiguration configuration,
		String mode ) throws CoreException
{
	if ( ( helper.debugType & DEBUG_TYPE_JAVA_CLASS ) == DEBUG_TYPE_JAVA_CLASS )
	{
		mode = ILaunchManager.DEBUG_MODE;
	}
	else
	{
		mode = ILaunchManager.RUN_MODE;
	}

	return new ReportDebuggerVMRunner( super.getVMRunner( configuration,
			mode ),
			( helper.debugType & DEBUG_TYPE_JAVA_SCRIPT ) == DEBUG_TYPE_JAVA_SCRIPT,
			this );
}
 
Example 2
Source File: PythonRunnerConfigTestWorkbench.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public void testResourceLocation() throws Exception {
    ILaunchConfiguration config = new JythonLaunchShortcut().createDefaultLaunchConfiguration(FileOrResource
            .createArray(new IResource[] { mod1 }));
    PythonRunnerConfig runnerConfig = new PythonRunnerConfig(config, ILaunchManager.RUN_MODE,
            PythonRunnerConfig.RUN_JYTHON);
    assertEquals(mod1.getLocation(), runnerConfig.resource[0]);
}
 
Example 3
Source File: PythonRunnerConfigTestWorkbench.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public void testOverridingResourceLocation() throws Exception {
    ILaunchConfiguration config = new JythonLaunchShortcut().createDefaultLaunchConfiguration(FileOrResource
            .createArray(new IResource[] { mod1 }));
    ILaunchConfigurationWorkingCopy configCopy = config.getWorkingCopy();
    String customResourcePath = "/foo/bar/acme.py";
    configCopy.setAttribute(Constants.ATTR_ALTERNATE_LOCATION, customResourcePath);
    PythonRunnerConfig runnerConfig = new PythonRunnerConfig(configCopy, ILaunchManager.RUN_MODE,
            PythonRunnerConfig.RUN_JYTHON);
    assertEquals(Path.fromOSString(customResourcePath), runnerConfig.resource[0]);
}
 
Example 4
Source File: PythonRunnerConfigTestWorkbench.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public void testUnittestCommandLine() throws Exception {
    ILaunchConfiguration config = new JythonLaunchShortcut().createDefaultLaunchConfiguration(FileOrResource
            .createArray(new IResource[] { mod1 }));
    PythonRunnerConfig runnerConfig = new PythonRunnerConfig(config, ILaunchManager.RUN_MODE,
            PythonRunnerConfig.RUN_JYTHON);
    String[] argv = runnerConfig.getCommandLine(false);
    assertFalse(arrayContains(argv, PythonRunnerConfig.getRunFilesScript()));
    assertTrue(arrayContains(argv, mod1.getLocation().toOSString()));
}
 
Example 5
Source File: PythonRunnerConfigTestWorkbench.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public void testPythonUnittestCommandLine() throws Exception {
    ILaunchConfiguration config = new UnitTestLaunchShortcut().createDefaultLaunchConfiguration(FileOrResource
            .createArray(new IResource[] { mod1 }));
    PythonRunnerConfig runnerConfig = new PythonRunnerConfig(config, ILaunchManager.RUN_MODE,
            PythonRunnerConfig.RUN_UNITTEST);
    String[] argv = runnerConfig.getCommandLine(false);
    assertTrue(arrayContains(argv, PythonRunnerConfig.getRunFilesScript()));
    assertTrue(arrayContains(argv, mod1.getLocation().toOSString()));
}
 
Example 6
Source File: PythonRunnerConfigTestWorkbench.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private PythonRunnerConfig createConfig() throws CoreException, InvalidRunException, MisconfigurationException {
    ILaunchConfiguration config = new LaunchShortcut().createDefaultLaunchConfiguration(FileOrResource
            .createArray(new IResource[] { mod1 }));
    PythonRunnerConfig runnerConfig = new PythonRunnerConfig(config, ILaunchManager.RUN_MODE,
            PythonRunnerConfig.RUN_REGULAR);
    return runnerConfig;
}
 
Example 7
Source File: LocalWebServer.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public String getMode()
{
	// We only support run mode...
	return ILaunchManager.RUN_MODE;
}
 
Example 8
Source File: ExternalWebServer.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param program
 * @param arguments
 * @param workingDirectory
 * @return created process
 * @throws CoreException
 */
private IProcess exec(String[] arguments, IPath workingDirectory) throws CoreException
{

	File workingDir = null;
	if (workingDirectory != null)
	{
		workingDir = workingDirectory.toFile();
		if (!workingDir.isDirectory())
		{
			workingDir = null;
		}
	}

	// FIXME Make a launch configuration? Doing this low-level stuff by hand is error-prone...
	Process p = DebugPlugin.exec(arguments, workingDir);
	IProcess process = null;
	if (p != null)
	{
		// Do a quick check to see if the execution immediately failed, meaning we probably have a busted command.
		try
		{
			int exitValue = p.exitValue();
			if (exitValue != 0)
			{
				throw new CoreException(ProcessUtil.processResult(p));
			}
		}
		catch (IllegalThreadStateException e)
		{
			// ignore
		}
		fLaunch = new Launch(null, ILaunchManager.RUN_MODE, null);
		fLaunch.setAttribute(DebugPlugin.ATTR_LAUNCH_TIMESTAMP, Long.toString(System.currentTimeMillis()));
		getLaunchManager().addLaunch(fLaunch);
		process = DebugPlugin.newProcess(fLaunch, p,
				MessageFormat.format("{0} - {1}", getType().getName(), getName())); //$NON-NLS-1$
		process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLine(arguments));

		if (fLaunchListener == null)
		{
			fLaunchListener = new LaunchListener();
		}
		getLaunchManager().addLaunchListener(fLaunchListener);
	}

	return process;
}
 
Example 9
Source File: ExternalWebServer.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public String getMode()
{
	return ILaunchManager.RUN_MODE;
}
 
Example 10
Source File: PythonRunnerConfigTestWorkbench.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
public void testPythonCommandLine() throws Exception {
    PythonNature nature = PythonNature.getPythonNature(mod1);

    // Create a temporary variable for testing
    IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
    IValueVariable myCustomVariable = variableManager.newValueVariable("pydev_python_runner_config_test_var", "",
            true, "my_custom_value");
    variableManager.addVariables(new IValueVariable[] { myCustomVariable });

    try {
        IInterpreterManager manager = InterpreterManagersAPI.getPythonInterpreterManager(true);
        InterpreterInfo info = (InterpreterInfo) manager.getDefaultInterpreterInfo(false);
        info.setEnvVariables(new String[] { "MY_CUSTOM_VAR_FOR_TEST=FOO", "MY_CUSTOM_VAR_FOR_TEST2=FOO2",
                "MY_CUSTOM_VAR_WITH_VAR=${pydev_python_runner_config_test_var}" });

        // Make sure variable hasn't been expanded too early
        assertTrue(arrayContains(info.getEnvVariables(),
                "MY_CUSTOM_VAR_WITH_VAR=${pydev_python_runner_config_test_var}"));

        PythonRunnerConfig runnerConfig = createConfig();
        assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST=FOO"));
        assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST2=FOO2"));
        assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_WITH_VAR=my_custom_value"));

        String[] argv = runnerConfig.getCommandLine(false);
        assertFalse(arrayContains(argv, PythonRunnerConfig.getRunFilesScript()));
        assertTrue(arrayContains(argv, mod1.getLocation().toOSString()));

        nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, IPythonNature.DEFAULT_INTERPRETER);
        assertEquals(manager.getDefaultInterpreterInfo(false).getExecutableOrJar(), nature.getProjectInterpreter()
                .getExecutableOrJar());
        runnerConfig = createConfig();
        argv = runnerConfig.getCommandLine(false);
        assertEquals(manager.getDefaultInterpreterInfo(false).getExecutableOrJar(), argv[0]);

        IInterpreterManager interpreterManager = nature.getRelatedInterpreterManager();

        InterpreterInfo info2 = new InterpreterInfo(IPythonNature.PYTHON_VERSION_2_6, "c:\\interpreter\\py25.exe",
                new ArrayList<String>());
        interpreterManager.setInfos(new IInterpreterInfo[] { info, info2 }, null, null);

        nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, "c:\\interpreter\\py25.exe");
        assertEquals("c:\\interpreter\\py25.exe", nature.getProjectInterpreter().getExecutableOrJar());
        runnerConfig = createConfig();
        argv = runnerConfig.getCommandLine(false);
        assertEquals("c:\\interpreter\\py25.exe", argv[0]);
        nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, IPythonNature.DEFAULT_INTERPRETER);

        ILaunchConfiguration config;
        config = new LaunchShortcut().createDefaultLaunchConfiguration(FileOrResource
                .createArray(new IResource[] { mod1 }));
        ILaunchConfigurationWorkingCopy workingCopy = config.getWorkingCopy();
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("VAR_SPECIFIED_IN_LAUNCH", "BAR");
        map.put("MY_CUSTOM_VAR_FOR_TEST2", "BAR2"); //The one in the launch configuration always has preference.
        workingCopy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map);
        config = workingCopy.doSave();

        runnerConfig = new PythonRunnerConfig(config, ILaunchManager.RUN_MODE, PythonRunnerConfig.RUN_REGULAR);
        assertTrue(arrayContains(runnerConfig.envp, "VAR_SPECIFIED_IN_LAUNCH=BAR"));
        assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST=FOO"));
        assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST2=BAR2"));
        assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_WITH_VAR=my_custom_value"));
    } catch (Throwable e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    } finally {
        //restore the default!
        nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, IPythonNature.DEFAULT_INTERPRETER);
        variableManager.removeVariables(new IValueVariable[] { myCustomVariable });
    }
}
 
Example 11
Source File: AbstractLaunchShortcut.java    From xds-ide with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * This method is used to ensure that when Debug perspective should not appear (say when we are launching PKT as external process) - it will not appear.
 * @param mode
 * @param p
 * @param configuration
 * @return
 * @throws CoreException
 */
protected static String determineLaunchMode(String mode, IProject p, ILaunchConfiguration configuration) throws CoreException {
	if (ILaunchManager.RUN_MODE.equals(mode)) {
		return mode;
	}
   	return LaunchUtils.canLaunchInIdeDebugMode(p, configuration)? ILaunchManager.DEBUG_MODE : ILaunchManager.RUN_MODE;
   }
 
Example 12
Source File: LaunchUtil.java    From dartboard with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Passes a supplied file path to the Dart binary at a supplied SDK location.
 *
 * @param dartSdk  - The location of the Dart SDK that should be used for the
 *                 execution
 * @param dartFile - The path to a file that should be executed. Assumes correct
 *                 OS strings (e.g. correct separators). These can be obtained
 *                 from {@link File#separator}.
 */
public static void launchDartFile(String dartSdk, String dartFile) {
	Launch launch = new Launch(null, ILaunchManager.RUN_MODE, null);
	DebugPlugin.getDefault().getLaunchManager().addLaunch(launch);
	launchDartFile(launch, dartSdk, dartFile);
}