1 package at.ac.tuwien.sbc.valesriegler.pizzeria.gui.tablemodels;
3 import java.util.ArrayList;
6 import at.ac.tuwien.sbc.valesriegler.common.TableModel;
7 import at.ac.tuwien.sbc.valesriegler.types.GroupData;
8 import at.ac.tuwien.sbc.valesriegler.types.Order;
10 public class OrdersOverviewModel extends TableModel<GroupData> {
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[] { ID, TABLE_ID, GROUP_ID, STATUS };
19 public Object getValueAt(int rowIndex, int columnIndex) {
20 List<GroupData> values = new ArrayList<>(items.values());
21 GroupData group = values.get(rowIndex);
22 Order order = group.getOrder();
23 String wantedColumn = COLUMNS[columnIndex];
24 switch (wantedColumn) {
28 return group.getTable().getId() ;
30 return order.getGroupId();
32 return order.getStatus();
34 throw new RuntimeException(UNHANDLEDCOLUMN);
38 public GroupData getGroupOfRow(int rowIndex) {
39 return new ArrayList<>(items.values()).get(rowIndex);
43 protected String[] getColumns() {