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.comp;
015:
016: import org.w3c.dom.Element;
017:
018: /**
019: * Used by table components to locate the required elements of the table layout.
020: *
021: * <p>Default implementation respects the normal layout of HTML <table> structures,
022: * if no HTML table is involved (free table) then is expected a similar layout than in an HTML table.</p>
023: *
024: * @author Jose Maria Arranz Santamaria
025: * @see ItsNatComponentManager#createDefaultItsNatTableStructure()
026: * @see ItsNatTable#getItsNatTableStructure()
027: * @see org.itsnat.core.domutil.ElementTableStructure
028: */
029: public interface ItsNatTableStructure {
030: /**
031: * Returns the table head element.
032: *
033: * <p>Default implementation returns (if exists) the <thead> element if the
034: * table element is a <table>, else (free table) returns the first child
035: * element if the table contains more than one child element, else returns null (no head).
036: * </p>
037: *
038: * @param table the table component, may be used to provide contextual information. Default implementation ignores it.
039: * @param tableElem the parent element of the table.
040: * Is a hint, if provided should be obtained by calling <code>table.getElement()</code>.
041: * @return the head element. May be null.
042: */
043: public Element getHeadElement(ItsNatTable table, Element tableElem);
044:
045: /**
046: * Returns the table body element.
047: *
048: * <p>Default implementation returns (if exists) the first <tbody> element if the
049: * table element is a <table>, else (free table) returns the second child
050: * element if the table contains more than one child element, else
051: * returns the table element (the one child element is considered a row pattern). Never is null.
052: * </p>
053: *
054: * @param table the table component, may be used to provide contextual information. Default implementation ignores it.
055: * @param tableElem the parent element of the table.
056: * Is a hint, if provided should be obtained by calling <code>table.getElement()</code>.
057: * @return the body element.
058: */
059: public Element getBodyElement(ItsNatTable table, Element tableElem);
060:
061: /**
062: * Returns the content element of a table header column. This element is used to render
063: * header column.
064: *
065: * <p>Default implementation delegates to the default {@link org.itsnat.core.domutil.ElementListStructure}.</p>
066: *
067: * @param tableHeader the table header component, may be used to provide contextual information. Default implementation ignores it.
068: * @param column the column index.
069: * @param itemElem the element containing the column markup in this position.
070: * Is a hint, if provided should be obtained by calling <code>tableHeader.getItsNatTableHeaderUI().getColumnElementAt(index)</code>.
071: * @return the content element.
072: * @see ItsNatTableHeaderCellRenderer
073: */
074: public Element getHeaderColumnContentElement(
075: ItsNatTableHeader tableHeader, int column, Element itemElem);
076:
077: /**
078: * Returns the content element of a table row. This element is used as the parent
079: * of table cell elements.
080: *
081: * <p>Default implementation delegates to the default {@link org.itsnat.core.domutil.ElementTableStructure}.</p>
082: *
083: * @param table the table component, may be used to provide contextual information. Default implementation ignores it.
084: * @param row index of the row.
085: * @param rowElem the element containing the row (row element).
086: * This element is a hint, if provided, should be the same as returned by <code>table.getItsNatTableUI().getRowElementAt(row)</code>.
087: * @return the row content element.
088: */
089: public Element getRowContentElement(ItsNatTable table, int row,
090: Element rowElem);
091:
092: /**
093: * Returns the content element of a table cell. This element is used to render
094: * the cell value.
095: *
096: * <p>Default implementation delegates to the default {@link org.itsnat.core.domutil.ElementTableStructure}.</p>
097: *
098: * @param table the table component, may be used to provide contextual information. Default implementation ignores it.
099: * @param row index of the row.
100: * @param col index of the column.
101: * @param cellElem the element containing the cell (cell element).
102: * This element is a hint, if provided, should be the same as returned by <code>table.getItsNatTableUI().getCellElementAt(row,col)</code>.
103: * @return the cell content element.
104: * @see ItsNatTableCellRenderer
105: */
106: public Element getCellContentElement(ItsNatTable table, int row,
107: int col, Element cellElem);
108: }
|