|
Re: TitleAreaDialog using databinding validation to disable the OK button [message #647721 is a reply to message #647707] |
Sat, 08 January 2011 03:36 |
|
Hi,
It is fine if you are using TitleAreaDialog. You just have to add enabling and disabling of Ok button in case of validations. You can do one simple thing, and that is, adding ModifyListeners and then enabling and disabling okButton in it. For eg.
firstNameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
validate();
}
});
In validate() method, you can check for validation and if there is an invalid Text, you can do the following:-
setErrorMessage("Invalid Input");
okButton.setEnabled(false);
And if the text is valid, then:-
setErrorMessage(null);
okButton.setEnabled(true);
Hope this helps.
Regards,
Animesh
Regards,
Animesh
|
|
|
|
Re: TitleAreaDialog using databinding validation to disable the OK button [message #647768 is a reply to message #647707] |
Sat, 08 January 2011 18:06 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
http://tomsondev.bestsolution.at/2011/01/08/enhanced-rcp-usa ge-of-titlearedialogsupport/
Am 07.01.11 23:18, schrieb Martin:
> Hi Folks,
>
> I needed to create a few simple dialogs with text fields to allow users
> to input data. Examples are like inputing a Persons details like
> forename, surname, age, address etc. The dialogs just have Ok and
> Cancel buttons.
>
> Extending TitleAreaDialog I was able to create a dialog laid out as
> required, the validation I've done myself, disabling the OK button for
> erroneous data entries. Now I'd like to use JFace databinding on the
> dialog but have seen that the TitleAreaDialogSupport does not disable
> the OK button when a validation error occurs, it just shows up the error
> message.
>
> I have tried using a WizardDialog with one page and changing the name of
> the Finish button to OK. This works but is surely not the way to go for
> my simple common use case.
>
> I think it may be possible to extend TitleAreaDialogSupport to also
> disable the OK button. However the lack of OK button disablement on
> validation failure is such an obvious omission from
> TitleAreaDialogSupport that I think I'm missing the point somewhere.
> Maybe I should not be using TitleAreaDialog at all whenever validation
> is needed.
> This is such a common GUI use case I wanted to check that I'm not doing
> more work than necessary.
>
> thanks,
> Martin.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03093 seconds