18 package org.turro.zkoss.label;
20 import java.util.Collection;
21 import org.zkoss.zk.ui.event.Event;
22 import org.zkoss.zk.ui.event.EventListener;
23 import org.zkoss.zk.ui.event.Events;
24 import org.zkoss.zk.ui.ext.AfterCompose;
25 import org.zkoss.zul.*;
26 import org.zkoss.zul.impl.InputElement;
34 private String label, image, oldLabel;
35 private boolean editing =
false, editable =
true;
36 private int editorCols;
37 private Collection<String> values;
56 this.editable = editable;
64 this.editing = editing;
72 this.editorCols = editorCols;
100 this.values = values;
108 private void createComponent() {
109 getChildren().clear();
111 Label l =
new Label(label);
112 l.setSclass(
"softLabel");
116 Toolbarbutton tb =
new Toolbarbutton(label, image);
117 tb.setSclass(
"softLabel");
118 tb.addEventListener(Events.ON_CLICK,
new EventListener() {
120 public void onEvent(Event event)
throws Exception {
128 final InputElement tb;
129 if(values !=
null && !values.isEmpty()) {
130 tb =
new Combobox(label);
131 ((Combobox) tb).setModel(
new ListModelList(values));
133 tb =
new Textbox(label);
136 tb.setCols(editorCols);
137 }
else if(editorCols == -1) {
140 tb.setSclass(
"softLabel");
141 tb.addEventListener(Events.ON_OK,
new EventListener() {
143 public void onEvent(Event event)
throws Exception {
145 label = tb.getText();
151 tb.addEventListener(Events.ON_CANCEL,
new EventListener() {
153 public void onEvent(Event event)
throws Exception {
158 tb.addEventListener(Events.ON_BLUR,
new EventListener() {
160 public void onEvent(Event event)
throws Exception {
LabelEditable(String label, String image)
LabelEditable(String label)
void setEditing(boolean editing)
Collection< String > getValues()
void setImage(String image)
void setValues(Collection< String > values)
void setLabel(String label)
void setEditable(boolean editable)
void setEditorCols(int editorCols)