BrightSide Workbench Full Report + Source Code
InactiveProspectGrid.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2013 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 
19 package org.turro.crm.zul.activity;
20 
21 import java.util.List;
22 import org.turro.command.CommandUtil;
23 import org.turro.crm.entity.SaleProspect;
24 import org.turro.crm.entity.Vendor;
25 import org.turro.crm.search.InactiveProspects;
26 import org.turro.i18n.I_;
27 import org.turro.zkoss.grid.PagingGrid;
28 import org.turro.zkoss.label.LabelExtended;
29 import org.zkoss.zk.ui.ext.AfterCompose;
30 import org.zkoss.zul.Column;
31 import org.zkoss.zul.Columns;
32 import org.zkoss.zul.Row;
33 import org.zkoss.zul.Rows;
34 
39 public class InactiveProspectGrid extends PagingGrid implements AfterCompose {
40 
41  private Vendor vendor;
42 
43  public void setVendor(Vendor vendor) {
44  this.vendor = vendor;
45  }
46 
47  @Override
48  public void afterCompose() {
49  addColumns();
50  }
51 
52  public void reload() {
53  addRows();
54  }
55 
56  private void addRows() {
57  List<SaleProspect> list = new InactiveProspects().getObjectValues(vendor);
58 
59  Rows rows = getRows(true);
60  rows.getChildren().clear();
61 
62  for(final SaleProspect sp : list) {
63  Row row = new Row();
64  rows.appendChild(row);
65  row.appendChild(new LabelExtended().setDate(sp.getProspectDate()));
66  row.appendChild(CommandUtil.getLinkOrSpace(sp));
67  }
68 
69  setRowCount(list.size());
70  }
71 
72  private void addColumns() {
73  Columns cols = new Columns();
74  appendChild(cols);
75 
76  Column col = new Column(I_.get("Date"), null, "90px");
77  cols.appendChild(col);
78 
79  col = new Column(I_.get("Description"));
80  cols.appendChild(col);
81  }
82 
83 }
static HtmlBasedComponent getLinkOrSpace(Object entity)
java.util.List< SaleProspect > getObjectValues(Vendor vendor)
Rows getRows(boolean create)