19 package org.turro.zul.commentit;
21 import org.turro.command.CommandUtil;
22 import org.turro.commentit.CommentItUtil;
23 import org.turro.contacts.CommentIt;
24 import org.turro.contacts.db.ContactsPU;
25 import org.turro.elephant.context.Application;
26 import org.turro.elephant.util.Messages;
27 import org.turro.html.HTMLEntities;
28 import org.turro.i18n.I_;
29 import org.turro.zkoss.grid.PagingGrid;
30 import org.turro.zkoss.label.LabelExtended;
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.zk.ui.ext.AfterCompose;
35 import org.zkoss.zul.Button;
36 import org.zkoss.zul.Column;
37 import org.zkoss.zul.Columns;
38 import org.zkoss.zul.Hlayout;
39 import org.zkoss.zul.Label;
40 import org.zkoss.zul.Row;
41 import org.zkoss.zul.Rows;
50 private String entityPath;
57 this.entityPath = entityPath;
65 private void addColumns() {
66 Columns cols =
new Columns();
67 cols.setSizable(
true);
68 cols.setMenupopup(
"auto");
71 Column col =
new Column(
I_.
get(
"Date"),
null,
"120px");
72 cols.appendChild(col);
74 col =
new Column(
I_.
get(
"Author"),
null,
"250px");
75 cols.appendChild(col);
77 col =
new Column(
I_.
get(
"Comment"));
78 cols.appendChild(col);
80 col =
new Column(
"",
null,
"250px");
81 cols.appendChild(col);
84 private void addRows() {
86 rows.getChildren().clear();
88 for(
final CommentIt ci : CommentItUtil.allComments(entityPath)) {
89 final Row row =
new Row();
91 rows.appendChild(row);
93 LabelExtended lext =
new LabelExtended();
94 lext.setDate(ci.getDateCreation());
95 lext.setSclass(
"ldate");
96 row.appendChild(lext);
98 if(ci.getCreator() !=
null) {
99 row.appendChild(CommandUtil.getLinkOrSpace(ci.getCreator()));
101 Label author =
new Label(
102 ci.getName() +
" (" +
105 " " + ci.getWeb() +
" " +
107 author.setSclass(
"lauthor");
108 row.appendChild(author);
111 Label body =
new Label(HTMLEntities.unescape(ci.getBody()));
112 body.setSclass(
"lbody");
113 row.appendChild(body);
115 Hlayout hbox =
new Hlayout();
116 if(app.
isInRole(
"publication:accept")) {
117 if(!ci.isAccepted()) {
118 final Button confirm =
new Button(I_.get(
"Accept"));
119 confirm.addEventListener(Events.ON_CLICK,
new EventListener() {
121 public void onEvent(Event event)
throws Exception {
122 Messages.confirmAcceptation().show(() -> {
123 CommentItUtil.acceptComment(ci);
128 hbox.appendChild(confirm);
130 Button
delete =
new Button(I_.get(
"Delete"));
131 delete.addEventListener(Events.ON_CLICK,
new EventListener() {
133 public void onEvent(Event event)
throws Exception {
134 Messages.confirmDeletion().show(() -> {
135 new ContactsPU().deleteObject(ci);
140 hbox.appendChild(
delete);
142 row.appendChild(hbox);
boolean isInRole(String role)
static Application getApplication()
static String get(String msg)
Rows getRows(boolean create)