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 * Constructs a new <code>SaleProcessLogOn</code> 021 * 022 */ 023 public SaleProcessLogOn() { 024 super("SaleProcessLogOn"); 025 } 026 027 /** 028 * Implementation of the inherited abstract method. 029 * 030 * @return a <code>Gate</code> where the user selects it`s user-name and is asked for his/her password. 031 * 032 * @see sale.SaleProcess#getInitialGate() 033 */ 034 protected Gate getInitialGate() { 035 036 UIGate uig_log_on = new UIGate(null, null); 037 038 LogOnForm lof_initial = new LogOnForm( 039 "Are you a registered user?", 040 "Select your user name!", 041 "Enter your passphrase!", 042 true, 043 UserManager.getGlobalUM(), 044 null, 045 null); 046 047 lof_initial.addContentCreator(new LogOnLOFContentCreator()); 048 049 uig_log_on.setFormSheet(lof_initial); 050 051 return uig_log_on; 052 } 053 054 public Gate restart() 055 { 056 return getInitialGate(); 057 } 058 059 060 /** 061 * @return a <code>Gate</code> that shows an error-message. 062 */ 063 public Gate getFaultGate() { 064 065 UIGate uig_fault = new UIGate(null, null); 066 067 MsgForm mf_fault = new MsgForm( 068 "Log on failed!", 069 "You didn`t choose a user name or the passphrase didn`t match!"); 070 071 mf_fault.addContentCreator(new LogOnMFContentCreator()); 072 073 uig_fault.setFormSheet(mf_fault); 074 075 return uig_fault; 076 } 077 078 /** 079 * @return a <code>Gate</code> where the user can select the next activity, like renting a video. 080 */ 081 public Gate getMainGate() { 082 083 UIGate uig_main = new UIGate(null, null); 084 085 SingleTableFormSheet stfs_main = 086 SingleTableFormSheet.create( 087 "Select an action!", 088 VideoShop.getVideoStock(), 089 uig_main, 090 false, 091 new TEDVideoStock()); 092 093 stfs_main.addContentCreator(new LogOnSTFSContentCreator(this)); 094 095 return uig_main; 096 } 097 }