[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform] Re: [Databinding} Mess with tables/ Validation in structured Beans
|
Hi Thomas,
Would you be able to write a new snippet for this and contribute it through
Bugzilla?
Thanks
Boris
"Thomas" <thomas.kratz@xxxxxxxxxx> wrote in message
news:ghojga$ta5$1@xxxxxxxxxxxxxxxxxxxx
> 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