001 package market.stdform; 002 003 import market.UCustomer; 004 import market.UMUserBase; 005 import sale.FormSheet; 006 import sale.FormSheetContentCreator; 007 import users.UserManagerFilter; 008 import users.stdforms.UserTableFormSheet; 009 import util.swing.AbstractTableEntryDescriptor; 010 011 /** 012 * This FormSheet displays all customers of the market in a table. Customers can be selected for a 013 * detailed view or for deletion. 014 */ 015 public class FSManagerCustomerOverview extends UserTableFormSheet { 016 017 /** 018 * Creates a {@link UserTableFormSheet}. The look of the table is 019 * defined by the {@link TEDManagerCustomerOverview}. 020 */ 021 public FSManagerCustomerOverview() { 022 super("Kunden", new UserManagerFilter(UMUserBase.getGlobalBase().getCustomers()), 023 null, null, null, new TEDManagerCustomerOverview()); 024 addContentCreator(new FormSheetContentCreator() { 025 public void createFormSheetContent(final FormSheet fs) { 026 fs.removeAllButtons(); 027 fs.addButton("Daten bearbeiten", ButtonIDs.BTN_EDIT, null); 028 fs.addButton("Geschäftsbeziehung beenden", ButtonIDs.BTN_DELETE, null); 029 } 030 }); 031 } 032 } 033 034 /** 035 * The {@link util.swing.TableEntryDescriptor} used by {@link FSManagerCustomerOverview}. 036 */ 037 class TEDManagerCustomerOverview extends AbstractTableEntryDescriptor { 038 039 /** 040 * @return the number of the table's columns. 041 */ 042 public int getColumnCount() { 043 return 2; 044 } 045 046 /** 047 * @param nIndex the affected column. 048 * @return columns' names. 049 */ 050 public String getColumnName(int nIndex) { 051 return (new String[]{"Name", "Firma"}) [nIndex]; 052 } 053 054 /** 055 * @param nIndex the affected column. 056 * @return columns' classes. They indicate how column's values should be aligned. 057 */ 058 public Class getColumnClass (int nIndex) { 059 return String.class; 060 } 061 062 /** 063 * @param oRecord the affected table record. 064 * @param nIndex the affected column. 065 * @return columns' values 066 */ 067 public Object getValueAt(Object oRecord, int nIndex) { 068 UCustomer usr = (UCustomer)oRecord; 069 switch (nIndex) { 070 case 0: 071 return usr.getSurname() + ", " + usr.getFirstName(); 072 case 1: 073 return usr.getCompany(); 074 } 075 return null; 076 } 077 078 079 /** 080 * Determines if columns can be sorted by the user. 081 * 082 * @param nIndex the affected column. 083 * @return <ul><li>true: columns can be sorted</li> 084 * <li>false: columns cannot be sorted</li></ul> 085 */ 086 public boolean canSortByColumn(int nIndex) { 087 return true; 088 } 089 090 }