]> git.somenet.org - pub/jan/sbc.git/blob - src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/gui/tablemodels/GroupsOverviewModel.java
Some space refactoring. Doing away with unnecessary containers. Auto-Reloading of...
[pub/jan/sbc.git] / src / main / java / at / ac / tuwien / sbc / valesriegler / pizzeria / gui / tablemodels / GroupsOverviewModel.java
1 package at.ac.tuwien.sbc.valesriegler.pizzeria.gui.tablemodels;
2
3 import java.util.ArrayList;
4 import java.util.Iterator;
5 import java.util.List;
6
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
11 public class GroupsOverviewModel extends TableModel<GroupData> {
12         private static final String ID = "ID";
13         private static final String SIZE = "Size";
14
15         private static final String[] COLUMNS = new String[] { ID, SIZE };
16
17         @Override
18         protected String[] getColumns() {
19                 return COLUMNS;
20         }
21         
22
23         @Override
24         public Object getValueAt(int rowIndex, int columnIndex) {
25                 List<GroupData> values = new ArrayList<>(items.values());
26
27                 GroupData group = values.get(rowIndex);
28                 String wantedColumn = COLUMNS[columnIndex];
29                 switch (wantedColumn) {
30                 case ID:
31                         return group.getId();
32                 case SIZE:
33                         return group.getSize();
34                 default:
35                         throw new RuntimeException(UNHANDLEDCOLUMN);
36                 }
37         }
38
39         public void removeGroup(int id) {
40                 items.remove(id);
41                 
42                 fireTableDataChanged();
43         }
44
45 }