1 package org.turro.crm.zul.sale;
3 import org.turro.crm.db.CrmPU;
4 import org.turro.crm.entity.SaleProspect;
5 import org.turro.crm.search.SaleProspectResults;
6 import org.turro.zkoss.label.LabelExtended;
7 import org.zkoss.lang.Strings;
8 import org.zkoss.zk.ui.Component;
9 import org.zkoss.zk.ui.WrongValueException;
10 import org.zkoss.zk.ui.event.Event;
11 import org.zkoss.zk.ui.event.EventListener;
12 import org.zkoss.zk.ui.event.Events;
13 import org.zkoss.zk.ui.ext.AfterCompose;
14 import org.zkoss.zul.*;
24 private int wordWrap = 0, maxChars = 0, parentCount = 1;
25 private boolean showDescription =
false;
32 return showDescription;
36 this.showDescription = showDescription;
38 addEventListener(Events.ON_CHANGE,
new EventListener() {
40 public void onEvent(Event event)
throws Exception {
52 this.saleProspect = saleProspect;
53 if(saleProspect !=
null) {
63 this.maxChars = maxChars;
71 this.parentCount = parentCount;
79 this.wordWrap = wordWrap;
84 if(!showDescription)
return;
89 Component comp = getParent();
90 for(
int i = 1; i < parentCount; i++) {
91 comp = comp.getParent();
93 comp.appendChild(description);
97 public void setValue(String value)
throws WrongValueException {
98 if(Strings.isEmpty(value)) value =
"0";
99 super.setValue(value);
102 private void addPopup() {
103 Bandpopup popup =
new Bandpopup();
106 final Listbox saleProspects =
new Listbox();
107 saleProspects.addEventListener(Events.ON_SELECT,
new EventListener() {
109 public void onEvent(Event event)
throws Exception {
116 popup.appendChild(saleProspects);
118 SaleProspectResults results =
new SaleProspectResults();
120 for(SaleProspect sp : results.getSaleProspectList()) {
121 Listitem item =
new Listitem();
122 saleProspects.appendChild(item);
124 Listcell cell =
new Listcell(sp.getId() +
"");
125 item.appendChild(cell);
127 cell =
new Listcell(sp.getCustomer().getName() +
" - " + sp.getDescription());
128 item.appendChild(cell);
133 private String loadValue() {
134 if(!Strings.isEmpty(getValue()) && Long.valueOf(getValue()) > 0) {
135 saleProspect =
new CrmPU().find(SaleProspect.class, Long.valueOf(getValue()));
136 if(saleProspect !=
null) {
boolean isShowDescription()
void setParentCount(int parentCount)
void setValue(String value)
void setShowDescription(boolean showDescription)
void setMaxChars(int maxChars)
void setWordWrap(int wordWrap)
void setSaleProspect(SaleProspect saleProspect)
SaleProspect getSaleProspect()
LabelExtended setWordWrap(int wordWrap)
void setValue(String value)
LabelExtended setMaxChars(int maxChars)