Reputation: 539
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
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