Enhanced RCP: Usage of TitleAreDialogSupport


Eclipse Databinding comes with many utility classes and one of them is TitleAreaDialogSupport which can be used to show validation errors when running in an TitleAreaDialog.


But the default implementation has some missing features:

  • Once a validation error is shown the default message is not coming back when correcting them
  • The Ok-Button does not get disabled in case of validation errors

So we have to enhance it a bit by subclassing:

TitleAreaDialogSupport.create(this, dbc).setValidationMessageProvider(new ValidationMessageProvider() {
  @Override
  public String getMessage(ValidationStatusProvider statusProvider) {
    if (statusProvider == null) {
      return "Neuanlage/Bearbeitung einer Abteilung";
    }
    return super.getMessage(statusProvider);
  }
			
  @Override
  public int getMessageType(ValidationStatusProvider statusProvider) {
    int type = super.getMessageType(statusProvider);
    if( getButton(IDialogConstants.OK_ID) != null ) {
      getButton(IDialogConstants.OK_ID).setEnabled(type != IMessageProvider.ERROR);
    }
    return type;
  }
});

There’s already a feature request for this open but it is not fixed yet.

Advertisement
This entry was posted in Enhanced RCP. Bookmark the permalink.

1 Response to Enhanced RCP: Usage of TitleAreDialogSupport

  1. daudo says:

    now I know where the counter readings reset popup comes from 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.