18 package org.turro.dossier.zul.dossier;
20 import java.util.Comparator;
21 import java.util.List;
23 import org.turro.attach.zul.control.AttachmentControl;
24 import org.turro.contacts.zul.label.ContactInfo;
25 import org.turro.dossier.db.DossierPU;
26 import org.turro.dossier.dossier.DossierData;
27 import org.turro.dossier.dossier.DossierWrapper;
28 import org.turro.dossier.dw.DossierDWReport;
29 import org.turro.dossier.entity.Dossier;
30 import org.turro.dossier.entity.DossierVersion;
31 import org.turro.dossier.entity.DossierVersionStatus;
32 import org.turro.dossier.entity.Participant;
33 import org.turro.dossier.search.DossierIds;
34 import org.turro.dossier.search.DossierResults;
35 import org.turro.elephant.context.Application;
36 import org.turro.elephant.util.Messages;
37 import org.turro.i18n.I_;
38 import org.turro.jpa.grid.RendererOnDemand;
39 import org.turro.log.SystemLogType;
40 import org.turro.log.SystemLogger;
41 import org.turro.util.CompareUtil;
42 import org.turro.zkoss.dialog.SelectionDialog;
43 import org.turro.zkoss.grid.PagingGrid;
44 import org.turro.zkoss.label.LabelExtended;
45 import org.turro.zkoss.label.LabelTypes;
46 import org.turro.zul.frame.Framework;
47 import org.zkoss.zk.ui.Component;
48 import org.zkoss.zk.ui.event.Event;
49 import org.zkoss.zk.ui.event.EventListener;
50 import org.zkoss.zk.ui.event.Events;
51 import org.zkoss.zul.A;
52 import org.zkoss.zul.Column;
53 import org.zkoss.zul.Columns;
54 import org.zkoss.zul.Group;
55 import org.zkoss.zul.GroupsModelArray;
56 import org.zkoss.zul.Hlayout;
57 import org.zkoss.zul.Image;
58 import org.zkoss.zul.Label;
59 import org.zkoss.zul.Row;
60 import org.zkoss.zul.Rows;
61 import org.zkoss.zul.Vlayout;
86 private void addColumns() {
87 Columns cols =
new Columns();
88 cols.setSizable(
true);
89 cols.setMenupopup(
"auto");
94 Column col =
new Column(
"#");
96 cols.appendChild(col);
97 col =
new Column(
I_.
get(
"Description"));
98 cols.appendChild(col);
99 col =
new Column(
I_.
get(
"Creation"));
100 col.setWidth(
"120px");
101 cols.appendChild(col);
102 col =
new Column(
I_.
get(
"Status"));
103 col.setWidth(
"200px");
104 cols.appendChild(col);
105 col =
new Column(
I_.
get(
"Data"));
106 col.setWidth(
"250px");
107 cols.appendChild(col);
110 col.setWidth(
"25px");
111 cols.appendChild(col);
115 private void addRows(List dossiers) {
117 setRowRenderer(
new RendererOnDemand<Dossier, DossierIds>(() ->
new DossierPU()) {
119 protected Object getId(DossierIds
id) {
123 protected void renderRow(Row row,
final Dossier dossier) {
124 fillRow(row, dossier);
127 protected void renderGroup(Group group, Dossier dossier) {
128 group.setLabel(dossier.getCategory().getFullDescription());
132 setModel(
new GroupsModelArray<DossierIds, String, String, Object>(
133 (DossierIds[]) dossiers.toArray(
new DossierIds[0]),
134 new Comparator<DossierIds>() {
136 public int compare(DossierIds o1, DossierIds o2) {
137 return CompareUtil.compare(o1.categoryId, o2.categoryId);
152 private void fillRow(Row row,
final Dossier dossier) {
153 Label label =
new Label(dossier.getId() +
"");
154 row.appendChild(label);
156 Vlayout vbox =
new Vlayout();
157 row.appendChild(vbox);
159 Hlayout hbox =
new Hlayout();
160 vbox.appendChild(hbox);
161 hbox.appendChild(
new DossierLabel(dossier,
false));
163 Set<DossierVersion> dvs = dossier.getActiveVersions();
165 hbox.appendChild(LabelTypes.getTinyLabel(
" ["));
166 for(DossierVersion dv : dvs) {
168 hbox.appendChild(createLabel(dv));
171 hbox.appendChild(LabelTypes.getTinyLabel(
"]"));
174 Participant subject = dossier.getSubject();
175 if(subject !=
null) {
176 ContactInfo ci =
new ContactInfo(subject.getIdContact());
177 ci.setSclass(
"softLabel");
178 vbox.appendChild(ci);
181 LabelExtended lext =
new LabelExtended();
182 lext.setStyle(
"color:gray;font-size:11px");
183 lext.setValue(dossier.getExtraDescription());
184 lext.setMaxChars(70);
185 lext.setShowTooltip(
true);
186 vbox.appendChild(lext);
188 vbox =
new Vlayout();
189 row.appendChild(vbox);
191 lext =
new LabelExtended();
192 lext.setDate(dossier.getCreation());
193 vbox.appendChild(lext);
195 hbox =
new Hlayout();
196 vbox.appendChild(hbox);
198 lext =
new LabelExtended();
199 lext.setStyle(
"color:gray;font-size:11px;");
200 lext.setDate(
new DossierWrapper(dossier).getIssueLastModification());
201 hbox.appendChild(lext);
203 hbox.appendChild(
new Image(
"/_zul/images/activity.png"));
205 vbox.appendChild(hbox);
207 vbox =
new Vlayout();
208 row.appendChild(vbox);
210 lext =
new LabelExtended();
211 lext.setResourceValue(dossier.getStatus().toString());
212 vbox.appendChild(lext);
214 DossierDWReport dr =
new DossierDWReport();
215 dr.setReportValues(
null,
null, dossier.getId());
217 label =
new Label(((
long) dr.getOnWork()) +
" " +
218 I_.get(
"Of") +
" " + ((
long) dr.getIssueCount()) +
" " +
219 I_.get(
"Work in progress"));
220 label.setStyle(
"color:gray;font-size:11px;");
221 vbox.appendChild(label);
223 label =
new Label(dr.getEfectivity() +
"%" +
" " +
224 I_.get(
"Efectivity"));
225 label.setStyle(
"color:gray;font-size:11px;");
226 vbox.appendChild(label);
228 vbox =
new Vlayout();
229 row.appendChild(vbox);
231 if(Application.getApplication().isInRole(
"dossier:attach")) {
232 A a =
new A(I_.get(
"Attachments"),
"/_zul/images/clip.png");
233 a.addEventListener(Events.ON_CLICK,
new EventListener() {
235 public void onEvent(Event event)
throws Exception {
241 AttachmentControl ac =
new AttachmentControl();
242 ac.setEntity(dossier);
243 ac.setPublicOnly(!(
new DossierWrapper(dossier).getCanShowAllAttachments()));
244 SelectionDialog.showComponent(getPage(), I_.get(
"Attachments"),
245 ac,
"80%",
"80%",
null);
251 DossierData dd = dr.getData();
252 if(dd.isExpenses()) {
253 label =
new Label(I_.get(
"Expenses"));
254 label.setStyle(
"color:navy;font-size:11px");
255 vbox.appendChild(label);
256 label =
new Label(dd.getExpensesString());
257 label.setStyle(
"color:#666;font-size:11px");
258 vbox.appendChild(label);
261 label =
new Label(I_.get(
"Hours"));
262 label.setStyle(
"color:navy;font-size:11px");
263 vbox.appendChild(label);
264 label =
new Label(dd.getHoursString());
265 label.setStyle(
"color:#666;font-size:11px");
266 vbox.appendChild(label);
269 label =
new Label(I_.get(
"Price"));
270 label.setStyle(
"color:navy;font-size:11px");
271 vbox.appendChild(label);
272 label =
new Label(dd.getPriceString());
273 label.setStyle(
"color:#666;font-size:11px");
274 vbox.appendChild(label);
277 if(Application.getApplication().isInRole(
"dossier:delete")) {
278 Image img =
new Image(
"/_zul/images/edit-delete.png");
279 img.setStyle(
"cursor:pointer");
280 img.addEventListener(Events.ON_CLICK,
new EventListener() {
282 public void onEvent(Event event)
throws Exception {
283 Messages.confirmDeletion().show(() -> {
284 SystemLogger.getInstance().doLog(SystemLogType.LOG_INFO, dossier,
"deleted",
285 dossier.getFullDescription());
286 new DossierWrapper(dossier).
delete();
287 Framework.getCurrent().invalidateSelected();
291 row.appendChild(img);
295 private Component createLabel(DossierVersion dv) {
296 Label l = LabelTypes.getTinyLabel(dv.getVersionId());
297 DossierVersionStatus dvs = dv.getStatus();
298 if(dvs.equals(DossierVersionStatus.VERSION_READY)) {
299 l.setStyle(
"color:green !important;");
300 }
else if(dvs.equals(DossierVersionStatus.VERSION_STOPPED)) {
301 l.setStyle(
"color:red !important;");
302 }
else if(dvs.equals(DossierVersionStatus.VERSION_NOTRECOMMENDED)) {
303 l.setStyle(
"color:blue !important;");
java.util.List< DossierIds > getDossierIdList()
void setDossierResults(DossierResults results)
boolean isInRole(String role)
static Application getApplication()
static String get(String msg)
void setRowCount(int rows)