当前位置: 首页>>代码示例>>Java>>正文


Java IStreamListener类代码示例

本文整理汇总了Java中org.eclipse.debug.core.IStreamListener的典型用法代码示例。如果您正苦于以下问题:Java IStreamListener类的具体用法?Java IStreamListener怎么用?Java IStreamListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IStreamListener类属于org.eclipse.debug.core包,在下文中一共展示了IStreamListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addAndNotifyStreamListener

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
/**
 * Adds listener to monitor, and calls listener with any content monitor already has.
 * NOTE: This methods synchronises on monitor while listener is called. Listener may
 * not wait on any thread that waits for monitors monitor, what would result in dead-lock.
 */
public static void addAndNotifyStreamListener(IStreamMonitor monitor, IStreamListener listener) {
	// Synchronise on monitor to prevent writes to stream while we are adding listener.
	// It's weird to synchronise on monitor because that's a shared object, but that's
	// what ProcessConsole does.
	synchronized (monitor) {
		String contents = monitor.getContents();
		if (!contents.isEmpty()) {
			// Call to unknown code while synchronising on monitor. This is dead-lock prone!
			// Listener must not wait for other threads that are waiting in line to
			// synchronise on monitor.
			listener.streamAppended(contents, monitor);
		}
		monitor.addListener(listener);
	}
}
 
开发者ID:wpilibsuite,项目名称:EclipsePlugins,代码行数:21,代码来源:AntLauncher.java

示例2: onAfterCodeServerStarted

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
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);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:23,代码来源:GwtWtpPlugin.java

示例3: flush

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
@Override
		public synchronized void flush() throws IOException {
			super.flush();
			String cont;
			try {
				cont = this.toString(encoding);
				
			} 
			catch (UnsupportedEncodingException ex) {
				DbgActivator.getDefault().logError("Encoding problem", ex);
				cont = this.toString();
			}
			String appended = cont.substring(flushLength);
			flushLength = cont.length();
			if (this.content != null) {
				this.reset();
				flushLength = 0;
			}
			
//			System.out.println(oldLength + ":" + this.toString() + ":" + appended + ":" + this.listeners.size());
			for (IStreamListener l : this.listeners) {
				l.streamAppended(appended, monitor);
			}
		}
 
开发者ID:RichardBirenheide,项目名称:brainfuck,代码行数:25,代码来源:BfProcess.java

示例4: exec

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
/**
 * Executes the given command and returns a handle to the 
 * process. Should only be used if access to {@link IProcess}
 * instance is desired. 
 * 
 * @param command
 * @param workingDirectory
 * @param monitor
 * @param envp
 * @param launchConfiguration
 * @param outStreamListener
 * @param errorStreamListener
 * @return the process
 * @throws CoreException
 */
public IProcess exec(String[] command, File workingDirectory, IProgressMonitor monitor, 
		String[] envp, ILaunchConfiguration launchConfiguration, 
		IStreamListener outStreamListener, IStreamListener errorStreamListener ) throws CoreException{
	
	checkCommands(command);
	checkWorkingDirectory(workingDirectory);
	if(monitor == null ){
		monitor = new NullProgressMonitor();
	}
	if (envp == null && launchConfiguration != null ){
		envp = DebugPlugin.getDefault().getLaunchManager().getEnvironment(launchConfiguration);
	}
	if (monitor.isCanceled()) {
		return null;
	}
	Process process = DebugPlugin.exec(command, workingDirectory, envp);
	
	Map<String, String> processAttributes = generateProcessAttributes(command, launchConfiguration);
	Launch launch = new Launch(launchConfiguration, "run", null);
	IProcess prcs = DebugPlugin.newProcess(launch, process, command[0], processAttributes);
	setTracing(command, outStreamListener, errorStreamListener, prcs);
	DebugPlugin.getDefault().getLaunchManager().addLaunch(launch);
	return prcs;
}
 
开发者ID:eclipse,项目名称:thym,代码行数:40,代码来源:ExternalProcessUtility.java

示例5: setTracing

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
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);
	}
}
 
