001: /**
002: * $RCSfile: XuiWizard.java,v $
003: * @creation 01/02/00
004: * @modification $Date: 2002/06/20 17:35:45 $
005: */package com.memoire.vainstall.xui;
006:
007: import java.awt.*;
008: import java.awt.event.ActionListener;
009: import java.awt.event.ActionEvent;
010: import javax.swing.*;
011: import javax.swing.border.*;
012: import com.memoire.vainstall.VAStep;
013: import com.memoire.vainstall.VAWizardInterface;
014: import com.memoire.vainstall.VAGlobals;
015: import com.memoire.vainstall.VALanguageStep;
016: import com.memoire.vainstall.VAWelcomeStep;
017:
018: /**
019: * Based on mode 'Graphic' by Axel von Arnim.
020: * @version $Id: XuiWizard.java,v 1.8 2002/06/20 17:35:45 desnoix Exp $
021: * @author Guillaume Desnoix
022: */
023:
024: public class XuiWizard extends JDialog implements VAWizardInterface,
025: ActionListener {
026: private static XuiWizard UNIQUE_WIZARD = null;
027: JButton btAbout_, btNext_, btBack_, btCancel_;
028: XuiAbstractPanel panel_;
029: JPanel pnNav_;
030:
031: protected XuiWizard() {
032: super (XuiBlueScreen.MAIN);
033: init();
034: }
035:
036: protected void init() {
037: super .setTitle("VAInstall");
038: super .setDefaultCloseOperation(HIDE_ON_CLOSE);
039: setModal(true);
040: setResizable(false);
041:
042: Container cp = getContentPane();
043: cp.setLayout(new BorderLayout());
044: cp.setBackground(Color.black);
045:
046: pnNav_ = new XuiPanel();
047: pnNav_.setLayout(new FlowLayout(FlowLayout.RIGHT, 4, 0));
048: // pnNav_.setBorder(new CompoundBorder(new EtchedBorder(),
049: // new EmptyBorder(new Insets(5, 5, 5, 5))));
050: pnNav_.setBackground(Color.black);
051: pnNav_.setBorder(new EmptyBorder(5, 5, 5, 5));
052:
053: btAbout_ = new XuiButton(VAGlobals.i18n("XuiWizard_About"));
054: btNext_ = new XuiButton(VAGlobals.i18n("UI_Next"));
055: btBack_ = new XuiButton(VAGlobals.i18n("UI_Back"));
056: btCancel_ = new XuiButton(VAGlobals.i18n("UI_Cancel"));
057:
058: pnNav_.add(btAbout_);
059: pnNav_.add(btCancel_);
060: pnNav_.add(btBack_);
061: pnNav_.add(btNext_);
062:
063: btAbout_.addActionListener(this );
064: btNext_.addActionListener(this );
065: btBack_.addActionListener(this );
066: btCancel_.addActionListener(this );
067:
068: panel_ = new XuiAbstractPanel();
069: panel_.setPreferredSize(new Dimension(660, 360));
070: cp.add(BorderLayout.CENTER, panel_);
071: cp.add(BorderLayout.SOUTH, pnNav_);
072:
073: setSize(getPreferredSize());
074: doLayout();
075: validate();
076:
077: // center dialog
078: Dimension dimScreen = Toolkit.getDefaultToolkit()
079: .getScreenSize();
080: this .setLocation((dimScreen.width - this .getSize().width) / 2,
081: (dimScreen.height - this .getSize().height) / 2);
082:
083: }
084:
085: public static VAWizardInterface createWizard() {
086: if (UNIQUE_WIZARD == null)
087: UNIQUE_WIZARD = new XuiWizard();
088: else
089: UNIQUE_WIZARD.init();
090: return UNIQUE_WIZARD;
091: }
092:
093: public void setStep(VAStep step) {
094: panel_ = (XuiAbstractPanel) step;
095: Container pnContent = getContentPane();
096: pnContent.removeAll();
097: panel_.setPreferredSize(new Dimension(660, 360));
098: // panel_.setBorder(new CompoundBorder(new EtchedBorder(),
099: // new EmptyBorder(new Insets(5, 5, 5, 5))));
100: pnContent.add(BorderLayout.CENTER, panel_);
101:
102: // in case of language change we need to update the pnNav_ panel
103: // this is a hack due to the static way of handling language
104: if (step instanceof VAWelcomeStep
105: || step instanceof VALanguageStep) {
106: btAbout_.setText(VAGlobals.i18n("XuiWizard_About"));
107: btNext_.setText(VAGlobals.i18n("UI_Next"));
108: btBack_.setText(VAGlobals.i18n("UI_Back"));
109: btCancel_.setText(VAGlobals.i18n("UI_Cancel"));
110: doLayout();
111: validate();
112: }
113:
114: pnContent.add(BorderLayout.SOUTH, pnNav_);
115: pnContent.doLayout();
116: invalidate();
117: pnContent.validate();
118: // Dimension size=getSize();
119: // setSize(new Dimension(size.width, size.height));
120: Dimension size = getSize();
121: //setSize(new Dimension(size.width+1, size.height+1));
122: //repaint();
123: }
124:
125: public XuiAbstractPanel getPanel() {
126: return panel_;
127: }
128:
129: public void setActionEnabled(int actions) {
130: btCancel_.setEnabled((actions & CANCEL) == CANCEL);
131: btBack_.setEnabled((actions & BACK) == BACK);
132: btNext_.setEnabled(((actions & NEXT) == NEXT)
133: || ((actions & FINISH) == FINISH));
134: if ((actions & FINISH) == FINISH)
135: btNext_.setText(VAGlobals.i18n("UI_Finish"));
136: }
137:
138: public void actionPerformed(ActionEvent e) {
139: Object src = e.getSource();
140: if (src == btCancel_)
141: dispose(true);
142: else if (src == btBack_)
143: panel_.backAction();
144: else if (src == btNext_)
145: panel_.nextAction();
146: else if (src == btAbout_)
147: about();
148: }
149:
150: public void about() {
151: XuiOptionPane.showMessageDialog(this , "\n^" + VAGlobals.NAME
152: + " " + VAGlobals.VERSION + "\n" + VAGlobals.AUTHOR
153: + " <" + VAGlobals.EMAIL + ">\n" + VAGlobals.HTTP
154: + "\n" + VAGlobals.i18n("UI_License")
155: + VAGlobals.LICENSE + "\n" + "(c) "
156: + VAGlobals.COPYRIGHT + " " + VAGlobals.AUTHOR + "\n"
157: + "\n^Xtra Mode\n" + "(c) 2001-2002 Guillaume Desnoix",
158: VAGlobals.i18n("XuiWizard_About"));
159: }
160:
161: public void hide(boolean question) {
162: /*
163: if( question ) {
164: int res=JOptionPane.showConfirmDialog(
165: this,
166: VAGlobals.getString("Do you want to abort installation ?"),
167: VAGlobals.getString("Exit"),
168: JOptionPane.YES_NO_OPTION,
169: JOptionPane.QUESTION_MESSAGE);
170: if( res==JOptionPane.YES_OPTION ) {
171: panel_.cancelAction();
172: }
173: } else super.hide();
174: */
175:
176: if (question) {
177: int res = XuiOptionPane.showConfirmDialog(this , VAGlobals
178: .i18n("UI_AbortQuestion"), VAGlobals
179: .i18n("UI_Cancel")
180: // JOptionPane.YES_NO_OPTION,
181: // JOptionPane.QUESTION_MESSAGE
182: );
183: if (res == XuiOptionPane.YES)
184: panel_.cancelAction();
185: } else
186: super .hide();
187: }
188:
189: public void dispose() {
190: hide(true);
191: }
192:
193: public void dispose(boolean confirm) {
194: hide(confirm);
195: }
196:
197: public void show() {
198: super .show();
199: }
200:
201: public void hide() {
202: hide(true);
203: }
204: }
|