001 package market.stdform; 002 003 import market.SICustomer; 004 import market.UCustomer; 005 import sale.FormSheet; 006 import sale.FormSheetContentCreator; 007 import users.UserManager; 008 import util.swing.AbstractTableEntryDescriptor; 009 import util.swing.TableEntryDescriptor; 010 import data.StoringStock; 011 import data.stdforms.SingleTableFormSheet; 012 013 014 /** 015 * This FormSheet displays the customers who are waiting at the till in a table, 016 * with the customer who waits the longest time at the top. 017 */ 018 public class FSSellerCustomerTable { 019 020 /** 021 * @return the customer table. 022 * 023 * @param ss the StoringStock containing the waiting customers in form of {@link SICustomer}. 024 */ 025 public static SingleTableFormSheet getCustomerTable(StoringStock ss){ 026 027 SingleTableFormSheet stfs = SingleTableFormSheet.create( 028 "Kunden-Warteschlange", 029 ss, 030 null, 031 getTED()); 032 033 stfs.addContentCreator(new FormSheetContentCreator() { 034 private static final long serialVersionUID = -7993263388943367240L; 035 protected void createFormSheetContent(final FormSheet fs) { 036 fs.removeAllButtons(); 037 fs.addButton("Kunden bedienen", ButtonIDs.BTN_OK, null); 038 fs.addButton("Auftrag stornieren", ButtonIDs.BTN_CANCEL, null); 039 }} 040 ); 041 return stfs; 042 } 043 044 /** 045 * @return the TableEntryDescriptor of the table, declaring two columns: the userID and full name of the customer. 046 */ 047 private static TableEntryDescriptor getTED(){ 048 AbstractTableEntryDescriptor ted = new AbstractTableEntryDescriptor() { 049 private static final long serialVersionUID = 1001790005005190466L; 050 public int getColumnCount() { 051 return 2; 052 } 053 054 public String getColumnName(int nIdx) { 055 return (new String[]{ "KundenID", "Name"}) [nIdx]; 056 } 057 058 public Class<?> getColumnClass(int nIdx) { 059 return (new Class[] {String.class, String.class}) [nIdx]; 060 } 061 062 public Object getValueAt(Object oRecord, int nIdx) { 063 UCustomer customer = (UCustomer)UserManager.getGlobalUM().getUser(((SICustomer)oRecord).getName()); 064 switch(nIdx){ 065 case 0: return customer.getName(); 066 case 1: return customer.getFullName(); 067 } 068 return null; 069 } 070 }; 071 return ted; 072 } 073 }