Jayant
Jayant

Reputation: 539

Open modal JFace Dialog on top of another modal JFace Dialog

I have a custom JFace Dialog (called PropertyDialog) which extends the FormDialog. I would like to open a modal Message Dialog over the PropertryDialog as soon as it opens, to display a message to the user.

How could this be accomplished? Would I have to override the open() method? Note that it is required that the PropertyDialog.open() does not return until a button is pressed on the button bar.

Thanks for your help.

Upvotes: 1

Views: 618

Answers (1)

greg-449
greg-449

Reputation: 111142

You can do this by displaying the message at the end of the createContents method, like this:

  @Override
  protected Control createContents(final Composite parent)
  {
    final Control control = super.createContents(parent);

    parent.getDisplay().asyncExec(new Runnable() {
      public void run()
      {
        MessageDialog.openInformation(getShell(), "title", "message");
      }
    });

    return control;
  }

You need to use Display.asyncExec so that the dialog is not displayed until the parent dialog has been displayed.

Upvotes: 3

Related Questions