19 package org.turro.contacts.zul.control;
21 import java.util.ArrayList;
22 import org.turro.command.Command;
23 import org.turro.command.Context;
24 import org.turro.contacts.Contact;
25 import org.turro.contacts.control.ContactFieldList;
26 import org.turro.contacts.util.ContactListbox;
27 import org.turro.elephant.context.Application;
28 import org.turro.i18n.I_;
29 import org.turro.zkoss.input.GenericBandbox;
30 import org.zkoss.zk.ui.event.Event;
31 import org.zkoss.zk.ui.event.EventListener;
32 import org.zkoss.zk.ui.event.Events;
33 import org.zkoss.zk.ui.event.InputEvent;
34 import org.zkoss.zul.Button;
35 import org.zkoss.zul.Hbox;
36 import org.zkoss.zul.Vlayout;
45 private boolean typing =
false;
58 Vlayout vbox =
new Vlayout();
59 vbox.setVflex(
"true");
60 contacts.setVflex(
true);
62 vbox.appendChild(contacts);
63 addEventListener(Events.ON_CHANGING,
new EventListener() {
65 public void onEvent(Event event)
throws Exception {
75 contacts.addEventListener(Events.ON_SELECT,
new EventListener() {
77 public void onEvent(Event event) {
79 Events.postEvent(
new Event(Events.ON_CHANGE,
ContactFinder.this));
85 Hbox butCont =
new Hbox();
86 butCont.setSclass(
"buttonDialogContainer");
87 butCont.setHflex(
"true");
88 butCont.setPack(
"end");
89 butCont.setStyle(
"padding:10px");
90 butCont.setSpacing(
"15px");
91 Button newContact =
new Button(
I_.
get(
"New contact"));
92 newContact.addEventListener(Events.ON_CLICK,
new EventListener<Event>() {
94 public void onEvent(Event event) throws Exception {
95 if(fields.isEmpty()) {
96 fields.createMinimumContact();
98 ContactForm.newContact(fields, new Command() {
100 public Object execute(Context context) {
101 Contact contact = (Contact) context.get(
"contact");
102 if(contact != null) {
103 if(contacts.getCollection() == null) {
104 contacts.setCollection(new ArrayList<Contact>());
106 contacts.getCollection().add(contact);
107 contacts.updateCollection();
108 setObjectValue(contact);
115 butCont.appendChild(newContact);
116 vbox.appendChild(butCont);
124 Contact v = contacts.getObjectValue();
135 contacts.setObjectValue(v);
boolean isInRole(String role)
static Application getApplication()
static String get(String msg)