You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Sandro Martini <sa...@gmail.com> on 2013/01/24 10:03:13 UTC
Re: Is that a way to check or uncheck a checkbox using data binding?
Hi all,
I'm ready to look better at this, maybe to include in 2.0.3 (soon to
be released) ...
Objections from someone for including this ?
If not I'll create a jira issue (and post here the link) , but I need
the original author to attach there the code, so we are all happy (due
to ASF rules) :-) ... ok ?
Tell me.
Thanks,
Sandro
2012/11/8 treponema <tr...@orange.fr>:
> Hi,
> Sorry for this late answer.
> This is the more generic helper that I use on different windows :
>
> private static class CheckboxMapping<T> implements
> Button.ButtonDataBindMapping {
> private final Set<Key<T>> set;
> private final Checkbox cb;
> private final Key<T> key;
>
> public CheckboxMapping(Checkbox cb, Key<T> key, Set<Key<T>> set) {
>
>
> this.cb = cb;
> this.key = key;
> this.set = set;
>
> }
>
> @Override
> public Object toButtonData(Object value) {
> if (value != null && ((List<Key<T>>) value).contains(key))
> cb.setSelected(true);
> else
> cb.setSelected(false);
>
> return cb.getButtonData();
> }
>
> @Override
> public Object valueOf(Object buttonData) {
> if (cb.isSelected())
> set.add(this.key);
> return new ArrayList<Key<T>>(set);
> }
>
> }
>