BrightSide Workbench Full Report + Source Code
RelatedDocRow.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.RelatedDocument;
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.Cell;
26 import org.zkoss.zul.Detail;
27 import org.zkoss.zul.Hbox;
28 import org.zkoss.zul.Hlayout;
29 import org.zkoss.zul.Image;
30 import org.zkoss.zul.Label;
31 import org.zkoss.zul.Row;
32 
37 public class RelatedDocRow extends Row {
38 
39  private RelatedDocument relatedDocument;
40 
41  public RelatedDocRow(RelatedDocument relatedDocument) {
42  this.relatedDocument = relatedDocument;
43  addCells();
44  }
45 
46  private void addCells() {
47  addDetail();
48  Hlayout hbox = new Hlayout();
49  hbox.setSpacing("20px");
50  Label l = new Label(relatedDocument.getDocumentDefinition().getName());
51  l.setStyle("cursor:pointer");
52  l.addEventListener(Events.ON_CLICK, new EventListener() {
53  @Override
54  public void onEvent(Event event) throws Exception {
56  }
57  });
58  hbox.appendChild(l);
59  if(relatedDocument.isAllowed()) {
60  hbox.appendChild(new Image("/_zul/images/ok.png"));
61  } else {
62  hbox.appendChild(new Image("/_zul/images/cancel.png"));
63  }
64  if(relatedDocument.getDocumentDefinition().isAutoNumbered()) {
65  hbox.appendChild(new Image("/_zul/images/auto_num.png"));
66  }
67  appendChild(hbox);
68  }
69 
70  private void addDetail() {
71  Detail detail = new Detail();
72  appendChild(detail);
73 
74  Hbox hbox = new Hbox();
75  hbox.setHflex("1");
76  Cell cell = new Cell();
77  cell.setHflex("2");
78  cell.appendChild(new RelatedColsGrid(relatedDocument.getDocumentDefinition().getDocumentColumns()));
79  hbox.appendChild(cell);
80  cell = new Cell();
81  cell.setHflex("4");
82  cell.appendChild(new RelatedLineTypeGrid(relatedDocument.getDocumentDefinition().getRelatedLineTypes()));
83  hbox.appendChild(cell);
84  cell = new Cell();
85  cell.setHflex("3");
86  cell.appendChild(new RelatedStoresGrid(relatedDocument.getDocumentDefinition().getRelatedStoreDefinitions()));
87  hbox.appendChild(cell);
88  detail.appendChild(hbox);
89  }
90 
91 }
RelatedDocRow(RelatedDocument relatedDocument)