X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Foutput%2FDataTable.java;h=9794c1f8ec976ece55a0a2e4c4a7f253aaa27595;hp=c9ba47b89082eda87f9606b5e9dd8652f9704b13;hb=da6953ff84576acd584ea678ab7eaa35d00dbbcc;hpb=89fed14fafeb0af07b09c183bf934e1234d21e48 diff --git a/src/org/cacert/gigi/output/DataTable.java b/src/org/cacert/gigi/output/DataTable.java index c9ba47b8..9794c1f8 100644 --- a/src/org/cacert/gigi/output/DataTable.java +++ b/src/org/cacert/gigi/output/DataTable.java @@ -6,29 +6,31 @@ import java.util.Map; import org.cacert.gigi.Language; -public abstract class DataTable implements Outputable { - protected abstract Cell[] getColumns(); +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) { - out.println(""); - out.println(""); - for (Cell column : getColumns()) { - out.print(""); + public void output(PrintWriter out, Language l) { + 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() / getColumns().length; i++) { + System.out.println(mesCells); + out.println("
"); - out.print(column.shouldTranslate() ? l.getTranslation(column - .getText()) : column.getText()); - out.println("
"); + int cellsRendered = 0; + for (int i = 0; i < (mesCells / columnCount) - 1; i++) { out.println(""); - for (int j = 0; j < getColumns().length; j++) { - Cell current = tableContnet.get((i * getColumns().length) + j); - out.println(""); @@ -38,28 +40,32 @@ public abstract class DataTable implements Outputable { out.println("
"); + for (int j = 0; j < columnCount;) { + Cell current = cells.get(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() { @@ -70,10 +76,19 @@ public abstract class DataTable implements Outputable { return text; } + public int getColSpan() { + return colSpan; + } + public String getHtmlAttribs() { return htmlAttribs; } } + @Override + public void output(PrintWriter out, Language l, Map vars) { + output(out, l); + } + }