19 package org.turro.zul.intouch;
21 import org.turro.string.Strings;
22 import org.turro.command.Command;
23 import org.turro.command.Context;
24 import org.turro.contacts.Contact;
25 import org.turro.contacts.InTouch;
26 import org.turro.contacts.zul.label.AddressInfo;
27 import org.turro.contacts.zul.label.ContactInfo;
28 import org.turro.elephant.util.Images;
29 import org.turro.elephant.util.Messages;
30 import org.turro.elephant.zkoss.Modal;
31 import org.turro.entities.Entities;
32 import org.turro.intouch.InTouchUtil;
33 import org.turro.zkoss.label.LabelExtended;
34 import org.turro.zkoss.label.LabelTypes;
35 import org.turro.zkoss.layout.GridLayout;
36 import org.zkoss.zk.ui.HtmlBasedComponent;
37 import org.zkoss.zk.ui.event.Event;
38 import org.zkoss.zk.ui.event.EventListener;
39 import org.zkoss.zk.ui.event.Events;
40 import org.zkoss.zk.ui.ext.AfterCompose;
41 import org.zkoss.zul.A;
42 import org.zkoss.zul.Space;
43 import org.zkoss.zul.Vlayout;
44 import org.zkoss.zul.Window;
52 private String entityPath;
60 this.provider = provider;
68 this.entityPath = entityPath;
77 if(provider ==
null || entityPath.endsWith(
"/0") || Strings.isBlank(entityPath)) {
82 addEventListener(Events.ON_CHANGE,
new EventListener<Event>() {
84 public void onEvent(Event event) throws Exception {
90 private void showInTouchs() {
92 for(InTouch inTouch : InTouchUtil.inTouch(entityPath)) {
93 Vlayout vbox =
new Vlayout();
94 vbox.appendChild(LabelTypes.getCaptionLabel(inTouch.getName()));
95 vbox.appendChild(LabelTypes.getSoftLabel(inTouch.getDescription()));
97 addComponent(
new ContactInfo(inTouch.getContact()));
98 addComponent(
new AddressInfo(inTouch.getAddress(), provider));
99 addComponent(
new LabelExtended().setDate(inTouch.getControl()));
100 addComponent(getEditButton(inTouch));
101 addComponent(getDeleteButton(inTouch));
102 getCurrentRow().setSclass(
"z-valign-middle");
105 addComponent(
new Space());
106 addComponent(
new Space());
107 addComponent(
new Space());
108 addComponent(
new Space());
109 InTouch inTouch =
new InTouch();
110 inTouch.setPath(entityPath);
111 addComponent(getEditButton(inTouch));
112 addComponent(
new Space());
115 private HtmlBasedComponent getEditButton(
final InTouch inTouch) {
116 A edit =
new A(
null, Images.getImage(Strings.isBlank(inTouch.getId()) ?
"list-add" :
"edit"));
117 edit.addEventListener(Events.ON_CLICK,
new EventListener<Event>() {
119 public void onEvent(Event event) throws Exception {
120 InTouchEdit edit = new InTouchEdit(provider, inTouch);
121 edit.setMode(Window.MODAL);
122 Modal.doModal(edit, new Command() {
124 public Object execute(Context context) {
134 private HtmlBasedComponent getDeleteButton(
final InTouch inTouch) {
135 A
delete =
new A(
null, Images.getImage(
"list-remove"));
136 delete.addEventListener(Events.ON_CLICK,
new EventListener<Event>() {
138 public void onEvent(Event event) throws Exception {
139 Messages.confirmDeletion().add(inTouch.getName()).show(() -> {
140 InTouchUtil.removeInTouch(inTouch);
static IElephantEntity getController(String path)
void setColumns(int columns)
void setProvider(Contact provider)
void setEntity(Object entity)
void setEntityPath(String entityPath)