BrightSide Workbench Full Report + Source Code
model/RelatedLineTypeGrid.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 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 package org.turro.financials.model;
19 
20 import java.util.Set;
21 import org.turro.elephant.util.DecimalFormats;
22 import org.turro.financials.entity.LineTypeAccount;
23 import org.turro.financials.entity.RelatedLineType;
24 import org.turro.zkoss.grid.PagingGrid;
25 import org.turro.zkoss.label.LabelTypes;
26 import org.zkoss.zul.Hlayout;
27 import org.zkoss.zul.Image;
28 import org.zkoss.zul.Label;
29 import org.zkoss.zul.Row;
30 import org.zkoss.zul.Rows;
31 import org.zkoss.zul.Vlayout;
32 
37 public class RelatedLineTypeGrid extends PagingGrid {
38 
39  private Set<RelatedLineType> relatedLineTypes;
40 
41  public RelatedLineTypeGrid(Set<RelatedLineType> relatedLineTypes) {
42  this.relatedLineTypes = relatedLineTypes;
43  setSizedByContent(true);
44  setDefaultBehavior(false);
45  addRows();
46  }
47 
48  private void addRows() {
49  Rows rows = new Rows();
50  appendChild(rows);
51 
52  for(final RelatedLineType rlt : relatedLineTypes) {
53  Row row = new Row();
54  rows.appendChild(row);
55 
56  Vlayout vbox = new Vlayout();
57  row.appendChild(vbox);
58 
59  Hlayout hbox = new Hlayout();
60  hbox.setSpacing("20px");
61  hbox.appendChild(new Label(rlt.getLineType().getName()));
62  hbox.appendChild(new Label(DecimalFormats.format(rlt.getLineType().getStockCoefficient())));
63  if(rlt.isDefaultLineType()) {
64  hbox.appendChild(new Image("/_zul/images/ok.png"));
65  }
66  vbox.appendChild(hbox);
67 
68  for(LineTypeAccount lta : rlt.getLineType().getLineTypeAccounts()) {
69  vbox.appendChild(LabelTypes.getSoftLabel(lta.getDescription()));
70  }
71  }
72 
73  setRowCount(relatedLineTypes.size());
74  }
75 
76 }
static String format(Number value, String pattern)
RelatedLineTypeGrid(Set< RelatedLineType > relatedLineTypes)
void setDefaultBehavior(boolean defaultBehavior)