Author: koen.aers(a)jboss.com
Date: 2011-07-07 04:10:02 -0400 (Thu, 07 Jul 2011)
New Revision: 32686
Removed:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/console/ConsoleOutputStream.java
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/console/StreamListener.java
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/console/Console.java
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartition.java
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartitioner.java
Log:
get rid of unnecessary StreamListener and ConsoleOutputStream classes
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/console/Console.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/console/Console.java 2011-07-07
07:36:30 UTC (rev 32685)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/console/Console.java 2011-07-07
08:10:02 UTC (rev 32686)
@@ -5,6 +5,7 @@
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.IStreamListener;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.IStreamMonitor;
import org.eclipse.debug.core.model.IStreamsProxy;
@@ -20,9 +21,8 @@
private ConsolePartitioner partitioner;
private ConsoleInputStream inputStream;
- private ConsoleOutputStream outputStream;
private IProcess process = null;
- private StreamListener outputStreamListener;
+ private IStreamListener outputStreamListener;
public Console(IProcess process) {
@@ -44,14 +44,16 @@
}
private void initOutputStream() {
- outputStream = new ConsoleOutputStream(this);
- IStreamMonitor streamMonitor = getOutputStreamMonitor();
- if (streamMonitor != null) {
- synchronized(streamMonitor) {
- outputStreamListener = new StreamListener(outputStream);
- streamMonitor.addListener(outputStreamListener);
- }
- }
+ outputStreamListener = new IStreamListener() {
+ @Override
+ public void streamAppended(String text, IStreamMonitor monitor) {
+ appendString(text);
+ }
+ };
+ IStreamMonitor streamMonitor = getOutputStreamMonitor();
+ synchronized(streamMonitor) {
+ streamMonitor.addListener(outputStreamListener);
+ }
}
private IStreamMonitor getOutputStreamMonitor() {
@@ -97,8 +99,6 @@
private synchronized void closeStreams() {
try {
inputStream.close();
- outputStream.close();
-// partitioner.streamsClosed();
} catch (IOException e) {}
}
@@ -112,7 +112,6 @@
}
}
outputStreamListener = null;
- outputStream = null;
inputStream = null;
}
Deleted:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/console/ConsoleOutputStream.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/console/ConsoleOutputStream.java 2011-07-07
07:36:30 UTC (rev 32685)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/console/ConsoleOutputStream.java 2011-07-07
08:10:02 UTC (rev 32686)
@@ -1,59 +0,0 @@
-package org.jboss.tools.forge.console;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-public class ConsoleOutputStream extends OutputStream {
-
- private boolean closed = false;
- private Console console;
-
- ConsoleOutputStream(Console console) {
- this.console = console;
- }
-
- public synchronized boolean isClosed() {
- return closed;
- }
-
- public synchronized void close() throws IOException {
- if(closed) {
- throw new IOException("Output Stream is closed");
- }
- closed = true;
- console = null;
- }
-
- public void flush() throws IOException {
- if(closed) {
- throw new IOException("Output Stream is closed");
- }
- }
-
- public void write(byte[] b, int off, int len) throws IOException {
- if(closed) {
- throw new IOException("Output Stream is closed");
- }
- notifyPartitioner(new String(b, off, len));
- }
-
- public void write(byte[] b) throws IOException {
- write(b, 0, b.length);
- }
-
- public void write(int b) throws IOException {
- write(new byte[] {(byte)b}, 0, 1);
- }
-
- public synchronized void write(String str) throws IOException {
- if(closed) {
- throw new IOException("Output Stream is closed");
- }
- notifyPartitioner(str);
- }
-
- private void notifyPartitioner(String str) throws IOException {
- console.appendString(str);
- }
-
-}
Deleted:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/console/StreamListener.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/console/StreamListener.java 2011-07-07
07:36:30 UTC (rev 32685)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/console/StreamListener.java 2011-07-07
08:10:02 UTC (rev 32686)
@@ -1,44 +0,0 @@
-package org.jboss.tools.forge.console;
-
-import java.io.IOException;
-
-import org.eclipse.debug.core.IStreamListener;
-import org.eclipse.debug.core.model.IStreamMonitor;
-import org.jboss.tools.forge.ForgeUIPlugin;
-
-class StreamListener implements IStreamListener {
-
- private ConsoleOutputStream stream;
- private StringBuffer buffer = new StringBuffer();
- private boolean creatingProject = false;
-
- StreamListener(ConsoleOutputStream stream) {
- this.stream = stream;
- }
-
- public void streamAppended(String text, IStreamMonitor streamMonitor) {
- try {
- buffer.append(text);
- if (buffer.indexOf("new-project") != -1) {
- creatingProject = true;
- }
- stream.write(text);
- if (creatingProject
- && (text.indexOf('\n') != -1)
- && (buffer.indexOf("Created project [") != -1)
- && (buffer.indexOf("] in new working directory [") !=
-1)) {
- postProcessCreatedProject(buffer.toString());
- creatingProject = false;
- buffer = new StringBuffer();
- }
- } catch (IOException e) {
- ForgeUIPlugin.log(e);
- }
- }
-
- private void postProcessCreatedProject(String command) {
- System.out.println("processing created project: \n" + command);
- }
-
-}
-
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartition.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartition.java 2011-07-07
07:36:30 UTC (rev 32685)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartition.java 2011-07-07
08:10:02 UTC (rev 32686)
@@ -1,10 +1,11 @@
package org.jboss.tools.forge.old;
+import java.io.OutputStream;
+
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.ui.console.ConsolePlugin;
import org.jboss.tools.forge.console.ConsoleInputStream;
-import org.jboss.tools.forge.console.ConsoleOutputStream;
public class ConsolePartition implements ITypedRegion {
public static final String OUTPUT_PARTITION_TYPE = ConsolePlugin.getUniqueIdentifier() +
".io_console_output_partition_type"; //$NON-NLS-1$
@@ -25,7 +26,7 @@
/**
* Only one of inputStream or outputStream will be null depending on the partitions
type.
*/
- private ConsoleOutputStream outputStream;
+ private OutputStream outputStream;
@SuppressWarnings("unused")
private ConsoleInputStream inputStream;
private int length;
@@ -33,7 +34,7 @@
/**
* Creates a new partition to contain output to console.
*/
- public ConsolePartition(ConsoleOutputStream outputStream, int length) {
+ public ConsolePartition(OutputStream outputStream, int length) {
this.outputStream = outputStream;
this.length = length;
this.type = OUTPUT_PARTITION_TYPE;
@@ -160,7 +161,7 @@
*
* @return the underlying output stream
*/
- ConsoleOutputStream getStream() {
+ OutputStream getStream() {
return outputStream;
}
}
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartitioner.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartitioner.java 2011-07-07
07:36:30 UTC (rev 32685)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/old/ConsolePartitioner.java 2011-07-07
08:10:02 UTC (rev 32686)
@@ -1,6 +1,7 @@
package org.jboss.tools.forge.old;
import java.io.IOException;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -26,7 +27,6 @@
import org.eclipse.ui.progress.WorkbenchJob;
import org.jboss.tools.forge.console.Console;
import org.jboss.tools.forge.console.ConsoleInputStream;
-import org.jboss.tools.forge.console.ConsoleOutputStream;
/**
* Partitions an IOConsole's document
@@ -444,7 +444,7 @@
* @param stream The stream that was written to.
* @param s The string that should be appended to the document.
*/
- public void streamAppended(ConsoleOutputStream stream, String s) throws IOException {
+ public void streamAppended(OutputStream stream, String s) throws IOException {
System.out.println("streamAppended : " + s);
if (s.indexOf('\t') != -1) System.out.println("Got a tab!");
if (document == null) {
@@ -485,9 +485,9 @@
*/
private class PendingPartition {
StringBuffer text = new StringBuffer(8192);
- ConsoleOutputStream stream;
+ OutputStream stream;
- PendingPartition(ConsoleOutputStream stream, String text) {
+ PendingPartition(OutputStream stream, String text) {
this.stream = stream;
if (text != null) {
append(text);