Java Code Examples for org.eclipse.debug.core.ILaunch#terminate()

The following examples show how to use org.eclipse.debug.core.ILaunch#terminate() . 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: FlexMavenPackagedProjectStagingDelegate.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/**
 * Waits until {@code launch} terminates or {@code monitor} is canceled. if the monitor is
 * canceled, attempts to terminate the launch before returning.
 *
 * @return true if the launch terminated normally; false otherwise
 */
@VisibleForTesting
static boolean waitUntilLaunchTerminates(ILaunch launch, IProgressMonitor monitor)
    throws InterruptedException, DebugException {
  while (!launch.isTerminated() && !monitor.isCanceled()) {
    Thread.sleep(100 /*ms*/);
  }

  if (monitor.isCanceled()) {
    launch.terminate();
    return false;
  }
  for (IProcess process : launch.getProcesses()) {
    if (process.getExitValue() != 0) {
      return false;
    }
  }
  return true;
}
 
Example 2
Source File: SwtBotLaunchManagerActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
public static void terminateAllLaunchConfigs(SWTBot bot) {
  SwtBotUtils.print("Terminating Launches");

  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  ILaunch[] launches = manager.getLaunches();
  if (launches == null || launches.length == 0) {
    SwtBotUtils.print("No Launches to terminate");
  }

  for (ILaunch launch : launches) {
    if (!launch.isTerminated()) {
      try {
        launch.terminate();
      } catch (DebugException e) {
        SwtBotUtils.printError("Could not terminate launch." + e.getMessage());
      }
    }
  }

  SwtBotWorkbenchActions.waitForIdle(bot);

  SwtBotUtils.print("Terminated Launches");
}
 
Example 3
Source File: TerminateAllLaunchesAction.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
public static void terminateAllLaunches() {
    Job job = new Job("Terminate all Launches") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
            for (ILaunch iLaunch : launches) {
                try {
                    if (!iLaunch.isTerminated()) {
                        iLaunch.terminate();
                    }
                } catch (Exception e) {
                    Log.log(e);
                }
            }
            return Status.OK_STATUS;
        }
    };
    job.setPriority(Job.INTERACTIVE);
    job.schedule();
}
 
Example 4
Source File: TestDebug.java    From wildwebdeveloper with Eclipse Public License 2.0 5 votes vote down vote up
private void removeAllLaunches() throws DebugException {
	for (ILaunch launch : this.launchManager.getLaunches()) {
		launch.terminate();
		for (IDebugTarget debugTarget : launch.getDebugTargets()) {
			debugTarget.terminate();
			launch.removeDebugTarget(debugTarget);
		}
		launchManager.removeLaunch(launch);
	}
}
 
Example 5
Source File: TestDebugConfiguration.java    From corrosion with Eclipse Public License 2.0 5 votes vote down vote up
@After
@Before
public void stopLaunchesAndCloseConsoles() throws DebugException {
	for (ILaunch launch : DebugPlugin.getDefault().getLaunchManager().getLaunches()) {
		launch.terminate();
	}
	IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
	consoleManager.removeConsoles(consoleManager.getConsoles());
	IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	for (IViewReference view : activePage.getViewReferences()) {
		if (IConsoleConstants.ID_CONSOLE_VIEW.equals(view.getId())) {
			activePage.hideView(view);
		}
	}
}
 
Example 6
Source File: LaunchTerminator.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
private static void terminateLaunch( ILaunch launch ) {
  try {
    launch.terminate();
  } catch( DebugException debugException ) {
    StatusManager.getManager().handle( debugException.getStatus(), StatusManager.LOG );
  }
}
 
Example 7
Source File: TerminateLaunchesAction.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
private void terminateLaunch( ILaunch launch ) {
  try {
    if( launch.canTerminate() ) {
      launch.terminate();
    }
  } catch( DebugException e ) {
    status.merge( e.getStatus() );
  }
}
 
Example 8
Source File: LaunchConfigsPDETest.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testIsRunningWithLaunchedLaunchConfig() throws CoreException {
  ILaunchConfigurationWorkingCopy launchConfig = launchConfigRule.createPublicLaunchConfig();
  ILaunch launch = launchConfig.launch( RUN_MODE, null );

  boolean running = LaunchConfigs.isRunning( launchConfig );
  launch.terminate();

  assertThat( running ).isTrue();
}
 
Example 9
Source File: LaunchTerminatorPDETest.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testTerminateLaunchesWithTerminatedLaunch() throws CoreException {
  ILaunchConfiguration launchConfig = launchConfigRule.createPublicLaunchConfig().doSave();
  ILaunch launch = launchConfig.launch( RUN_MODE, new NullProgressMonitor() );
  launch.terminate();

  new LaunchTerminator( launchConfig ).terminateLaunches();

  assertThat( launch.isTerminated() ).isTrue();
}
 
Example 10
Source File: LaunchConfigCleanerPDETest.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testNoCleanupWhenLaunchConfigRenamed() throws CoreException {
  prepareLaunchPreferences( true, launchConfigRule.getPublicTestLaunchConfigType() );
  launchConfigCleaner.install();
  ILaunchConfiguration launchConfig = launchConfigRule.createPublicLaunchConfig().doSave();

  ILaunch launch = launchConfig.launch( RUN_MODE, null );
  String newName = launchConfigRule.renameLaunchConfig( launchConfig );
  launch.terminate();

  assertThat( getLaunchConfigs() ).extracting( "name" ).contains( newName );
}
 
Example 11
Source File: LaunchConfigCleanerPDETest.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testNoCleanupWhenLaunchConfigDeleted() throws CoreException {
  prepareLaunchPreferences( true, launchConfigRule.getPublicTestLaunchConfigType() );
  launchConfigCleaner.install();
  ILaunchConfiguration launchConfig = launchConfigRule.createPublicLaunchConfig().doSave();

  ILaunch launch = launchConfig.launch( RUN_MODE, null );
  launchConfig.delete();
  launch.terminate();

  assertThat( getLaunchConfigs() ).extracting( "name" ).doesNotContain( launchConfig.getName() );
}
 
Example 12
Source File: AbstractLaunchConfigurationDelegate.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private void finishLaunchWithError(ILaunch launch) {
    try {
        launch.terminate();

        ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
        launchManager.removeLaunch(launch);
    } catch (Throwable x) {
        Log.log(x);
    }
}
 
Example 13
Source File: TestDebug.java    From aCute with Eclipse Public License 2.0 4 votes vote down vote up
private void removeAllLaunches() throws DebugException {
	for (ILaunch launch : this.launchManager.getLaunches()) {
		launch.terminate();
	}
}
 
Example 14
Source File: LaunchConfigRule.java    From eclipse-extras with Eclipse Public License 1.0 4 votes vote down vote up
private void terminateLaunches() throws DebugException {
  for( ILaunch launch : launchManager.getLaunches() ) {
    launch.terminate();
  }
}