BrightSide Workbench Full Report + Source Code
WorthValueGrid.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2017 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.dossier.zul.dossier;
20 
21 import org.turro.contacts.zul.label.ContactInfo;
22 import org.turro.dossier.entity.Dossier;
23 import org.turro.dossier.entity.WorthValue;
24 import org.turro.elephant.util.DecimalFormats;
25 import org.turro.i18n.I_;
26 import org.turro.zkoss.grid.PagingGrid;
27 import org.zkoss.zk.ui.ext.AfterCompose;
28 import org.zkoss.zul.Column;
29 import org.zkoss.zul.Columns;
30 import org.zkoss.zul.Label;
31 import org.zkoss.zul.Row;
32 import org.zkoss.zul.Rows;
33 
38 public class WorthValueGrid extends PagingGrid implements AfterCompose {
39 
40  private Dossier dossier;
41 
42  public void setDossier(Dossier dossier) {
43  this.dossier = dossier;
44  }
45 
46  @Override
47  public void afterCompose() {
48  addColumns();
49  addRows();
50  }
51 
52  private void addRows() {
53  Rows rows = new Rows();
54  appendChild(rows);
55 
56  for(final WorthValue wv : dossier.getWorths()) {
57  Row row = new Row();
58  rows.appendChild(row);
59  row.appendChild(new Label(wv.getWorthDefinition().getTitle()));
60  row.appendChild(new ContactInfo(wv.getIdContact()));
61  row.appendChild(new Label(DecimalFormats.format(wv.getValue())));
62  }
63 
64  setRowCount(dossier.getWorths().size());
65  }
66 
67  private void addColumns() {
68  Columns cols = new Columns();
69  appendChild(cols);
70 
71  Column col = new Column(I_.get("Title"));
72  col.setHflex("3");
73  cols.appendChild(col);
74 
75  col = new Column(I_.get("Contact"));
76  col.setHflex("3");
77  cols.appendChild(col);
78 
79  col = new Column(I_.get("Value"));
80  col.setHflex("1");
81  cols.appendChild(col);
82  }
83 
84 }
Set< WorthValue > getWorths()
Definition: Dossier.java:243
static String format(Number value, String pattern)