01: /*
02: * Copyright Javelin Software, All rights reserved.
03: */
04:
05: package com.javelin.swinglets.plaf.wml;
06:
07: import java.awt.*;
08: import java.util.*;
09: import java.io.*;
10:
11: import com.javelin.swinglets.*;
12: import com.javelin.swinglets.table.*;
13: import com.javelin.swinglets.plaf.*;
14:
15: /**
16: * WMLTableHeaderUI defines a look and feel for default WML.
17: *
18: * @author Robin Sharp
19: */
20:
21: public class WMLTableHeaderUI extends WMLComponentUI {
22:
23: /**
24: * Render the UI on the PrintWriter
25: */
26: public void update(PrintWriter out, SComponent c) {
27: if (!c.isVisible())
28: return;
29:
30: STableHeader tableHeader = (STableHeader) c;
31: STable table = tableHeader.getTable();
32:
33: if (!tableHeader.isVisible())
34: return;
35:
36: out.println("<tr>");
37:
38: STableCellRenderer headerCellRenderer = tableHeader
39: .getTableHeaderRenderer();
40: SComponent component = null;
41:
42: for (int column = 0; column < table.getColumnCount(); column++) {
43: String columnName = table.getModel().getColumnName(column);
44:
45: out.print("<td");
46:
47: //Load the component to render the header
48: if (headerCellRenderer != null) {
49: component = headerCellRenderer
50: .getTableCellRendererComponent(table,
51: columnName, -1, column);
52: }
53:
54: //PAINT THE HEADER CELL AS A COMPONENT OR TEXT
55: if (component != null) {
56: //Change the look and feel to that of the table.
57: component.setLookAndFeel(table.getLookAndFeel());
58:
59: out.print(">");
60: component.paint(out);
61: out.println("</td>");
62: } else {
63: out.print(">");
64: out.print(columnName);
65: out.println("</td>");
66: }
67:
68: }
69: out.println("</tr>");
70:
71: }
72:
73: }
|