JFace's MessageDialog fails in open() method

Viewed 86

I have a JFace application and want to do some work on startup. So I overrode the open method of the window.
But now I have the problem that in the case of a failure I can't display an error message because the shell is null at this time. And I have no idea to solve this problem.

public class MyExample extends ApplicationWindow {
  public MyExample() {
    super(null);
  }

  public void run() {
    setBlockOnOpen(true);
    open();
    Display.getCurrent().dispose();
  }

  @Override
  public int open() {
    // do some work
    if (...) {
      MessageDialog.openError(getShell(), "Error", "Error occured");
    }
    return super.open();
  }
}
1 Answers
Related