edit this page - page history - about editing

Displaying an Eclipse MessageDialog in a Non-UI Thread

Eclipse

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);

Categories: Eclipse | Java
edit this page - what links to here? - page history - top
Last edited by jevon jevon 100 months ago