/* License see bottom */
package jtrackbase.gui.table;
import java.util.Collection;
import jtrackbase.db.Medium;
/**
*
* @author Onkobu Tanaake
*
*/
public class MediumTableModel extends EntityTableModel<Medium> {
private static final String[] columnNames={
"Id",
"Name",
"Label",
"Year",
"Tracks"
};
private static final Class<?>[] columnClasses= {
Integer.class,
String.class,
String.class,
Integer.class,
Integer.class
};
public MediumTableModel() {
super();
}
public MediumTableModel(Collection<Medium> coll) {
super(coll);
}
@Override
public Class<?> getColumnClass(int columnIndex) {
return columnClasses[columnIndex];
}
@Override
public int getColumnCount() {
return columnNames.length;
}
@Override
public String getColumnName(int columnIndex) {
return columnNames[columnIndex];
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
Medium m=get(rowIndex);
if (m==null) {
return null;
}
switch (columnIndex) {
case 0:{
return m.getId();
}
case 1:{
return m.getName();
}
case 2: {
return m.getLabel()==null?"":m.getLabel().getName();
}
case 3: {
return m.getYearReleased();
}
case 4: {
return m.getTracks()==null?-1:m.getTracks().size();
}
}
return null;
}
}
/*
Copyright (C) 2008 Onkobu Tanaake
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (gplv3.txt).
*/