[Databinding] Validate that item only appears once in IObservableListhttps://www.eclipse.org/forums/index.php/mv/msg/163503/517472/#msg_517472
I have a table editor that allows the creation of new entries.
There should be only one entry in the table with a specific name.
The table cell editor should therefor prevent the user from changing the
name to a value already existing in the table (list).

What kind of binding would do that automatically?

Thanks,
Phil]]>Philipp Kursawe2010-02-28T13:00:56-00:00Re: [Databinding] Validate that item only appears once in IObservableListhttps://www.eclipse.org/forums/index.php/mv/msg/163503/517707/#msg_517707
> Hello,
>
> I have a table editor that allows the creation of new entries.
> There should be only one entry in the table with a specific name.
> The table cell editor should therefor prevent the user from changing the
> name to a value already existing in the table (list).
>
> What kind of binding would do that automatically?

One idea is to wrap the observable in an
org.eclipse.core.databinding.observable.value.IVetoableValue (see
org.eclipse.core.databinding.observable.value.DecoratingVeto ableValue)

Another idea is to provide a custom UpdateValueStrategy to the binding.

Hope this helps,
Eric]]>Eric Rizzo2010-03-01T18:49:56-00:00Re: [Databinding] Validate that item only appears once in IObservableListhttps://www.eclipse.org/forums/index.php/mv/msg/163503/518431/#msg_518431
> Hello,
>
> I have a table editor that allows the creation of new entries.
> There should be only one entry in the table with a specific name.
> The table cell editor should therefor prevent the user from changing the
> name to a value already existing in the table (list).
>
> What kind of binding would do that automatically?
>
> Thanks,
> Phil

You could allow the change in the UI but prevent invalid changes from
propagating to the model using a MultiValidator:

This much will flag a validation error in your UI (assuming you have the
validation status wired up and displayed somewhere--right?).

Next you can tell uniqueNamesValidator to wrap your target observable
list in a validated wrapper. Changes to the wrapped observable will
only propagate out to the wrapper when the validator is in a passing status: