|
From: SVN by r. <sv...@ca...> - 2009-01-19 15:43:57
|
Author: roy
Date: 2009-01-19 16:43:49 +0100 (Mon, 19 Jan 2009)
New Revision: 361
Modified:
src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java
Log:
more thread handling
Modified: src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2009-01-19 14:26:56 UTC (rev 360)
+++ src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2009-01-19 15:43:49 UTC (rev 361)
@@ -158,7 +158,7 @@
SwingUtilities.invokeLater(eventThead);
}
- public void paintSlow(Screen screen) {
+ public void paintSlow(final Screen screen) {
int totalLineCount = 0;
StringBuilder newText = new StringBuilder();
for (CharSequence seq: new ArrayList<CharSequence>(screen.getScreenBuffer())) {
@@ -174,7 +174,7 @@
totalLineCount++;
}
}
- List<String> commandLines = formatCommandLines(screen.getShowPrompt()
+ final List<String> commandLines = formatCommandLines(screen.getShowPrompt()
, screen.getEmptyLine(),(List<CharSequence>) getCommand().getLines());
for (int i = 0; i < commandLines.size(); i++) {
CharSequence seq = commandLines.get(i);
@@ -187,20 +187,28 @@
if (totalLineCount > getScreenHeight()-1) {
totalLineCount = getScreenHeight()-1;
}
- String trimmed = trim(newText, screen.getPageUpCount());
- if (trimmed.startsWith(textComponent.getText())) {
- textComponent.append(trimmed.substring(textComponent.getText().length()));
- } else {
- textComponent.replaceRange(trimmed, 0, textComponent.getText().length());
- }
- Point cursorPos = screen.getCursorPosition();
- try {
- int start = textComponent.getLineStartOffset(totalLineCount - (commandLines.size() - cursorPos.y));
- textComponent.setCaretPosition(start + cursorPos.x + (Screen.PROMPT+" >").length());
- } catch(Exception e) {
- debug("ERROR: failed to calculate line end: "+ totalLineCount +"-"+ cursorPos.y +"/"+ getScreenHeight());
- }
- textComponent.draw();
+ final int lineCount = totalLineCount;
+ final String trimmed = trim(newText, screen.getPageUpCount());
+ Runnable r = new Runnable() {
+
+ public void run() {
+ if (trimmed.startsWith(textComponent.getText())) {
+ textComponent.append(trimmed.substring(textComponent.getText().length()));
+ } else {
+ textComponent.replaceRange(trimmed, 0, textComponent.getText().length());
+ }
+ Point cursorPos = screen.getCursorPosition();
+ try {
+ int start = textComponent.getLineStartOffset(lineCount - (commandLines.size() - cursorPos.y));
+ textComponent.setCaretPosition(start + cursorPos.x + (Screen.PROMPT+" >").length());
+ } catch(Exception e) {
+ debug("ERROR: failed to calculate line end: "+ lineCount +"-"+ cursorPos.y +"/"+ getScreenHeight());
+ }
+ textComponent.draw();
+ }
+
+ };
+ SwingUtilities.invokeLater(r);
}
@Override
|