001: /*
002: ItsNat Java Web Application Framework
003: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004: Author: Jose Maria Arranz Santamaria
005:
006: This program is free software: you can redistribute it and/or modify
007: it under the terms of the GNU Affero General Public License as published by
008: the Free Software Foundation, either version 3 of the License, or
009: (at your option) any later version. See the GNU Affero General Public
010: License for more details. See the copy of the GNU Affero General Public License
011: included in this program. If not, see <http://www.gnu.org/licenses/>.
012: */
013:
014: package org.itsnat.impl.comp.html;
015:
016: import org.itsnat.comp.html.ItsNatHTMLComponentManager;
017: import org.itsnat.comp.html.ItsNatHTMLTable;
018: import org.itsnat.comp.html.ItsNatHTMLTableHeader;
019: import org.itsnat.comp.html.ui.ItsNatHTMLElementComponentUI;
020: import org.itsnat.comp.html.ui.ItsNatHTMLTableHeaderUI;
021: import org.itsnat.comp.ui.ItsNatComponentUI;
022: import org.itsnat.core.html.ItsNatHTMLDocument;
023: import org.itsnat.core.domutil.ItsNatTreeWalker;
024: import org.itsnat.impl.comp.ItsNatTableHeaderImpl;
025: import org.itsnat.impl.comp.html.ui.ItsNatHTMLTableHeaderUIImpl;
026: import org.itsnat.impl.core.html.ItsNatHTMLDocumentImpl;
027: import org.itsnat.impl.core.http.ItsNatImpl;
028: import org.w3c.dom.Node;
029: import org.w3c.dom.html.HTMLElement;
030: import org.w3c.dom.html.HTMLTableRowElement;
031: import org.w3c.dom.html.HTMLTableSectionElement;
032:
033: /**
034: *
035: * @author jmarranz
036: */
037: public class ItsNatHTMLTableHeaderImpl extends ItsNatTableHeaderImpl
038: implements ItsNatHTMLTableHeader {
039: /** Creates a new instance of ItsNatHTMLTableHeaderImpl */
040: public ItsNatHTMLTableHeaderImpl(ItsNatHTMLTableImpl tableComp,
041: HTMLTableSectionElement headerElem) {
042: super (tableComp, headerElem);
043: }
044:
045: public HTMLTableSectionElement getHTMLTableSectionElement() {
046: return (HTMLTableSectionElement) getElement();
047: }
048:
049: public HTMLTableRowElement getHTMLTableRowElement() {
050: HTMLTableSectionElement tHeadElement = getHTMLTableSectionElement();
051: if (ItsNatImpl.isOldXerces())
052: return (HTMLTableRowElement) ItsNatTreeWalker
053: .getFirstChildElementWithTag(tHeadElement, "TR");
054: else
055: return (HTMLTableRowElement) tHeadElement.getRows().item(0); // Debe existir al menos un <tr>
056: }
057:
058: public ItsNatHTMLTable getItsNatHTMLTable() {
059: return (ItsNatHTMLTable) tableComp;
060: }
061:
062: public ItsNatHTMLTableHeaderUI getItsNatHTMLTableHeaderUI() {
063: return (ItsNatHTMLTableHeaderUI) compUI;
064: }
065:
066: public ItsNatHTMLTableHeaderUI createDefaultItsNatHTMLTableHeaderUI() {
067: return new ItsNatHTMLTableHeaderUIImpl(this );
068: }
069:
070: public ItsNatComponentUI createDefaultItsNatComponentUI() {
071: return createDefaultItsNatHTMLTableHeaderUI();
072: }
073:
074: public Node createDefaultNode() {
075: // Este componente es esclavo del <table> y si el <table> no tiene
076: // <thead> no lo imponemos aquí.
077: return null;
078: }
079:
080: public ItsNatHTMLComponentManagerImpl getItsNatHTMLComponentManagerImpl() {
081: return (ItsNatHTMLComponentManagerImpl) componentMgr;
082: }
083:
084: public ItsNatHTMLComponentManager getItsNatHTMLComponentManager() {
085: return getItsNatHTMLComponentManagerImpl();
086: }
087:
088: public ItsNatHTMLElementComponentUI getItsNatHTMLElementComponentUI() {
089: return (ItsNatHTMLElementComponentUI) compUI;
090: }
091:
092: public ItsNatHTMLDocumentImpl getItsNatHTMLDocumentImpl() {
093: return getItsNatHTMLComponentManagerImpl()
094: .getItsNatHTMLDocumentImpl();
095: }
096:
097: public ItsNatHTMLDocument getItsNatHTMLDocument() {
098: return getItsNatHTMLDocumentImpl();
099: }
100:
101: public HTMLElement getHTMLElement() {
102: return (HTMLElement) getNode();
103: }
104: }
|