Displaying an Eclipse MessageDialog in a Non-UI Thread
If you are executing code in the current Non-UI thread, then you can ask the Display to render a model dialog box with the following code:
/**
* Show an information dialog box.
*/
public void showInformation(final String title, final String message) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openInformation(null, title, message);
}
});
}
ErrorDialog the error message-displaying equivalent of MessageDialog.
IF you were in a UI thread, you could achieve a dialog box with just this:
boolean result = MessageDialog.openConfirm(PlatformUI
.getWorkbench().getActiveWorkbenchWindow()
.getShell(), title, message);