X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fcacert%2Fgigi%2Foutput%2FDataTable.java;h=771a0c2a82a9f06aace35d0d1820d61a51d491da;hb=472e110e96de8f2b71766f793d1f498eb87c2cdf;hp=47f1fc974c1d4bf769d9d2caca7357f4ee795ff7;hpb=593548a6309299e63fa56f54d97b569d9d704150;p=gigi.git diff --git a/src/org/cacert/gigi/output/DataTable.java b/src/org/cacert/gigi/output/DataTable.java index 47f1fc97..771a0c2a 100644 --- a/src/org/cacert/gigi/output/DataTable.java +++ b/src/org/cacert/gigi/output/DataTable.java @@ -6,21 +6,32 @@ import java.util.Map; import org.cacert.gigi.Language; -public abstract class DataTable implements Outputable { - protected abstract int getColoumnCount(); +public class DataTable implements Outputable { + private LinkedList cells; + private int columnCount; - protected abstract LinkedList getTableContent(); + public DataTable(int coloumnCount, LinkedList content) { + this.columnCount = coloumnCount; + this.cells = content; + } @Override public void output(PrintWriter out, Language l, Map vars) { + int mesCells = cells.size(); + for (Cell c : cells) { + if (c.getColSpan() > 1) { + mesCells += c.getColSpan(); + } + } out.println(""); - LinkedList tableContnet = getTableContent(); - for (int i = 0; i < tableContnet.size() / getColoumnCount(); i++) { + int cellsRendered = 0; + for (int i = 0; i < mesCells / columnCount; i++) { out.println(""); - for (int j = 0; j < getColoumnCount(); j++) { - Cell current = tableContnet.get((i * getColoumnCount()) + j); - out.println(""); @@ -30,28 +41,32 @@ public abstract class DataTable implements Outputable { out.println("
"); + for (int j = 0; j < columnCount;) { + Cell current = cells.get(cellsRendered); + cellsRendered++; + j += current.getColSpan(); + out.println(""); out.print(current.shouldTranslate() ? l.getTranslation(current .getText()) : current.getText()); out.print("
"); } - /** - * Note: All cells have the html attribute class="DataTD"! - * - * @author janis - * - */ public static class Cell { private String text, htmlAttribs; private boolean translate; + private int colSpan; public Cell() { this(" ", false); } - public Cell(String text, boolean translate, String htmlAttribs) { + public Cell(String text, boolean translate, int colSpan, + String htmlAttribs) { this.text = text; this.translate = translate; this.htmlAttribs = htmlAttribs; + if (colSpan > 1) { + this.htmlAttribs += " colspan=\"" + colSpan + "\""; + } + this.colSpan = colSpan; } public Cell(String text, boolean translate) { - this(text, translate, ""); + this(text, translate, 1, "class=\"DataTD\""); + } + + public Cell(String text, boolean translate, int colSpan) { + this(text, translate, colSpan, "class=\"DataTD\""); } public boolean shouldTranslate() { @@ -62,6 +77,10 @@ public abstract class DataTable implements Outputable { return text; } + public int getColSpan() { + return colSpan; + } + public String getHtmlAttribs() { return htmlAttribs; }