Author: dbkr
Date: 2006-08-27 00:10:41 +0000 (Sun, 27 Aug 2006)
New Revision: 10274

Added:
   trunk/apps/Freemail/src/freemailgui/
   trunk/apps/Freemail/src/freemailgui/SetupWizard.java
   trunk/apps/Freemail/src/freemailgui/WizardChooseUsername.java
   trunk/apps/Freemail/src/freemailgui/WizardWelcome.java
   trunk/apps/Freemail/src/freemailgui/images/
   trunk/apps/Freemail/src/freemailgui/images/logo_and_text.png
   trunk/apps/Freemail/src/freemailgui/images/pigeon_small.png
   trunk/apps/Freemail/src/freemailgui/text/
   trunk/apps/Freemail/src/freemailgui/text/MessageBundle_en_GB.properties
Log:
The start of a config wizard. Commit this before I take the second page to bits 
to get it to lay out sensibly. It doesn't do anything useful yet, but it 
doesn't break anything either.


Added: trunk/apps/Freemail/src/freemailgui/SetupWizard.java
===================================================================
--- trunk/apps/Freemail/src/freemailgui/SetupWizard.java        2006-08-26 
21:26:41 UTC (rev 10273)
+++ trunk/apps/Freemail/src/freemailgui/SetupWizard.java        2006-08-27 
00:10:41 UTC (rev 10274)
@@ -0,0 +1,140 @@
+package freemailgui;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JLabel;
+import javax.swing.UIManager;
+import javax.swing.ImageIcon;
+import javax.swing.BoxLayout;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.Box;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+import java.util.ResourceBundle;
+import java.util.Locale;
+import java.util.MissingResourceException;
+
+public class SetupWizard implements ActionListener {
+       private final JFrame frame;
+       private final JPanel panel;
+       private JPanel subpanel;
+       private final JButton backbutton;
+       private final JButton cancelbutton;
+       private final JButton nextbutton;
+       private ResourceBundle bundle;
+       private final JLabel logolabel;
+       private int currentstep;
+
+       public static void main(String args[]) {
+               javax.swing.SwingUtilities.invokeLater(new Runnable() {
+                       public void run() {
+                               new SetupWizard().show();
+                       }
+               });
+       }
+       
+       public SetupWizard() {
+               try {
+                       
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+               } catch (Exception e) {
+               }
+               
+               try {
+                       this.bundle = 
ResourceBundle.getBundle("freemailgui.text.MessageBundle", Locale.getDefault());
+               } catch (MissingResourceException mre) {
+                       this.bundle = 
ResourceBundle.getBundle("freemailgui.text.MessageBundle", new Locale("en", 
"GB")); 
+               }
+               
+               this.frame = new JFrame(this.bundle.getString("wizard_title"));
+               this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+               
+               ImageIcon icon = new 
ImageIcon(getClass().getResource("images/pigeon_small.png"));
+               this.frame.setIconImage(icon.getImage());
+               
+               this.panel = new JPanel();
+               this.panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 
10, 10));
+               this.panel.setLayout(new BoxLayout(this.panel, 
BoxLayout.Y_AXIS));
+               
+               ImageIcon logo = new 
ImageIcon(getClass().getResource("images/logo_and_text.png"));
+               this.logolabel = new JLabel();
+               logolabel.setIcon(logo);
+               logolabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
+               
+               this.backbutton = new JButton("<< "+bundle.getString("back"));
+               this.backbutton.addActionListener(this);
+               
+               this.cancelbutton = new JButton(bundle.getString("cancel"));
+               this.cancelbutton.addActionListener(this);
+               
+               this.nextbutton = new JButton(bundle.getString("next")+" >>");
+               this.nextbutton.addActionListener(this);
+               
+               this.currentstep = 0;
+               this.makeGUI();
+               this.frame.add(this.panel);
+       }
+       
+       public void show() {
+               // make the window a fixed size - it's a wizard
+               this.frame.setSize(500, 400);
+               // center
+               this.frame.setLocationRelativeTo(null);
+               this.frame.validate();
+               this.frame.setVisible(true);
+       }
+       
+       private void makeGUI() {
+               this.panel.removeAll();
+               
+               this.panel.add(logolabel, 0);
+               this.panel.add(Box.createVerticalGlue());
+               
+               switch (this.currentstep) {
+                       case 0:
+                               this.subpanel = new WizardWelcome(this.bundle);
+                               break;
+                       case 1:
+                               this.subpanel = new 
WizardChooseUsername(this.bundle);
+                               break;
+               }
+               
+               if (this.currentstep == 0) {
+                       this.backbutton.setEnabled(false);
+               } else {
+                       this.backbutton.setEnabled(true);
+               }
+               
+               this.panel.add(this.subpanel);
+               
+               this.panel.add(Box.createVerticalGlue());
+               
+               JPanel buttons = new JPanel();
+               buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
+               buttons.add(this.backbutton);
+               buttons.add(Box.createHorizontalGlue());
+               buttons.add(this.cancelbutton);
+               buttons.add(Box.createHorizontalGlue());
+               buttons.add(this.nextbutton);
+               
+               this.panel.add(buttons);
+               this.frame.validate();
+       }
+       
+       public void actionPerformed(ActionEvent e) {
+               if (e.getSource() == this.cancelbutton) {
+                       System.exit(0);
+               } else if (e.getSource() == this.nextbutton) {
+                       this.currentstep++;
+                       this.makeGUI();
+                       this.panel.repaint();
+                       //this.show();
+               } else if (e.getSource() == this.backbutton) {
+                       this.currentstep--;
+                       this.makeGUI();
+                       this.panel.repaint();
+                       //this.show();
+               }
+       }
+}

