18 package org.turro.zkoss.input;
20 import java.util.Collection;
21 import org.turro.i18n.I_;
22 import org.turro.zkoss.label.LabelTypes;
23 import org.zkoss.zul.Listcell;
24 import org.zkoss.zul.Listitem;
25 import org.zkoss.zul.Vlayout;
35 ITEM_SEPARATOR_REGEX =
"\\|\\|\\|",
36 SUBITEM_SEPARATOR =
"%%%",
37 SUBITEM_SEPARATOR_REGEX =
"\\%\\%\\%";
39 private Collection<V> collection;
40 private boolean allowNull, nullAtBottom;
41 private String nullLabel =
"None";
47 this.collection = collection;
67 this.allowNull = allowNull;
75 this.collection = collection;
83 this.nullAtBottom = nullAtBottom;
91 this.nullLabel = nullLabel;
98 if(collection ==
null)
return;
99 if(allowNull && !nullAtBottom) {
100 Listitem li =
new Listitem(
"<" +
I_.
get(nullLabel) +
">",
null);
105 if(getListhead() !=
null && !getListhead().getChildren().isEmpty()) {
106 cells = getListhead().getChildren().size();
108 for(V v : collection) {
111 Listitem li =
new Listitem();
114 String ssa[] = s.split(SUBITEM_SEPARATOR_REGEX);
116 Listcell cell =
new Listcell(ssa[0]);
117 li.appendChild(cell);
118 Vlayout vbox =
new Vlayout();
119 vbox.setStyle(
"padding:2px");
120 for(
int i = 1; i < ssa.length; i++) {
123 cell.appendChild(vbox);
125 if(s !=
null && s.endsWith(SUBITEM_SEPARATOR)) {
126 s = s.replaceAll(SUBITEM_SEPARATOR_REGEX,
"");
128 li.appendChild(
new Listcell(s));
139 if(allowNull && nullAtBottom) {
140 Listitem li =
new Listitem(
"<" +
I_.
get(nullLabel) +
">",
null);
147 protected boolean equals(V value, V obj) {
150 return (v1 ==
null && v2 ==
null) ||
151 (v1 !=
null && v1.equals(v2));
static String get(String msg)
static Label getSoftLabel(String value)