org.eclipse.debug.core.IStreamListener Java Examples
The following examples show how to use
org.eclipse.debug.core.IStreamListener.
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: 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 #2
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 #3
Source File: OutputStreamMonitor.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public void notifyAppend(String text) { if (text == null) { return; } fText = text; Object[] copiedListeners= fListeners.getListeners(); for (int i= 0; i < copiedListeners.length; i++) { fListener = (IStreamListener) copiedListeners[i]; SafeRunner.run(this); } fListener = null; fText = null; }
Example #4
Source File: HybridProjectTest.java From thym with Eclipse Public License 1.0 | 5 votes |
private CordovaProjectCLI setupMockCLI(HybridProject project) throws CoreException { IProcess mockProcess = mock(IProcess.class); IStreamsProxy2 mockStreams = mock(IStreamsProxy2.class); CordovaProjectCLI mockCLI = spy(CordovaProjectCLI.newCLIforProject(mockProject)); doReturn(mockProcess).when(mockCLI).startShell(any(IStreamListener.class), any(IProgressMonitor.class), any(ILaunchConfiguration.class)); when(mockProcess.getStreamsProxy()).thenReturn(mockStreams); when(mockProcess.isTerminated()).thenReturn(Boolean.TRUE); doReturn(mockCLI).when(project).getProjectCLI(); return mockCLI; }
Example #5
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 #6
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 #7
Source File: CordovaCLITest.java From thym with Eclipse Public License 1.0 | 5 votes |
@Test public void testAdditionalEnvProperties() throws CoreException{ CordovaCLI mockCLI = getMockCLI(); IProcess mockProcess = mock(IProcess.class); IStreamsProxy2 mockStreams = mock(IStreamsProxy2.class); setupMocks(mockCLI, mockProcess, mockStreams); ArgumentCaptor<ILaunchConfiguration> confCaptor = ArgumentCaptor.forClass(ILaunchConfiguration.class); mockCLI.version(new NullProgressMonitor()); 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 #8
Source File: AndroidSDKManager.java From thym with Eclipse Public License 1.0 | 5 votes |
public void logcat(String filter, IStreamListener outListener, IStreamListener errorListener, String serialNumber) throws CoreException{ ExternalProcessUtility processUtility = new ExternalProcessUtility(); StringBuilder command = new StringBuilder(getADBCommand()); command.append(" -s ").append(serialNumber); command.append(" logcat "); if(filter !=null && !filter.isEmpty()){ command.append(filter); } processUtility.execAsync(command.toString(), null, outListener, errorListener, null); }
Example #9
Source File: ExternalProcessUtility.java From thym with Eclipse Public License 1.0 | 5 votes |
/** * Convenience method to specify command line as a string for {@link #execAsync(String[], File, IStreamListener, IStreamListener, String[])} */ public void execAsync ( String commandLine, File workingDirectory, IStreamListener outStreamListener, IStreamListener errorStreamListener, String[] envp) throws CoreException{ checkCommandLine(commandLine); this.execAsync(DebugPlugin.parseArguments(commandLine), workingDirectory, outStreamListener, errorStreamListener, envp); }
Example #10
Source File: ExternalProcessUtility.java From thym with Eclipse Public License 1.0 | 5 votes |
/** * Convenience method to specify command line as a String * for {@link #execSync(String[], File, IStreamListener, IStreamListener, IProgressMonitor, String[], ILaunchConfiguration)} */ public int execSync ( String commandLine, File workingDirectory, IStreamListener outStreamListener, IStreamListener errorStreamListener, IProgressMonitor monitor, String[] envp, ILaunchConfiguration launchConfiguration) throws CoreException{ String[] cmd = DebugPlugin.parseArguments(commandLine); return this.execSync(cmd, workingDirectory, outStreamListener, errorStreamListener, monitor, envp, launchConfiguration); }
Example #11
Source File: CordovaCLITest.java From thym with Eclipse Public License 1.0 | 4 votes |
private void setupMocks(CordovaCLI mockCLI, IProcess mockProcess, IStreamsProxy2 mockStreams) throws CoreException { doReturn(mockProcess).when(mockCLI).startShell(any(IStreamListener.class), any(IProgressMonitor.class),any(ILaunchConfiguration.class)); when(mockProcess.getStreamsProxy()).thenReturn(mockStreams); when(mockProcess.isTerminated()).thenReturn(Boolean.TRUE); }
Example #12
Source File: ScanWorkspaceOperation.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(Messages.scanningWorkspace, IProgressMonitor.UNKNOWN); final ILaunchManager manager = getLaunchManager(); final ILaunchConfigurationType ltype = manager .getLaunchConfigurationType(IPDELauncherConstants.ECLIPSE_APPLICATION_LAUNCH_CONFIGURATION_TYPE); try { final ILaunchConfigurationWorkingCopy workingCopy = ltype.newInstance(null, "Scan workspace"); workingCopy.setAttribute(IPDELauncherConstants.APPLICATION, applicationId()); workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "-scan"); if (Objects.equals(Platform.getOS(), Platform.OS_MACOSX)) { workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_USE_START_ON_FIRST_THREAD, true); } workingCopy.setAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false); workingCopy.setAttribute(IPDELauncherConstants.RUN_IN_UI_THREAD, true); workingCopy.setAttribute(IPDELauncherConstants.DOCLEAR, false); workingCopy.setAttribute(IPDELauncherConstants.LOCATION, tmpWorskpaceFolder()); workingCopy.setAttribute(IPDELauncherConstants.USE_PRODUCT, false); final ILaunch launch = workingCopy.launch("run", Repository.NULL_PROGRESS_MONITOR); launch.getProcesses()[0].getStreamsProxy().getOutputStreamMonitor().addListener(new IStreamListener() { @Override public void streamAppended(String text, IStreamMonitor streamMonitor) { if (text.startsWith("$SCAN_PROGRESS_")) { scanStatus(text); } } }); while (!launch.isTerminated()) { Thread.sleep(1000); } if (workspaceModel.isEmpty()) { workspaceModel.setStatus(ValidationStatus.error(Messages.noRepositoryFoundAtLocation)); } if (launch.isTerminated()) { monitor.done(); } } catch (final CoreException | IOException e) { throw new InvocationTargetException(e); } }
Example #13
Source File: TracingStreamListener.java From thym with Eclipse Public License 1.0 | 4 votes |
public TracingStreamListener(IStreamListener delegate){ this.delegate = delegate; }
Example #14
Source File: OutputStreamMonitor.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
@Override public synchronized void addListener(IStreamListener listener) { fListeners.add(listener); }
Example #15
Source File: CordovaProjectCLITest.java From thym with Eclipse Public License 1.0 | 4 votes |
private void setupMocks(CordovaCLI mockCLI, IProcess mockProcess, IStreamsProxy2 mockStreams) throws CoreException { doReturn(mockProcess).when(mockCLI).startShell(any(IStreamListener.class), any(IProgressMonitor.class),any(ILaunchConfiguration.class)); when(mockProcess.getStreamsProxy()).thenReturn(mockStreams); when(mockProcess.isTerminated()).thenReturn(Boolean.TRUE); }
Example #16
Source File: OutputStreamMonitor.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
@Override public synchronized void removeListener(IStreamListener listener) { fListeners.remove(listener); }
Example #17
Source File: ExternalProcessUtility.java From thym with Eclipse Public License 1.0 | 3 votes |
/** * Executes the given commands asynchronously. * * <p> * If the workingDirectory is null, the current directory for process is used. * </p> * @param command the command line can not be null or empty * @param workingDirectory working directory for the executed command can be null * @param outStreamListener listener for output, can be null * @param errorStreamListene listener for error output, can be null * @param envp environment variables to set in the process can be null * @throws CoreException if execution fails * @throws IllegalArgumentException * <ul> * <li>If command is null or empty</li> * <li>If specified workingDirectory does not exist or not a directory</li> * </ul> */ public void execAsync (String [] command, File workingDirectory, IStreamListener outStreamListener, IStreamListener errorStreamListener, String[] envp) throws CoreException{ HybridCore.trace("Async Execute command line: "+Arrays.toString(command)); exec(command, workingDirectory, new NullProgressMonitor(), envp, null,outStreamListener,errorStreamListener); }