001 package market.stdform;
002
003 import market.UMUserBase;
004 import market.UStaffer;
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 the whole staff of the market in a table. New workers can be employed and
013 * current workers can have their data edited by the manager or even be fired.
014 */
015 public class FSManagerEmployeeOverview extends UserTableFormSheet {
016
017 /**
018 * Creates a {@link UserTableFormSheet}. The look of the table is
019 * defined by the {@link TEDManagerEmployeeOverview}.
020 */
021 public FSManagerEmployeeOverview() {
022 super("Angestellte", new UserManagerFilter(UMUserBase.getGlobalBase().getStaff()),
023 null, null, null, new TEDManagerEmployeeOverview());
024 addContentCreator(new FormSheetContentCreator() {
025 public void createFormSheetContent(final FormSheet fs) {
026 fs.removeAllButtons();
027 fs.addButton("Einstellen", ButtonIDs.BTN_ADD, null);
028 fs.addButton("Daten bearbeiten", ButtonIDs.BTN_EDIT, null);
029 fs.addButton("Entlassen", ButtonIDs.BTN_DELETE, null);
030 }
031 });
032 }
033 }
034
035 /**
036 * The {@link util.swing.TableEntryDescriptor} used by {@link FSManagerEmployeeOverview}.
037 */
038 class TEDManagerEmployeeOverview extends AbstractTableEntryDescriptor {
039
040 /**
041 * @return the number of the table's columns.
042 */
043 public int getColumnCount() {
044 return 2;
045 }
046
047 /**
048 * @param nIndex the affected column.
049 * @return columns' names.
050 */
051 public String getColumnName(int nIndex) {
052 return (new String[]{"Name", "Abteilung"}) [nIndex];
053 }
054
055 /**
056 * @param nIndex the affected column.
057 * @return columns' classes. They indicate how column's values should be aligned.
058 */
059 public Class getColumnClass (int nIndex) {
060 return String.class;
061 }
062
063 /**
064 * @param oRecord the affected table record.
065 * @param nIndex the affected column.
066 * @return columns' values
067 */
068 public Object getValueAt(Object oRecord, int nIndex) {
069 UStaffer usr = (UStaffer)oRecord;
070 switch (nIndex) {
071 case 0: return usr.getSurname() + ", " + usr.getFirstName();
072 case 1: return usr.getQualification();
073 }
074 return null;
075 }
076
077 /**
078 * Determines if columns can be sorted by the user.
079 *
080 * @param nIndex the affected column.
081 * @return <ul><li>true: columns can be sorted</li>
082 * <li>false: columns cannot be sorted</li></ul>
083 */
084 public boolean canSortByColumn(int nIndex) {
085 return true;
086 }
087 }