X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Foutput%2FDataTable.java;h=771a0c2a82a9f06aace35d0d1820d61a51d491da;hp=8c8b06e66d4570f6b88698aa26ee7f54cbf2e2f8;hb=472e110e96de8f2b71766f793d1f498eb87c2cdf;hpb=7ff9efc4b22e9f32a78ed70409064ec887d2fb4d diff --git a/src/org/cacert/gigi/output/DataTable.java b/src/org/cacert/gigi/output/DataTable.java index 8c8b06e6..771a0c2a 100644 --- a/src/org/cacert/gigi/output/DataTable.java +++ b/src/org/cacert/gigi/output/DataTable.java @@ -6,27 +6,32 @@ import java.util.Map; import org.cacert.gigi.Language; -public abstract class DataTable implements Outputable { - protected abstract String[] 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 (String 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(l.getTranslation(column)); - out.println("
"); + int cellsRendered = 0; + for (int i = 0; i < mesCells / columnCount; i++) { out.println(""); - for (int j = 0; j < getColumns().length; j++) { - out.println(""); @@ -37,12 +42,31 @@ public abstract class DataTable implements Outputable { } public static class Cell { - private String text; + private String text, htmlAttribs; private boolean translate; + private int colSpan; - public Cell(String text, boolean translate) { + public Cell() { + this(" ", false); + } + + 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, 1, "class=\"DataTD\""); + } + + public Cell(String text, boolean translate, int colSpan) { + this(text, translate, colSpan, "class=\"DataTD\""); } public boolean shouldTranslate() { @@ -53,12 +77,12 @@ public abstract class DataTable implements Outputable { return text; } - } - - public static class EmptyCell extends Cell { + public int getColSpan() { + return colSpan; + } - public EmptyCell() { - super(" ", false); + public String getHtmlAttribs() { + return htmlAttribs; } }
"); - Cell current = tableContnet.get((i * getColumns().length) + j); + 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("