18 package org.turro.dossier.zul.issue;
20 import java.util.HashSet;
22 import org.turro.dossier.entity.IssueStatus;
23 import org.turro.i18n.I_;
24 import org.turro.util.PhraseBuilder;
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.event.SelectEvent;
29 import org.zkoss.zul.Bandbox;
30 import org.zkoss.zul.Bandpopup;
31 import org.zkoss.zul.Listbox;
32 import org.zkoss.zul.Listhead;
33 import org.zkoss.zul.Listheader;
34 import org.zkoss.zul.Listitem;
42 private Set<IssueStatus> statusSet =
new HashSet<>();
43 private Listbox status;
55 this.statusSet = statusSet;
60 private void addPopup() {
61 Bandpopup popup =
new Bandpopup();
64 status =
new Listbox();
65 status.setWidth(
"300px");
66 status.setMultiple(
true);
67 status.setCheckmark(
true);
68 Listhead lh =
new Listhead();
69 lh.appendChild(
new Listheader(
I_.
get(
"Status")));
70 status.appendChild(lh);
71 status.addEventListener(Events.ON_SELECT,
new EventListener() {
73 public void onEvent(Event event)
throws Exception {
74 Set<Listitem> selected = ((SelectEvent) event).getSelectedItems();
75 if(selected !=
null) {
76 for(Listitem li : selected) {
80 Set<Listitem> unselected = ((SelectEvent) event).getUnselectedItems();
81 if(unselected !=
null) {
82 for(Listitem li : unselected) {
83 statusSet.remove((IssueStatus) li.getValue());
90 for(IssueStatus is : IssueStatus.values()) {
91 Listitem li =
new Listitem(I_.byKey(is.toString()));
93 status.appendChild(li);
96 popup.appendChild(status);
99 private void updateCheckMarks() {
100 for(Object obj : status.getChildren()) {
101 if(obj instanceof Listitem) {
102 Listitem li = (Listitem) obj;
103 li.setSelected(statusSet.contains(li.getValue()));
109 private void updateText() {
110 PhraseBuilder pb =
new PhraseBuilder();
111 for(Object obj : status.getChildren()) {
112 if(obj instanceof Listitem) {
113 Listitem li = (Listitem) obj;
114 if(li.isSelected()) {
115 pb.addWord(I_.byKey(li.getValue().toString()));
116 pb.addPendingSeparator(
",");
121 setText(pb.toString());
Set< IssueStatus > getStatusSet()
void setStatusSet(Set< IssueStatus > statusSet)
static String get(String msg)