1 package at.ac.tuwien.sbc.valesriegler.pizzeria.gui.tablemodels;
5 import at.ac.tuwien.sbc.valesriegler.common.TableModel;
6 import at.ac.tuwien.sbc.valesriegler.pizzeria.gui.Table;
7 import at.ac.tuwien.sbc.valesriegler.pizzeria.gui.Table.TableStatus;
9 public class TablesOverviewModel extends TableModel<Table> {
10 private static final String TABLE_ID = "ID";
11 private static final String STATUS = "Status";
12 private static final String GROUP_ID = "Group ID";
13 private static final String[] COLUMNS = new String[] {
14 TABLE_ID, STATUS, GROUP_ID
17 public TablesOverviewModel(List<Table> tables) {
22 protected String[] getColumns() {
27 public Object getValueAt(int rowIndex, int columnIndex) {
28 Table table = items.get(rowIndex);
29 String wantedColumn = COLUMNS[columnIndex];
30 switch(wantedColumn) {
31 case TABLE_ID : return table.getId();
32 case STATUS : return table.getStatus();
33 case GROUP_ID : return table.getGroupId();
34 default : throw new RuntimeException(UNHANDLEDCOLUMN);
38 public int getNumberOfFreeTables() {
40 for(Table table : items) {
41 if(table.getStatus() == TableStatus.FREE) {