| 
| [Databinding} Mess with tables/ Validation in structured Beans [message #333400] | Tue, 09 December 2008 11:27  |  | 
| Eclipse User  |  |  |  |  | This is parially a cross post to something I asked on the SWT group. Guess I have an editor that edits a person object. a person has many
 adresses so the editor shows them in a table. but withmy current
 solution the fields in the table can only be validated when the user
 edits cells (via EditingSupport) bindings are dynamically created. But
 in my scenario I cant create a valid new record. So if the user doesnt
 edit it he will never see any validating message. Are there any ideas
 out there to solve that ?
 |  |  |  | 
| 
| Re: [Databinding} Mess with tables/ Validation in structured Beans [message #333402 is a reply to message #333400] | Tue, 09 December 2008 12:05   |  | 
| Eclipse User  |  |  |  |  | Any cross-observable or compound constraint validators should be enforced using a ValidationStatusProvider.  You can extend
 ValidationStatusProvider and manually monitor your address collection
 for validation errors.  Or, you could extend MultiValidator and have it
 monitor the relevant observables to check for errors.  If you are using
 ObservableMapLabelProvider then I would suggest observing the values()
 for the IObservableMap used by the relevant table column.
 
 As an example:
 
 TableViewer addressViewer = ...
 ObservableListContentProvider cp = new ObservableListContentProvider();
 final IObservableMap[] maps =  BeansObservables.observeMaps(
 cp.getKnownElements,
 Address.class,
 new String[] {"street", "street2", "city", "province", "code" } );
 addressViewer.setLabelProvider(new ObservableMapLabelProvider(maps));
 
 MultiValidator addressValidator = new MultiValidator(realm) {
 protected IStatus validate() {
 Set addresses = maps[0].keySet();
 IStatus status = ValidationStatus.ok();
 for (Iterator it = addresses.iterator(); it.hasNext(); ) {
 Address address = (Address) it.next();
 // validate address, update status variable if more severe
 // than current value
 }
 return status;
 }
 }
 
 Hope this helps,
 
 Matthew Hall
 
 Thomas wrote:
 > This is parially a cross post to something I asked on the SWT group.
 > Guess I have an editor that edits a person object. a person has many
 > adresses so the editor shows them in a table. but withmy current
 > solution the fields in the table can only be validated when the user
 > edits cells (via EditingSupport) bindings are dynamically created. But
 > in my scenario I cant create a valid new record. So if the user doesnt
 > edit it he will never see any validating message. Are there any ideas
 > out there to solve that ?
 |  |  |  | 
|  | 
| 
| Re: [Databinding} Mess with tables/ Validation in structured Beans [message #333419 is a reply to message #333403] | Wed, 10 December 2008 09:25   |  | 
| Eclipse User  |  |  |  |  | Thanks Matthew, 
 thats exactly what I was looking for !
 
 Thomas
 
 Matthew Hall schrieb:
 > Matthew Hall wrote:
 >> TableViewer addressViewer = ...
 >> ObservableListContentProvider cp = new ObservableListContentProvider();
 >> final IObservableMap[] maps =  BeansObservables.observeMaps(
 >>     cp.getKnownElements,
 >>     Address.class,
 >>     new String[] {"street", "street2", "city", "province", "code" } );
 >> addressViewer.setLabelProvider(new ObservableMapLabelProvider(maps));
 >>
 >> MultiValidator addressValidator = new MultiValidator(realm) {
 >>   protected IStatus validate() {
 >>     Set addresses = maps[0].keySet();
 >>     IStatus status = ValidationStatus.ok();
 >>     for (Iterator it = addresses.iterator(); it.hasNext(); ) {
 >>       Address address = (Address) it.next();
 >>       // validate address, update status variable if more severe
 >>       // than current value
 >>     }
 >>     return status;
 >>   }
 >> }
 >
 > Forgot to say, you need to add the MultiValidator to the
 > DataBindingContext:
 >
 > dbc.addValidationStatusProvider(addressValidator);
 >
 > Matthew
 |  |  |  | 
| 
| Re: [Databinding} Mess with tables/ Validation in structured Beans [message #333443 is a reply to message #333419] | Thu, 11 December 2008 10:06  |  | 
| Eclipse User  |  |  |  |  | Hi Thomas, 
 Would you be able to write a new snippet for this and contribute it through
 Bugzilla?
 
 Thanks
 Boris
 
 "Thomas" <thomas.kratz@eiswind.de> wrote in message
 news:ghojga$ta5$1@build.eclipse.org...
 > Thanks Matthew,
 >
 > thats exactly what I was looking for !
 >
 > Thomas
 >
 > Matthew Hall schrieb:
 >> Matthew Hall wrote:
 >>> TableViewer addressViewer = ...
 >>> ObservableListContentProvider cp = new ObservableListContentProvider();
 >>> final IObservableMap[] maps =  BeansObservables.observeMaps(
 >>>     cp.getKnownElements,
 >>>     Address.class,
 >>>     new String[] {"street", "street2", "city", "province", "code" } );
 >>> addressViewer.setLabelProvider(new ObservableMapLabelProvider(maps));
 >>>
 >>> MultiValidator addressValidator = new MultiValidator(realm) {
 >>>   protected IStatus validate() {
 >>>     Set addresses = maps[0].keySet();
 >>>     IStatus status = ValidationStatus.ok();
 >>>     for (Iterator it = addresses.iterator(); it.hasNext(); ) {
 >>>       Address address = (Address) it.next();
 >>>       // validate address, update status variable if more severe
 >>>       // than current value
 >>>     }
 >>>     return status;
 >>>   }
 >>> }
 >>
 >> Forgot to say, you need to add the MultiValidator to the
 >> DataBindingContext:
 >>
 >> dbc.addValidationStatusProvider(addressValidator);
 >>
 >> Matthew
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.03143 seconds