001 package videoautomat.gui; 002 import java.util.Comparator; 003 004 import sale.FormSheet; 005 import sale.FormSheetContentCreator; 006 import sale.UIGate; 007 import sale.stdforms.MsgForm; 008 import users.UserManager; 009 import users.stdforms.LogOnForm; 010 import users.swing.UserFilter; 011 import util.swing.TableEntryDescriptor; 012 import data.CountingStock; 013 import data.stdforms.SingleTableFormSheet; 014 015 /** 016 * This class implements graphical-user-interface elements for the SaleProcessLogOn 017 */ 018 public class LogOn { 019 /** 020 * An ID to identify the <code>FormButton</code> rent 021 */ 022 public static int FB_RENT = 1; 023 024 /** 025 * An ID to identify the <code>FormButton</code> hand back 026 */ 027 public static int FB_HANDBACK = 2; 028 029 /** 030 * An ID to identify the <code>FormButton</code> admin 031 */ 032 public static int FB_ADMIN = 3; 033 034 /** 035 * An ID to identify the <code>FormButton</code> logout 036 */ 037 public static int FB_LOGOUT = 4; 038 /** 039 * @return a <code>LogOnForm</code> 040 * @param ask_password 041 * if false no password is needed and selection of the user name is sufficient. 042 * @param um 043 * the UserManager that manages the users to select from. 044 * @param cmp 045 * a comparator that defines the order in which the user names appear. If null, users will be ordered by 046 * their names. 047 * @param uf 048 * a filter that allows only a subset of the users to be selected from. If null, no filtering will 049 * occur. 050 * 051 */ 052 public static LogOnForm getLogOnForm( 053 boolean ask_password, 054 UserManager um, 055 Comparator cmp, 056 UserFilter uf) { 057 LogOnForm lof = 058 new LogOnForm( 059 "Are you a registered user?", 060 "Select your user name!", 061 "Enter your passphrase!", 062 ask_password, 063 um, 064 cmp, 065 uf); 066 return lof; 067 } 068 069 /** 070 * @return a <code>FormSheet<code> informing the user, that logging on failed. 071 */ 072 public static FormSheet getFaultFormSheet() { 073 return new MsgForm( 074 "Log on failed!", 075 "You didnt choose a user name or the passphrase didn`t match!"); 076 } 077 078 /** 079 * @return a <code>FormSheet<code> where the video-offer is displayed and possibilities exist to start further activities. 080 * @param cs the <code>Stock</code> that contains the video-offer 081 * @param uigGate the <code>UIGate</code> this <code>FormSheet</code> is displayed 082 * @param show_zeros if false, lines containing a '0' in the "Count" field will be hidden. 083 * @param ted the <code>TableEntryDescriptor</code> used to display the <Stock> 084 * 085 */ 086 public static FormSheet getMainFormSheet( 087 CountingStock cs, 088 UIGate uigGate, 089 boolean show_zeros, 090 TableEntryDescriptor ted) { 091 SingleTableFormSheet stfs_main = 092 SingleTableFormSheet.create( 093 "Select an action!", 094 cs, 095 uigGate, 096 show_zeros, 097 ted); 098 stfs_main.addContentCreator(new FormSheetContentCreator() { 099 public void createFormSheetContent(FormSheet fs) { 100 fs.removeAllButtons(); 101 fs.addButton("Rent", FB_RENT, null); 102 fs.addButton("Hand back", FB_HANDBACK, null); 103 fs.addButton("Administrate", FB_ADMIN, null); 104 fs.addButton("Logout", FB_LOGOUT, null); 105 } 106 }); 107 108 return stfs_main; 109 } 110 }