18 package org.turro.zkoss.dialog;
21 import org.turro.command.Command;
22 import org.turro.command.Context;
23 import org.turro.elephant.zkoss.Modal;
24 import org.turro.elephant.zkoss.ModalWindow;
25 import org.zkoss.zk.ui.Page;
26 import org.zkoss.zk.ui.event.Event;
27 import org.zkoss.zk.ui.event.EventListener;
28 import org.zkoss.zk.ui.event.Events;
29 import org.zkoss.zk.ui.ext.AfterCompose;
30 import org.zkoss.zul.*;
39 private Set<DialogButton> buttons;
41 private Vbox container;
45 super(title,
"normal",
false);
47 this.buttons = buttons;
50 Panelchildren pc =
new Panelchildren();
51 pc.setStyle(
"padding: 5px;");
52 panel.appendChild(pc);
53 container =
new Vbox();
54 container.setSclass(
"inputDialogContainer");
55 pc.appendChild(container);
57 container.appendChild(
new Separator());
69 private void createFields() {
71 container.appendChild(field);
72 if(field.getEditor() instanceof AfterCompose) {
73 ((AfterCompose) field.getEditor()).afterCompose();
78 private void createButtons() {
79 Hbox butCont =
new Hbox();
80 butCont.setSclass(
"buttonDialogContainer");
81 butCont.setHflex(
"true");
82 butCont.setPack(
"end");
83 butCont.setStyle(
"padding:10px");
84 butCont.setSpacing(
"15px");
85 container.appendChild(butCont);
86 boolean panelDone =
false;
87 for(
final DialogButton button : buttons) {
88 Button b = button.getButton();
89 EventListener el =
new EventListener() {
91 public void onEvent(Event event)
throws Exception {
92 pressedButton = button;
93 Events.postEvent(
new Event(Events.ON_CLOSE,
InputDialog.this));
96 b.addEventListener(Events.ON_CLICK, el);
98 panel.addEventListener(Events.ON_OK, el);
101 butCont.appendChild(b);
105 public static void getInput(Page page, String title, String label, Object value,
106 String format,
int scale,
final Command onOk) {
107 getInput(page, title, label, value, format, scale, onOk,
null);
110 public static void getInput(Page page, String title, String label, Object value,
111 String format,
int scale,
final Command onOk,
final Command onClose) {
118 public Object execute(Context context) {
119 if(onClose !=
null) onClose.execute(context);
121 context.put(
"value",
id.
getFields()[0].getValue());
122 if(onOk !=
null) onOk.execute(context);
140 getInput(page, title, fields, onOk,
null);
143 public static void getInput(Page page, String title,
InputField[] fields,
final Command onOk,
final Command onClose) {
149 public Object execute(Context context) {
150 if(onClose !=
null) onClose.execute(context);
153 if(onOk !=
null) onOk.execute(context);
static int doModal(String file)