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.

About these ads

One Response to “Enhanced RCP: Usage of TitleAreDialogSupport”

  1. 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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 665 other followers

%d bloggers like this: