19 package org.turro.publication.model;
21 import org.turro.contacts.social.SocialGroupListbox;
22 import org.turro.entities.EntityCombobox;
23 import org.turro.string.Strings;
24 import org.zkoss.zk.ui.annotation.ComponentAnnotation;
25 import org.zkoss.zk.ui.event.Event;
26 import org.zkoss.zk.ui.event.Events;
27 import org.zkoss.zk.ui.event.InputEvent;
28 import org.zkoss.zk.ui.ext.AfterCompose;
29 import org.zkoss.zul.Hlayout;
30 import org.zkoss.zul.Space;
31 import org.zkoss.zul.Toolbarbutton;
37 @ComponentAnnotation({
"value:@ZKBIND(ACCESS=both,SAVE_EVENT=onChange)"})
54 if(Strings.isBlank(keyId)) {
56 }
else if(keyId.startsWith(
"/")) {
64 private void updateControl(String keyId) {
66 getChildren().remove(0);
67 getChildren().add(0,
new Space());
68 }
else if(mode == ConstraintKeyMode.ENTITY) {
69 getChildren().remove(0);
70 EntityCombobox combo =
new EntityCombobox();
71 combo.setEntityPath(keyId);
72 combo.setWidth(
"400px");
73 combo.addEventListener(Events.ON_SELECT, (Event event) -> {
74 Events.postEvent(new InputEvent(
"onChange", this, combo.getEntityPath(), null));
76 getChildren().add(0, combo);
77 }
else if(mode == ConstraintKeyMode.SOCIAL_GROUP) {
78 getChildren().remove(0);
79 SocialGroupListbox list =
new SocialGroupListbox();
80 list.setMold(
"select");
81 list.setKeyString(keyId);
82 list.addEventListener(Events.ON_SELECT, (Event event) -> {
83 Events.postEvent(new InputEvent(
"onChange", this, list.getKeyString(), null));
85 getChildren().add(0, list);
91 appendChild(
new Space());
92 Toolbarbutton social =
new Toolbarbutton();
93 social.setImage(
"/_zul/images/contact.png");
94 social.addEventListener(Events.ON_CLICK, (Event event) -> {
95 mode = ConstraintKeyMode.SOCIAL_GROUP;
99 Toolbarbutton entity =
new Toolbarbutton();
100 entity.setImage(
"/_zul/images/entity.png");
101 entity.addEventListener(Events.ON_CLICK, (Event event) -> {
102 mode = ConstraintKeyMode.ENTITY;
106 Toolbarbutton
delete =
new Toolbarbutton();
107 delete.setImage(
"/_zul/images/delete.png");
108 delete.addEventListener(Events.ON_CLICK, (Event event) -> {
109 mode = ConstraintKeyMode.EMPTY;
111 Events.postEvent(new InputEvent(
"onChange", this,
"", null));
void setValue(String keyId)