1 package org.cacert.gigi.output;
3 import java.io.PrintWriter;
4 import java.util.LinkedList;
7 import org.cacert.gigi.Language;
9 public class DataTable implements Outputable {
10 private LinkedList<Cell> cells;
11 private int columnCount;
13 public DataTable(int coloumnCount, LinkedList<Cell> content) {
14 this.columnCount = coloumnCount;
18 public void output(PrintWriter out, Language l) {
19 int mesCells = cells.size();
20 for (Cell c : cells) {
21 if (c.getColSpan() > 1) {
22 mesCells += c.getColSpan();
25 out.println("<table align=\"center\" valign=\"middle\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"wrapper\">");
26 int cellsRendered = 0;
27 for (int i = 0; i < mesCells / columnCount; i++) {
29 for (int j = 0; j < columnCount;) {
30 Cell current = cells.get(cellsRendered);
32 j += current.getColSpan();
33 out.println("<td " + current.getHtmlAttribs() + " >");
34 out.print(current.shouldTranslate() ? l.getTranslation(current
35 .getText()) : current.getText());
40 out.println("</table>");
43 public static class Cell {
44 private String text, htmlAttribs;
45 private boolean translate;
49 this(" ", false);
52 public Cell(String text, boolean translate, int colSpan,
55 this.translate = translate;
56 this.htmlAttribs = htmlAttribs;
58 this.htmlAttribs += " colspan=\"" + colSpan + "\"";
60 this.colSpan = colSpan;
63 public Cell(String text, boolean translate) {
64 this(text, translate, 1, "class=\"DataTD\"");
67 public Cell(String text, boolean translate, int colSpan) {
68 this(text, translate, colSpan, "class=\"DataTD\"");
71 public boolean shouldTranslate() {
75 public String getText() {
79 public int getColSpan() {
83 public String getHtmlAttribs() {
90 public void output(PrintWriter out, Language l, Map<String, Object> vars) {