X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Foutput%2FDataTable.java;h=771a0c2a82a9f06aace35d0d1820d61a51d491da;hp=c9ba47b89082eda87f9606b5e9dd8652f9704b13;hb=472e110e96de8f2b71766f793d1f498eb87c2cdf;hpb=89fed14fafeb0af07b09c183bf934e1234d21e48 diff --git a/src/org/cacert/gigi/output/DataTable.java b/src/org/cacert/gigi/output/DataTable.java index c9ba47b8..771a0c2a 100644 --- a/src/org/cacert/gigi/output/DataTable.java +++ b/src/org/cacert/gigi/output/DataTable.java @@ -6,29 +6,32 @@ 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(""); + 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++) { + out.println("
"); - out.print(column.shouldTranslate() ? l.getTranslation(column - .getText()) : column.getText()); - out.println("
"); + int cellsRendered = 0; + for (int i = 0; i < mesCells / columnCount; i++) { out.println(""); - for (int j = 0; j < getColumns().length; j++) { - Cell current = tableContnet.get((i * getColumns().length) + j); - out.println(""); @@ -38,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() { @@ -70,6 +77,10 @@ public abstract class DataTable implements Outputable { return text; } + public int getColSpan() { + return colSpan; + } + public String getHtmlAttribs() { return htmlAttribs; }