Skip to content

Commit

Permalink
make sure DelegatingDocument performs updates on the UI trhead
Browse files Browse the repository at this point in the history
  • Loading branch information
koentsje committed Mar 7, 2014
1 parent 3157a00 commit 07a6fe6
Showing 1 changed file with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jboss.tools.aesh.ui.document;

import org.eclipse.jface.text.BadLocationException;
import org.eclipse.swt.widgets.Display;
import org.jboss.tools.aesh.core.ansi.StyleRange;
import org.jboss.tools.aesh.core.ansi.Document;
import org.jboss.tools.aesh.ui.AeshUIPlugin;
Expand Down Expand Up @@ -53,12 +54,23 @@ public int getLineLength(int line) {
}

@Override
public void moveCursorTo(int offset) {
document.moveCursorTo(offset);
public void moveCursorTo(final int offset) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
document.moveCursorTo(offset);
}
});
}

@Override
public void reset() {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
document.reset();
}
});
document.reset();
}

Expand All @@ -68,17 +80,27 @@ public int getLength() {
}

@Override
public void replace(int pos, int length, String text) {
try {
document.replace(pos, length, text);
} catch (BadLocationException e) {
AeshUIPlugin.log(e);
}
public void replace(final int pos, final int length, final String text) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
try {
document.replace(pos, length, text);
} catch (BadLocationException e) {
AeshUIPlugin.log(e);
}
}
});
}

@Override
public void restoreCursor() {
document.restoreCursor();
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
document.restoreCursor();
}
});
}

@Override
Expand Down

0 comments on commit 07a6fe6

Please sign in to comment.