org.eclipse.debug.core.model.IProcess Java Examples
The following examples show how to use
org.eclipse.debug.core.model.IProcess.
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: FlexMavenPackagedProjectStagingDelegateTest.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Test public void testWaitUntilLaunchTerminates_atLeastOneNonZeroExit() throws DebugException, InterruptedException { IProcess process = mock(IProcess.class); when(process.getExitValue()).thenReturn(0); IProcess nonZeroExitProcess = mock(IProcess.class); when(nonZeroExitProcess.getExitValue()).thenReturn(1); ILaunch launch = mock(ILaunch.class); when(launch.isTerminated()).thenReturn(true); when(launch.getProcesses()).thenReturn(new IProcess[] {process, nonZeroExitProcess}); boolean normalExit = FlexMavenPackagedProjectStagingDelegate.waitUntilLaunchTerminates( launch, new NullProgressMonitor()); assertFalse(normalExit); }
Example #2
Source File: StandardScriptVMRunner.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Checks and forwards an error from the specified process * * @param process * @throws CoreException */ private void checkErrorMessage( IProcess process ) throws CoreException { IStreamsProxy streamsProxy = process.getStreamsProxy( ); if ( streamsProxy != null ) { String errorMessage = streamsProxy.getErrorStreamMonitor( ) .getContents( ); if ( errorMessage.length( ) == 0 ) { errorMessage = streamsProxy.getOutputStreamMonitor( ) .getContents( ); } if ( errorMessage.length( ) != 0 ) { abort( errorMessage, null, IJavaLaunchConfigurationConstants.ERR_VM_LAUNCH_ERROR ); } } }
Example #3
Source File: PyDebugTarget.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public PyDebugTarget(ILaunch launch, IProcess process, IPath[] file, AbstractRemoteDebugger debugger, IProject project, boolean isAuxiliaryDebugTarget) { this.launch = launch; this.process = process; this.file = file; this.debugger = debugger; this.threads = new PyThread[0]; this.project = project; this.isAuxiliaryDebugTarget = isAuxiliaryDebugTarget; launch.addDebugTarget(this); debugger.addTarget(this); IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); breakpointManager.addBreakpointListener(this); PyExceptionBreakPointManager.getInstance().addListener(this); PyPropertyTraceManager.getInstance().addListener(this); // we have to know when we get removed, so that we can shut off the debugger DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); }
Example #4
Source File: LaunchUtil.java From dartboard with Eclipse Public License 2.0 | 6 votes |
/** * Passes a supplied file path to the Dart binary at a supplied SDK location. * * @param launch - The launch where the started Dart process will be attached * to. * @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(ILaunch launch, String dartSdk, String dartFile) { ProcessBuilder processBuilder = new ProcessBuilder(dartSdk + "/bin/dart", dartFile);//$NON-NLS-1$ Job job = Job.create("Running " + dartFile, runnable -> { //$NON-NLS-1$ Process process; try { process = processBuilder.start(); IProcess runtimeProcess = DebugPlugin.newProcess(launch, process, Messages.Console_Name); launch.addProcess(runtimeProcess); // adding also opens an Eclipse console for the process } catch (IOException e) { LOG.log(DartLog.createError("Could not start Dart process", e)); //$NON-NLS-1$ } }); job.schedule(); }
Example #5
Source File: PydevIProcessFactory.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public static String getEncodingFromFrame(PyStackFrame selectedFrame) { try { IDebugTarget adapter = selectedFrame.getAdapter(IDebugTarget.class); if (adapter == null) { return "UTF-8"; } IProcess process = adapter.getProcess(); if (process == null) { return "UTF-8"; } ILaunch launch = process.getLaunch(); if (launch == null) { Log.log("Unable to get launch for: " + process); return "UTF-8"; } return getEncodingFromLaunch(launch); } catch (Exception e) { Log.log(e); return "UTF-8"; } }
Example #6
Source File: PythonConsoleLineTracker.java From Pydev with Eclipse Public License 1.0 | 6 votes |
@Override public void init(final IConsole console) { IProcess process = console.getProcess(); if (process != null) { ILaunch launch = process.getLaunch(); if (launch != null) { initLaunchConfiguration(launch.getLaunchConfiguration()); } } this.linkContainer = new ILinkContainer() { @Override public void addLink(IHyperlink link, int offset, int length) { if (length <= 0) { // Log.log("Trying to create link with invalid len: " + length); return; } console.addLink(link, offset, length); } @Override public String getContents(int offset, int length) throws BadLocationException { return console.getDocument().get(offset, length); } }; }
Example #7
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 #8
Source File: AndroidSDKManager.java From thym with Eclipse Public License 1.0 | 6 votes |
/** * 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 #9
Source File: RestartLaunchAction.java From Pydev with Eclipse Public License 1.0 | 6 votes |
@Override public void update() { IProcess process = console.getProcess(); setEnabled(true); KeySequence binding = KeyBindingHelper .getCommandKeyBinding("org.python.pydev.debug.ui.actions.relaunchLastAction"); String str = binding != null ? "(" + binding.format() + " with focus on editor)" : "(unbinded)"; if (process.canTerminate()) { this.setImageDescriptor( ImageCache.asImageDescriptor(SharedUiPlugin.getImageCache().getDescriptor(UIConstants.RELAUNCH))); this.setToolTipText("Restart the current launch. " + str); } else { this.setImageDescriptor( ImageCache.asImageDescriptor(SharedUiPlugin.getImageCache().getDescriptor(UIConstants.RELAUNCH1))); this.setToolTipText("Relaunch with the same configuration." + str); } }
Example #10
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 #11
Source File: ExternalProcessUtility.java From thym with Eclipse Public License 1.0 | 6 votes |
private void setTracing(String[] command, IStreamListener outStreamListener, IStreamListener errorStreamListener, IProcess prcs) { if(HybridCore.DEBUG){ HybridCore.trace("Creating TracingStreamListeners for " + Arrays.toString(command)); outStreamListener = new TracingStreamListener(outStreamListener); errorStreamListener = new TracingStreamListener(outStreamListener); } if( outStreamListener != null ){ prcs.getStreamsProxy().getOutputStreamMonitor().addListener(outStreamListener); //See bug 121454. Ensure that output to fast processes is processed outStreamListener.streamAppended(prcs.getStreamsProxy().getOutputStreamMonitor().getContents(), null); } if( errorStreamListener != null ){ prcs.getStreamsProxy().getErrorStreamMonitor().addListener(errorStreamListener); //See bug 121454. Ensure that output to fast processes is processed errorStreamListener.streamAppended(prcs.getStreamsProxy().getErrorStreamMonitor().getContents(), null); } }
Example #12
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 #13
Source File: CordovaProjectCLI.java From thym with Eclipse Public License 1.0 | 5 votes |
public CordovaCLIResult plugin(final Command command, final IProgressMonitor monitor, final String... options) throws CoreException{ final CordovaCLIStreamListener streamListener = new CordovaCLIStreamListener(); IProcess process = startShell(streamListener, monitor, getLaunchConfiguration("cordova plugin "+ command.getCliCommand())); String cordovaCommand = generateCordovaCommand(P_COMMAND_PLUGIN,command, options); sendCordovaCommand(process, cordovaCommand, monitor); CordovaCLIResult result = new CordovaCLIResult(streamListener.getMessage()); return result; }
Example #14
Source File: CordovaProjectCLITest.java From thym with Eclipse Public License 1.0 | 5 votes |
@Test public void testGeneratedPlatformCommandCorrectlyForUPDATE() throws CoreException,IOException{ CordovaProjectCLI mockCLI = getMockCLI(); IProcess mockProcess = mock(IProcess.class); IStreamsProxy2 mockStreams = mock(IStreamsProxy2.class); setupMocks(mockCLI, mockProcess, mockStreams); mockCLI.platform(Command.UPDATE, new NullProgressMonitor(), "[email protected]", CordovaProjectCLI.OPTION_SAVE); verify(mockStreams).write("cordova platform update [email protected] --save\n"); }
Example #15
Source File: CordovaProjectCLITest.java From thym with Eclipse Public License 1.0 | 5 votes |
@Test public void testGeneratedPlatformCommandCorrectlyForREMOVE() throws CoreException,IOException{ CordovaProjectCLI mockCLI = getMockCLI(); IProcess mockProcess = mock(IProcess.class); IStreamsProxy2 mockStreams = mock(IStreamsProxy2.class); setupMocks(mockCLI, mockProcess, mockStreams); mockCLI.platform(Command.REMOVE, new NullProgressMonitor(), "ios", CordovaProjectCLI.OPTION_SAVE); verify(mockStreams).write("cordova platform remove ios --save\n"); }
Example #16
Source File: ConsoleRestartLaunchPageParticipant.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public void init(IPageBookViewPage page, IConsole console) { try { if (!(console instanceof ProcessConsole)) { return; } ProcessConsole processConsole = (ProcessConsole) console; IProcess process = processConsole.getProcess(); if (process == null) { return; } String attribute = process.getAttribute(IMiscConstants.PYDEV_ADD_RELAUNCH_IPROCESS_ATTR); if (!IMiscConstants.PYDEV_ADD_RELAUNCH_IPROCESS_ATTR_TRUE.equals(attribute)) { //Only provide relaunch if specified return; } this.fConsole = processConsole; DebugPlugin.getDefault().addDebugEventListener(this); IActionBars bars = page.getSite().getActionBars(); IToolBarManager toolbarManager = bars.getToolBarManager(); restartLaunchAction = new RestartLaunchAction(page, processConsole); terminateAllLaunchesAction = new TerminateAllLaunchesAction(); toolbarManager.appendToGroup(IConsoleConstants.LAUNCH_GROUP, restartLaunchAction); toolbarManager.appendToGroup(IConsoleConstants.LAUNCH_GROUP, terminateAllLaunchesAction); bars.updateActionBars(); } catch (Exception e) { Log.log(e); } }
Example #17
Source File: CordovaProjectCLI.java From thym with Eclipse Public License 1.0 | 5 votes |
public CordovaCLIResult platform (final Command command, final IProgressMonitor monitor, final String... options ) throws CoreException{ final CordovaCLIStreamListener streamListener = new CordovaCLIStreamListener(); IProcess process = startShell(streamListener, monitor, getLaunchConfiguration("cordova platform "+ command.getCliCommand())); String cordovaCommand = generateCordovaCommand(P_COMMAND_PLATFORM, command, options); sendCordovaCommand(process, cordovaCommand, monitor); CordovaCLIResult result = new CordovaCLIResult(streamListener.getMessage()); return result; }
Example #18
Source File: CordovaCLI.java From thym with Eclipse Public License 1.0 | 5 votes |
public IProcess startShell(final IStreamListener listener, final IProgressMonitor monitor, final ILaunchConfiguration launchConfiguration) throws CoreException{ ArrayList<String> commandList = new ArrayList<String>(); if(isWindows()){ commandList.add("cmd"); }else{ commandList.add("/bin/bash"); commandList.add("-l"); } ExternalProcessUtility ep = new ExternalProcessUtility(); IProcess process = ep.exec(commandList.toArray(new String[commandList.size()]), getWorkingDirectory(), monitor, null, launchConfiguration, listener, listener); return process; }
Example #19
Source File: CordovaCLI.java From thym with Eclipse Public License 1.0 | 5 votes |
public CordovaCLIResult version(final IProgressMonitor monitor) throws CoreException{ final CordovaCLIStreamListener streamListener = new CordovaCLIStreamListener(); IProcess process = startShell(streamListener, monitor, getLaunchConfiguration("cordova -version")); String cordovaCommand = "cordova -version\n"; sendCordovaCommand(process, cordovaCommand, monitor); CordovaCLIResult result = new CordovaCLIResult(streamListener.getMessage()); return result; }
Example #20
Source File: CordovaProjectCLI.java From thym with Eclipse Public License 1.0 | 5 votes |
public CordovaCLIResult run (final IProgressMonitor monitor, final String...options )throws CoreException{ final CordovaCLIStreamListener streamListener = new CordovaCLIStreamListener(); IProcess process = startShell(streamListener, monitor, getLaunchConfiguration("cordova run")); String cordovaCommand = generateCordovaCommand(P_COMMAND_RUN, null, options); sendCordovaCommand(process, cordovaCommand, monitor); CordovaCLIResult result = new CordovaCLIResult(streamListener.getMessage()); return result; }
Example #21
Source File: CordovaCLITest.java From thym with Eclipse Public License 1.0 | 5 votes |
@Test public void testGeneratedNodeVersionCommandCorrectly() throws CoreException,IOException{ CordovaCLI mockCLI = getMockCLI(); IProcess mockProcess = mock(IProcess.class); IStreamsProxy2 mockStreams = mock(IStreamsProxy2.class); setupMocks(mockCLI, mockProcess, mockStreams); mockCLI.nodeVersion(new NullProgressMonitor()); verify(mockStreams).write("node -v\n"); }
Example #22
Source File: CordovaProjectCLITest.java From thym with Eclipse Public License 1.0 | 5 votes |
@Test public void testGeneratedPlatformCommandCorrectlyForADD() throws CoreException,IOException{ CordovaProjectCLI mockCLI = getMockCLI(); IProcess mockProcess = mock(IProcess.class); IStreamsProxy2 mockStreams = mock(IStreamsProxy2.class); setupMocks(mockCLI, mockProcess, mockStreams); mockCLI.platform(Command.ADD, new NullProgressMonitor(), "[email protected]", CordovaProjectCLI.OPTION_SAVE); verify(mockStreams).write("cordova platform add [email protected] --save\n"); }
Example #23
Source File: EclipseProcessLauncher.java From goclipse with Eclipse Public License 1.0 | 5 votes |
public IProcess newEclipseProcessWithLabelUpdater(ILaunch launch, Indexable<String> cmdLine, Process sp) throws CoreException { final String cmdLineLabel = renderCommandLineLabel(cmdLine); final String processLabel = renderProcessLabel(); IProcess process = newEclipseProcess(launch, sp, processLabel); process.setAttribute(IProcess.ATTR_CMDLINE, cmdLineLabel); return process; }
Example #24
Source File: PyThreadConsole.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public String getName() throws DebugException { if (getDebugTarget() == null || getDebugTarget().getProcess() == null) { // probably being terminated, return constant string return "Interactive Console"; } IProcess process = getDebugTarget().getProcess(); return "Interactive Console: " + process.getLabel(); }
Example #25
Source File: CurrentPyStackFrameForConsole.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override protected boolean acceptsSelection(PyStackFrame stackFrame) { if (super.acceptsSelection(stackFrame)) { AbstractDebugTarget target = (AbstractDebugTarget) stackFrame.getAdapter(IDebugTarget.class); IProcess process = target.getProcess(); if (DebugUITools.getConsole(process) == console) { return true; } } return false; }
Example #26
Source File: CordovaProjectCLITest.java From thym with Eclipse Public License 1.0 | 5 votes |
@Test public void testGeneratedPrepareCommandCorrectly() throws CoreException, IOException{ CordovaProjectCLI mockCLI = getMockCLI(); IProcess mockProcess = mock(IProcess.class); IStreamsProxy2 mockStreams = mock(IStreamsProxy2.class); setupMocks(mockCLI, mockProcess, mockStreams); mockCLI.prepare(new NullProgressMonitor(), "android"); verify(mockStreams).write("cordova prepare android\n"); }
Example #27
Source File: CordovaProjectCLITest.java From thym with Eclipse Public License 1.0 | 5 votes |
@Test public void testAdditionalEnvProperties() throws CoreException{ CordovaProjectCLI mockCLI = getMockCLI(); IProcess mockProcess = mock(IProcess.class); IStreamsProxy2 mockStreams = mock(IStreamsProxy2.class); setupMocks(mockCLI, mockProcess, mockStreams); ArgumentCaptor<ILaunchConfiguration> confCaptor = ArgumentCaptor.forClass(ILaunchConfiguration.class); mockCLI.prepare(new NullProgressMonitor(), "android"); verify(mockCLI).startShell(any(IStreamListener.class), any(IProgressMonitor.class), confCaptor.capture()); Map<String,String> attr = confCaptor.getValue().getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map<String,String>)null); assertEquals(EnvironmentPropsExt.ENV_VALUE, attr.get(EnvironmentPropsExt.ENV_KEY)); }
Example #28
Source File: PyDebugTargetConsole.java From Pydev with Eclipse Public License 1.0 | 5 votes |
public PyDebugTargetConsole(PydevConsoleCommunication scriptConsoleCommunication, ILaunch launch, IProcess process, RemoteDebuggerConsole debugger) { super(launch, process, null, debugger, null); virtualConsoleThread = new PyThreadConsole(this); virtualConsoleThreads = new IThread[] { virtualConsoleThread }; }
Example #29
Source File: ViewerServiceServer.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
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 #30
Source File: LogContent.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Find the TextConsole associated with the launch. This is required by the * {@link JavaStackTraceHyperlink} class (which we subclass). */ private TextConsole getLaunchConsole() { LaunchConfiguration launchConfiguration = null; T entity = log.getEntity(); if (entity instanceof BrowserTab) { BrowserTab browserTab = (BrowserTab) entity; launchConfiguration = browserTab.getLaunchConfiguration(); } else if (entity instanceof LaunchConfiguration) { launchConfiguration = (LaunchConfiguration) entity; } if (launchConfiguration != null) { IProcess[] processes = launchConfiguration.getLaunch().getProcesses(); if (processes.length > 0) { /* * Just get the console for the first process. If there are multiple * processes, they will all link back to the same ILaunch (which is what * JavaStackTraceHyperlink uses the console for anyway). */ IConsole console = DebugUITools.getConsole(processes[0]); if (console instanceof TextConsole) { return (TextConsole) console; } } } return null; }