18 package org.turro.dossier.zul.dossier;
20 import java.util.Collection;
21 import java.util.List;
22 import org.turro.dossier.dossier.CategoryWrapper;
23 import org.turro.dossier.entity.Category;
24 import org.turro.dossier.entity.CategoryParticipant;
25 import org.turro.dossier.search.CategoryResults;
26 import org.turro.dossier.zul.menu.DossierMenu;
27 import org.turro.elephant.util.Messages;
28 import org.turro.i18n.I_;
29 import org.turro.zul.frame.Framework;
30 import org.zkoss.zk.ui.Component;
31 import org.zkoss.zk.ui.event.Event;
32 import org.zkoss.zk.ui.event.EventListener;
33 import org.zkoss.zk.ui.event.Events;
34 import org.zkoss.zk.ui.ext.AfterCompose;
35 import org.zkoss.zul.*;
48 private void populateTree() {
50 if(!children.isEmpty()) {
52 if(children.size() > 3) {
58 createNodes(cbox, children);
62 private void createNodes(Box box, Collection<Category> list) {
63 box.setAlign(
"center");
64 box.setStyle(
"padding:10px;");
65 for(
final Category cat : list) {
66 Groupbox gb =
new Groupbox();
69 gb.appendChild(
new Caption(
"#" + cat.getId() +
" " + cat.getDescription()));
70 Vbox vbox =
new Vbox();
71 vbox.setAlign(
"center");
72 vbox.setSclass(
"participant");
74 for(CategoryParticipant cp : cat.getParticipants()) {
75 Hbox hbox =
new Hbox();
76 vbox.appendChild(hbox);
77 hbox.appendChild(
new Label(cp.getName()));
78 hbox.appendChild(
new Label(
"[" + I_.byKey(cp.getRole().toString()) +
"]"));
80 vbox.appendChild(
new Separator());
81 Button edit =
new Button(I_.get(
"Edit"),
"/_zul/images/edit.png");
82 edit.addEventListener(Events.ON_CLICK,
new EventListener() {
84 public void onEvent(Event event)
throws Exception {
85 DossierMenu.showCategory(cat.getId());
86 Framework.getCurrent().invalidateSelected();
89 if(
new CategoryWrapper(cat).canDelete()) {
90 Button
delete =
new Button(I_.get(
"Delete"),
"/_zul/images/edit-delete.png");
91 delete.addEventListener(Events.ON_CLICK,
new EventListener() {
93 public void onEvent(Event event)
throws Exception {
94 Messages.confirmDeletion().show(() -> {
95 new CategoryWrapper(cat).delete();
96 Framework.getCurrent().invalidateSelected();
100 vbox.appendChild(
new Hbox(
new Component[] {edit,
delete}));
102 vbox.appendChild(
new Hbox(
new Component[] {edit}));
104 vbox.appendChild(
new Separator());
105 Collection<Category> children = cat.getChildren();
106 if(!children.isEmpty()) {
108 if(children.size() > 3) {
113 vbox.appendChild(cbox);
114 createNodes(cbox, children);
java.util.List getCategoryRootList()