BrightSide Workbench Full Report + Source Code
SaleProspectGrid.java
Go to the documentation of this file.
1 package org.turro.crm.zul.sale;
2 
3 import java.util.Collection;
4 import org.turro.command.CommandUtil;
5 import org.turro.crm.entity.SaleProspect;
6 import org.turro.i18n.I_;
7 import org.turro.zkoss.grid.PagingGrid;
8 import org.turro.zkoss.label.LabelExtended;
9 import org.zkoss.zk.ui.ext.AfterCompose;
10 import org.zkoss.zul.Column;
11 import org.zkoss.zul.Columns;
12 import org.zkoss.zul.Row;
13 import org.zkoss.zul.Rows;
14 
19 public class SaleProspectGrid extends PagingGrid implements AfterCompose {
20 
21  private SaleProspectFilter filter = new SaleProspectFilter();
22  private SaleProspectFilterGrid filterGrid;
23 
25  return filter;
26  }
27 
28  public void setFilterGrid(SaleProspectFilterGrid filterGrid) {
29  this.filterGrid = filterGrid;
30  }
31 
32  public void reload() {
33  if(getRows() != null) {
34  getRows().detach();
35  }
36  addRows();
37  }
38 
39  @Override
40  public void afterCompose() {
41  addColumns();
42  }
43 
44  private void addRows() {
45  if(!filterGrid.hasValues()) return;
46 
47  Collection<SaleProspect> list = filter.getObjectValues(filterGrid.getValues());
48 
49  Rows rows = new Rows();
50  appendChild(rows);
51 
52  for(final SaleProspect cd : list) {
53  Row row = new Row();
54  rows.appendChild(row);
55  row.appendChild(new LabelExtended().setDate(cd.getProspectDate()));
56  row.appendChild(CommandUtil.getLinkOrSpace(cd));
57  }
58 
59  setRowCount(list.size());
60  }
61 
62  private void addColumns() {
63  Columns cols = new Columns();
64  appendChild(cols);
65 
66  Column col = new Column(I_.get("Date"), null, "90px");
67  cols.appendChild(col);
68 
69  col = new Column(I_.get("Description"));
70  cols.appendChild(col);
71  }
72 
73 }
static HtmlBasedComponent getLinkOrSpace(Object entity)
Collection< SaleProspect > getObjectValues(List< IFilterValue > values)
void setFilterGrid(SaleProspectFilterGrid filterGrid)
List< IFilterValue > getValues()
Rows getRows(boolean create)