19 package org.turro.zul.groupit;
21 import org.turro.string.Strings;
22 import org.turro.contacts.GroupIt;
23 import org.turro.i18n.I_;
24 import org.zkoss.zk.ui.event.Event;
25 import org.zkoss.zk.ui.event.EventListener;
26 import org.zkoss.zk.ui.event.Events;
27 import org.zkoss.zk.ui.ext.AfterCompose;
28 import org.zkoss.zul.Treechildren;
29 import org.zkoss.zul.Treeitem;
35 public class GroupItItem extends Treeitem implements AfterCompose {
37 private Treechildren children;
38 private boolean loadOnDemand;
39 private final String entityPath;
43 this.loadOnDemand = loadOnDemand;
44 this.entityPath = entityPath;
46 setLabel(group ==
null ?
I_.
get(
"All") : group.
getName());
47 setTooltiptext(getLabel());
65 if(!
isLeaf() && children ==
null) {
66 children =
new Treechildren();
67 appendChild(children);
69 if(children !=
null) {
70 children.getChildren().clear();
77 if(Strings.isBlank(entityPath)) {
78 return group ==
null ?
82 return group ==
null ?
84 group.
children(entityPath).isEmpty();
88 private void initLoadOnDemand() {
89 if(!loadOnDemand)
return;
93 addEventListener(Events.ON_OPEN,
new EventListener() {
95 public void onEvent(Event event)
throws Exception {
106 children.appendChild(cat);
111 private void fillGroup() {
112 if(children !=
null && children.getChildren().isEmpty()) {
114 if(Strings.isBlank(entityPath)) {
115 for(
GroupIt gpr : group ==
null ?
121 for(GroupIt gpr : group ==
null ?
122 GroupIt.roots(
getTree().getCategory(), entityPath) :
130 private void addChildrenSpace() {
132 children =
new Treechildren();
133 appendChild(children);
146 this.loadOnDemand = loadOnDemand;
static String get(String msg)
void setLoadOnDemand(boolean loadOnDemand)
GroupItItem addGroup(GroupIt group, boolean loadOnDemand)
GroupItItem(GroupIt group, boolean loadOnDemand, String entityPath)