1 package at.ac.tuwien.sbc.valesriegler.common;
5 import java.util.concurrent.ConcurrentSkipListMap;
7 import javax.swing.table.AbstractTableModel;
10 * Common base class of table models used in Group GUI and Pizzeria GUI.
12 * @author Gregor Riegler <gregor DOT riegler AT gmail DOT com>
15 public abstract class TableModel<Item extends HasId> extends AbstractTableModel {
16 protected static final String UNHANDLEDCOLUMN = "Unhandled column";
18 protected final Map<Integer, Item> items = new ConcurrentSkipListMap<Integer, Item>();
20 public void addItems(List<Item> newItems) {
21 for (Item item : newItems) {
22 items.put(item.getId(), item);
25 fireTableDataChanged();
28 public void setItems(List<Item> newItems) {
34 public int getRowCount() {
39 public String getColumnName(int column) {
40 return getColumns()[column];
44 public int getColumnCount() {
45 return getColumns().length;
48 protected abstract String[] getColumns();