Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsValidating a custom field
https://www.eclipse.org/forums/index.php/mv/msg/488048/1060593/#msg_1060593
I was hoping to add some way of checking the currently selected number of days in a method like execValidateValue() after each change of selection and when clicking the ok button.
Is there an easy way to add this functionality without having to implement all of IValueField (which would be massive overkill in my case)? Ideally I would like the functionality to be caught by the form without having to add extra code to the form.
]]>Urs Beeli2013-05-27T08:27:29-00:00Re: Validating a custom field
https://www.eclipse.org/forums/index.php/mv/msg/488048/1060597/#msg_1060597
May you share with us some source code? We only need the relevant parts,
cut out the other parts.
]]>Ivan Motsch2013-05-27T08:52:16-00:00Re: Validating a custom field
https://www.eclipse.org/forums/index.php/mv/msg/488048/1060624/#msg_1060624
public abstract class AbstractTagesfilterField extends AbstractCustomField implements ITagesfilterField {
where ITagesfilterField defines a few setters/getters to access the selected days.
However, I think the solution to my problem is easier than I had anticipated. The only "loss" of my solution is that the validation is not executed automatically, but needs to be triggered explicitely in my field.
I've added a method validateValue() which evaluates the min/max limites (defined as configuration properties) and the currently selected number of days. Depending on the outcome it just calls clearErrorStatus()/setErrorStatus() on the field. This is enough to be taken into account when I press the OK button on the form, the only thing that remains is to also use this information to graphically indicate the error status on the control itself. To handle dynamic changes, I am calling validateValue() in my UIFacade whenever a user interaction (mouse click) effects a change in selected days.
Below you see the result of all this (left side: invalid selection, right side: valid selection):
]]>Urs Beeli2013-05-27T11:22:43-00:00Re: Validating a custom field
https://www.eclipse.org/forums/index.php/mv/msg/488048/1060726/#msg_1060726
You might also take a look at #checkEmpty and #isSaveNeeded/touch/markSaved to decide if the field "contains information" respectively should be saved on "Ok".
]]>Ivan Motsch2013-05-28T09:08:41-00:00Re: Validating a custom field
https://www.eclipse.org/forums/index.php/mv/msg/488048/1060753/#msg_1060753
Urs Beeli2013-05-28T11:13:31-00:00