Skip to content

Commit

Permalink
JBIDE-17492: Added changes in UIOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi authored and koentsje committed Sep 12, 2014
1 parent cc15e8c commit 5e3be31
Showing 1 changed file with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

/**
* Eclipse implementation of {@link UIProvider}
*
*
* @author <a href="ggastald@redhat.com">George Gastaldi</a>
*/
public class ForgeUIProvider implements UIProvider, UIOutput {

private MessageConsole forgeConsole;
private PrintStream forgeConsoleOutputStream;
private PrintStream forgeConsoleErrorStream;
Expand All @@ -38,7 +38,7 @@ private MessageConsole getForgeConsole() {
}
return forgeConsole;
}

private String getName() {
return "Forge " + FurnaceRuntime.INSTANCE.getVersion() + " Console";
}
Expand Down Expand Up @@ -70,30 +70,57 @@ public UIOutput getOutput() {
@Override
public PrintStream out() {
if (forgeConsoleOutputStream == null) {
forgeConsoleOutputStream = new PrintStream(getForgeConsole().newMessageStream(), true);
forgeConsoleOutputStream = new PrintStream(getForgeConsole()
.newMessageStream(), true);
}
return forgeConsoleOutputStream;
}

@Override
public PrintStream err() {
if (forgeConsoleErrorStream == null) {
MessageConsoleStream messageConsoleStream = getForgeConsole().newMessageStream();
MessageConsoleStream messageConsoleStream = getForgeConsole()
.newMessageStream();
messageConsoleStream.setColor(getRed());
forgeConsoleErrorStream = new PrintStream(messageConsoleStream, true);
forgeConsoleErrorStream = new PrintStream(messageConsoleStream,
true);
}
return forgeConsoleErrorStream;
}

private Color getRed() {
if (red == null) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
red = Display.getDefault().getSystemColor(SWT.COLOR_RED);
}
}
});
}
return red;
}

@Override
public void error(PrintStream writer, String message) {
writer.print("[ERROR] ");
writer.println(message);
}

@Override
public void success(PrintStream writer, String message) {
writer.print("[SUCCESS] ");
writer.println(message);
}

@Override
public void info(PrintStream writer, String message) {
writer.print("[INFO] ");
writer.println(message);
}

@Override
public void warn(PrintStream writer, String message) {
writer.print("[WARNING] ");
writer.println(message);
}
}

0 comments on commit 5e3be31

Please sign in to comment.