[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
|
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 ?