Added: trunk/apps/Freemail/src/freemailgui/WizardChooseUsername.java
===================================================================
--- trunk/apps/Freemail/src/freemailgui/WizardChooseUsername.java       
2006-08-26 21:26:41 UTC (rev 10273)
+++ trunk/apps/Freemail/src/freemailgui/WizardChooseUsername.java       
2006-08-27 00:10:41 UTC (rev 10274)
@@ -0,0 +1,88 @@
+package freemailgui;
+
+import javax.swing.JPanel;
+import javax.swing.JLabel;
+import javax.swing.BoxLayout;
+import javax.swing.SwingConstants;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import javax.swing.JTextField;
+import javax.swing.JPasswordField;
+
+import java.util.ResourceBundle;
+
+public class WizardChooseUsername extends JPanel {
+       public static final long serialVersionUID = -1;
+       private JTextField usernametext;
+       private JTextField passwordtext;
+       private JTextField passwordconfirmtext;
+
+       public WizardChooseUsername(ResourceBundle bundle) {
+               super();
+               
+               this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+               
+               this.add(Box.createVerticalGlue());
+               
+               JLabel welcomelabel = new 
JLabel(bundle.getString("choose_a_username_and_password"), 
SwingConstants.CENTER);
+               welcomelabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
+               this.add(welcomelabel);
+               
+               JPanel usernamebox = new JPanel();
+               usernamebox.setBorder(BorderFactory.createEmptyBorder(30, 30, 
30, 30));
+               GridBagLayout gb = new GridBagLayout();
+               GridBagConstraints c = new GridBagConstraints();
+               usernamebox.setLayout(gb);
+               
+               JLabel usernamelbl = new JLabel(bundle.getString("username")+": 
", SwingConstants.RIGHT);
+               usernamelbl.setAlignmentX(JLabel.RIGHT_ALIGNMENT);
+               c.gridwidth = 1;
+               c.fill = GridBagConstraints.NONE;
+               c.weightx = 0;
+               gb.setConstraints(usernamelbl, c);
+               usernamebox.add(usernamelbl);
+               
+               this.usernametext = new JTextField();
+               c.gridwidth = GridBagConstraints.REMAINDER;
+               c.fill = GridBagConstraints.HORIZONTAL;
+               c.weightx = 1;
+               gb.setConstraints(this.usernametext, c);
+               usernamebox.add(this.usernametext);
+                
+               
+               JLabel passwordlbl = new JLabel(bundle.getString("password")+": 
", SwingConstants.RIGHT);
+               passwordlbl.setAlignmentX(JLabel.RIGHT_ALIGNMENT);
+               c.gridwidth = 1;
+               c.fill = GridBagConstraints.NONE;
+               c.weightx = 0;
+               gb.setConstraints(passwordlbl, c);
+               usernamebox.add(passwordlbl);
+               
+               this.passwordtext = new JPasswordField();
+               c.gridwidth = GridBagConstraints.REMAINDER;
+               c.fill = GridBagConstraints.HORIZONTAL;
+               c.weightx = 1;
+               gb.setConstraints(this.passwordtext, c);
+               usernamebox.add(this.passwordtext);
+               
+               JLabel passwordconfirmlbl = new 
JLabel(bundle.getString("confirm_password")+": ", SwingConstants.RIGHT);
+               passwordconfirmlbl.setAlignmentX(JLabel.LEFT_ALIGNMENT);
+               c.gridwidth = 1;
+               c.fill = GridBagConstraints.NONE;
+               c.weightx = 0;
+               gb.setConstraints(passwordconfirmlbl, c);
+               usernamebox.add(passwordconfirmlbl);
+               
+               this.passwordconfirmtext = new JPasswordField();
+               c.gridwidth = GridBagConstraints.REMAINDER;
+               c.fill = GridBagConstraints.HORIZONTAL;
+               c.weightx = 1;
+               gb.setConstraints(this.passwordconfirmtext, c);
+               usernamebox.add(this.passwordconfirmtext);
+               
+               this.add(usernamebox);
+               this.add(Box.createVerticalGlue());
+       }
+}

Added: trunk/apps/Freemail/src/freemailgui/WizardWelcome.java
===================================================================
--- trunk/apps/Freemail/src/freemailgui/WizardWelcome.java      2006-08-26 
21:26:41 UTC (rev 10273)
+++ trunk/apps/Freemail/src/freemailgui/WizardWelcome.java      2006-08-27 
00:10:41 UTC (rev 10274)
@@ -0,0 +1,30 @@
+package freemailgui;
+
+import javax.swing.JPanel;
+import javax.swing.JLabel;
+import javax.swing.BoxLayout;
+import javax.swing.SwingConstants;
+import javax.swing.Box;
+import java.awt.Dimension;
+
+import java.util.ResourceBundle;
+
+public class WizardWelcome extends JPanel {
+       public static final long serialVersionUID = -1;
+
+       public WizardWelcome(ResourceBundle bundle) {
+               super();
+               
+               this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+               
+               JLabel welcomelabel = new JLabel(bundle.getString("welcome"), 
SwingConstants.CENTER);
+               welcomelabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
+               this.add(welcomelabel);
+               
+               this.add(Box.createRigidArea(new Dimension(0,15)));
+               
+               JLabel introlabel = new JLabel(bundle.getString("intro"));
+               introlabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
+               this.add(introlabel);
+       }
+}

Added: trunk/apps/Freemail/src/freemailgui/images/logo_and_text.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/apps/Freemail/src/freemailgui/images/logo_and_text.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/apps/Freemail/src/freemailgui/images/pigeon_small.png
===================================================================
(Binary files differ)


Property changes on: trunk/apps/Freemail/src/freemailgui/images/pigeon_small.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/apps/Freemail/src/freemailgui/text/MessageBundle_en_GB.properties
===================================================================
--- trunk/apps/Freemail/src/freemailgui/text/MessageBundle_en_GB.properties     
2006-08-26 21:26:41 UTC (rev 10273)
+++ trunk/apps/Freemail/src/freemailgui/text/MessageBundle_en_GB.properties     
2006-08-27 00:10:41 UTC (rev 10274)
@@ -0,0 +1,10 @@
+welcome = Welcome to Freemail!
+wizard_title = Freemail Setup Wizard
+intro = This guide will take you through the process of setting up Freemail
+cancel = Cancel
+next = Next
+choose_a_username_and_password = Please choose a username and password for use 
with Freemail:
+username = Username
+password = Password
+confirm_password = Confirm Password
+back = Back


Reply via email to