Java Code Examples for org.eclipse.debug.core.ILaunch#getProcesses()
The following examples show how to use
org.eclipse.debug.core.ILaunch#getProcesses() .
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: TestResultsView.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * 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 2
Source File: FlexMavenPackagedProjectStagingDelegate.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
/** * 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 3
Source File: GwtWtpPlugin.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
private void onAfterCodeServerStarted(DebugEvent event) { if (!(event.getSource() instanceof IProcess)) { return; } IProcess runtimeProcess = (IProcess) event.getSource(); final ILaunch launch = runtimeProcess.getLaunch(); IProcess[] processes = launch.getProcesses(); final IProcess process = processes[0]; // Look for the links in the sdm console output consoleStreamListenerCodeServer = new IStreamListener() { @Override public void streamAppended(String text, IStreamMonitor monitor) { displayCodeServerUrlInDevMode(launch, text); } }; // Listen to Console output streamMonitorCodeServer = process.getStreamsProxy().getOutputStreamMonitor(); streamMonitorCodeServer.addListener(consoleStreamListenerCodeServer); }
Example 4
Source File: InteractiveConsolePlugin.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Removes a launch from a pydev console and stops the related process (may be called from a thread). * * @param launch the launch to be removed */ public void removeConsoleLaunch(ILaunch launch) { boolean removed; synchronized (consoleLaunchesLock) { removed = consoleLaunches.remove(launch); } if (removed) { IProcess[] processes = launch.getProcesses(); if (processes != null) { for (IProcess p : processes) { try { p.terminate(); } catch (Exception e) { Log.log(e); } } } } }
Example 5
Source File: TestRunConfiguration.java From corrosion with Eclipse Public License 2.0 | 5 votes |
@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 6
Source File: DerbyServerUtils.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void startDerbyServer( IProject proj) throws CoreException { String args = CommonNames.START_DERBY_SERVER; String vmargs=""; DerbyProperties dprop=new DerbyProperties(proj); //Starts the server as a Java app args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort(); //Set Derby System Home from the Derby Properties if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){ vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome(); } String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.START_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")"; ILaunch launch = DerbyUtils.launch(proj, procName , CommonNames.DERBY_SERVER_CLASS, args, vmargs, CommonNames.START_DERBY_SERVER); IProcess ip=launch.getProcesses()[0]; //set a name to be seen in the Console list ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName); // saves the mapping between (server) process and project //servers.put(launch.getProcesses()[0], proj); servers.put(ip, proj); // register a listener to listen, when this process is finished DebugPlugin.getDefault().addDebugEventListener(listener); //Add resource listener IWorkspace workspace = ResourcesPlugin.getWorkspace(); workspace.addResourceChangeListener(rlistener); setRunning(proj, Boolean.TRUE); Shell shell = new Shell(); MessageDialog.openInformation( shell, CommonNames.PLUGIN_NAME, Messages.D_NS_ATTEMPT_STARTED+dprop.getPort()+"."); }
Example 7
Source File: DerbyServerUtils.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void stopDerbyServer( IProject proj) throws CoreException, ClassNotFoundException, SQLException { String args = CommonNames.SHUTDOWN_DERBY_SERVER; String vmargs=""; DerbyProperties dprop=new DerbyProperties(proj); args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort(); // Set Derby System Home from the Derby Properties if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){ vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome(); } String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.SHUTDOWN_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")"; // starts the server as a Java app ILaunch launch = DerbyUtils.launch(proj, procName, CommonNames.DERBY_SERVER_CLASS, args, vmargs,CommonNames.SHUTDOWN_DERBY_SERVER); IProcess ip=launch.getProcesses()[0]; //set a name to be seen in the Console list ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName); //update the objectState setRunning(proj, Boolean.FALSE); if(proj.isOpen()){ Shell shell = new Shell(); MessageDialog.openInformation( shell, CommonNames.PLUGIN_NAME, Messages.D_NS_ATTEMPT_STOPPED+dprop.getPort()+"." ); } }
Example 8
Source File: DerbyUtils.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static void runIJ(IFile currentScript, IProject currentProject) throws CoreException { String launchType=""; String args=""; //the above some times throws wrong 'create=true|false' errors String vmargs=""; DerbyProperties dprop=new DerbyProperties(currentProject); if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){ vmargs+=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome(); } if(currentScript!=null){ launchType=CommonNames.SQL_SCRIPT; //Preferable to use the full String with quotes to take care of spaces //in file names args="\""+currentScript.getLocation().toOSString()+"\""; }else{ launchType=CommonNames.IJ; args=""; } ILaunch launch=launch(currentProject,launchType,CommonNames.IJ_CLASS,args, vmargs, CommonNames.IJ); IProcess ip=launch.getProcesses()[0]; String procName="["+currentProject.getName()+"] - "+CommonNames.IJ+" "+args; ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName); }
Example 9
Source File: DerbyUtils.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static void runSysInfo(IProject currentProject) throws CoreException { String args=""; ILaunch launch=launch(currentProject,CommonNames.SYSINFO,CommonNames.SYSINFO_CLASS,args, null, CommonNames.SYSINFO); IProcess ip=launch.getProcesses()[0]; String procName="["+currentProject.getName()+"] - "+CommonNames.SYSINFO; ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName); }
Example 10
Source File: DerbyServerUtils.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void startDerbyServer( IProject proj) throws CoreException { String args = CommonNames.START_DERBY_SERVER; String vmargs=""; DerbyProperties dprop=new DerbyProperties(proj); //Starts the server as a Java app args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort(); //Set Derby System Home from the Derby Properties if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){ vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome(); } String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.START_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")"; ILaunch launch = DerbyUtils.launch(proj, procName , CommonNames.DERBY_SERVER_CLASS, args, vmargs, CommonNames.START_DERBY_SERVER); IProcess ip=launch.getProcesses()[0]; //set a name to be seen in the Console list ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName); // saves the mapping between (server) process and project //servers.put(launch.getProcesses()[0], proj); servers.put(ip, proj); // register a listener to listen, when this process is finished DebugPlugin.getDefault().addDebugEventListener(listener); //Add resource listener IWorkspace workspace = ResourcesPlugin.getWorkspace(); workspace.addResourceChangeListener(rlistener); setRunning(proj, Boolean.TRUE); Shell shell = new Shell(); MessageDialog.openInformation( shell, CommonNames.PLUGIN_NAME, Messages.D_NS_ATTEMPT_STARTED+dprop.getPort()+"."); }
Example 11
Source File: DerbyServerUtils.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void stopDerbyServer( IProject proj) throws CoreException, ClassNotFoundException, SQLException { String args = CommonNames.SHUTDOWN_DERBY_SERVER; String vmargs=""; DerbyProperties dprop=new DerbyProperties(proj); args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort(); // Set Derby System Home from the Derby Properties if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){ vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome(); } String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.SHUTDOWN_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")"; // starts the server as a Java app ILaunch launch = DerbyUtils.launch(proj, procName, CommonNames.DERBY_SERVER_CLASS, args, vmargs,CommonNames.SHUTDOWN_DERBY_SERVER); IProcess ip=launch.getProcesses()[0]; //set a name to be seen in the Console list ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName); //update the objectState setRunning(proj, Boolean.FALSE); if(proj.isOpen()){ Shell shell = new Shell(); MessageDialog.openInformation( shell, CommonNames.PLUGIN_NAME, Messages.D_NS_ATTEMPT_STOPPED+dprop.getPort()+"." ); } }
Example 12
Source File: DerbyUtils.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static void runIJ(IFile currentScript, IProject currentProject) throws CoreException { String launchType=""; String args=""; //the above some times throws wrong 'create=true|false' errors String vmargs=""; DerbyProperties dprop=new DerbyProperties(currentProject); if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){ vmargs+=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome(); } if(currentScript!=null){ launchType=CommonNames.SQL_SCRIPT; //Preferable to use the full String with quotes to take care of spaces //in file names args="\""+currentScript.getLocation().toOSString()+"\""; }else{ launchType=CommonNames.IJ; args=""; } ILaunch launch=launch(currentProject,launchType,CommonNames.IJ_CLASS,args, vmargs, CommonNames.IJ); IProcess ip=launch.getProcesses()[0]; String procName="["+currentProject.getName()+"] - "+CommonNames.IJ+" "+args; ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName); }
Example 13
Source File: DerbyUtils.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static void runSysInfo(IProject currentProject) throws CoreException { String args=""; ILaunch launch=launch(currentProject,CommonNames.SYSINFO,CommonNames.SYSINFO_CLASS,args, null, CommonNames.SYSINFO); IProcess ip=launch.getProcesses()[0]; String procName="["+currentProject.getName()+"] - "+CommonNames.SYSINFO; ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName); }
Example 14
Source File: PydevConsoleFactory.java From Pydev with Eclipse Public License 1.0 | 4 votes |
private void createDebugTarget(PydevConsoleInterpreter interpreter, PydevConsole console, IProgressMonitor monitor) throws IOException, CoreException, DebugException, UserCanceledException { monitor.beginTask("Connect Debug Target", 2); try { // Jython within Eclipse does not yet support debugging // NOTE: Jython within Eclipse currently works "once", i.e. it sets up properly and you can debug your // scripts you run within Eclipse, but the termination does not work properly and it seems that // we don't clean-up properly. There is a small additional problem, pysrc is not on the PYTHONPATH // so it fails to run properly, a simple hack to the pydevconsole to add its dirname to the sys.path // resolves that issue though. Process process = interpreter.getProcess(); if (InteractiveConsolePrefs.getConsoleConnectDebugSession() && !(process instanceof JythonEclipseProcess)) { PydevConsoleCommunication consoleCommunication = (PydevConsoleCommunication) interpreter .getConsoleCommunication(); int acceptTimeout = PydevPrefs.getEclipsePreferences().getInt(PyDevEditorPreferences.CONNECT_TIMEOUT, PyDevEditorPreferences.DEFAULT_CONNECT_TIMEOUT); PyDebugTargetConsole pyDebugTargetConsole = null; ILaunch launch = interpreter.getLaunch(); IProcess eclipseProcess = launch.getProcesses()[0]; RemoteDebuggerConsole debugger = new RemoteDebuggerConsole(); ListenConnector connector = new ListenConnector(acceptTimeout); debugger.startConnect(connector); pyDebugTargetConsole = new PyDebugTargetConsole(consoleCommunication, launch, eclipseProcess, debugger); Socket socket = null; try { consoleCommunication.connectToDebugger(connector.getLocalPort()); socket = debugger.waitForConnect(monitor, process, eclipseProcess); if (socket == null) { throw new UserCanceledException("Cancelled"); } } catch (Exception ex) { try { if (ex instanceof UserCanceledException) { //Only close the console communication if the user actually cancelled (otherwise the user will expect it to still be working). consoleCommunication.close(); debugger.dispose(); //Can't terminate the process either! } else { //But we still want to dispose of the connector. debugger.disposeConnector(); } } catch (Exception e) { // Don't hide important information from user Log.log(e); } if (ex instanceof UserCanceledException) { UserCanceledException userCancelled = (UserCanceledException) ex; throw userCancelled; } String message = "Unexpected error setting up the debugger"; if (ex instanceof SocketTimeoutException) { message = "Timed out after " + Float.toString(acceptTimeout / 1000) + " seconds while waiting for python script to connect."; } throw new CoreException(PydevDebugPlugin.makeStatus(IStatus.ERROR, message, ex)); } pyDebugTargetConsole.startTransmission(socket); // this starts reading/writing from sockets pyDebugTargetConsole.initialize(); consoleCommunication.setDebugTarget(pyDebugTargetConsole); launch.addDebugTarget(pyDebugTargetConsole); launch.setSourceLocator(new PySourceLocator()); ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); launchManager.addLaunch(launch); pyDebugTargetConsole.setConsole(console); console.setProcess(pyDebugTargetConsole.getProcess()); pyDebugTargetConsole.finishedInit = true; } } finally { monitor.done(); } }