01: /*
02: ItsNat Java Web Application Framework
03: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
04: Author: Jose Maria Arranz Santamaria
05:
06: This program is free software: you can redistribute it and/or modify
07: it under the terms of the GNU Affero General Public License as published by
08: the Free Software Foundation, either version 3 of the License, or
09: (at your option) any later version. See the GNU Affero General Public
10: License for more details. See the copy of the GNU Affero General Public License
11: included in this program. If not, see <http://www.gnu.org/licenses/>.
12: */
13:
14: package org.itsnat.impl.comp.html.ui;
15:
16: import org.itsnat.comp.html.ItsNatHTMLElementComponent;
17: import org.itsnat.comp.html.ItsNatHTMLTableHeader;
18: import org.itsnat.comp.html.ui.ItsNatHTMLTableHeaderUI;
19: import org.itsnat.core.ItsNatException;
20: import org.itsnat.core.domutil.ItsNatTreeWalker;
21: import org.itsnat.impl.comp.html.ItsNatHTMLTableHeaderImpl;
22: import org.itsnat.impl.comp.ui.ItsNatTableHeaderUIImpl;
23: import org.itsnat.impl.core.http.ItsNatImpl;
24: import org.w3c.dom.html.HTMLElement;
25: import org.w3c.dom.html.HTMLTableCellElement;
26: import org.w3c.dom.html.HTMLTableRowElement;
27: import org.w3c.dom.html.HTMLTableSectionElement;
28:
29: /**
30: *
31: * @author jmarranz
32: */
33: public class ItsNatHTMLTableHeaderUIImpl extends
34: ItsNatTableHeaderUIImpl implements ItsNatHTMLTableHeaderUI {
35:
36: /**
37: * Creates a new instance of ItsNatHTMLTableHeaderUIImpl
38: */
39: public ItsNatHTMLTableHeaderUIImpl(
40: ItsNatHTMLTableHeaderImpl parentComp) {
41: super (parentComp, getUniqueHTMLTableRowElement(parentComp));
42: }
43:
44: public static HTMLTableRowElement getUniqueHTMLTableRowElement(
45: ItsNatHTMLTableHeaderImpl parentComp) {
46: HTMLTableSectionElement tHeadElement = parentComp
47: .getHTMLTableSectionElement();
48:
49: HTMLTableRowElement rowElement;
50: if (ItsNatImpl.isOldXerces())
51: rowElement = (HTMLTableRowElement) ItsNatTreeWalker
52: .getFirstChildElementWithTag(tHeadElement, "TR");
53: else
54: rowElement = (HTMLTableRowElement) tHeadElement.getRows()
55: .item(0); // Debe existir al menos un <tr>
56: if (rowElement == null)
57: throw new ItsNatException("Header needs almost a row");
58: return rowElement;
59: }
60:
61: public HTMLTableSectionElement getHTMLTableSectionElement() {
62: return getItsNatHTMLTableHeader().getHTMLTableSectionElement();
63: }
64:
65: public HTMLTableRowElement getHTMLTableRowElement() {
66: return getItsNatHTMLTableHeader().getHTMLTableRowElement();
67: }
68:
69: public ItsNatHTMLTableHeader getItsNatHTMLTableHeader() {
70: return (ItsNatHTMLTableHeader) parentComp;
71: }
72:
73: public HTMLTableCellElement getHTMLTableCellElementAt(int column) {
74: return (HTMLTableCellElement) getElementAt(column);
75: }
76:
77: public ItsNatHTMLElementComponent getItsNatHTMLElementComponent() {
78: return (ItsNatHTMLElementComponent) parentComp;
79: }
80:
81: }
|