18 package org.turro.zkoss.wizard;
20 import java.util.LinkedList;
21 import org.turro.elephant.zkoss.Modal;
22 import org.turro.i18n.I_;
23 import org.zkoss.zk.ui.Page;
24 import org.zkoss.zk.ui.event.Event;
25 import org.zkoss.zk.ui.event.EventListener;
26 import org.zkoss.zk.ui.event.Events;
27 import org.zkoss.zul.*;
35 private Button prior, next, finish, cancel;
38 private Tabpanels panels;
39 private LinkedList<WizardPanelOld> wpanels;
47 wpanels =
new LinkedList<WizardPanelOld>();
51 Tab tab =
new Tab(wpanels.size() +
" - " + panel.
getLabel());
52 tabs.appendChild(tab);
53 Tabpanel tpanel =
new Tabpanel();
54 panels.appendChild(tpanel);
55 tpanel.appendChild(panel);
59 public void show(Page page) {
61 if(tabs.getChildren().isEmpty()) {
64 body.setSelectedIndex(0);
86 int current = body.getSelectedIndex();
87 if(current < 1)
return;
88 if(wpanels.get(current).doLeave()) {
90 for(
int i = current; i > 0; i--) {
94 body.setSelectedIndex(i);
103 int current = body.getSelectedIndex();
104 if(current > wpanels.size() - 2)
return;
105 if(wpanels.get(current).doLeave()) {
107 for(
int i = current; i < wpanels.size(); i++) {
111 body.setSelectedIndex(i);
120 prior.setDisabled(!enabled);
124 next.setDisabled(!enabled);
128 finish.setDisabled(!enabled);
132 cancel.setDisabled(!enabled);
135 private void addComponents() {
136 Borderlayout layout =
new Borderlayout();
138 Center center =
new Center();
139 layout.appendChild(center);
140 South south =
new South();
141 layout.appendChild(south);
143 center.appendChild(body);
145 panels =
new Tabpanels();
146 body.appendChild(tabs);
147 body.appendChild(panels);
148 Hbox buttons =
new Hbox();
149 south.appendChild(buttons);
150 buttons.setAlign(
"end");
151 buttons.setPack(
"center");
152 prior =
new Button(
I_.
get(
"<< Previous"));
153 prior.addEventListener(Events.ON_CLICK,
new EventListener() {
155 public void onEvent(Event event)
throws Exception {
159 buttons.appendChild(prior);
160 next =
new Button(I_.get(
"Next >>"));
161 next.addEventListener(Events.ON_CLICK,
new EventListener() {
163 public void onEvent(Event event)
throws Exception {
167 buttons.appendChild(next);
168 finish =
new Button(I_.get(
"Finish"));
169 finish.addEventListener(Events.ON_CLICK,
new EventListener() {
171 public void onEvent(Event event)
throws Exception {
175 buttons.appendChild(finish);
176 cancel =
new Button(I_.get(
"Cancel"));
177 cancel.addEventListener(Events.ON_CLICK,
new EventListener() {
179 public void onEvent(Event event)
throws Exception {
183 buttons.appendChild(cancel);
static int doModal(String file)
static String get(String msg)
void setNextStatus(boolean enabled)
void setCancelStatus(boolean enabled)
void setFinishStatus(boolean enabled)
WizardPanelOld addPanel(WizardPanelOld panel)
void setPriorStatus(boolean enabled)
void setWizard(WizardOld wizard)