1 package org.turro.crm.zul.customer;
4 import org.turro.crm.entity.Customer;
5 import org.turro.crm.entity.CustomerOwner;
6 import org.turro.crm.entity.FormulaType;
7 import org.turro.crm.zul.vendor.FormulaListbox;
8 import org.turro.crm.zul.vendor.VendorCombobox;
9 import org.turro.elephant.util.Messages;
10 import org.turro.i18n.I_;
11 import org.zkoss.zk.ui.event.Event;
12 import org.zkoss.zk.ui.event.EventListener;
13 import org.zkoss.zk.ui.event.Events;
14 import org.zkoss.zul.Grid;
15 import org.zkoss.zul.Hbox;
16 import org.zkoss.zul.Image;
17 import org.zkoss.zul.Label;
18 import org.zkoss.zul.Row;
19 import org.zkoss.zul.Rows;
20 import org.zkoss.zul.Toolbar;
21 import org.zkoss.zul.Toolbarbutton;
22 import org.zkoss.zul.Vbox;
31 private boolean editable;
33 private Toolbar toolbar;
34 private Toolbarbutton addButton;
42 this.editable = editable;
43 if(customer !=
null) {
50 this.customer = customer;
51 rows.getChildren().clear();
52 if(customer !=
null) {
59 toolbar =
new Toolbar();
60 getParent().appendChild(toolbar);
67 final Row row =
new Row();
69 rows.appendChild(row);
71 Vbox vbox =
new Vbox();
72 row.appendChild(vbox);
75 Hbox hbox =
new Hbox();
76 vbox.appendChild(hbox);
80 vendor.addEventListener(Events.ON_CHANGE,
new EventListener() {
82 public void onEvent(Event event)
throws Exception {
84 co.setOwningDate(
new Date());
87 hbox.appendChild(vendor);
89 final Image img =
new Image(
"/_zul/images/delete.png");
90 img.setStyle(
"cursor:pointer");
91 img.addEventListener(Events.ON_CLICK,
new EventListener() {
93 public void onEvent(Event event)
throws Exception {
100 hbox.appendChild(img);
105 comission.addEventListener(Events.ON_SELECT,
new EventListener() {
107 public void onEvent(Event event)
throws Exception {
111 vbox.appendChild(comission);
117 alert.addEventListener(Events.ON_SELECT,
new EventListener() {
119 public void onEvent(Event event)
throws Exception {
123 vbox.appendChild(alert);
127 Label label =
new Label(co.getVendor() !=
null ? co.getVendor().getName() :
"***");
128 row.appendChild(label);
130 label =
new Label(co.getComission().getName());
131 row.appendChild(label);
133 label =
new Label(co.getAlert().getName());
134 row.appendChild(label);
139 private void addToolbarButtons() {
140 addButton =
new Toolbarbutton(
142 "/_zul/images/new.png"
144 addButton.addEventListener(Events.ON_CLICK,
new EventListener() {
146 public void onEvent(Event event)
throws Exception {
153 toolbar.appendChild(addButton);
158 private void updateButtons() {
159 if(toolbar !=
null) {
160 addButton.setVisible(editable);
void setCustomer(Customer customer)
Set< CustomerOwner > getOwnedBy()
void setCustomer(Customer customer)
void setAddToolbar(boolean addToolbar)
void setEditable(boolean editable)
static Messages confirmDeletion()
static String get(String msg)