18 package org.turro.zkoss.input;
20 import java.util.Collection;
21 import java.util.HashSet;
22 import java.util.List;
23 import org.turro.zkoss.layout.VboxH;
24 import org.zkoss.zk.ui.Component;
25 import org.zkoss.zk.ui.event.Event;
26 import org.zkoss.zk.ui.event.EventListener;
27 import org.zkoss.zk.ui.event.Events;
28 import org.zkoss.zk.ui.ext.AfterCompose;
29 import org.zkoss.zul.Checkbox;
37 private Collection<V> internalValues;
39 private Collection<V> collection;
47 this.collection = collection;
67 this.collection = collection;
73 if(collection ==
null)
return;
74 for(V v : collection) {
76 cb.setAttribute(
"obj", v);
78 cb.addEventListener(Events.ON_CHECK,
new EventListener() {
80 public void onEvent(Event event)
throws Exception {
87 protected boolean equals(V value, V obj) {
90 return (v1 ==
null && v2 ==
null) ||
91 (v1 !=
null && v1.equals(v2));
98 internalValues = collection;
101 if(c instanceof Checkbox) {
102 Checkbox cb = (Checkbox) c;
103 cb.setChecked(
false);
104 for(V v : collection) {
116 return internalValues;
118 HashSet<V>
set =
new HashSet<V>();
120 if(c instanceof Checkbox) {
121 Checkbox cb = (Checkbox) c;
123 set.add((V) cb.getAttribute(
"obj"));
135 if (internalValues !=
null) {
137 internalValues =
null;
void addComponent(Component comp)