1 package at.ac.tuwien.sbc.valesriegler.pizzeria.gui.tablemodels;
3 import java.util.ArrayList;
4 import java.util.Iterator;
7 import at.ac.tuwien.sbc.valesriegler.common.TableModel;
8 import at.ac.tuwien.sbc.valesriegler.types.GroupData;
9 import at.ac.tuwien.sbc.valesriegler.types.GroupState;
11 public class GroupsOverviewModel extends TableModel<GroupData> {
12 private static final String ID = "ID";
13 private static final String SIZE = "Size";
15 private static final String[] COLUMNS = new String[] { ID, SIZE };
18 protected String[] getColumns() {
23 public Object getValueAt(int rowIndex, int columnIndex) {
24 List<GroupData> values = new ArrayList<>(items.values());
25 Iterator<GroupData> it = values.iterator();
26 while (it.hasNext()) {
27 GroupData groupData = it.next();
28 // Show only the waiting groups!
29 if(groupData.getState() != GroupState.WAITING) {
33 GroupData group = values.get(rowIndex);
34 String wantedColumn = COLUMNS[columnIndex];
35 switch (wantedColumn) {
39 return group.getSize();
41 throw new RuntimeException(UNHANDLEDCOLUMN);