19 package org.turro.zkoss.wizard;
21 import java.util.Iterator;
22 import java.util.LinkedList;
23 import org.turro.i18n.I_;
24 import org.turro.zkoss.util.ComponentIterator;
25 import org.zkoss.zk.ui.event.Event;
26 import org.zkoss.zk.ui.event.Events;
27 import org.zkoss.zk.ui.util.GenericForwardComposer;
28 import org.zkoss.zul.Button;
29 import org.zkoss.zul.Caption;
30 import org.zkoss.zul.Tab;
31 import org.zkoss.zul.Tabbox;
37 public class Wizard extends GenericForwardComposer {
39 private Button wbprior, wbnext, wbfinish, wbcancel;
40 private LinkedList<WizardPanel> list =
new LinkedList<WizardPanel>();
41 private Tabbox wizardbox;
71 Events.postEvent(
new Event(Events.ON_CLOSE,
self));
80 Events.postEvent(
new Event(Events.ON_CLOSE,
self));
86 int current = wizardbox.getSelectedIndex();
87 if(current < 1)
return;
91 for(
int i = current; i >= 0; i--) {
95 wizardbox.setSelectedIndex(i);
105 int current = wizardbox.getSelectedIndex();
106 if(current > list.size() - 2)
return;
110 for(
int i = current; i < list.size(); i++) {
114 wizardbox.setSelectedIndex(i);
124 wbprior.setDisabled(!enabled);
128 wbnext.setDisabled(!enabled);
132 wbfinish.setDisabled(!enabled);
136 wbcancel.setDisabled(!enabled);
142 Caption caption =
new Caption(
null,
"/_zul/images/wizard.png");
143 self.appendChild(caption);
144 wizardbox.setSclass(
"wizard");
145 wizardbox.setHflex(
"true");
146 wizardbox.setVflex(
"true");
147 wizardbox.getTabs().setSclass(
"wtabs");
148 for(Iterator it = wizardbox.getTabs().getChildren().iterator(); it.hasNext();) {
149 Tab tab = (Tab) it.next();
150 tab.setDisabled(
true);
151 tab.setSclass(
"wizardtab");
155 protected void doComponent(
WizardPanel component) {
159 list.getFirst().setAllowPrior(
false);
160 list.getLast().setAllowNext(
false);
162 wbprior.setLabel(
I_.
get(
"<< Previous"));
163 wbnext.setLabel(
I_.
get(
"Next >>"));
164 wbfinish.setLabel(
I_.
get(
"Finish"));
165 wbcancel.setLabel(
I_.
get(
"Cancel"));
167 if(!wp.shouldSkip && !wp.checkSkipFirst()) {
169 wizardbox.setSelectedPanel(wp);
179 for(Iterator it = wizardbox.getTabs().getChildren().iterator(); it.hasNext();) {
180 Tab tab = (Tab) it.next();
181 if(tab.getIndex() < wp.getIndex()) {
182 tab.setSclass(
"wpdone");
183 }
else if(tab.getIndex() == wp.getIndex()) {
184 tab.setSclass(
"wpcurrent");
186 tab.setSclass(
"wppending");
190 wbfinish.setLabel(
I_.
get(
"Close"));
static String get(String msg)
boolean doLeave(boolean forwards)
void setNextStatus(boolean enabled)
void setPriorStatus(boolean enabled)
void setCancelStatus(boolean enabled)
void setFinishStatus(boolean enabled)