]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/output/DataTable.java
Another calc fix
[gigi.git] / src / org / cacert / gigi / output / DataTable.java
index 60893b0446ef0875453168059abbc0a4881c527e..e17714c8ab02569edda2d31af6fc1e2f729554c7 100644 (file)
@@ -15,22 +15,21 @@ public class DataTable implements Outputable {
                this.cells = content;
        }
 
-       @Override
-       public void output(PrintWriter out, Language l, Map<String, Object> vars) {
-               int mesCells = cells.size();
+       public void output(PrintWriter out, Language l) {
+               float mesCells = cells.size();
                for (Cell c : cells) {
                        if (c.getColSpan() > 1) {
                                mesCells += c.getColSpan();
                        }
                }
                out.println("<table align=\"center\" valign=\"middle\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"wrapper\">");
-               for (int i = 0; i < mesCells / columnCount; i++) {
+               int cellsRendered = 0;
+               for (int i = 0; i < Math.ceil(mesCells / columnCount) - 1; i++) {
                        out.println("<tr>");
                        for (int j = 0; j < columnCount;) {
-                               Cell current = cells.get((i * columnCount) + j);
+                               Cell current = cells.get(cellsRendered++);
                                j += current.getColSpan();
-                               out.println("<td " + current.getHtmlAttribs()
-                                               + " class=\"DataTD\">");
+                               out.println("<td " + current.getHtmlAttribs() + " >");
                                out.print(current.shouldTranslate() ? l.getTranslation(current
                                                .getText()) : current.getText());
                                out.print("</td>");
@@ -40,12 +39,6 @@ public class DataTable implements Outputable {
                out.println("</table>");
        }
 
-       /**
-        * <b>Note:</b> All cells have the html attribute class="DataTD"!
-        * 
-        * @author janis
-        * 
-        */
        public static class Cell {
                private String text, htmlAttribs;
                private boolean translate;
@@ -60,15 +53,18 @@ public class DataTable implements Outputable {
                        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, "");
+                       this(text, translate, 1, "class=\"DataTD\"");
                }
 
                public Cell(String text, boolean translate, int colSpan) {
-                       this(text, translate, colSpan, "");
+                       this(text, translate, colSpan, "class=\"DataTD\"");
                }
 
                public boolean shouldTranslate() {
@@ -89,4 +85,9 @@ public class DataTable implements Outputable {
 
        }
 
+       @Override
+       public void output(PrintWriter out, Language l, Map<String, Object> vars) {
+               output(out, l);
+       }
+
 }