BrightSide Workbench Full Report + Source Code
ContractDefRow.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 org.turro.financials.entity.ContractDefinition;
21 import org.turro.financials.menu.FinancialsMenu;
22 import org.zkoss.zk.ui.event.Event;
23 import org.zkoss.zk.ui.event.EventListener;
24 import org.zkoss.zk.ui.event.Events;
25 import org.zkoss.zul.Detail;
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.Vlayout;
31 
36 public class ContractDefRow extends Row {
37 
38  private ContractDefinition contractDefinition;
39 
40  public ContractDefRow(ContractDefinition contractDefinition) {
41  this.contractDefinition = contractDefinition;
42  addCells();
43  }
44 
45  private void addCells() {
46  addDetail();
47  Hlayout hbox = new Hlayout();
48  hbox.setSpacing("20px");
49  Label l = new Label(contractDefinition.getDescription());
50  l.setStyle("cursor:pointer");
51  l.addEventListener(Events.ON_CLICK, new EventListener() {
52  @Override
53  public void onEvent(Event event) throws Exception {
54  FinancialsMenu.showContractDefinition(contractDefinition.getId());
55  }
56  });
57  hbox.appendChild(l);
58  if(contractDefinition.isStock()) {
59  hbox.appendChild(new Image("/_zul/images/store.png"));
60  }
61  if(contractDefinition.isCash()) {
62  hbox.appendChild(new Image("/_zul/images/cash.png"));
63  }
64  appendChild(hbox);
65  }
66 
67  private void addDetail() {
68  Detail detail = new Detail();
69  appendChild(detail);
70 
71  detail.addEventListener(Events.ON_OPEN, new EventListener() {
72  @Override
73  public void onEvent(Event event) throws Exception {
74  if(event.getTarget().getChildren().isEmpty()) {
75  Vlayout vbox = new Vlayout();
76  vbox.appendChild(new RelatedDocGrid(contractDefinition.getRelatedDocuments()));
77  vbox.appendChild(new DocumentWFGrid(contractDefinition.getDocumentWorkflows()));
78  event.getTarget().appendChild(vbox);
79  }
80  }
81  });
82  }
83 
84 
85 }
ContractDefRow(ContractDefinition contractDefinition)