📄 buildconsoleproxy.java
字号:
/**
* Copyright (c) 2003-2007 Craig Setera
* All Rights Reserved.
* Licensed under the Eclipse Public License - v 1.0
* For more information see http://www.eclipse.org/legal/epl-v10.html
*/
package eclipseme.core.console;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import org.eclipse.debug.core.IStreamListener;
import org.eclipse.debug.core.model.IStreamMonitor;
/**
* The proxied implementation of {@link IBuildConsoleProxy}.
* <p />
* Copyright (c) 2003-2007 Craig Setera<br>
* All Rights Reserved.<br>
* Licensed under the Eclipse Public License - v 1.0<p/>
* <br>
* $Revision$
* <br>
* $Date$
* <br>
* @author Craig Setera
*/
public class BuildConsoleProxy implements IBuildConsoleProxy {
public static final BuildConsoleProxy instance = new BuildConsoleProxy();
private static NullOutputStream nullStream = new NullOutputStream();
private static class NullOutputStream extends OutputStream {
public void write(int arg0) throws IOException {
}
}
private IBuildConsoleProxy proxy;
private PrintWriter traceWriter;
private BuildConsoleProxy() { }
/**
* Add a new listener to the specified console stream.
*
* @param id
* @param monitor
*/
public void addConsoleStreamListener(String id, IStreamMonitor monitor) {
final PrintWriter writer = getConsoleWriter(id);
monitor.addListener(new IStreamListener() {
public void streamAppended(String text, IStreamMonitor monitor) {
writer.print(text);
writer.flush();
}
});
writer.print(monitor.getContents());
writer.flush();
}
/**
* @see eclipseme.core.console.IBuildConsoleProxy#getConsoleWriter(java.lang.String)
*/
public PrintWriter getConsoleWriter(String id) {
return (proxy == null) ? new PrintWriter(nullStream) : proxy.getConsoleWriter(id);
}
/**
* Print the specified information to the log output stream.
*
* @param text
*/
public void trace(String text) {
if (traceWriter == null) {
traceWriter = getConsoleWriter(ID_TRACE_STREAM);
}
traceWriter.print(text);
traceWriter.flush();
}
/**
* Print the specified information to the log output stream.
*
* @param text
*/
public void traceln(String text) {
trace(text + "\n");
}
/**
* Set the proxy being wrapped by this proxy.
*
* @param proxy
*/
public void setProxy(IBuildConsoleProxy proxy) {
this.proxy = proxy;
traceWriter = null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -