}
@Override
public void observe(Event genericEvent) {
if (!(genericEvent instanceof ServerMatchUpdatedEvent)) return;
ServerMatchUpdatedEvent event = (ServerMatchUpdatedEvent)genericEvent;
Match match = event.getMatch();
DefaultTableModel model = (DefaultTableModel) queueTable.getModel();
for (int i = 0; i < model.getRowCount(); i++) {
String rowMatchId = model.getValueAt(i, 0).toString();
if (rowMatchId.equals(match.getMatchId())) {
String status = "active";
if (match.isAborted()) status = "aborted";
if (match.isCompleted()) status = "done";
model.setValueAt(status, i, 3);
if (match.isCompleted()) {
model.setValueAt(getLinebreakString(match.getGoalValues()), i, 5);
}
List<Integer> errorCounts = new ArrayList<Integer>();
List<String> errorCountStrings = new ArrayList<String>();
for (int j = 0; j < match.getPlayerNamesFromHost().size(); j++) {
errorCounts.add(0);
}
for (List<String> errors : match.getErrorHistory()) {
for (int j = 0; j < errors.size(); j++) {
if (!errors.get(j).isEmpty()) {
errorCounts.set(j, errorCounts.get(j) + 1);
}
}
}
for (int errorCount : errorCounts) {
if (errorCount > 0) {
errorCountStrings.add("<font color=red>" + errorCount + "</font>");
} else {
errorCountStrings.add("0");
}
}
model.setValueAt(getLinebreakString(errorCountStrings), i, 6);
model.setValueAt(match.getStateHistory().size()-1, i, 7);
if (event.getExternalPublicationKey() != null) {
matchIdToURL.put(match.getMatchId(), "http://www.ggp.org/view/all/matches/" + event.getExternalPublicationKey() + "/");
}
if (event.getExternalFilename() != null) {
matchIdToFilename.put(match.getMatchId(), event.getExternalFilename());
}
return;
}
}