19 package org.turro.hierarchy;
21 import java.util.Collection;
22 import java.util.Iterator;
24 import java.util.TreeMap;
25 import org.turro.zkoss.grid.PagingGrid;
26 import org.zkoss.zk.ui.event.Event;
27 import org.zkoss.zk.ui.event.EventListener;
28 import org.zkoss.zk.ui.event.Events;
29 import org.zkoss.zul.Hlayout;
30 import org.zkoss.zul.Row;
31 import org.zkoss.zul.Rows;
32 import org.zkoss.zul.Space;
33 import org.zkoss.zul.Toolbarbutton;
41 private Collection<Hierarchical> items;
42 private Map<Hierarchical, Boolean> breakdown;
43 private int showBreakdownLevel;
45 public void setCollection(Collection<Hierarchical> items,
int showBreakdownLevel) {
46 this.showBreakdownLevel = showBreakdownLevel;
53 rows.getChildren().clear();
55 breakdown =
new TreeMap<Hierarchical, Boolean>();
72 breakdown.put(value, showBreakdownLevel <= 0 || getLevel(value) < showBreakdownLevel);
75 for(Iterator it = value.
children().iterator(); it.hasNext();) {
76 Object obj = it.next();
77 if(obj instanceof Collection) {
78 for(Object o : (Collection) obj) {
82 processValue((Hierarchical) obj);
90 for(Object row :
getRows().getChildren()) {
91 if(row instanceof Row) {
94 ((Row) row).getChildren().clear();
102 Hlayout hbox =
new Hlayout();
103 Space s =
new Space();
104 s.setWidth(getLevel(value) * 15 +
"px");
108 Toolbarbutton bd =
new Toolbarbutton();
110 bd.addEventListener(Events.ON_CLICK,
new EventListener() {
112 public void onEvent(Event event)
throws Exception {
117 hbox.appendChild(bd);
127 return "/_zul/images/breakdown-open.png";
129 return "/_zul/images/breakdown-closed.png";
138 return breakdown.get(value);
boolean isShowBreakdown(Hierarchical value)
abstract void refreshValue(Row row, Hierarchical value)
void changeBreakdownState(Hierarchical value)
Hlayout getNameLayout(final Hierarchical value)
boolean isVisible(Hierarchical value)
String getBreakdownImage(Hierarchical value)
void setCollection(Collection< Hierarchical > items, int showBreakdownLevel)
Rows getRows(boolean create)
void setRowCount(int rows)