19 package org.turro.dossier.zul.dossier;
21 import java.util.HashSet;
23 import org.turro.dossier.entity.DossierType;
24 import org.turro.i18n.I_;
25 import org.turro.util.PhraseBuilder;
26 import org.zkoss.zk.ui.event.Event;
27 import org.zkoss.zk.ui.event.EventListener;
28 import org.zkoss.zk.ui.event.Events;
29 import org.zkoss.zk.ui.event.SelectEvent;
30 import org.zkoss.zul.Bandbox;
31 import org.zkoss.zul.Bandpopup;
32 import org.zkoss.zul.Listbox;
33 import org.zkoss.zul.Listhead;
34 import org.zkoss.zul.Listheader;
35 import org.zkoss.zul.Listitem;
43 private Set<DossierType> typeSet =
new HashSet<>();
55 this.typeSet = typeSet;
60 private void addPopup() {
63 Bandpopup popup =
new Bandpopup();
67 type.setWidth(
"300px");
68 type.setMultiple(
true);
69 type.setCheckmark(
true);
70 Listhead lh =
new Listhead();
71 lh.appendChild(
new Listheader(
I_.
get(
"Type")));
73 type.addEventListener(Events.ON_SELECT,
new EventListener() {
75 public void onEvent(Event event)
throws Exception {
76 Set<Listitem> selected = ((SelectEvent) event).getSelectedItems();
77 if(selected !=
null) {
78 for(Listitem li : selected) {
82 Set<Listitem> unselected = ((SelectEvent) event).getUnselectedItems();
83 if(unselected !=
null) {
84 for(Listitem li : unselected) {
85 typeSet.remove((DossierType) li.getValue());
91 popup.appendChild(type);
93 for(DossierType is : DossierType.values()) {
94 Listitem li =
new Listitem(I_.byKey(is.toString()));
100 private void updateCheckMarks() {
101 for(Object obj : type.getChildren()) {
102 if(obj instanceof Listitem) {
103 Listitem li = (Listitem) obj;
104 li.setSelected(typeSet.contains(li.getValue()));
110 private void updateText() {
111 PhraseBuilder pb =
new PhraseBuilder();
112 for(Object obj : type.getChildren()) {
113 if(obj instanceof Listitem) {
114 Listitem li = (Listitem) obj;
115 if(li.isSelected()) {
116 pb.addWord(I_.byKey(((DossierType) li.getValue()).toString()));
117 pb.addPendingSeparator(
",");
122 setText(pb.toString());
Set< DossierType > getTypeSet()
void setTypeSet(Set< DossierType > typeSet)
static String get(String msg)