KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > memoire > vainstall > xui > XuiWizard


1 /**
2  * $RCSfile: XuiWizard.java,v $
3  * @creation 01/02/00
4  * @modification $Date: 2002/06/20 17:35:45 $
5  */

6
7 package com.memoire.vainstall.xui;
8
9 import java.awt.*;
10 import java.awt.event.ActionListener JavaDoc;
11 import java.awt.event.ActionEvent JavaDoc;
12 import javax.swing.*;
13 import javax.swing.border.*;
14 import com.memoire.vainstall.VAStep;
15 import com.memoire.vainstall.VAWizardInterface;
16 import com.memoire.vainstall.VAGlobals;
17 import com.memoire.vainstall.VALanguageStep;
18 import com.memoire.vainstall.VAWelcomeStep;
19
20 /**
21  * Based on mode 'Graphic' by Axel von Arnim.
22  * @version $Id: XuiWizard.java,v 1.8 2002/06/20 17:35:45 desnoix Exp $
23  * @author Guillaume Desnoix
24  */

25
26 public class XuiWizard
27        extends JDialog
28        implements VAWizardInterface, ActionListener JavaDoc
29 {
30   private static XuiWizard UNIQUE_WIZARD=null;
31   JButton btAbout_, btNext_, btBack_, btCancel_;
32   XuiAbstractPanel panel_;
33   JPanel pnNav_;
34
35   protected XuiWizard()
36   {
37     super(XuiBlueScreen.MAIN);
38     init();
39   }
40   
41   protected void init()
42   {
43     super.setTitle("VAInstall");
44     super.setDefaultCloseOperation(HIDE_ON_CLOSE);
45     setModal(true);
46     setResizable(false);
47
48     Container cp=getContentPane();
49     cp.setLayout(new BorderLayout());
50     cp.setBackground(Color.black);
51     
52     pnNav_=new XuiPanel();
53     pnNav_.setLayout(new FlowLayout(FlowLayout.RIGHT,4,0));
54     // pnNav_.setBorder(new CompoundBorder(new EtchedBorder(),
55
// new EmptyBorder(new Insets(5, 5, 5, 5))));
56
pnNav_.setBackground(Color.black);
57     pnNav_.setBorder(new EmptyBorder(5,5,5,5));
58
59     btAbout_ =new XuiButton(VAGlobals.i18n("XuiWizard_About"));
60     btNext_ =new XuiButton(VAGlobals.i18n("UI_Next"));
61     btBack_ =new XuiButton(VAGlobals.i18n("UI_Back"));
62     btCancel_=new XuiButton(VAGlobals.i18n("UI_Cancel"));
63
64     pnNav_.add(btAbout_);
65     pnNav_.add(btCancel_);
66     pnNav_.add(btBack_);
67     pnNav_.add(btNext_);
68
69     btAbout_ .addActionListener(this);
70     btNext_ .addActionListener(this);
71     btBack_ .addActionListener(this);
72     btCancel_.addActionListener(this);
73     
74     panel_=new XuiAbstractPanel();
75     panel_.setPreferredSize(new Dimension(660,360));
76     cp.add(BorderLayout.CENTER, panel_);
77     cp.add(BorderLayout.SOUTH, pnNav_);
78
79     setSize(getPreferredSize());
80     doLayout();
81     validate();
82
83     // center dialog
84
Dimension dimScreen=Toolkit.getDefaultToolkit().getScreenSize();
85     this.setLocation((dimScreen.width-this.getSize().width)/2,
86                      (dimScreen.height-this.getSize().height)/2);
87
88   }
89
90   public static VAWizardInterface createWizard()
91   {
92     if( UNIQUE_WIZARD==null ) UNIQUE_WIZARD=new XuiWizard();
93     else UNIQUE_WIZARD.init();
94     return UNIQUE_WIZARD;
95   }
96   
97   public void setStep(VAStep step)
98   {
99     panel_=(XuiAbstractPanel)step;
100     Container pnContent=getContentPane();
101     pnContent.removeAll();
102     panel_.setPreferredSize(new Dimension(660,360));
103     // panel_.setBorder(new CompoundBorder(new EtchedBorder(),
104
// new EmptyBorder(new Insets(5, 5, 5, 5))));
105
pnContent.add(BorderLayout.CENTER, panel_);
106
107     // in case of language change we need to update the pnNav_ panel
108
// this is a hack due to the static way of handling language
109
if(step instanceof VAWelcomeStep ||
110        step instanceof VALanguageStep) {
111       btAbout_.setText(VAGlobals.i18n("XuiWizard_About"));
112       btNext_.setText(VAGlobals.i18n("UI_Next"));
113       btBack_.setText(VAGlobals.i18n("UI_Back"));
114       btCancel_.setText(VAGlobals.i18n("UI_Cancel"));
115       doLayout();
116       validate();
117     }
118
119     pnContent.add(BorderLayout.SOUTH, pnNav_);
120     pnContent.doLayout();
121     invalidate();
122     pnContent.validate();
123 // Dimension size=getSize();
124
// setSize(new Dimension(size.width, size.height));
125
Dimension size=getSize();
126     //setSize(new Dimension(size.width+1, size.height+1));
127
//repaint();
128
}
129   
130   public XuiAbstractPanel getPanel() { return panel_; }
131   
132   public void setActionEnabled(int actions)
133   {
134     btCancel_.setEnabled((actions&CANCEL)==CANCEL);
135     btBack_.setEnabled((actions&BACK)==BACK);
136     btNext_.setEnabled(((actions&NEXT)==NEXT)||((actions&FINISH)==FINISH));
137     if( (actions&FINISH)==FINISH ) btNext_.setText(VAGlobals.i18n("UI_Finish"));
138   }
139   
140   public void actionPerformed(ActionEvent JavaDoc e)
141   {
142     Object JavaDoc SRC=e.getSource();
143     if( SRC==btCancel_ ) dispose(true);
144     else
145     if( SRC==btBack_ ) panel_.backAction();
146     else
147     if( SRC==btNext_ ) panel_.nextAction();
148     else
149     if( SRC==btAbout_ ) about();
150   }
151   
152   public void about()
153   {
154     XuiOptionPane.showMessageDialog(
155        this,
156        "\n^"+VAGlobals.NAME+" "+VAGlobals.VERSION+"\n"+
157        VAGlobals.AUTHOR+" <"+VAGlobals.EMAIL+">\n"+
158        VAGlobals.HTTP+"\n"+
159        VAGlobals.i18n("UI_License")+VAGlobals.LICENSE+"\n"+
160        "(c) "+VAGlobals.COPYRIGHT+" "+VAGlobals.AUTHOR+"\n"+
161        "\n^Xtra Mode\n"+
162        "(c) 2001-2002 Guillaume Desnoix",
163        VAGlobals.i18n("XuiWizard_About")
164        );
165   }
166   
167   public void hide(boolean question)
168   {
169     /*
170     if( question ) {
171       int res=JOptionPane.showConfirmDialog(
172         this,
173         VAGlobals.getString("Do you want to abort installation ?"),
174         VAGlobals.getString("Exit"),
175         JOptionPane.YES_NO_OPTION,
176         JOptionPane.QUESTION_MESSAGE);
177       if( res==JOptionPane.YES_OPTION ) {
178         panel_.cancelAction();
179       }
180     } else super.hide();
181     */

182
183     if(question)
184     {
185       int res=XuiOptionPane.showConfirmDialog(
186         this,
187         VAGlobals.i18n("UI_AbortQuestion"),
188         VAGlobals.i18n("UI_Cancel")
189         // JOptionPane.YES_NO_OPTION,
190
// JOptionPane.QUESTION_MESSAGE
191
);
192       if(res==XuiOptionPane.YES)
193         panel_.cancelAction();
194     }
195     else super.hide();
196   }
197   
198   public void dispose()
199   {
200     hide(true);
201   }
202   
203   public void dispose(boolean confirm)
204   {
205     hide(confirm);
206   }
207   
208   public void show()
209   {
210     super.show();
211   }
212   
213   public void hide()
214   {
215     hide(true);
216   }
217 }
218
Popular Tags