18 package org.turro.zul.acceptance;
20 import org.turro.acceptance.AcceptanceMail;
21 import org.turro.acceptance.AcceptanceUtil;
22 import org.turro.auth.Authentication;
23 import org.turro.contacts.Acceptance;
24 import org.turro.contacts.Contact;
25 import org.turro.contacts.zul.label.ContactInfo;
26 import org.turro.elephant.util.DateFormats;
27 import org.turro.entities.Entities;
28 import org.turro.i18n.I_;
29 import org.turro.plugin.contacts.IContact;
30 import org.turro.zkoss.grid.GroupExtended;
31 import org.turro.zkoss.grid.PagingGrid;
32 import org.zkoss.zk.ui.event.Event;
33 import org.zkoss.zk.ui.event.EventListener;
34 import org.zkoss.zk.ui.event.Events;
35 import org.zkoss.zk.ui.ext.AfterCompose;
36 import org.zkoss.zul.*;
45 private boolean showGroups =
true;
48 this.showGroups = showGroups;
56 private void loadRows() {
59 appendChild(
new Rows());
63 rows.getChildren().clear();
66 rows.appendChild(
new GroupExtended(I_.get(
"Pending to accept")));
68 for(
final Acceptance acceptance : AcceptanceUtil.getPendingAcceptances((Contact) contact.
getContact())) {
70 row.setZclass(
"none");
71 for(String colStr :
getVarColumnsList(
"contact,creation,entity,accept,comment")) {
72 if(
"contact".equals(colStr)) {
73 row.appendChild(
new ContactInfo(acceptance.getPetitioner()));
74 }
else if(
"creation".equals(colStr)) {
75 row.appendChild(
new Label(DateFormats.format(acceptance.getDateRequest(),
true)));
76 }
else if(
"entity".equals(colStr)) {
77 row.appendChild(
new Label(Entities.getController(acceptance.getPath()).getName()));
78 }
else if(
"accept".equals(colStr)) {
79 Toolbarbutton b =
new Toolbarbutton(I_.get(
"Accept"),
"/_zul/images/ok.png");
80 b.addEventListener(Events.ON_CLICK,
new EventListener() {
82 public void onEvent(Event event)
throws Exception {
83 new AcceptanceMail(AcceptanceUtil.accept(acceptance)).sendMail();
88 }
else if(
"comment".equals(colStr)) {
89 row.appendChild(
new Label(acceptance.getAcceptanceComment()));
92 rows.appendChild(row);
96 rows.appendChild(
new GroupExtended(I_.get(
"Pending requests")));
98 for(Acceptance acceptance : AcceptanceUtil.getPendingRequests((Contact) contact.
getContact())) {
100 row.setZclass(
"none");
101 for(String colStr :
getVarColumnsList(
"contact,creation,entity,accept,comment")) {
102 if(
"contact".equals(colStr)) {
103 row.appendChild(
new ContactInfo(acceptance.getContact()));
104 }
else if(
"creation".equals(colStr)) {
105 row.appendChild(
new Label(DateFormats.format(acceptance.getDateRequest(),
true)));
106 }
else if(
"entity".equals(colStr)) {
107 row.appendChild(
new Label(Entities.getController(acceptance.getPath()).getName()));
108 }
else if(
"accept".equals(colStr)) {
109 row.appendChild(
new Label());
110 }
else if(
"comment".equals(colStr)) {
111 row.appendChild(
new Label(acceptance.getAcceptanceComment()));
114 rows.appendChild(row);
120 private void addColumns() {
121 Columns cols =
new Columns();
122 cols.setSizable(
true);
123 cols.setMenupopup(
"auto");
124 cols.setVisible(
false);
127 for(String colStr :
getVarColumnsList(
"contact,creation,entity,accept,comment")) {
128 if(
"contact".equals(colStr)) {
129 Column col =
new Column(I_.get(
"Contact"));
130 cols.appendChild(col);
131 }
else if(
"creation".equals(colStr)) {
132 Column col =
new Column(I_.get(
"Creation"));
133 col.setWidth(
"120px");
134 cols.appendChild(col);
135 }
else if(
"entity".equals(colStr)) {
136 Column col =
new Column(I_.get(
"Entity"));
137 cols.appendChild(col);
138 }
else if(
"accept".equals(colStr)) {
139 Column col =
new Column();
140 col.setWidth(
"120px");
141 cols.appendChild(col);
142 }
else if(
"comment".equals(colStr)) {
143 Column col =
new Column(I_.get(
"Comment"));
144 col.setWidth(
"300px");
145 cols.appendChild(col);
static IContact getIContact()
Rows getRows(boolean create)
Collection< String > getVarColumnsList(String defaultCols)
void setShowGroups(boolean showGroups)