18 package org.turro.dossier.dossier;
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import org.turro.dossier.db.DossierPU;
23 import org.turro.dossier.entity.Category;
24 import org.turro.elephant.context.Application;
25 import org.turro.elephant.db.WhereClause;
26 import org.turro.i18n.I_;
27 import org.turro.jpa.Dao;
28 import org.zkoss.zk.ui.event.Event;
29 import org.zkoss.zk.ui.event.EventListener;
30 import org.zkoss.zk.ui.event.Events;
31 import org.zkoss.zk.ui.ext.AfterCompose;
32 import org.zkoss.zul.Treechildren;
33 import org.zkoss.zul.Treeitem;
39 public class CategoryItem extends Treeitem implements AfterCompose {
41 private Treechildren children;
42 private boolean loadOnDemand;
46 this.loadOnDemand = loadOnDemand;
49 setTooltiptext(getLabel());
67 if(children !=
null) {
68 children.getChildren().clear();
77 private void initLoadOnDemand() {
78 if(!loadOnDemand)
return;
82 addEventListener(Events.ON_OPEN,
new EventListener() {
84 public void onEvent(Event event)
throws Exception {
95 children.appendChild(cat);
100 private void fillCategory() {
101 if(children !=
null && children.getChildren().isEmpty()) {
108 private void addChildrenSpace() {
110 children =
new Treechildren();
111 appendChild(children);
124 this.loadOnDemand = loadOnDemand;
131 wc.
addClause(
"select category from Category as category");
135 wc.
addClause(
"where parent = :category");
139 wc.
addClause(
"order by category.description");
140 ArrayList<Category> list =
new ArrayList<Category>();
141 for(Object o : dao.getResultList(wc)) {
CategoryItem addCategory(Category category, boolean loadOnDemand)
Collection< Category > getCategoryChildren()
CategoryItem(Category category, boolean loadOnDemand)
void setLoadOnDemand(boolean loadOnDemand)
boolean isInRole(String role)
static Application getApplication()
void addClause(String clause)
void addNamedValue(String name, Object value)
static String get(String msg)