Author: koen.aers(a)jboss.com
Date: 2011-02-15 16:46:09 -0500 (Tue, 15 Feb 2011)
New Revision: 29163
Added:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/MyPartitioner.java
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/ConsoleOutputStream.java
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartitioner.java
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleText.java
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleViewer.java
Log:
tab completion and backspace are working
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-15
21:09:03 UTC (rev 29162)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/Console.java 2011-02-15
21:46:09 UTC (rev 29163)
@@ -8,6 +8,8 @@
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.IStreamMonitor;
import org.eclipse.debug.core.model.IStreamsProxy;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.console.IConsoleDocumentPartitioner;
import org.eclipse.ui.console.IConsoleView;
import org.eclipse.ui.console.TextConsole;
@@ -15,7 +17,7 @@
public class Console extends TextConsole implements IDebugEventSetListener {
- private ConsolePartitioner partitioner;
+ private MyPartitioner partitioner;
private ConsoleInputStream inputStream;
private ConsoleOutputStream outputStream;
private IProcess process = null;
@@ -36,7 +38,7 @@
}
private void initOutputStream() {
- outputStream = new ConsoleOutputStream(partitioner);
+ outputStream = new ConsoleOutputStream(this);
IStreamMonitor streamMonitor = getOutputStreamMonitor();
if (streamMonitor != null) {
synchronized(streamMonitor) {
@@ -62,7 +64,7 @@
}
private void initPartitioner() {
- partitioner = new ConsolePartitioner(inputStream, this);
+ partitioner = new MyPartitioner();
partitioner.connect(getDocument());
}
@@ -90,7 +92,7 @@
try {
inputStream.close();
outputStream.close();
- partitioner.streamsClosed();
+// partitioner.streamsClosed();
} catch (IOException e) {}
}
@@ -128,5 +130,22 @@
DebugPlugin.getDefault().addDebugEventListener(this);
}
}
+
+ public void appendString(final String str) {
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ for (int i = 0; i < str.length(); i++) {
+ if (str.charAt(i) == '\b') {
+ getDocument().replace(getDocument().getLength() - 1, 1, "");
+ } else {
+ getDocument().replace(getDocument().getLength(), 0, str.substring(i, i + 1));
+ }
+ }
+ } catch (BadLocationException e) {}
+ }
+ });
+ }
}
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsoleOutputStream.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsoleOutputStream.java 2011-02-15
21:09:03 UTC (rev 29162)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsoleOutputStream.java 2011-02-15
21:46:09 UTC (rev 29163)
@@ -6,10 +6,10 @@
public class ConsoleOutputStream extends OutputStream {
private boolean closed = false;
- private ConsolePartitioner partitioner;
+ private Console console;
- ConsoleOutputStream(ConsolePartitioner partitioner) {
- this.partitioner = partitioner;
+ ConsoleOutputStream(Console console) {
+ this.console = console;
}
public synchronized boolean isClosed() {
@@ -21,7 +21,7 @@
throw new IOException("Output Stream is closed");
}
closed = true;
- partitioner = null;
+ console = null;
}
public void flush() throws IOException {
@@ -34,7 +34,7 @@
if(closed) {
throw new IOException("Output Stream is closed");
}
- notifyParitioner(new String(b, off, len));
+ notifyPartitioner(new String(b, off, len));
}
public void write(byte[] b) throws IOException {
@@ -49,18 +49,11 @@
if(closed) {
throw new IOException("Output Stream is closed");
}
- notifyParitioner(str);
+ notifyPartitioner(str);
}
- private void notifyParitioner(String str) throws IOException {
- try {
- partitioner.streamAppended(this, str);
- } catch (IOException e) {
- if (!closed) {
- close();
- }
- throw e;
- }
+ private void notifyPartitioner(String str) throws IOException {
+ console.appendString(str);
}
}
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartitioner.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartitioner.java 2011-02-15
21:09:03 UTC (rev 29162)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartitioner.java 2011-02-15
21:46:09 UTC (rev 29163)
@@ -89,7 +89,7 @@
private int fBuffer;
- public ConsolePartitioner(ConsoleInputStream inputStream, Console console) {
+ private ConsolePartitioner(ConsoleInputStream inputStream, Console console) {
this.inputStream = inputStream;
this.console = console;
trimJob.setRule(console.getSchedulingRule());
Added:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/MyPartitioner.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/MyPartitioner.java
(rev 0)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/MyPartitioner.java 2011-02-15
21:46:09 UTC (rev 29163)
@@ -0,0 +1,70 @@
+package org.jboss.tools.seam.forge.console;
+
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.ui.console.IConsoleDocumentPartitioner;
+
+public class MyPartitioner implements IConsoleDocumentPartitioner {
+
+ @Override
+ public void connect(IDocument document) {
+ document.setDocumentPartitioner(this);
+ }
+
+ @Override
+ public void disconnect() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void documentAboutToBeChanged(DocumentEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean documentChanged(DocumentEvent event) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public String[] getLegalContentTypes() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getContentType(int offset) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ITypedRegion[] computePartitioning(int offset, int length) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ITypedRegion getPartition(int offset) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isReadOnly(int offset) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public StyleRange[] getStyleRanges(int offset, int length) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/MyPartitioner.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleText.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleText.java 2011-02-15
21:09:03 UTC (rev 29162)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleText.java 2011-02-15
21:46:09 UTC (rev 29163)
@@ -13,29 +13,28 @@
public void invokeAction(int action) {
checkWidget();
switch (action) {
- // Navigation
case ST.LINE_UP:
doLineUp();
break;
case ST.LINE_DOWN:
doLineDown();
break;
- case ST.DELETE_PREVIOUS:
- doDeletePrevious();
- break;
+// case ST.DELETE_PREVIOUS:
+// doDeletePrevious();
+// break;
default:
super.invokeAction(action);
}
}
private void doLineUp() {
- System.out.println("Line up");
+// System.out.println("Line up");
}
private void doLineDown() {
- System.out.println("Line down");
+// System.out.println("Line down");
}
- private void doDeletePrevious() {
- System.out.println("Backspace");
- }
+// private void doDeletePrevious() {
+// System.out.println("Backspace");
+// }
}
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleViewer.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleViewer.java 2011-02-15
21:09:03 UTC (rev 29162)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleViewer.java 2011-02-15
21:46:09 UTC (rev 29163)
@@ -15,8 +15,8 @@
public class ConsoleViewer extends TextConsoleViewer {
private static String BACKSPACE = new String(new byte[] {'\b'});
- private static String UP_ARROW = new String(new byte[] { 0x1b, 0x5b, 0x41 });
- private static String DOWN_ARROW = new String(new byte[] { 0x1b, 0x5b, 0x42 });
+// private static String UP_ARROW = new String(new byte[] { 0x1b, 0x5b, 0x41 });
+// private static String DOWN_ARROW = new String(new byte[] { 0x1b, 0x5b, 0x42 });
private Console console = null;
@@ -32,17 +32,16 @@
}
private void handleBackspace() {
- System.out.println("handle backspace");
-// console.getInputStream().appendData(BACKSPACE);
+ console.getInputStream().appendData(BACKSPACE);
}
private void handleArrowUp() {
- System.out.println("handle arrow up");
+// System.out.println("handle arrow up");
// console.getInputStream().appendData(UP_ARROW);
}
private void handleArrowDown() {
- System.out.println("handle arrow down");
+// System.out.println("handle arrow down");
// console.getInputStream().appendData(DOWN_ARROW);
}