18 package org.turro.zkoss.text;
20 import org.turro.i18n.I_;
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.Button;
26 import org.zkoss.zul.Hbox;
27 import org.zkoss.zul.Html;
28 import org.zkoss.zul.Textbox;
29 import org.zkoss.zul.Vbox;
37 private Textbox editor;
39 private String value, caption;
40 private boolean editing =
false;
48 this.caption = caption;
64 this.editing = editing;
81 private void createComponents() {
83 getChildren().clear();
85 Button b =
new Button(
I_.
get(
"Edit") +
" " + caption,
"/_zul/images/edit.png");
86 b.addEventListener(Events.ON_CLICK,
new EventListener() {
88 public void onEvent(Event event)
throws Exception {
93 html =
new Html(value);
98 Button b =
new Button(I_.get(
"Save") +
" " + caption,
"/_zul/images/save.png");
99 b.addEventListener(Events.ON_CLICK,
new EventListener() {
101 public void onEvent(Event event)
throws Exception {
102 value = editor.getValue();
103 Events.postEvent(
new Event(Events.ON_CHANGE, TextEditable.this));
108 b =
new Button(I_.get(
"Cancel"),
null);
109 b.addEventListener(Events.ON_CLICK,
new EventListener() {
111 public void onEvent(Event event)
throws Exception {
117 editor =
new Textbox();
118 editor.setHflex(
"1");
119 editor.setRows(rows);
120 editor.setValue(value);
static String get(String msg)
void setCaption(String caption)
void setValue(String value)
void setEditing(boolean editing)