BrightSide Workbench Full Report + Source Code
DocumentWFGrid.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.financials.entity.DocumentWorkflow;
22 import org.turro.financials.menu.FinancialsMenu;
23 import org.turro.zkoss.grid.PagingGrid;
24 import org.zkoss.zk.ui.event.Event;
25 import org.zkoss.zk.ui.event.EventListener;
26 import org.zkoss.zk.ui.event.Events;
27 import org.zkoss.zul.Hbox;
28 import org.zkoss.zul.Image;
29 import org.zkoss.zul.Label;
30 import org.zkoss.zul.Row;
31 import org.zkoss.zul.Rows;
32 
37 public class DocumentWFGrid extends PagingGrid {
38 
39  private Set<DocumentWorkflow> documentWorkflows;
40 
41  public DocumentWFGrid(Set<DocumentWorkflow> documentWorkflows) {
42  this.documentWorkflows = documentWorkflows;
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 DocumentWorkflow dwf : documentWorkflows) {
53  Row row = new Row();
54  rows.appendChild(row);
55 
56  Hbox hbox = new Hbox();
57  hbox.setSpacing("20px");
58  Label l = new Label(dwf.getAncestor().getName());
59  l.setStyle("cursor:pointer");
60  l.addEventListener(Events.ON_CLICK, new EventListener() {
61  @Override
62  public void onEvent(Event event) throws Exception {
63  FinancialsMenu.showDocumentDefinition(dwf.getAncestor().getId());
64  }
65  });
66  hbox.appendChild(l);
67  hbox.appendChild(new Image("/_zul/images/forward.png"));
68  l = new Label(dwf.getDescendant().getName());
69  l.setStyle("cursor:pointer");
70  l.addEventListener(Events.ON_CLICK, new EventListener() {
71  @Override
72  public void onEvent(Event event) throws Exception {
73  FinancialsMenu.showDocumentDefinition(dwf.getDescendant().getId());
74  }
75  });
76  hbox.appendChild(l);
77  row.appendChild(hbox);
78  }
79 
80  setRowCount(documentWorkflows.size());
81  }
82 
83 }
DocumentWFGrid(Set< DocumentWorkflow > documentWorkflows)
void setDefaultBehavior(boolean defaultBehavior)