18 package org.turro.dossier.zul.issue;
20 import java.util.Iterator;
21 import org.turro.contacts.Contact;
22 import org.turro.contacts.util.ContactCombobox;
23 import org.turro.contacts.zul.label.ContactInfo;
24 import org.turro.dossier.db.DossierPU;
25 import org.turro.dossier.entity.IDossierParticipant;
26 import org.turro.dossier.entity.Issue;
27 import org.turro.dossier.entity.IssueParticipant;
28 import org.turro.dossier.entity.IssueParticipantRole;
29 import org.turro.i18n.I_;
30 import org.turro.plugin.contacts.IContact;
31 import org.zkoss.zk.ui.event.Event;
32 import org.zkoss.zk.ui.event.EventListener;
33 import org.zkoss.zk.ui.event.Events;
34 import org.zkoss.zul.Column;
35 import org.zkoss.zul.Columns;
36 import org.zkoss.zul.Grid;
37 import org.zkoss.zul.Hbox;
38 import org.zkoss.zul.Image;
39 import org.zkoss.zul.Label;
40 import org.zkoss.zul.Listbox;
41 import org.zkoss.zul.Listitem;
42 import org.zkoss.zul.Row;
43 import org.zkoss.zul.Rows;
44 import org.zkoss.zul.Toolbar;
45 import org.zkoss.zul.Toolbarbutton;
54 private boolean editable;
56 private Toolbar toolbar;
57 private Toolbarbutton editButton, addButton, saveButton, cancelButton;
66 this.editable = editable;
75 rows.getChildren().clear();
83 toolbar =
new Toolbar();
84 getParent().appendChild(toolbar);
89 private void addColumns() {
90 Columns cols =
new Columns();
91 cols.setSizable(
true);
92 cols.setMenupopup(
"auto");
95 Column col =
new Column(
I_.
get(
"Name"));
96 cols.appendChild(col);
98 col =
new Column(
I_.
get(
"Role"));
99 col.setWidth(
"180px");
100 cols.appendChild(col);
108 rows.appendChild(row);
113 contact.addEventListener(Events.ON_CHANGE,
new EventListener() {
115 public void onEvent(Event event)
throws Exception {
118 p.setIdContact(c.
getId());
124 row.appendChild(contact);
126 final Listbox role =
new Listbox();
127 role.setMold(
"select");
128 role.addEventListener(Events.ON_SELECT,
new EventListener() {
131 public void onEvent(Event event)
throws Exception {
136 row.appendChild(role);
139 Listitem li =
new Listitem(
I_.
byKey(ipr.toString()));
141 li.setSelected(li.getValue().equals(p.getRole()));
142 role.appendChild(li);
149 rows.appendChild(row);
154 Hbox hbox =
new Hbox();
155 row.appendChild(hbox);
156 hbox.appendChild(
new Image(
"/_zul/images/forward.png"));
158 hbox.appendChild(
new Image(
"/_zul/images/mail_forward.png"));
162 row.appendChild(label);
166 Hbox hbox =
new Hbox();
167 row.appendChild(hbox);
168 hbox.appendChild(
new Image(
"/_zul/images/mail_forward.png"));
171 row.appendChild(label);
177 private void addToolbarButtons() {
178 editButton =
new Toolbarbutton(
179 I_.
get(
"Edit participants"),
180 "/_zul/images/edit.png"
182 editButton.addEventListener(Events.ON_CLICK,
new EventListener() {
185 public void onEvent(Event event)
throws Exception {
190 toolbar.appendChild(editButton);
192 saveButton =
new Toolbarbutton(
194 "/_zul/images/save.png"
196 saveButton.addEventListener(Events.ON_CLICK,
new EventListener() {
199 public void onEvent(Event event)
throws Exception {
204 toolbar.appendChild(saveButton);
206 cancelButton =
new Toolbarbutton(
208 "/_zul/images/cancel.png"
210 cancelButton.addEventListener(Events.ON_CLICK,
new EventListener() {
213 public void onEvent(Event event)
throws Exception {
218 toolbar.appendChild(cancelButton);
220 addButton =
new Toolbarbutton(
221 I_.get(
"Add participant"),
222 "/_zul/images/new.png"
224 addButton.addEventListener(Events.ON_CLICK,
new EventListener() {
226 public void onEvent(Event event)
throws Exception {
227 IssueParticipant ip =
new IssueParticipant();
228 ip.setRole(IssueParticipantRole.ISSUE_ASSISTANT);
235 toolbar.appendChild(addButton);
240 private void doCancel() {
241 issue =
new DossierPU().find(Issue.class, issue.
getId());
245 private void doSave() {
247 while(it.hasNext()) {
248 IssueParticipant ip = it.next();
249 if(!ip.getIContact().isValid()) {
252 ip.setIContact(ip.getIContact());
255 issue =
new DossierPU().saveObject(issue);
259 private void updateButtons() {
260 if(toolbar !=
null) {
261 editButton.setVisible(!editable);
262 addButton.setVisible(editable);
263 saveButton.setVisible(editable);
264 cancelButton.setVisible(editable);
IssueParticipantRole getRole()
ParticipantSet getFullParticipants()
Set< IssueParticipant > getParticipants()
void setIssue(Issue issue)
void setEditable(boolean editable)
void setAddToolbar(boolean addToolbar)
static String byKey(String key)
static String get(String msg)
boolean isShowAllIssues()
ParticipantRole getRole()
boolean isReceiveAllEmails()