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.
now I know where the counter readings reset popup comes from 🙂