Author: koen.aers(a)jboss.com
Date: 2011-02-08 05:21:51 -0500 (Tue, 08 Feb 2011)
New Revision: 29058
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/Console.java
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsoleInputStream.java
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartition.java
Log:
cleanup
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/Console.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/Console.java 2011-02-07
22:23:02 UTC (rev 29057)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/Console.java 2011-02-08
10:21:51 UTC (rev 29058)
@@ -46,7 +46,7 @@
}
partitioner = new ConsolePartitioner(inputStream, this);
partitioner.connect(getDocument());
- inputStream.setColor(ColorManager.getInstance().getColor(INPUT_STREAM_RGB));
+// inputStream.setColor(ColorManager.getInstance().getColor(INPUT_STREAM_RGB));
connect();
}
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsoleInputStream.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsoleInputStream.java 2011-02-07
22:23:02 UTC (rev 29057)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsoleInputStream.java 2011-02-08
10:21:51 UTC (rev 29058)
@@ -2,25 +2,15 @@
import java.io.IOException;
import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.ui.console.IConsoleConstants;
-
public class ConsoleInputStream extends InputStream {
- private byte[] input = new byte[100];
- private int inPointer = 0;
+ private byte[] input = new byte[0];
private int outPointer = 0;
private int size = 0;
private boolean eofSent = false;
private boolean closed = false;
private Console console;
- private Color color;
- private int fontStyle = SWT.NORMAL;
-
- private char c = (char)-1;
ConsoleInputStream(Console console) {
this.console = console;
@@ -43,7 +33,6 @@
private void waitForData() {
while (size == 0 && !closed) {
-// while (c != -1 && !closed) {
try {
wait();
} catch (InterruptedException e) {}
@@ -51,90 +40,21 @@
}
public synchronized void appendData(String text) {
- String encoding = console.getEncoding();
- byte[] newData;
- if (encoding!=null)
- try {
- newData = text.getBytes(encoding);
- } catch (UnsupportedEncodingException e) {
- newData = text.getBytes();
- }
- else
- newData = text.getBytes();
-
- while(input.length-size < newData.length) {
- growArray();
- }
-
- if (size == 0) { //inPointer == outPointer
- System.arraycopy(newData, 0, input, 0, newData.length);
- inPointer = newData.length;
- size = newData.length;
- outPointer = 0;
- } else if (inPointer < outPointer || input.length - inPointer >
newData.length) {
- System.arraycopy(newData, 0, input, inPointer, newData.length);
- inPointer += newData.length;
- size += newData.length;
- } else {
- System.arraycopy(newData, 0, input, inPointer, input.length-inPointer);
- System.arraycopy(newData, input.length-inPointer, input, 0,
newData.length-(input.length-inPointer));
- inPointer = newData.length-(input.length-inPointer);
- size += newData.length;
- }
-
- if (inPointer == input.length) {
- inPointer = 0;
- }
+ input = text.getBytes();
+ size = text.length();
+ outPointer = 0;
notifyAll();
}
- private void growArray() {
- byte[] newInput = new byte[input.length+1024];
- if (outPointer < inPointer) {
- System.arraycopy(input, outPointer, newInput, 0, size);
- } else {
- System.arraycopy(input, outPointer, newInput, 0, input.length-outPointer);
- System.arraycopy(input, 0, newInput, input.length-outPointer, inPointer);
- }
- outPointer = 0;
- inPointer = size;
- input = newInput;
- newInput = null;
- }
-
- public int getFontStyle() {
- return fontStyle;
- }
-
- public void setFontStyle(int newFontStyle) {
- if (newFontStyle != fontStyle) {
- int old = fontStyle;
- fontStyle = newFontStyle;
- console.firePropertyChange(this, IConsoleConstants.P_FONT_STYLE, new
Integer(old), new Integer(fontStyle));
- }
- }
-
- public void setColor(Color newColor) {
- Color old = color;
- if (old == null || !old.equals(newColor)) {
- color = newColor;
- console.firePropertyChange(this, IConsoleConstants.P_STREAM_COLOR, old,
newColor);
- }
- }
-
- public Color getColor() {
- return color;
- }
-
public int available() throws IOException {
if (closed && eofSent) {
- throw new IOException("Input Stream Closed"); //$NON-NLS-1$
+ throw new IOException("Input Stream Closed");
} else if (size == 0) {
if (!eofSent) {
eofSent = true;
return -1;
}
- throw new IOException("Input Stream Closed"); //$NON-NLS-1$
+ throw new IOException("Input Stream Closed");
}
return size;
@@ -142,7 +62,7 @@
public synchronized void close() throws IOException {
if(closed) {
- throw new IOException("Input Stream Closed"); //$NON-NLS-1$
+ throw new IOException("Input Stream Closed");
}
closed = true;
notifyAll();
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartition.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartition.java 2011-02-07
22:23:02 UTC (rev 29057)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartition.java 2011-02-08
10:21:51 UTC (rev 29058)
@@ -129,7 +129,7 @@
* of this partition in a viewer.
*/
public StyleRange getStyleRange(int rangeOffset, int rangeLength) {
- return new StyleRange(rangeOffset, rangeLength, getColor(), null,
getFontStyle());
+ return new StyleRange(rangeOffset, rangeLength, null, null);
}
/**
@@ -139,12 +139,12 @@
*
* @return the font of one of the backing streams
*/
- private int getFontStyle() {
- if (type.equals(INPUT_PARTITION_TYPE)) {
- return inputStream.getFontStyle();
- }
- return outputStream.getFontStyle();
- }
+// private int getFontStyle() {
+// if (type.equals(INPUT_PARTITION_TYPE)) {
+// return inputStream.getFontStyle();
+// }
+// return outputStream.getFontStyle();
+// }
/**
* Returns the colour of the input stream if the type of the partition
@@ -153,12 +153,12 @@
*
* @return the colour of one of the backing streams
*/
- public Color getColor() {
- if (type.equals(INPUT_PARTITION_TYPE)) {
- return inputStream.getColor();
- }
- return outputStream.getColor();
- }
+// public Color getColor() {
+// if (type.equals(INPUT_PARTITION_TYPE)) {
+// return inputStream.getColor();
+// }
+// return outputStream.getColor();
+// }
/**
* Returns if this partition is read-only.