1 package at.ac.tuwien.sbc.valesriegler.pizzeria.gui.tablemodels;
3 import at.ac.tuwien.sbc.valesriegler.common.TableModel;
4 import at.ac.tuwien.sbc.valesriegler.types.GroupData;
5 import at.ac.tuwien.sbc.valesriegler.types.Table;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
9 import java.util.ArrayList;
10 import java.util.List;
12 public class GroupsOverviewModel extends TableModel<GroupData> {
13 private static final Logger log = LoggerFactory.getLogger(GroupsOverviewModel.class);
14 private static final String ID = "ID";
15 private static final String SIZE = "Size";
17 private static final String[] COLUMNS = new String[] { ID, SIZE };
20 protected String[] getColumns() {
26 public Object getValueAt(int rowIndex, int columnIndex) {
27 List<GroupData> values = new ArrayList<GroupData>(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 synchronized (items) {
48 for (Table table : tables) {
49 final int groupId = table.getGroupId();
50 items.remove(groupId);
53 fireTableDataChanged();