18 package org.turro.dossier.zul.issue;
20 import java.util.HashSet;
22 import org.turro.dossier.entity.IssueParticipantRole;
23 import org.turro.i18n.I_;
24 import org.zkoss.lang.Strings;
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<IssueParticipantRole> roleSet =
new HashSet<>();
54 public void setRoleSet(Set<IssueParticipantRole> roleSet) {
55 this.roleSet = roleSet;
60 private void addPopup() {
61 Bandpopup popup =
new Bandpopup();
65 role.setWidth(
"100%");
66 role.setMultiple(
true);
67 role.setCheckmark(
true);
68 Listhead lh =
new Listhead();
69 lh.appendChild(
new Listheader(
I_.
get(
"Role")));
71 role.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 roleSet.remove((IssueParticipantRole) li.getValue());
90 for(IssueParticipantRole ipr : IssueParticipantRole.values()) {
91 Listitem li =
new Listitem(I_.byKey(ipr.toString()));
96 popup.appendChild(role);
99 private void updateCheckMarks() {
100 for(Object obj : role.getChildren()) {
101 if(obj instanceof Listitem) {
102 Listitem li = (Listitem) obj;
103 li.setSelected(roleSet.contains(li.getValue()));
108 private void updateText() {
110 for(Object obj : role.getChildren()) {
111 if(obj instanceof Listitem) {
112 Listitem li = (Listitem) obj;
113 newText += (Strings.isEmpty(newText) ?
"" :
",") +
114 (li.isSelected() ? I_.byKey(li.getValue().toString()) :
"");
117 Events.postEvent(
new Event(Events.ON_CHANGE,
IssueRoleCtrl.this));
void setRoleSet(Set< IssueParticipantRole > roleSet)
Set< IssueParticipantRole > getRoleSet()
static String get(String msg)