01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.html;
04:
05: public class HtmlTableListingBuilder {
06: private int shade = 0;
07:
08: private HtmlTag table;
09:
10: public HtmlTableListingBuilder() {
11: makeTable();
12: }
13:
14: public HtmlTag getTable() {
15: return table;
16: }
17:
18: private HtmlTag makeTable() {
19: table = new HtmlTag("table");
20: table.addAttribute("border", "0");
21: table.addAttribute("cellspacing", "0");
22: table.addAttribute("class", "dirListing");
23: return table;
24: }
25:
26: public void addRow(HtmlElement[] rowItems) throws Exception {
27: HtmlTag row = new HtmlTag("tr");
28: addShade(row);
29:
30: HtmlTag cell = null;
31: for (int i = 0; i < rowItems.length; i++) {
32: HtmlElement rowItem = rowItems[i];
33: cell = new HtmlTag("td", rowItem);
34: row.add(cell);
35: }
36: if (cell != null) {
37: cell.addAttribute("style", "text-align: right;");
38: }
39: table.add(row);
40: }
41:
42: private void addShade(HtmlTag row) {
43: if (shade++ % 2 == 0)
44: row.addAttribute("style", "background-color: #EFEFEF;");
45: else
46: row.addAttribute("style", "background-color: #FFFFFF;");
47: }
48: }
|