BrightSide Workbench Full Report + Source Code
BalanceTree.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.register;
19 
20 import java.text.NumberFormat;
21 import org.turro.financials.model.business.CompanyWrapper;
22 import org.turro.i18n.I_;
23 import org.zkoss.zk.ui.ext.AfterCompose;
24 import org.zkoss.zul.Tree;
25 import org.zkoss.zul.Treechildren;
26 import org.zkoss.zul.Treecol;
27 import org.zkoss.zul.Treecols;
28 
33 public class BalanceTree extends Tree implements AfterCompose {
34 
35  private Treechildren children;
36  private BalanceFilter filter;
37  private NumberFormat currencyFormatter;
38 
39  public BalanceTree() {
40  super();
41  currencyFormatter = CompanyWrapper.getCurrencyFormatter();
42  addColumns();
43  addChildrenSpace();
44  }
45 
47  return filter;
48  }
49 
50  public void setFilter(BalanceFilter filter) {
51  this.filter = filter;
52  }
53 
54  public void refreshTree() {
55  children.getChildren().clear();
56  afterCompose();
57  }
58 
59  private void addColumns() {
60  Treecols cols = new Treecols();
61  cols.setSizable(true);
62  appendChild(cols);
63 
64  Treecol col = new Treecol();
65  col.setLabel("");
66  col.setWidth("220px");
67  cols.appendChild(col);
68 
69  col = new Treecol();
70  col.setLabel(I_.get("Description"));
71  cols.appendChild(col);
72 
73  col = new Treecol();
74  col.setLabel(I_.get("Debit"));
75  col.setAlign("right");
76  col.setWidth("170px");
77  cols.appendChild(col);
78 
79  col = new Treecol();
80  col.setLabel(I_.get("Credit"));
81  col.setAlign("right");
82  col.setWidth("170px");
83  cols.appendChild(col);
84 
85  col = new Treecol();
86  col.setLabel(I_.get("Balance"));
87  col.setAlign("right");
88  col.setWidth("170px");
89  cols.appendChild(col);
90 
91  col = new Treecol();
92  col.setWidth("25px");
93  cols.appendChild(col);
94  }
95 
96  private void addChildrenSpace() {
97  children = new Treechildren();
98  appendChild(children);
99  }
100 
101  @Override
102  public void afterCompose() {
103  BalanceTopItem bti = new BalanceTopItem(true);
104  children.appendChild(bti);
105  bti.afterCompose();
106  }
107 
108  public String formatCurrency(double value) {
109  return currencyFormatter.format(value);
110  }
111 
112 }
void setFilter(BalanceFilter filter)
static String get(String msg)
Definition: I_.java:41