1 package net.sourceforge.phpeclipse.externaltools;
3 import java.io.IOException;
4 import java.io.InputStream;
6 import org.eclipse.swt.graphics.Color;
7 import org.eclipse.ui.console.ConsolePlugin;
8 import org.eclipse.ui.console.IConsole;
9 import org.eclipse.ui.console.MessageConsole;
10 import org.eclipse.ui.console.MessageConsoleStream;
12 public class PHPConsole {
13 private MessageConsole myConsole;
15 private MessageConsoleStream stream;
17 private boolean hasMessages;
21 myConsole = new MessageConsole("PHPeclipse Console", null);
22 ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { myConsole });
23 ConsolePlugin.getDefault().getConsoleManager().showConsoleView(myConsole);
24 // layout.addView(IConsoleConstants.ID_CONSOLE_VIEW, IPageLayout.BOTTOM, .5f,IPageLayout.ID_EDITOR_AREA);
25 stream = myConsole.newMessageStream();
31 public Color getColor() {
32 return stream.getColor();
38 public MessageConsole getConsole() {
39 return stream.getConsole();
45 * @see java.lang.Object#hashCode()
47 public int hashCode() {
48 return stream.hashCode();
54 public void print(String message) {
56 stream.print(message);
62 public void println() {
70 public void println(String message) {
72 stream.println(message);
78 public void setColor(Color color) {
79 stream.setColor(color);
82 // public void reportError(String title, String message) {
84 // WikiEditorPlugin.getDefault().reportError(title, message);
88 // public void reportError() {
89 // reportError("Problems listed", "Open console view for problems log!");
92 * Creates a string buffer from the given input stream
94 public static String getStringFromStream(InputStream stream) throws IOException {
95 StringBuffer buffer = new StringBuffer();
96 byte[] b = new byte[100];
98 while (finished != -1) {
99 finished = stream.read(b);
100 if (finished != -1) {
101 String current = new String(b, 0, finished);
102 buffer.append(current);
105 return buffer.toString();