Java Code Examples for org.eclipse.debug.core.model.IProcess#isTerminated()

The following examples show how to use org.eclipse.debug.core.model.IProcess#isTerminated() . 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: TestRunConfiguration.java    From corrosion with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testBasicRun() throws IOException, CoreException, InterruptedException {
	CargoRunDelegate delegate = new CargoRunDelegate();
	IProject project = getProject(BASIC_PROJECT_NAME);
	delegate.launch(new StructuredSelection(project), "run");
	new DisplayHelper() {
		@Override
		protected boolean condition() {
			return DebugPlugin.getDefault().getLaunchManager().getProcesses().length != 0 || getErrorPopup() != null;
		}
	}.waitForCondition(Display.getCurrent(), 15000);
	assertNull(getErrorPopup());
	assertTrue(DebugPlugin.getDefault().getLaunchManager().getProcesses().length != 0);
	for (IProcess process : DebugPlugin.getDefault().getLaunchManager().getProcesses()) {
		if (process.getLabel().equals("cargo run")) {
			while (!process.isTerminated()) {
				Thread.sleep(50);
			}
			assertEquals(0, process.getExitValue());
			return;
		}
	}
}
 
Example 2
Source File: AndroidSDKManager.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Wait for Android Emulator
 * @param emulatorProcess android emulator process
 * @param monitor progress monitor to be checked for cancellation
 * @throws CoreException
 */
public void waitForEmulator(IProcess emulatorProcess, IProgressMonitor monitor) throws CoreException{
	while(!emulatorProcess.isTerminated()){ //check if process is terminated - could not start etc..
		List<AndroidDevice> devices = this.listDevices();
		if(devices != null ){
			for (AndroidDevice androidDevice : devices) {
				if(androidDevice.isEmulator() && androidDevice.getState() == AndroidDevice.STATE_DEVICE)
					return;
			}
		}
		try {
			Thread.sleep(200);
		} catch (InterruptedException e) {
			throw new CoreException(new Status(IStatus.ERROR, AndroidCore.PLUGIN_ID, "Exception occured while waiting for emulator",e));
		}
		if (monitor.isCanceled()){
			throw new CoreException(new Status(IStatus.ERROR, AndroidCore.PLUGIN_ID, "Operation cancelled"));
		}
	}
	throw new CoreException(new Status(IStatus.ERROR, AndroidCore.PLUGIN_ID, "Android emulator was terminated"));
}
 
Example 3
Source File: TestRunConfiguration.java    From corrosion with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testTranslateVariablesInBuildCommand() throws InterruptedException, IOException, CoreException {
	IProject project = getProject(BASIC_PROJECT_NAME);
	ILaunchConfigurationWorkingCopy launchConfiguration = createLaunchConfiguration(project);
	launchConfiguration.setAttribute("BUILD_COMMAND", "-- ${workspace_loc}");
	ILaunch launch = launchConfiguration.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());

	new DisplayHelper() {
		@Override
		protected boolean condition() {
			return launch.getProcesses().length != 0;
		}
	}.waitForCondition(Display.getDefault(), 15000);

	for (IProcess process : launch.getProcesses()) {
		if (process.getLabel().equals("cargo run")) {
			while (!process.isTerminated()) {
				Thread.sleep(50);
			}
			String command = process.getAttribute(IProcess.ATTR_CMDLINE);
			// confirm ${workspace_loc} has been replaced with its actual value
			assertTrue(command
					.matches(".*" + ResourcesPlugin.getWorkspace().getRoot().getLocation().toString() + ".*"));
			assertEquals(0, process.getExitValue());
			return;
		}
	}
	fail();
}
 
Example 4
Source File: RuntimeProcessExtension.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public static String calcExtendedProcessLabel(IProcess process) {
	ILaunch launch = process.getLaunch();
	
	StringBuffer buffer = new StringBuffer();
	
	if (process.isTerminated()) {
		try {
			int exitValue = process.getExitValue();
			buffer.append("<exit code: " + exitValue + "> ");
		} catch (DebugException e) {
			// Should not happen
		}
	}
	
	ILaunchConfiguration launchConfiguration = launch.getLaunchConfiguration();
	if (launchConfiguration != null) {
		buffer.append(launchConfiguration.getName());

		try {
			ILaunchConfigurationType launchConfigType = launchConfiguration.getType();
			if (launchConfigType != null) {
				String type = launchConfigType.getName();

				buffer.append(" [");
				buffer.append(type);
				buffer.append("] ");
			}
		} catch (CoreException ce) {
			EclipseCore.logStatus(ce);
		}
	}
	buffer.append(process.getLabel());
	return buffer.toString();
}