Java 类org.eclipse.ui.console.IOConsoleOutputStream 实例源码
项目:gemoc-studio
文件:EclipseConsoleIO.java
public void println(final ConsoleMessage message) {
// use normal print for the message itself
print(message);
// add the carriage return
Runnable r = new Runnable() {
public void run() {
changeStyle(message.getColor(), message.getStyle());
if(!((IOConsoleOutputStream)getOutputStream()).isClosed()){
try {
((IOConsoleOutputStream)getOutputStream()).write("\n");
} catch (IOException e) {
}
}
}
};
ConsolePlugin.getStandardDisplay().asyncExec(r);
}
项目:turnus
文件:EclipseConsoleHandler.java
@Override
public void run() {
String message = getFormatter().format(record);
IOConsoleOutputStream outStream = console.newOutputStream();
if (record.getLevel() == Level.SEVERE) {
outStream.setColor(new Color(null, 255, 0, 0));
} else if (record.getLevel() == Level.WARNING) {
outStream.setColor(new Color(null, 250, 133, 50));
} else if (record.getLevel() == Level.FINER) {
outStream.setColor(new Color(null, 133, 200, 62));
} else {
outStream.setColor(new Color(null, 0, 0, 156));
}
try {
outStream.write(message);
outStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
项目:cft
文件:ApplicationLogConsoleStream.java
/**
* Writes a CF application log to the console. The content type of the
* application log is resolved first and a corresponding stream is fetched
* or created as part of streaming the log message to the console.
*/
public synchronized void write(CloudLog log) throws CoreException {
if (log == null) {
return;
}
IOConsoleOutputStream activeOutStream = getOutputStream(log.getLogType());
if (activeOutStream != null && log.getMessage() != null) {
try {
activeOutStream.write(log.getMessage());
}
catch (IOException e) {
throw CloudErrorUtil.toCoreException(e);
}
}
}
项目:dockerfoundry
文件:ApplicationLogConsoleStream.java
/**
* Writes a loggregator application log to the console. The content type of
* the application log is resolved first and a corresponding stream is
* fetched or created as part of streaming the log message to the console.
*/
public synchronized void write(ApplicationLog appLog) throws CoreException {
if (appLog == null) {
return;
}
// Convert it to a CloudLog that contains the appropriate log content
// type
CloudLog log = getCloudlog(appLog);
IOConsoleOutputStream activeOutStream = getOutputStream(log.getLogType());
if (activeOutStream != null && log.getMessage() != null) {
try {
activeOutStream.write(log.getMessage());
}
catch (IOException e) {
throw CloudErrorUtil.toCoreException(e);
}
}
}
项目:dockerfoundry
文件:DockerFoundryTraceConsole.java
public synchronized void initialiseStreams() {
if (streams != null && !streams.isEmpty()) {
return;
}
streams = new HashMap<LogContentType, TraceConsoleStream>();
for (TraceUIType type : TRACE_TYPES) {
IOConsoleOutputStream outStream = getMessageConsole().newOutputStream();
if (outStream != null) {
TraceConsoleStream stream = new TraceConsoleStream(type);
stream.initialiseStream(outStream);
streams.put(type.getTraceType(), stream);
}
}
}
项目:APICloud-Studio
文件:ConsoleThemer.java
/**
* applyTheme
*
* @param name
* @param stream
* @param defaultColor
* @return
*/
private void applyTheme(String name, IOConsoleOutputStream stream, Color defaultColor)
{
Theme theme = ThemePlugin.getDefault().getThemeManager().getCurrentTheme();
Color color = defaultColor;
int style = SWT.NONE;
// grab theme values, if they exist
if (theme.hasEntry(name))
{
TextAttribute attr = theme.getTextAttribute(name);
color = theme.getForeground(name);
style = attr.getStyle();
}
// apply new values
stream.setColor(color);
stream.setFontStyle(style);
}
项目:plugindependencies
文件:PluginDependenciesConsole.java
public void showState(PlatformState newState) {
if(state == newState){
return;
}
this.state = newState;
IOConsoleOutputStream out = newOutputStream();
try(PrintWriter pw = new PrintWriter(out)){
pw.println("### Overview ###");
state.dumpAllElements(pw);
pw.println("### - ###\n");
pw.println("### Warnings / errors ###");
StringBuilder sb = state.dumpLogs();
pw.println(sb.toString());
pw.println("### - ###");
}
}
项目:e4macs
文件:EmacsPlusConsole.java
protected void printMessage(String message, Color c, int style) {
if (message != null) {
IOConsoleOutputStream outputStream = getOutputStream();
outputStream.setActivateOnWrite(true);
if (c != null) {
outputStream.setColor(c);
}
outputStream.setFontStyle(style);
try {
outputStream.write(message);
outputStream.flush();
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
项目:Pydev
文件:PyLintVisitor.java
private static void write(String cmdLineToExe, IOConsoleOutputStream out, Object... args) {
try {
if (out != null) {
synchronized (lock) {
if (args != null) {
for (Object arg : args) {
if (arg instanceof String) {
cmdLineToExe += " " + arg;
} else if (arg instanceof String[]) {
String[] strings = (String[]) arg;
for (String string : strings) {
cmdLineToExe += " " + string;
}
}
}
}
out.write(cmdLineToExe + "\n");
}
}
} catch (IOException e) {
Log.log(e);
}
}
项目:Pydev
文件:MessageConsoles.java
public static IOConsoleOutputStream getConsoleOutputStream(String name, String iconPath) {
synchronized (lock) {
IOConsoleOutputStream outputStream = consoleOutputs.get(name);
if (outputStream == null) {
MessageConsole console = getConsole(name, iconPath);
HashMap<IOConsoleOutputStream, String> themeConsoleStreamToColor = new HashMap<IOConsoleOutputStream, String>();
outputStream = console.newOutputStream();
themeConsoleStreamToColor.put(outputStream, "console.output");
console.setAttribute("themeConsoleStreamToColor", themeConsoleStreamToColor);
ConsoleColorCache.getDefault().keepConsoleColorsSynched(console);
consoles.put(name, console);
consoleOutputs.put(name, outputStream);
}
return outputStream;
}
}
项目:felinx
文件:PluginConsole.java
private void initializeIO() {
IOConsoleOutputStream out = newOutputStream();
out.setColor(BLUE);
outputStream = new PrintStream(out);
System.setOut(outputStream);
IOConsoleOutputStream err = newOutputStream();
err.setColor(RED);
System.setErr(new PrintStream(err));
InputStream input = getInputStream();
System.setIn(input);
//InputStreamListener ipsl = new InputStreamListener(input);
//ipsl.start();
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { this });
ConsolePlugin.getDefault().getConsoleManager().showConsoleView(this);
}
项目:mule-tooling-incubator
文件:GradleRunner.java
public static void run(final BuildLauncher build, final IProgressMonitor monitor, String... runArgs) {
monitor.beginTask("Running gradle build", IProgressMonitor.UNKNOWN);
MessageConsole messageConsole = UiUtils.getMessageConsole("Gradle run");
final IOConsoleOutputStream consoleStream = messageConsole.newOutputStream();
build.setStandardOutput(consoleStream);
build.setStandardError(consoleStream);
GradlePluginUtils.setBuildLoggingOptions(build, runArgs);
UiUtils.showConsoleView();
// STUDIO-2676 - bring new console to front
ConsolePlugin.getDefault().getConsoleManager().showConsoleView(messageConsole);
build.addProgressListener(new ProgressListener() {
@Override
public void statusChanged(ProgressEvent progressEvent) {
monitor.beginTask(progressEvent.getDescription(), IProgressMonitor.UNKNOWN);
}
});
build.run();
monitor.done();
}
项目:mule-tooling-incubator
文件:LifeCycleJob.java
private void redirectOutputToConsole(PipedOutputStream nextOutput) {
MessageConsole messageConsole = MavenUIPlugin.getDefault().getGenericOutputConsole();
final IOConsoleOutputStream consoleStream = messageConsole.newOutputStream();
PipedInputStream inputStream = null;
try {
inputStream = new PipedInputStream(nextOutput);
} catch (IOException e) {
throw new RuntimeException("IO exception creating piped streams (should not happen)", e);
}
redirectOutputToConsoleThread = new OutputRedirectorThread(inputStream, consoleStream, RunnableUtils.newRunnableClosing(inputStream, consoleStream));
UiUtils.showConsoleView();
// STUDIO-2676 - bring new console to front
ConsolePlugin.getDefault().getConsoleManager().showConsoleView(messageConsole);
redirectOutputToConsoleThread.start();
}
项目:mule-tooling-incubator
文件:InstallJar.java
private void redirectOutputToConsole(PipedOutputStream nextOutput) {
MessageConsole messageConsole = MavenUIPlugin.getDefault().getGenericOutputConsole();
final IOConsoleOutputStream consoleStream = messageConsole.newOutputStream();
PipedInputStream inputStream = null;
try {
inputStream = new PipedInputStream(nextOutput);
} catch (IOException e) {
throw new RuntimeException("IO exception creating piped streams (should not happen)", e);
}
redirectOutputToConsoleThread = new OutputRedirectorThread(inputStream, consoleStream, RunnableUtils.newRunnableClosing(inputStream, consoleStream));
UiUtils.showConsoleView();
// STUDIO-2676 - bring new console to front
ConsolePlugin.getDefault().getConsoleManager().showConsoleView(messageConsole);
redirectOutputToConsoleThread.start();
}
项目:gemoc-studio
文件:EclipseConsoleIO.java
/** deal with not justified and large string
* this is because large string may block Eclipse UI
*/
protected void safePrint(String message, final Color c, final int style, IProgressMonitor monitor){
try {
String justifiedMsg = justifyMessage(message);
if(justifiedMsg.length() > LARGE_MESSAGE_SIZE){
// deal with large messages ... chunk the message
int nbChunk = justifiedMsg.length()/LARGE_MESSAGE_SIZE;
monitor.beginTask("writing large string to the console", nbChunk+1);
int start, end= 0;
for(int i = 0; i< nbChunk; i++){
start = LARGE_MESSAGE_SIZE*i;
end = LARGE_MESSAGE_SIZE*i + LARGE_MESSAGE_SIZE;
changeStream();
safeChangeStyle(c, style);
((IOConsoleOutputStream)getOutputStream()).write(justifiedMsg.substring(start, end));
monitor.worked(1);
}
changeStream();
safeChangeStyle(c, style);
((IOConsoleOutputStream)getOutputStream()).write(justifiedMsg.substring(end, justifiedMsg.length()));
monitor.done();
}
else{
safeChangeStyle(c, style);
((IOConsoleOutputStream)getOutputStream()).write(justifiedMsg);
}
} catch (IOException e) {
e.printStackTrace();
}
}
项目:gemoc-studio
文件:EclipseConsoleIO.java
/**
* this methods allow to change the color of future message
* (this is because a simple change of current stream color, change the color for all messages, even previous ones ...)
* @param c
*/
@Override
public void changeColor(Color c){
Color previousColor = ((IOConsoleOutputStream) getOutputStream()).getColor();
if( (c==null && c!= previousColor) || (c!=null && !c.equals(previousColor)) ){
// need to change to another stream for the new color
changeStream(); // reset the stream
((IOConsoleOutputStream) getOutputStream()).setColor(c);
}
}
项目:gemoc-studio
文件:EclipseConsoleIO.java
/**
* this methods allow to change the color and font style of future message
* (this is because a simple change of current stream color, change the color for all messages, even previous ones ...)
* @param c
*/
@Override
public void changeStyle(Color c, int style){
Color previousColor = ((IOConsoleOutputStream) getOutputStream()).getColor();
int previousStyle = ((IOConsoleOutputStream) getOutputStream()).getFontStyle();
if( (c==null && c!= previousColor) || (c!=null && !c.equals(previousColor)) || style!= previousStyle ){
// need to change to another stream for the new color
changeStream(); // reset the stream
((IOConsoleOutputStream) getOutputStream()).setColor(c);
((IOConsoleOutputStream) getOutputStream()).setFontStyle(style);
}
}
项目:gemoc-studio
文件:EclipseConsoleIO.java
/**
* does the same as changeStyle() but ensure to do it in the UI Thread
* @param c
* @param style
*/
protected void safeChangeStyle(final Color c, final int style) {
Color previousColor = ((IOConsoleOutputStream) getOutputStream()).getColor();
int previousStyle = ((IOConsoleOutputStream) getOutputStream()).getFontStyle();
if( (c==null && c!= previousColor) || (c!=null && !c.equals(previousColor)) || style!= previousStyle ){
Display.getDefault().syncExec(new Runnable() {
public void run() {
// need to change to another stream for the new color
changeStream(); // reset the stream
((IOConsoleOutputStream) getOutputStream()).setColor(c);
((IOConsoleOutputStream) getOutputStream()).setFontStyle(style);
}
});
}
}
项目:gemoc-studio
文件:EclipseConsoleIO.java
/**
* this methods allow to change the font style of future message
* (this is because a simple change of current stream color, change the color for all messages, even previous ones ...)
* @param style
*/
@Override
public void changeFontStyle(int style){
int previousStyle = ((IOConsoleOutputStream) getOutputStream()).getFontStyle();
if( style!= previousStyle ){
// need to change to another stream for the new style
changeStream(); // reset the stream
((IOConsoleOutputStream) getOutputStream()).setFontStyle(style);
}
}
项目:cft
文件:ApplicationLogConsoleStream.java
@Override
protected IOConsoleOutputStream getOutputStream(LogContentType type) {
ConsoleStream consoleStream = getApplicationLogStream(type);
if (consoleStream != null && consoleStream.isActive()) {
return consoleStream.getOutputStream(type);
}
return null;
}
项目:cft
文件:ConsoleStream.java
public synchronized void write(CloudLog log) throws CoreException {
if (log == null || log.getMessage() == null) {
return;
}
IOConsoleOutputStream outStream = getOutputStream(log.getLogType());
if (outStream != null) {
try {
outStream.write(log.getMessage());
}
catch (IOException e) {
throw CloudErrorUtil.toCoreException(e);
}
}
}
项目:cft
文件:SingleConsoleStream.java
/**
* Returns an active outputstream associated with the given log
* @return Returns the output stream IFF it is active. Returns null
* otherwise.
*/
protected synchronized IOConsoleOutputStream getOutputStream(LogContentType type) {
if (isActive()) {
return outputStream;
}
return null;
}
项目:dockerfoundry
文件:ApplicationLogConsoleStream.java
@Override
protected IOConsoleOutputStream getOutputStream(LogContentType type) {
ConsoleStream consoleStream = getApplicationLogStream(type);
if (consoleStream != null && consoleStream.isActive()) {
return consoleStream.getOutputStream(type);
}
return null;
}
项目:dockerfoundry
文件:ConsoleStream.java
public synchronized void write(CloudLog log) throws CoreException {
if (log == null || log.getMessage() == null) {
return;
}
IOConsoleOutputStream outStream = getOutputStream(log.getLogType());
if (outStream != null) {
try {
outStream.write(log.getMessage());
}
catch (IOException e) {
throw CloudErrorUtil.toCoreException(e);
}
}
}
项目:dockerfoundry
文件:SingleConsoleStream.java
/**
* Returns an active outputstream associated with the given log
* @return Returns the output stream IFF it is active. Returns null
* otherwise.
*/
protected synchronized IOConsoleOutputStream getOutputStream(LogContentType type) {
if (isActive()) {
return outputStream;
}
return null;
}
项目:dockerfoundry
文件:DockerFoundryConsoleStream.java
public synchronized String write(String content) throws CoreException {
IOConsoleOutputStream activeOutStream = getActiveOutputStream();
if (activeOutStream != null && content != null && content.length() > 0) {
try {
activeOutStream.write(content);
return content;
}
catch (IOException e) {
throw CloudErrorUtil.toCoreException(e);
}
}
return null;
}
项目:dockerfoundry
文件:BaseConsoleStream.java
public synchronized void initialiseStream(IOConsoleOutputStream outputStream) {
this.outputStream = outputStream;
if (this.outputStream != null && !this.outputStream.isClosed()) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
doInitialiseStream(BaseConsoleStream.this.outputStream);
}
});
}
}
项目:dockerfoundry
文件:BaseConsoleStream.java
/**
* Returns the output stream IFF it is active. Conditions for determining if
* a stream is active is done through {@link #isActive()}
* @return Returns the output stream IFF it is active. Returns null
* otherwise.
*/
protected synchronized IOConsoleOutputStream getActiveOutputStream() {
if (isActive()) {
return outputStream;
}
return null;
}
项目:dockerfoundry
文件:DockerFoundryTraceConsole.java
public synchronized void write(String message) {
if (message == null) {
return;
}
IOConsoleOutputStream outStream = getActiveOutputStream();
if (outStream != null) {
try {
outStream.write(message);
}
catch (IOException e) {
DockerFoundryPlugin.logError(e);
close();
}
}
}
项目:dockerfoundry
文件:DockerFoundryFileConsole.java
protected IConsoleJob createConsoleJob(ICloudFoundryConsoleStream stream) {
IOConsoleOutputStream outputStream = console.newOutputStream();
IConsoleJob job = null;
if (outputStream != null) {
job = new ConsoleStreamJob( " - " + stream.getContentType().getId(), //$NON-NLS-1$
stream);
stream.initialiseStream(outputStream);
}
return job;
}
项目:dockerfoundry
文件:DockerFoundryFileConsole.java
protected IConsoleJob getStdStreamJob(StdContentType contentType) {
if (contentType == null) {
return null;
}
IConsoleJob job = getActiveStreams().getFirst(contentType);
// Lazily create the std streaming jobs, only when needed, as to not
// have running jobs that are not used. Only one job
// per std out content should exist per tailing session
if (job == null) {
LocalConsoleStream stdContent = null;
switch (contentType) {
case STD_ERROR:
stdContent = new LocalStdErrorConsoleStream();
break;
case STD_OUT:
stdContent = new LocalStdOutConsoleStream();
break;
}
if (stdContent != null) {
IOConsoleOutputStream outputStream = console.newOutputStream();
if (outputStream != null) {
stdContent.initialiseStream(outputStream);
job = new StdConsoleStreamJob(stdContent);
getActiveStreams().addJob(job);
}
}
}
return job;
}
项目:creel
文件:Builder.java
/**
* Creates and configures a Creel engine using plugin preferences and
* folders.
*
* @param project
* The project
* @param folders
* Map of artifact types to folders
* @return A Creel engine
* @throws CoreException
* In case of an Eclipse error
*/
public static Engine createEngine( IProject project, Map<Artifact.Type, IContainer> folders ) throws CoreException
{
IPreferenceStore preferences = Plugin.instance.getPreferenceStore();
Engine engine = new Engine();
IOConsole console = EclipseUtil.getConsole( "Creel" );
IOConsoleOutputStream stream = console.newOutputStream();
if( !preferences.getBoolean( PreferencesPage.QUIET ) )
( (EventHandlers) engine.getEventHandler() ).add( new ConsoleEventHandler( stream, false, false ) );
engine.setVerbosity( preferences.getInt( PreferencesPage.VERBOSITY ) );
engine.getDirectories().set( toDirectories( folders ) );
return engine;
}
项目:gama
文件:ConsoleView.java
private BufferedWriter getWriterFor(final ITopLevelAgent root, final GamaUIColor color) {
final Color c = color == null ? getColorFor(root) : color.color();
BufferedWriter writer = writers.get(c);
if (writer == null) {
final IOConsoleOutputStream stream = msgConsole.newOutputStream();
stream.setColor(c);
stream.setActivateOnWrite(false);
writer = new BufferedWriter(new OutputStreamWriter(stream));
writers.put(c, writer);
}
return writer;
}
项目:APICloud-Studio
文件:ConsoleThemePageParticipant.java
@SuppressWarnings({ "unchecked", "rawtypes" })
public void init(IPageBookViewPage page, IConsole console)
{
if (console instanceof TextConsole)
{
TextConsole textConsole = (TextConsole) console;
Object themeConsoleStreamToColor = textConsole.getAttribute(THEME_CONSOLE_STREAM_TO_COLOR_ATTRIBUTE);
if (themeConsoleStreamToColor instanceof Map<?, ?>)
{
Map m = (Map) themeConsoleStreamToColor;
Set<Map.Entry> entrySet = m.entrySet();
for (Map.Entry entry : entrySet)
{
if (!(entry.getKey() instanceof IOConsoleOutputStream) || !(entry.getValue() instanceof String))
{
return; // Cannot handle it.
}
}
this.extension = new ConsoleThemer(textConsole, (Map) themeConsoleStreamToColor);
}
if (page instanceof TextConsolePage)
{
TextConsolePage tcp = (TextConsolePage) page;
TextViewerThemer themer = new TextViewerThemer(tcp.getViewer());
themer.apply();
}
}
this.page = page;
}
项目:sadlos2
文件:SadlUiModule.java
public SadlUiModule(AbstractUIPlugin plugin) {
super(plugin);
IOConsoleOutputStream iocos = SadlConsole
.getOutputStream(MessageType.INFO);
System.setOut(new PrintStream(iocos));
System.setErr(new PrintStream(SadlConsole
.getOutputStream(MessageType.ERROR)));
// this is to prevent XtextReconcilerDebuger from continually reporting
// errors when debug level isn't initialized
Logger log = Logger.getLogger(XtextReconciler.class);
log.setLevel(Level.WARN);
}
项目:sadlos2
文件:JenaUiModule.java
public JenaUiModule(AbstractUIPlugin plugin) {
super(plugin);
IOConsoleOutputStream iocos = SadlConsole.getOutputStream(MessageType.INFO);
System.setOut(new PrintStream(iocos));
System.setErr(new PrintStream(SadlConsole.getOutputStream(MessageType.ERROR)));
// this is to prevent XtextReconcilerDebuger from continually reporting errors when debug level isn't initialized
Logger log = Logger.getLogger(XtextReconciler.class);
log.setLevel(Level.WARN);
}
项目:karaf-eik
文件:KarafRemoteConsole.java
private void writeTo(final IOConsoleOutputStream outputStream, final String message) {
try {
outputStream.write(message);
outputStream.flush();
} catch (final IOException e) {
// Do nothing
}
}
项目:antlr4ide
文件:DefaultConsole.java
@Override
protected void append(LoggingEvent logEvent) {
final String message = logEvent.getRenderedMessage();
final Level level = logEvent.getLevel();
final String streamId = getStreamId(level);
final Display display = Display.getDefault();
final Thread thread = display.getThread();
Thread _currentThread = Thread.currentThread();
final boolean uiThread = Objects.equal(thread, _currentThread);
final Runnable _function = new Runnable() {
@Override
public void run() {
try {
final IOConsole console = AntlrConsoleFactory.getConsole();
final IOConsoleOutputStream stream = console
.newOutputStream();
final ConsoleColorProvider colorProvider = new ConsoleColorProvider();
final Color color = colorProvider.getColor(streamId);
stream.setColor(color);
stream.setActivateOnWrite(true);
stream.write((message + "\n"));
stream.close();
} catch (Throwable ex) {
ex.printStackTrace();
}
}
};
final Runnable printTask = _function;
if (uiThread) {
printTask.run();
} else {
display.syncExec(printTask);
}
}
项目:Pydev
文件:ScriptOutput.java
/**
* Constructor - Uses the properties from the JyScriptingPreferencesPage to know if we should write to
* the console or not
*
* @param color the color of the output written
*/
public ScriptOutput(ICallback0<IOConsoleOutputStream> outputStream) {
this(outputStream, JyScriptingPreferencesPage.getShowScriptingOutput());
IPropertyChangeListener listener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
writeToConsole = JyScriptingPreferencesPage.getShowScriptingOutput();
}
};
JythonPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(listener);
}
项目:Pydev
文件:ScriptOutput.java
/**
* OutputStream interface
*/
@Override
public void write(int b) throws IOException {
if (writeToConsole) {
IOConsoleOutputStream out = getOutputStream();
out.write(b);
}
}