Java Code Examples for org.eclipse.debug.core.ILaunchManager#getLaunches()

The following examples show how to use org.eclipse.debug.core.ILaunchManager#getLaunches() . 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: CodewindEclipseApplication.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void reconnectDebugger() {
	// First check if there is a launch and it is registered
	if (launch != null) {
		ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
		for (ILaunch launchItem : launchManager.getLaunches()) {
			if (launch.equals(launchItem)) {
				// Check if the debugger is still attached (for Liberty, a small change to the app does not require a server restart)
				IDebugTarget debugTarget = launch.getDebugTarget();
				if (debugTarget == null || debugTarget.isDisconnected()) {
					// Clean up
					clearDebugger();
					// Reconnect the debugger
					connectDebugger();
				}
			}
		}
	}
}
 
Example 2
Source File: TestResultsView.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Collects targets associated with a process. -- copied from ConsoleTerminateAction
 *
 * @param process
 *            the process to collect {@link IDebugTarget}s for
 * @return associated targets
 */
private List<ITerminate> collectTargets(IProcess process) {
	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunch[] launches = launchManager.getLaunches();
	List<ITerminate> targets = new ArrayList<>();
	for (int i = 0; i < launches.length; i++) {
		ILaunch launch = launches[i];
		IProcess[] processes = launch.getProcesses();
		for (int j = 0; j < processes.length; j++) {
			IProcess process2 = processes[j];
			if (process2.equals(process)) {
				IDebugTarget[] debugTargets = launch.getDebugTargets();
				for (int k = 0; k < debugTargets.length; k++) {
					targets.add(debugTargets[k]);
				}
				return targets; // all possible targets have been terminated for the launch.
			}
		}
	}
	return targets;
}
 
Example 3
Source File: LaunchConfigurationUtils.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * <br> Finds Modula launch associated with the given project, if any (there should be only one)
 * @param project project to query
 * @return
 */
public static ILaunch getLaunch(IProject project) {
	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunch[] launches = launchManager.getLaunches();
	for (ILaunch launch : launches) {
		try {
			IProject launchProject = getProject(launch.getLaunchConfiguration());
			if (launchProject == null){
				continue;
			}
			if (Objects.equal(launchProject, project)) {
				return launch;
			}
		} catch (CoreException e) {
		}
	}
	return null;
}
 
Example 4
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 5
Source File: CodewindEclipseApplication.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public IDebugTarget getDebugTarget() {
	if (launch != null) {
		ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
		for (ILaunch launchItem : launchManager.getLaunches()) {
			if (launch.equals(launchItem)) {
				return launch.getDebugTarget();
			}
		}
	}
	return null;
}
 
Example 6
Source File: Model.java    From tlaplus with MIT License 5 votes vote down vote up
public boolean isRunning() {
	final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	final ILaunch[] launches = launchManager.getLaunches();
	for (int i = 0; i < launches.length; i++) {
		final ILaunch launch = launches[i];
		if (launch.getLaunchConfiguration() != null
				&& launch.getLaunchConfiguration().contentsEqual(this.launchConfig)) {
			if (!launch.isTerminated()) {
				return true;
			}
		}
	}
	return false;
}
 
Example 7
Source File: ViewerServiceServer.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private Response processInitialize(Initialize initialize) {
  String clientId = initialize.getClientId();
  assert (clientId != null);

  ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
  ILaunch[] launches = launchManager.getLaunches();
  ILaunch launch = null;
  for (int i = 0; launch == null && i < launches.length; ++i) {
    IProcess[] processes = launches[i].getProcesses();
    for (IProcess iProcess : processes) {
      String commandLine = iProcess.getAttribute(IProcess.ATTR_CMDLINE);
      if (commandLine != null && commandLine.indexOf(clientId) != -1) {
        launch = launches[i];
        break;
      }
    }
  }

  WebAppDebugModel model = WebAppDebugModel.getInstance();
  LaunchConfiguration lc = model.addOrReturnExistingLaunchConfiguration(launch, clientId, null);
  lc.setLaunchUrls(initialize.getStartupURLsList());
  setLaunchConfiguration(lc);
  DevModeServiceClient devModeServiceClient = new DevModeServiceClient(getTransport());
  DevModeServiceClientManager.getInstance().putClient(getLaunchConfiguration(),
      devModeServiceClient);
  performDevModeServiceCapabilityExchange(devModeServiceClient);

  return buildResponse(null);
}
 
Example 8
Source File: DebuggerTestUtils.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Waits until a launch becomes available 
 * @return the launch that was found
 */
public ILaunch waitForLaunchAvailable() throws Throwable {
    final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    waitForCondition(new ICallback() {

        @Override
        public Object call(Object args) throws Exception {
            ILaunch[] launches = launchManager.getLaunches();
            return launches.length > 0;
        }
    }, "waitForLaunchAvailable");
    return launchManager.getLaunches()[0];
}
 
Example 9
Source File: ViewerManager.java    From texlipse with Eclipse Public License 1.0 4 votes vote down vote up
/**
    * Closes the target output document using the DDE command from the
    * default viewer, or the most recently launched preview. This method
    * is probably fragile since the process and launches handling in
    * Texlipse is too weak to always know what documents are locked and
    * needs closing.  
    * 
    * @throws CoreException
    */
   public static void closeOutputDocument() throws CoreException {
	
       ViewerAttributeRegistry registry = new ViewerAttributeRegistry();
	
   	// Check to see if we have a running launch configuration which should
       // override the DDE close command
 	ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunch[] launches = manager.getLaunches();
    
    for (int i = 0; i < launches.length; i++) {
    	ILaunch l = launches[i];
    	ILaunchConfiguration configuration = l.getLaunchConfiguration();
    	if (configuration != null && configuration.exists() && configuration.getType().getIdentifier().equals(
    			TexLaunchConfigurationDelegate.CONFIGURATION_ID)) {
    		Map regMap = configuration.getAttributes();
	        registry.setValues(regMap);
	        break;
    	}
	}
    
   	ViewerManager mgr = new ViewerManager(registry, null);    	
	
	 if (!mgr.initialize()) {
         return;
     }
	
	// Can only close documents opened by DDE commands themselves
	Process process = mgr.getExisting();        
	if (process != null) {       
		mgr.sendDDECloseCommand();
           
		try {
               Thread.sleep(500); // A small delay required
           } catch (InterruptedException e) {
               // swallow
           }

           returnFocusToEclipse(false);
	}
}