1 package at.ac.tuwien.sbc.valesriegler.pizzeria.gui.tablemodels;
3 import java.util.ArrayList;
4 import java.util.Collection;
7 import at.ac.tuwien.sbc.valesriegler.DEP_Order;
8 import at.ac.tuwien.sbc.valesriegler.common.TableModel;
10 public class OrdersOverviewModel extends TableModel<DEP_Order> {
11 private static final String ID = "Order ID";
12 private static final String TABLE_ID = "Table ID";
13 private static final String GROUP_ID = "Group ID";
14 private static final String STATUS = "Status";
16 private static final String[] COLUMNS = new String[] {
17 ID, TABLE_ID, GROUP_ID, STATUS
21 public Object getValueAt(int rowIndex, int columnIndex) {
22 List<DEP_Order> values = new ArrayList<>(items.values());
23 DEP_Order order = values.get(rowIndex);
24 String wantedColumn = COLUMNS[columnIndex];
25 switch(wantedColumn) {
26 case ID : return order.getId();
27 case TABLE_ID : return order.getTableId();
28 case GROUP_ID : return order.getGroupId();
29 case STATUS : return order.getStatus();
30 default : throw new RuntimeException(UNHANDLEDCOLUMN);
34 public DEP_Order getOrderOfRow(int rowIndex) {
35 return new ArrayList<>(items.values()).get(rowIndex);
39 protected String[] getColumns() {