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;
10 import at.ac.tuwien.sbc.valesriegler.types.Table;
12 public class GroupsOverviewModel extends TableModel<GroupData> {
13 private static final String ID = "ID";
14 private static final String SIZE = "Size";
16 private static final String[] COLUMNS = new String[] { ID, SIZE };
19 protected String[] getColumns() {
25 public Object getValueAt(int rowIndex, int columnIndex) {
26 List<GroupData> values = new ArrayList<>(items.values());
28 GroupData group = values.get(rowIndex);
29 String wantedColumn = COLUMNS[columnIndex];
30 switch (wantedColumn) {
34 return group.getSize();
36 throw new RuntimeException(UNHANDLEDCOLUMN);
40 public void removeGroup(int id) {
43 fireTableDataChanged();
46 public void removeGroupsFromTables(List<Table> tables) {
47 for (Table table : tables) {
48 final int groupId = table.getGroupId();
49 items.remove(groupId);
51 fireTableDataChanged();