开发者ID:eclipse,项目名称:thym,代码行数:21,代码来源:ExternalProcessUtility.java

示例6: addListener

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
public synchronized void addListener(IStreamListener listener) {
	if (!this.listeners.contains(listener)) {
		this.listeners.add(listener);
	}
	try {
		this.content = this.toString(encoding);
	} 
	catch (UnsupportedEncodingException ex) {
		this.content = this.toString();
	}
	synchronized (this.lock) {
		this.lock.notify();
	}
}
 
开发者ID:RichardBirenheide,项目名称:brainfuck,代码行数:15,代码来源:BfProcess.java

示例7: flush

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
@Override
public synchronized void flush() {
  if (!isFlushing) {
    return;
  }
  String text = writer.toString();
  int lastLinePos;
  final boolean flushOnlyFullLines = true;
  if (flushOnlyFullLines) {
    int pos = text.lastIndexOf('\n');
    if (pos == -1) {
      // No full line in the buffer.
      return;
    }
    lastLinePos = pos + 1;
  } else {
    lastLinePos = text.length();
  }
  String readyText = text.substring(0, lastLinePos);
  writer = new StringWriter();
  if (lastLinePos != text.length()) {
    String rest = text.substring(lastLinePos);
    writer.append(rest);
  }
  for (IStreamListener listener : listeners) {
    listener.streamAppended(readyText, this);
  }
}
 
开发者ID:jbosstools,项目名称:chromedevtools,代码行数:29,代码来源:ConsolePseudoProcess.java

示例8: setupMockCLI

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:thym,代码行数:15,代码来源:HybridProjectTest.java

示例9: testAdditionalEnvProperties

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
@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));
}
 
开发者ID:eclipse,项目名称:thym,代码行数:13,代码来源:CordovaProjectCLITest.java

示例10: testAdditionalEnvProperties

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
@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));
  }
 
开发者ID:eclipse,项目名称:thym,代码行数:14,代码来源:CordovaCLITest.java

示例11: logcat

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
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);
}
 
开发者ID:eclipse,项目名称:thym,代码行数:11,代码来源:AndroidSDKManager.java

示例12: execAsync

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:eclipse,项目名称:thym,代码行数:11,代码来源:ExternalProcessUtility.java

示例13: execSync

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
/**
 * Executes the given commands synchronously.
 *
 * <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
 * @param launchConfiguration the launch to add as part of this call, can be null
 * @return the exit code for the process
 * @throws CoreException if the execution fails
 */
public int execSync ( String[] command, File workingDirectory, 
		IStreamListener outStreamListener, 
		IStreamListener errorStreamListener, IProgressMonitor monitor, 
		String[] envp, ILaunchConfiguration launchConfiguration) throws CoreException{
	if(monitor == null){
		monitor = new NullProgressMonitor();
	}
	HybridCore.trace("Sync Execute command line: "+Arrays.toString(command));
	IProcess prcs = exec(command, workingDirectory, monitor, envp, launchConfiguration,outStreamListener,errorStreamListener);
	if(prcs == null ){
		return 0;
	}
	
	while (!prcs.isTerminated()) {
		try {
			if (monitor.isCanceled()) {
				prcs.terminate();
				break;
			}
			Thread.sleep(50);
		} catch (InterruptedException e) {
			HybridCore.log(IStatus.INFO, "Exception waiting for process to terminate", e);
		}
	}
	return prcs.getExitValue();
}
 
开发者ID:eclipse,项目名称:thym,代码行数:42,代码来源:ExternalProcessUtility.java

示例14: startShell

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:thym,代码行数:16,代码来源:CordovaCLI.java

示例15: fireStreamAppend

import org.eclipse.debug.core.IStreamListener; //导入依赖的package包/类
private void fireStreamAppend(String text) {
    synchronized (listeners) {
        for (IStreamListener oneListener : listeners) {
            oneListener.streamAppended(text, this);
        }
    }
}
 
开发者ID:codenvy-legacy,项目名称:eclipse-plugin,代码行数:8,代码来源:StringBufferStreamMonitor.java


注:本文中的org.eclipse.debug.core.IStreamListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。