本文整理汇总了Java中org.eclipse.ui.console.IOConsoleOutputStream类的典型用法代码示例。如果您正苦于以下问题:Java IOConsoleOutputStream类的具体用法?Java IOConsoleOutputStream怎么用?Java IOConsoleOutputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IOConsoleOutputStream类属于org.eclipse.ui.console包,在下文中一共展示了IOConsoleOutputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: println
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
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);
}
示例2: run
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
@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();
}
}
示例3: write
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
/**
* 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);
}
}
}
示例4: write
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
/**
* 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);
}
}
}
示例5: initialiseStreams
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
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);
}
}
}
示例6: applyTheme
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
/**
* 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);
}
示例7: showState
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
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("### - ###");
}
}
示例8: printMessage
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
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();
}
}
}
示例9: write
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
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);
}
}
示例10: getConsoleOutputStream
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
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;
}
}
示例11: initializeIO
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
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);
}
示例12: run
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
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();
}
示例13: redirectOutputToConsole
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
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();
}
示例14: safePrint
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
/** 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();
}
}
示例15: changeColor
import org.eclipse.ui.console.IOConsoleOutputStream; //导入依赖的package包/类
/**
* 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);
}
}