package dnb.model;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import dnb.data.Label;
public class LabelTableModel extends AbstractTableModel {
private static final long serialVersionUID = 1L;
private final List<Label> labels;
public LabelTableModel(List<Label> labels) {
this.labels = labels;
}
@Override
public int getColumnCount() {
return 2;
}
@Override
public int getRowCount() {
return labels.size();
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
if (columnIndex == 0) {
return labels.get(rowIndex).getName();
} else {
Label l = labels.get(rowIndex);
final int c = l.size();
String entry = "";
for (int i = 0; i < c; i++) {
entry+= l.get(i) + " ";
}
return entry;
}
}
@Override
public String getColumnName(int column) {
if (column == 0) {
return "Label Name";
} else {
return "Label codes";
}
}
}