BrightSide Workbench Full Report + Source Code
StarItGrid.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.zul.starit;
20 
21 import org.turro.contacts.StarIt;
22 import org.turro.elephant.context.Application;
23 import org.turro.i18n.I_;
24 import org.turro.starit.StarItUtil;
25 import org.turro.zkoss.grid.PagingGrid;
26 import org.turro.zkoss.label.LabelExtended;
27 import org.zkoss.zk.ui.ext.AfterCompose;
28 import org.zkoss.zul.Column;
29 import org.zkoss.zul.Columns;
30 import org.zkoss.zul.Label;
31 import org.zkoss.zul.Row;
32 import org.zkoss.zul.Rows;
33 
38 public class StarItGrid extends PagingGrid implements AfterCompose {
39 
40  private Application app = Application.getApplication();
41  private String entityPath;
42 
43  public StarItGrid() {
44  addColumns();
45  }
46 
47  public void setEntityPath(String entityPath) {
48  this.entityPath = entityPath;
49  }
50 
51  @Override
52  public void afterCompose() {
53  addRows();
54  }
55 
56  private void addColumns() {
57  Columns cols = new Columns();
58  cols.setSizable(true);
59  cols.setMenupopup("auto");
60  appendChild(cols);
61 
62  Column col = new Column(I_.get("Date"), null, "120px");
63  cols.appendChild(col);
64 
65  col = new Column(I_.get("Author"));
66  cols.appendChild(col);
67 
68  col = new Column(I_.get("Votes"), null, "80px");
69  col.setAlign("right");
70  cols.appendChild(col);
71  }
72 
73  private void addRows() {
74  Rows rows = getRows(true);
75  rows.getChildren().clear();
76 
77  for(final StarIt si : StarItUtil.allStars(entityPath)) {
78  final Row row = new Row();
79  row.setValign("top");
80  rows.appendChild(row);
81 
82  LabelExtended lext = new LabelExtended();
83  lext.setDate(si.getDateCreation());
84  lext.setSclass("ldate");
85  row.appendChild(lext);
86 
87  row.appendChild(new Label(si.getAuthor_ip()));
88 
89  row.appendChild(new Label(si.getStars() + ""));
90  }
91  }
92 
93 }
static String get(String msg)
Definition: I_.java:41
Rows getRows(boolean create)
void setEntityPath(String entityPath)
Definition: StarItGrid.java:47