18 package org.turro.zkoss.dialog;
21 import org.turro.command.Command;
22 import org.turro.command.Context;
23 import org.turro.elephant.zkoss.ModalWindow;
24 import org.zkoss.zk.ui.Component;
25 import org.zkoss.zk.ui.HtmlBasedComponent;
26 import org.zkoss.zk.ui.Page;
27 import org.zkoss.zk.ui.event.Event;
28 import org.zkoss.zk.ui.event.EventListener;
29 import org.zkoss.zk.ui.event.Events;
30 import org.zkoss.zk.ui.ext.AfterCompose;
31 import org.zkoss.zul.*;
39 private Set<DialogButton> buttons;
41 private Vlayout container;
43 private Component component;
45 public SelectionDialog(String title, Component component, Set<DialogButton> buttons) {
46 super(title,
"normal",
false);
47 this.component = component;
48 this.buttons = buttons;
50 panel.setVflex(
"true");
51 panel.setHflex(
"true");
53 Panelchildren pc =
new Panelchildren();
54 panel.appendChild(pc);
55 container =
new Vlayout();
56 container.setHflex(
"true");
57 container.setVflex(
"true");
58 container.setSclass(
"_inputDialogContainer");
59 pc.appendChild(container);
60 container.appendChild(component);
61 if(component instanceof AfterCompose) {
62 ((AfterCompose) component).afterCompose();
77 if(((HtmlBasedComponent) this.component).getHeight()==
null) {
78 ((HtmlBasedComponent) this.component).setVflex(
"true");
80 if(((HtmlBasedComponent) this.component).getWidth() ==
null) {
81 ((HtmlBasedComponent) this.component).setHflex(
"true");
95 ((HtmlBasedComponent) component).setVflex(
"true");
96 ((HtmlBasedComponent) component).setHflex(
"true");
99 private void createButtons() {
100 Hbox butCont =
new Hbox();
101 butCont.setSclass(
"_buttonDialogContainer");
102 butCont.setHflex(
"true");
103 butCont.setPack(
"end");
104 butCont.setStyle(
"padding:10px");
105 butCont.setSpacing(
"15px");
106 container.appendChild(butCont);
107 boolean panelDone =
false;
109 Button b = button.getButton();
110 EventListener el =
new EventListener() {
112 public void onEvent(Event event)
throws Exception {
113 pressedButton = button;
117 b.addEventListener(Events.ON_CLICK, el);
119 panel.addEventListener(Events.ON_OK, el);
122 butCont.appendChild(b);
126 public static void getComponent(Page page, String title, Component component, String width, String height,
final Command command) {
128 if(width !=
null)
id.setWidth(width);
129 if(height !=
null)
id.setHeight(height);
130 id.show(page,
new Command() {
132 public Object execute(Context context) {
135 if(command !=
null) command.execute(context);
142 public static void showComponent(Page page, String title, Component component, String width, String height,
final Command command) {
144 if(width !=
null)
id.setWidth(width);
145 if(height !=
null)
id.setHeight(height);
146 id.show(page,
new Command() {
148 public Object execute(Context context) {
150 if(command !=
null) command.execute(context);
156 public static void popupComponent(Page page, String title, Component component, String width, String height) {
159 if(width !=
null)
id.setWidth(width);
160 if(height !=
null)
id.setHeight(height);
SelectionDialog(String title, Component component, Set< DialogButton > buttons)
static void showComponent(Page page, String title, Component component, String width, String height, final Command command)
DialogButton getPressedButton()
static void popupComponent(Page page, String title, Component component, String width, String height)
static void getComponent(Page page, String title, Component component, String width, String height, final Command command)