1 6 7 package com.memoire.vainstall.xui; 8 9 import java.awt.*; 10 import java.awt.event.ActionListener ; 11 import java.awt.event.ActionEvent ; 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 25 26 public class XuiWizard 27 extends JDialog 28 implements VAWizardInterface, ActionListener 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_.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 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 pnContent.add(BorderLayout.CENTER, panel_); 106 107 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(); 126 } 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 e) 141 { 142 Object 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 182 183 if(question) 184 { 185 int res=XuiOptionPane.showConfirmDialog( 186 this, 187 VAGlobals.i18n("UI_AbortQuestion"), 188 VAGlobals.i18n("UI_Cancel") 189 ); 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 |