18 package org.turro.dossier.zul.issue;
20 import org.turro.dossier.db.DossierPU;
21 import org.turro.dossier.entity.Issue;
22 import org.turro.dossier.issue.IssueWrapper;
23 import org.turro.dossier.search.IssueResults;
24 import org.turro.zkoss.label.LabelExtended;
25 import org.zkoss.lang.Strings;
26 import org.zkoss.zk.ui.Component;
27 import org.zkoss.zk.ui.WrongValueException;
28 import org.zkoss.zk.ui.event.Event;
29 import org.zkoss.zk.ui.event.EventListener;
30 import org.zkoss.zk.ui.event.Events;
31 import org.zkoss.zk.ui.ext.AfterCompose;
32 import org.zkoss.zul.*;
38 public class IssueCtrl extends Bandbox implements AfterCompose {
42 private int wordWrap = 0, maxChars = 0, parentCount = 1;
43 private boolean showDescription =
false;
50 return showDescription;
54 this.showDescription = showDescription;
56 addEventListener(Events.ON_CHANGE,
new EventListener() {
58 public void onEvent(Event event)
throws Exception {
81 this.maxChars = maxChars;
89 this.parentCount = parentCount;
97 this.wordWrap = wordWrap;
102 if(!showDescription)
return;
107 Component comp = getParent();
108 for(
int i = 1; i < parentCount; i++) {
109 comp = comp.getParent();
111 comp.appendChild(description);
115 public void setValue(String value)
throws WrongValueException {
116 if(Strings.isEmpty(value)) value =
"0";
117 super.setValue(value);
120 private void addPopup() {
121 Bandpopup popup =
new Bandpopup();
124 final Listbox issues =
new Listbox();
125 issues.addEventListener(Events.ON_SELECT,
new EventListener() {
127 public void onEvent(Event event)
throws Exception {
130 Events.postEvent(
new Event(Events.ON_CHANGE,
IssueCtrl.this));
134 popup.appendChild(issues);
136 IssueResults results =
new IssueResults();
138 for(IssueWrapper iw : results.getIssueList()) {
139 Listitem item =
new Listitem();
140 issues.appendChild(item);
142 Listcell cell =
new Listcell(iw.getIssue().getId() +
"");
143 item.appendChild(cell);
145 cell =
new Listcell(iw.getIssue().getDescription());
146 item.appendChild(cell);
151 private String loadValue() {
152 if(!Strings.isEmpty(getValue()) && Long.valueOf(getValue()) > 0) {
153 issue =
new DossierPU().find(Issue.class, Long.valueOf(getValue()));
void setIssue(Issue issue)
void setValue(String value)
void setWordWrap(int wordWrap)
boolean isShowDescription()
void setShowDescription(boolean showDescription)
void setParentCount(int parentCount)
void setMaxChars(int maxChars)
LabelExtended setWordWrap(int wordWrap)
void setValue(String value)
LabelExtended setMaxChars(int maxChars)