18 package org.turro.financials.contract;
20 import java.util.ArrayList;
21 import java.util.Iterator;
22 import org.turro.financials.contract.logic.ContractDefinitionWrapper;
23 import org.turro.financials.entity.ContractDefinition;
24 import org.turro.zkoss.tree.GenericTree;
25 import org.zkoss.zk.ui.event.Event;
26 import org.zkoss.zk.ui.event.EventListener;
27 import org.zkoss.zk.ui.event.Events;
28 import org.zkoss.zul.Treechildren;
29 import org.zkoss.zul.Treeitem;
37 private Treechildren children;
38 private ArrayList<ContractDefinition> ctcDefs;
43 addEventListener(Events.ON_SELECT,
new EventListener() {
45 public void onEvent(Event event) {
46 Treeitem ti = getSelectedItem();
49 event.stopPropagation();
58 n1 =
new Treeitem(
"Proveïdor (suministres, mercaderies, serveis, inversions, municipi)");
60 children.appendChild(n1);
89 n1 =
new Treeitem(
"Client (Clients en general)");
91 children.appendChild(n1);
98 n1 =
new Treeitem(
"Banc (Comptes corrents, tarjetes de crèdit, estalvi, etc.)");
100 children.appendChild(n1);
107 n1 =
new Treeitem(
"Prestecs (Prestecs a llarc plaç, leasings)");
109 children.appendChild(n1);
113 n1 =
new Treeitem(
"Gestoria (Gestors, administradors de finques");
115 children.appendChild(n1);
117 n1 =
new Treeitem(
"Impostos (de la Seguretat Social i Hisenda");
119 children.appendChild(n1);
124 n1 =
new Treeitem(
"Empresa (Socis, treballadors, magatzems, caixa fort, etc.)");
126 children.appendChild(n1);
130 n2 = addChildTo(n1,
"Laboral (Treballadors)");
133 n2 = addChildTo(n1,
"Dipòsits (Dipòsits d'explotació, oficina, botigues, magatzems, etc.)");
136 if(!ctcDefs.isEmpty()) {
137 n1 =
new Treeitem(
"No classificats");
139 children.appendChild(n1);
144 private void addChildrenSpace() {
145 children =
new Treechildren();
146 appendChild(children);
149 private Treeitem addChildTo(Treeitem item, String label) {
150 Treeitem ti =
new Treeitem(label);
156 private void addChildTo(Treeitem item,
long id) {
157 ContractDefinition cd = useCtcDef(
id);
159 Treeitem ti =
new Treeitem(cd.getName());
166 private void addAllChildTo(Treeitem item) {
167 for(ContractDefinition cd : ctcDefs) {
168 Treeitem ti =
new Treeitem(cd.getName());
176 private ContractDefinition useCtcDef(
long id) {
177 Iterator<ContractDefinition> it = ctcDefs.iterator();
178 ContractDefinition cd =
null;
179 while(it.hasNext()) {
181 if(cd.getId() ==
id) {
static Collection< ContractDefinition > getContractDefinitions()
void addTreeitem(Treeitem parent, Treeitem child)