001 package videoautomat; 002 import sale.Gate; 003 import sale.SaleProcess; 004 import sale.UIGate; 005 import sale.stdforms.MsgForm; 006 import users.UserManager; 007 import users.stdforms.LogOnForm; 008 import videoautomat.contentcreator.LogOnLOFContentCreator; 009 import videoautomat.contentcreator.LogOnMFContentCreator; 010 import videoautomat.contentcreator.LogOnSTFSContentCreator; 011 import data.stdforms.SingleTableFormSheet; 012 013 /** 014 * This class implements a <code>SaleProcess</code> used to log on and choose which activity should follow. 015 * 016 */ 017 public class SaleProcessLogOn extends SaleProcess { 018 019 /** 020 * ID for Serialization. 021 */ 022 private static final long serialVersionUID = -2721832856161125193L; 023 024 /** 025 * Constructs a new <code>SaleProcessLogOn</code> 026 * 027 */ 028 public SaleProcessLogOn() { 029 super("SaleProcessLogOn"); 030 } 031 032 /** 033 * Implementation of the inherited abstract method. 034 * 035 * @return a <code>Gate</code> where the user selects it`s user-name and is asked for his/her password. 036 * 037 * @see sale.SaleProcess#getInitialGate() 038 */ 039 protected Gate getInitialGate() { 040 041 UIGate uig_log_on = new UIGate(null, null); 042 043 LogOnForm lof_initial = new LogOnForm( 044 "Are you a registered user?", 045 "Select your user name", 046 "Enter your passphrase", 047 true, 048 UserManager.getGlobalUM(), 049 null, 050 null); 051 052 lof_initial.addContentCreator(new LogOnLOFContentCreator()); 053 054 uig_log_on.setFormSheet(lof_initial); 055 056 return uig_log_on; 057 } 058 059 /** 060 * Returns the initial gate. 061 * 062 * @return intialGate 063 */ 064 public Gate restart() 065 { 066 return getInitialGate(); 067 } 068 069 070 /** 071 * @return a <code>Gate</code> that shows an error-message. 072 */ 073 public Gate getFaultGate() { 074 075 UIGate uig_fault = new UIGate(null, null); 076 077 MsgForm mf_fault = new MsgForm( 078 "Log on failed!", 079 "You didn`t choose a user name or the passphrase didn`t match!"); 080 081 mf_fault.addContentCreator(new LogOnMFContentCreator()); 082 083 uig_fault.setFormSheet(mf_fault); 084 085 return uig_fault; 086 } 087 088 /** 089 * @return a <code>Gate</code> where the user can select the next activity, like renting a video. 090 */ 091 public Gate getMainGate() { 092 093 UIGate uig_main = new UIGate(null, null); 094 095 SingleTableFormSheet stfs_main = 096 SingleTableFormSheet.create( 097 "Select an action!", 098 VideoShop.getVideoStock(), 099 uig_main, 100 false, 101 new TEDVideoStock()); 102 103 stfs_main.addContentCreator(new LogOnSTFSContentCreator(this)); 104 105 return uig_main; 106 } 107 }