int row = 0;
final String layerName = tl.getName();
while (iter.hasNext()) {
GWCTask task = iter.next();
if (!listAll && !layerName.equals(task.getLayerName())) {
continue;
}
final long spent = task.getTimeSpent();
final long remining = task.getTimeRemaining();
final long tilesDone = task.getTilesDone();
final long tilesTotal = task.getTilesTotal();
NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH);
nf.setGroupingUsed(true);
final String tilesTotalStr;
if (tilesTotal < 0) {
tilesTotalStr = "Too many to count";
} else {
tilesTotalStr = nf.format(tilesTotal);
}
final String tilesDoneStr = nf.format(task.getTilesDone());
final STATE state = task.getState();
final String status = STATE.UNSET.equals(state) || STATE.READY.equals(state) ? "PENDING"
: state.toString();
String timeSpent = toTimeString(spent, tilesDone, tilesTotal);
String timeRemaining = toTimeString(remining, tilesDone, tilesTotal);
String bgColor = ++row % 2 == 0 ? "#FFFFFF" : "#DDDDDD";
doc.append("<tr style=\"background-color:" + bgColor + ";\">");
doc.append("<td style=\"text-align:right\">").append(task.getTaskId()).append("</td>");
doc.append("<td>");
if (!layerName.equals(task.getLayerName())) {
doc.append("<a href=\"./").append(task.getLayerName()).append("\">");
}
doc.append(task.getLayerName());
if (!layerName.equals(task.getLayerName())) {
doc.append("</a>");
}
doc.append("</td>");
doc.append("<td>").append(status).append("</td>");
doc.append("<td>").append(task.getType()).append("</td>");
doc.append("<td>").append(tilesTotalStr).append("</td>");
doc.append("<td>").append(tilesDoneStr).append("</td>");
doc.append("<td>").append(timeSpent).append("</td>");
doc.append("<td>").append(timeRemaining).append("</td>");
doc.append("<td>(Task ").append(task.getThreadOffset() + 1).append(" of ")
.append(task.getThreadCount()).append(") </td>");
doc.append("<td>").append(makeThreadKillForm(task.getTaskId(), tl)).append("</td>");
doc.append("<tr>");
}
if (tasks) {
doc.append("</table>");