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 int getRowCount() {
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 // TODO what is the GroupState.NEW?
30 if(!(groupData.getState() == GroupState.NEW || groupData.getState() == GroupState.WAITING)) {
39 public Object getValueAt(int rowIndex, int columnIndex) {
40 List<GroupData> values = new ArrayList<>(items.values());
41 Iterator<GroupData> it = values.iterator();
42 while (it.hasNext()) {
43 GroupData groupData = it.next();
44 // Show only the waiting groups!
45 if(groupData.getState() == GroupState.NEW || groupData.getState() == GroupState.WAITING) {
49 GroupData group = values.get(rowIndex);
50 String wantedColumn = COLUMNS[columnIndex];
51 switch (wantedColumn) {
55 return group.getSize();
57 throw new RuntimeException(UNHANDLEDCOLUMN);