19 package org.turro.zul.groupit;
21 import org.turro.contacts.Grouped;
22 import org.turro.contacts.db.ContactsPU;
23 import org.turro.elephant.util.Images;
24 import org.zkoss.lang.Strings;
25 import org.zkoss.zk.ui.event.Event;
26 import org.zkoss.zk.ui.event.EventListener;
27 import org.zkoss.zk.ui.event.Events;
28 import org.zkoss.zk.ui.ext.AfterCompose;
29 import org.zkoss.zul.Button;
30 import org.zkoss.zul.Hlayout;
36 public class GroupedLine extends Hlayout implements AfterCompose {
39 private final boolean allowEdit;
42 this.grouped = grouped;
43 this.allowEdit = allowEdit;
44 setSclass(
"z-valign-middle");
53 if(grouped !=
null && grouped.
getParent() !=
null) {
56 category.setDisabled(!allowEdit);
57 appendChild(category);
65 group.setDisabled(!allowEdit);
70 save.addEventListener(Events.ON_CLICK,
new EventListener<Event>() {
72 public void onEvent(Event event) throws Exception {
73 grouped.setParent(group.getObjectValue());
74 boolean isNew = Strings.isBlank(grouped.getId());
75 grouped = new ContactsPU().saveObject(grouped);
77 Events.postEvent(new Event(Events.ON_CHANGE, GroupedLine.this.getParent()));
81 if(!Strings.isBlank(grouped.
getId())) {
84 delete.addEventListener(Events.ON_CLICK,
new EventListener<Event>() {
86 public void onEvent(Event event) throws Exception {
87 new ContactsPU().deleteObject(grouped);
88 GroupedLine.this.detach();
93 category.addEventListener(Events.ON_SELECT,
new EventListener<Event>() {
95 public void onEvent(Event event) throws Exception {
96 group.setCategory(category.getObjectValue());
static String getImage(String image)
void setCategory(String category)
void setObjectValue(GroupIt v)
GroupedLine(Grouped grouped, boolean allowEdit)