BrightSide Workbench Full Report + Source Code
EntityGrid.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.elephant.zkoss;
19 
20 import java.util.Collection;
21 import org.turro.command.CommandUtil;
22 import org.turro.i18n.I_;
23 import org.turro.zkoss.dialog.SelectionDialog;
24 import org.turro.zkoss.grid.PagingGrid;
25 import org.turro.zul.frame.Framework;
26 import org.zkoss.zk.ui.Component;
27 import org.zkoss.zk.ui.ext.AfterCompose;
28 import org.zkoss.zul.Row;
29 import org.zkoss.zul.Rows;
30 
35 public class EntityGrid extends PagingGrid implements AfterCompose {
36 
37  private Rows rows;
38  private Collection entities;
39 
40  public Collection getEntities() {
41  return entities;
42  }
43 
44  public void setEntities(Collection entities) {
45  this.entities = entities;
46  }
47 
48  private void addRows() {
49 
50  setRowCount(entities.size());
51 
52  if(rows != null) removeChild(rows);
53 
54  rows = new Rows();
55  appendChild(rows);
56 
57  for(Object ia : entities) {
58  Row row = new Row();
59  Component comp = CommandUtil.getLink(ia);
60  if(comp != null) {
61  row.appendChild(comp);
62  row.setValue(ia);
63  rows.appendChild(row);
64  }
65  }
66  }
67 
68  @Override
69  public void afterCompose() {
70  addRows();
71  }
72 
73  public static void showEntities(Collection<String> entitiesPath) {
74  EntityGrid dl = new EntityGrid();
75  dl.setMaxResults(20);
76  dl.setEntities(entitiesPath);
78  Framework.getCurrent().getPage(),
79  I_.get("Entities"),
80  dl, "80%", "80%", null);
81  }
82 
83 }
84 
static HtmlBasedComponent getLink(Object entity)
static void showEntities(Collection< String > entitiesPath)
Definition: EntityGrid.java:73
void setEntities(Collection entities)
Definition: EntityGrid.java:44
static String get(String msg)
Definition: I_.java:41
static void showComponent(Page page, String title, Component component, String width, String height, final Command command)
void setMaxResults(int maxResults)
static Framework getCurrent()
Definition: Framework.java:203