19 package org.turro.dossier.dossier;
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import org.turro.dossier.db.DossierPU;
24 import org.turro.dossier.entity.Category;
25 import org.turro.dossier.entity.Dossier;
26 import org.turro.elephant.context.Application;
27 import org.turro.elephant.db.WhereClause;
28 import org.turro.i18n.I_;
29 import org.turro.jpa.Dao;
30 import org.zkoss.zk.ui.event.Event;
31 import org.zkoss.zk.ui.event.EventListener;
32 import org.zkoss.zk.ui.event.Events;
33 import org.zkoss.zk.ui.ext.AfterCompose;
34 import org.zkoss.zul.Treechildren;
35 import org.zkoss.zul.Treeitem;
43 private Treechildren children;
44 private boolean loadOnDemand, knowledgeBase;
48 this.loadOnDemand = loadOnDemand;
49 this.knowledgeBase = knowledgeBase;
51 setLabel(entity ==
null ?
I_.
get(
"All") : getDescription(entity));
52 setTooltiptext(getLabel());
70 if(children !=
null) {
71 children.getChildren().clear();
80 private void initLoadOnDemand() {
81 if(!loadOnDemand)
return;
85 addEventListener(Events.ON_OPEN,
new EventListener() {
87 public void onEvent(Event event)
throws Exception {
98 children.appendChild(obj);
103 private void fillCategory() {
104 if(children !=
null && children.getChildren().isEmpty()
107 addEntity(obj, loadOnDemand, knowledgeBase);
112 private void addChildrenSpace() {
114 children =
new Treechildren();
115 appendChild(children);
128 this.loadOnDemand = loadOnDemand;
133 ArrayList list =
new ArrayList();
136 wc.
addClause(
"select category from Category as category");
140 wc.
addClause(
"where parent = :category");
143 wc.
addClause(
"order by category.description");
144 for(Object o : dao.getResultList(wc)) {
145 if((knowledgeBase && ((
Category) (o)).isKnowledgeBase()) ||
152 wc.
addClause(
"select dossier from Dossier as dossier");
153 wc.
addClause(
"where category = :category");
155 wc.
addClause(
"order by dossier.description");
156 for(Object o : dao.getResultList(wc)) {
171 private String getDescription(Object entity) {
173 return ((
Category) entity).getDescription();
174 }
else if(entity instanceof Dossier) {
175 return ((Dossier) entity).getDescription();
CategoryDossierItem addEntity(Object entity, boolean loadOnDemand, boolean knowledgeBase)
Collection< Object > getCategoryChildren()
void setLoadOnDemand(boolean loadOnDemand)
CategoryDossierTree getTree()
CategoryDossierItem(Object entity, boolean loadOnDemand, boolean knowledgeBase)
boolean isInRole(String role)
static Application getApplication()
void addClause(String clause)
void addNamedValue(String name, Object value)
static String get(String msg)