18 package org.turro.zkoss.label;
20 import java.util.Date;
21 import org.turro.elephant.util.DateFormats;
22 import org.turro.elephant.util.DecimalFormats;
23 import org.turro.i18n.I_;
24 import org.zkoss.zul.Label;
32 private boolean showTooltip =
false;
33 private int maxChars = 0, wordWrap = 0;
34 private String format;
58 this.maxChars = maxChars;
68 if(resourceValue.startsWith(
"#")) {
125 this.showTooltip = showTooltip;
134 this.wordWrap = wordWrap;
141 if(maxChars > 0 && value.length() > maxChars) {
143 setTooltiptext(value);
145 value = value.substring(0, lastIndexOfWhiteChar(value, maxChars)) +
"...";
149 value = insertLF(value, wordWrap);
153 super.setValue(value);
156 private String insertLF(String s,
int from) {
157 StringBuffer sb =
new StringBuffer(s);
159 while(p < sb.length() - 1) {
161 if(c > from && sb.charAt(p) ==
' ') {
162 sb.setCharAt(p,
'\n');
165 else if(sb.charAt(p) ==
'\n')
168 return sb.toString();
171 private int lastIndexOfWhiteChar(String value,
int maxChars) {
172 int maxLast = 0, last;
173 last = value.lastIndexOf(
' ', maxChars);
174 if(last > maxLast) maxLast = last;
175 last = value.lastIndexOf(
'\n', maxChars);
176 if(last > maxLast) maxLast = last;
177 last = value.lastIndexOf(
'.', maxChars);
178 if(last > maxLast) maxLast = last;
179 last = value.lastIndexOf(
',', maxChars);
180 if(last > maxLast) maxLast = last;
static String byKey(String key)
static String get(String msg)
LabelExtended setFormat(String format)
LabelExtended setBoolean(String value)
LabelExtended setBoolean(boolean value)
LabelExtended setDateTime(Date date)
LabelExtended setWordWrap(int wordWrap)
LabelExtended setCSS(String style)
LabelExtended setString(String value)
LabelExtended setDate(Date date)
LabelExtended setDouble(double value)
LabelExtended setShowTooltip(boolean showTooltip)
LabelExtended setLong(long value)
void setValue(String value)
LabelExtended setEnum(Enum e)
LabelExtended setResourceValue(String resourceValue)
LabelExtended setMaxChars(int maxChars)