Skip to content

Commit

Permalink
Bugfix: Run showMessage via syncExec() so as not to do invalid access…
Browse files Browse the repository at this point in the history
… to the UI thread from background jobs
  • Loading branch information
samuell committed Nov 19, 2013
1 parent b6b37eb commit 578bf01
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.sh
@@ -1,4 +1,4 @@
/usr/bin/eclipse \
~/opt/eclipse/eclipse \
-nosplash \
-application org.eclipse.equinox.p2.director \
-repository http://update.bioclipse.net,http://devel.bioclipse.net,http://pele.farmbio.uu.se/jenkins/job/bioclipse.hpc/lastSuccessfulBuild/artifact/buckminster.output/net.bioclipse.hpc_site_2.5.0-eclipse.feature/site.p2/,http://download.eclipse.org/tm/updates/3.4/,http://download.eclipse.org/tools/orbit/downloads/drops/R20130827064939/repository/,http://download.eclipse.org/eclipse/updates/3.8 \
Expand Down
Expand Up @@ -297,22 +297,32 @@ private ProjInfoView getProjInfoView() {
}

/* ------------ Utility methods ------------ */

public void showErrorMessage(String title, String message) {
MessageBox messageDialog = new MessageBox(getShell(), SWT.ERROR);
messageDialog.setText(title);
messageDialog.setMessage(message);
int returnCode = messageDialog.open();
log.error("Error opening MessageBox: " + returnCode);
this.showMessage(title, message, SWT.ERROR);
}

public void showInfoMessage(String title, String message) {
MessageBox messageDialog = new MessageBox(getShell(),
SWT.ICON_INFORMATION);
messageDialog.setText(title);
messageDialog.setMessage(message);
int returnCode = messageDialog.open();
System.out.println(returnCode);
this.showMessage(title, message, SWT.ICON_INFORMATION);
}

public void showMessage(String title, String message, int iconType) {
class MessageDialogTask implements Runnable {
String title;
String message;
int iconType;
// Constructor
MessageDialogTask(String t, String m, int i) { title = t; message = m; iconType = i; }
public void run() {
MessageBox messageDialog = new MessageBox(getShell(), iconType);
messageDialog.setText(title);
messageDialog.setMessage(message);
int returnCode = messageDialog.open();
log.error("Error opening MessageBox: " + returnCode);
}
}
// We need to run via syncExec in order be call UI elements from background jobs
Display.getDefault().syncExec(new MessageDialogTask(title, message, iconType));
}

/**
Expand Down

0 comments on commit 578bf01

Please sign in to comment.