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 * ID for serialization.
019 */
020 private static final long serialVersionUID = 3267449147384918254L;
021
022 /**
023 * Creates a {@link UserTableFormSheet}. The look of the table is
024 * defined by the {@link TEDManagerEmployeeOverview}.
025 */
026 public FSManagerEmployeeOverview() {
027 super("Angestellte", new UserManagerFilter(UMUserBase.getGlobalBase().getStaff()),
028 null, null, null, new TEDManagerEmployeeOverview());
029 addContentCreator(new FormSheetContentCreator() {
030 private static final long serialVersionUID = -5651635858420607923L;
031 public void createFormSheetContent(final FormSheet fs) {
032 fs.removeAllButtons();
033 fs.addButton("Einstellen", ButtonIDs.BTN_ADD, null);
034 fs.addButton("Daten bearbeiten", ButtonIDs.BTN_EDIT, null);
035 fs.addButton("Entlassen", ButtonIDs.BTN_DELETE, null);
036 }
037 });
038 }
039 }
040
041 /**
042 * The {@link util.swing.TableEntryDescriptor} used by {@link FSManagerEmployeeOverview}.
043 */
044 class TEDManagerEmployeeOverview extends AbstractTableEntryDescriptor {
045
046 /**
047 * ID for serialization.
048 */
049 private static final long serialVersionUID = -5637971544602732337L;
050
051 /**
052 * @return the number of the table's columns.
053 */
054 public int getColumnCount() {
055 return 2;
056 }
057
058 /**
059 * @param nIndex the affected column.
060 * @return columns' names.
061 */
062 public String getColumnName(int nIndex) {
063 return (new String[]{"Name", "Abteilung"}) [nIndex];
064 }
065
066 /**
067 * @param nIndex the affected column.
068 * @return columns' classes. They indicate how column's values should be aligned.
069 */
070 public Class<?> getColumnClass (int nIndex) {
071 return String.class;
072 }
073
074 /**
075 * @param oRecord the affected table record.
076 * @param nIndex the affected column.
077 * @return columns' values
078 */
079 public Object getValueAt(Object oRecord, int nIndex) {
080 UStaffer usr = (UStaffer)oRecord;
081 switch (nIndex) {
082 case 0: return usr.getSurname() + ", " + usr.getFirstName();
083 case 1: return usr.getQualification();
084 }
085 return null;
086 }
087
088 /**
089 * Determines if columns can be sorted by the user.
090 *
091 * @param nIndex the affected column.
092 * @return <ul><li>true: columns can be sorted</li>
093 * <li>false: columns cannot be sorted</li></ul>
094 */
095 public boolean canSortByColumn(int nIndex) {
096 return true;
097 }
098 }