01: /*
02: * Beryl - A web platform based on XML, XSLT and Java
03: * This file is part of the Beryl XML GUI
04: *
05: * Copyright (C) 2004 Wenzel Jakob <wazlaf@tigris.org>
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11:
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this program; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-3107 USA
20: */
21:
22: package org.beryl.gui.widgets;
23:
24: import java.awt.Component;
25: import java.awt.Dimension;
26:
27: import org.beryl.gui.GUIException;
28: import org.beryl.gui.Widget;
29: import org.beryl.gui.WizardListener;
30: import org.beryl.gui.model.MapDataModel;
31: import org.beryl.gui.swing.JWizard;
32:
33: public class Wizard extends Widget {
34: private JWizard wizard = null;
35:
36: public Wizard(Widget parent, String name) throws GUIException {
37: super (parent, name);
38: wizard = new JWizard(this );
39: }
40:
41: public void addChild(Widget widget, Object constraint)
42: throws GUIException {
43: if (widget instanceof WizardPage) {
44: wizard.addPage((WizardPage) widget);
45: addChild(widget);
46: } else {
47: throw new GUIException(
48: "Only WizardPage children are allowed inside a WizardItem");
49: }
50: }
51:
52: public void addWizardListener(WizardListener listener) {
53: wizard.addWizardListener(listener);
54: }
55:
56: public void removeWizardListener(WizardListener listener) {
57: wizard.removeWizardListener(listener);
58: }
59:
60: public WizardPage getPage(String pageName) {
61: return wizard.getPage(pageName);
62: }
63:
64: public void hide() {
65: wizard.hide();
66: }
67:
68: public void show() {
69: /* Workaround for Bug 4102292
70: * http://developer.java.sun.com/developer/bugParade/bugs/4102292.html
71: */
72: Dimension ss = wizard.getToolkit().getScreenSize();
73: Dimension fs = wizard.getSize();
74: wizard.setLocation((ss.width - fs.width) / 2,
75: (ss.height - fs.height) / 2);
76: wizard.show();
77: }
78:
79: public void setDataModel(MapDataModel model) throws GUIException {
80: wizard.setDataModel(model);
81: super .setDataModel(model);
82: }
83:
84: public void dispose() {
85: wizard.dispose();
86: }
87:
88: public void updateButtons() {
89: wizard.updateButtons();
90: }
91:
92: public Component getWidget() {
93: return wizard;
94: }
95: }
|