diff options
author | Simon Rettberg | 2015-07-11 16:49:52 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-07-11 16:49:52 +0200 |
commit | a8edfc241edd1835edcfbef48e6575f7560121b6 (patch) | |
tree | b0b233f4919600b99be56099a450d80c503677a3 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java | |
parent | Merge branch 'v1.1' of git.openslx.org:openslx-ng/tutor-module into v1.1 (diff) | |
download | tutor-module-a8edfc241edd1835edcfbef48e6575f7560121b6.tar.gz tutor-module-a8edfc241edd1835edcfbef48e6575f7560121b6.tar.xz tutor-module-a8edfc241edd1835edcfbef48e6575f7560121b6.zip |
[client] Add helper methods for executing stuff in the gui thread from other threads.
Use those for error callbacks that want to display messages, as we can't know
which context they're fired in.
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java index 1bdb3220..080d21ed 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java @@ -17,6 +17,7 @@ import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.openslx.dozmod.Config; import org.openslx.dozmod.gui.helper.Gui; +import org.openslx.dozmod.gui.helper.Gui.GuiCallable; import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.gui.window.DisclaimerWindow; import org.openslx.dozmod.gui.window.LoginWindow; @@ -91,17 +92,27 @@ public abstract class MainWindow { // Set up thrift error message displaying ThriftManager.setErrorCallback(new ErrorCallback() { @Override - public boolean thriftError(int failCount, String method, Throwable t) { + public boolean thriftError(int failCount, String method, final Throwable t) { // Ask user if we should retry - return showMessageBox(mainShell, THRIFT_CONNECTION_ERROR, MessageType.ERROR_RETRY, LOGGER, t); + return Gui.syncExec(new GuiCallable<Boolean>() { + @Override + public Boolean run() { + return showMessageBox(mainShell, THRIFT_CONNECTION_ERROR, MessageType.ERROR_RETRY, LOGGER, t); + } + }); } }); // Same for config errors Config.setErrorCallback(new Config.ErrorCallback() { @Override - public void writeError(Throwable t) { - showMessageBox("Konnte Programmeinstellungen nicht speichern", MessageType.WARNING, LOGGER, t); + public void writeError(final Throwable t) { + Gui.asyncExec(new Runnable() { + @Override + public void run() { + showMessageBox("Konnte Programmeinstellungen nicht speichern", MessageType.WARNING, LOGGER, t); + } + }); } }); |