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.ui;
015:
016: import org.itsnat.comp.ItsNatTable;
017: import org.itsnat.comp.ItsNatTableHeader;
018: import org.itsnat.comp.ItsNatTableHeaderCellRenderer;
019: import org.itsnat.comp.ItsNatTableStructure;
020: import org.itsnat.comp.ui.ItsNatTableHeaderCellUI;
021: import org.itsnat.comp.ui.ItsNatTableHeaderUI;
022: import org.itsnat.impl.comp.ItsNatTableImpl;
023: import org.itsnat.impl.comp.ItsNatTableHeaderImpl;
024: import org.itsnat.impl.core.ItsNatDocumentImpl;
025: import org.itsnat.impl.core.domutil.ListElementInfoMasterImpl;
026: import org.w3c.dom.Element;
027: import org.w3c.dom.Node;
028:
029: /**
030: *
031: * @author jmarranz
032: */
033: public abstract class ItsNatTableHeaderUIImpl extends
034: ItsNatListBasedUIImpl implements ItsNatTableHeaderUI {
035: protected boolean enabled = true;
036:
037: /**
038: * Creates a new instance of ItsNatTableHeaderUIImpl
039: */
040: public ItsNatTableHeaderUIImpl(ItsNatTableHeaderImpl parentComp,
041: Element rowElement) {
042: super (parentComp);
043:
044: ItsNatTableImpl tableComp = (ItsNatTableImpl) parentComp
045: .getItsNatTable();
046: ItsNatTableStructure structure = tableComp
047: .getItsNatTableStructure();
048: ItsNatTableStructureCoreAdapterImpl structAdapter;
049: structAdapter = new ItsNatTableStructureCoreAdapterImpl(
050: structure, null, parentComp);
051:
052: ItsNatDocumentImpl itsNatDoc = getItsNatDocumentImpl();
053: this .elementList = itsNatDoc.createElementListInternal(
054: rowElement, true, structAdapter, null);
055: }
056:
057: public ItsNatTableHeader getItsNatTableHeader() {
058: return (ItsNatTableHeader) parentComp;
059: }
060:
061: public ItsNatTable getItsNatTable() {
062: return getItsNatTableHeader().getItsNatTable();
063: }
064:
065: public ItsNatTableStructure getItsNatTableStructure() {
066: return getItsNatTable().getItsNatTableStructure();
067: }
068:
069: public ItsNatTableHeaderCellRenderer getItsNatTableHeaderCellRenderer() {
070: return getItsNatTableHeader()
071: .getItsNatTableHeaderCellRenderer();
072: }
073:
074: public void setElementValueAt(int column, Object columnValue,
075: boolean isSelected, boolean cellHasFocus, Element element,
076: boolean isNew) {
077: ItsNatTableHeader tableHeader = getItsNatTableHeader();
078: Element contentElem = getContentElementAt(column, element);
079:
080: elementList.prepareRendering(contentElem, isNew);
081:
082: ItsNatTableHeaderCellRenderer renderer = getItsNatTableHeaderCellRenderer();
083: if (renderer != null)
084: renderer.renderTableHeaderCell(tableHeader, column,
085: columnValue, isSelected, cellHasFocus, contentElem,
086: isNew);
087: }
088:
089: public Element getContentElementAt(int index, Element elem) {
090: return getItsNatTableStructure().getHeaderColumnContentElement(
091: getItsNatTableHeader(), index, elem);
092: }
093:
094: public ItsNatListBasedCellUIImpl createItsNatListCellUI(
095: ListElementInfoMasterImpl elementInfo) {
096: return new ItsNatTableHeaderCellUIImpl(elementInfo, this );
097: }
098:
099: public ItsNatTableHeaderCellUI getItsNatTableHeaderCellUIAt(
100: int index) {
101: return (ItsNatTableHeaderCellUI) getItsNatListBasedCellUIAt(index);
102: }
103:
104: public ItsNatTableHeaderCellUI getItsNatTableHeaderCellUIFromNode(
105: Node node) {
106: return (ItsNatTableHeaderCellUI) getItsNatListBasedCellUIFromNode(node);
107: }
108:
109: public Element getContentElementAt(int index) {
110: return super .getContentElementAtBase(index);
111: }
112:
113: public void setElementValueAt(int index, Object anObject,
114: boolean isSelected, boolean cellHasFocus) {
115: super .setElementValueAtBase(index, anObject, isSelected,
116: cellHasFocus);
117: }
118:
119: public boolean isEmpty() {
120: return super .isEmptyBase();
121: }
122:
123: public int getLength() {
124: return super .getLengthBase();
125: }
126:
127: public void setLength(int len) {
128: super .setLengthBase(len);
129: }
130:
131: public Element getElementAt(int index) {
132: return super .getElementAtBase(index);
133: }
134:
135: public Element insertElementAt(int index, Object anObject) {
136: return super .insertElementAtBase(index, anObject);
137: }
138:
139: public void unrenderTableHeaderCell(int column) {
140: ItsNatTableHeaderCellRenderer renderer = getItsNatTableHeaderCellRenderer();
141: if (renderer == null)
142: return;
143:
144: Element cellElem = getElementAt(column);
145: if (cellElem == null)
146: return;
147:
148: Element contentElem = getContentElementAt(column, cellElem);
149: renderer.unrenderTableHeaderCell(getItsNatTableHeader(),
150: column, contentElem);
151: }
152:
153: public Element removeElementAt(int index) {
154: return super .removeElementAtBase(index);
155: }
156:
157: public void removeElementRange(int fromIndex, int toIndex) {
158: ItsNatTableHeaderCellRenderer renderer = getItsNatTableHeaderCellRenderer();
159: if (renderer != null) {
160: for (int i = fromIndex; i <= toIndex; i++)
161: unrenderTableHeaderCell(i);
162: }
163:
164: super .removeElementRangeBase(fromIndex, toIndex);
165: }
166:
167: public void removeAllElements() {
168: ItsNatTableHeaderCellRenderer renderer = getItsNatTableHeaderCellRenderer();
169: if (renderer != null) {
170: int len = getLength();
171: for (int i = 0; i < len; i++)
172: unrenderTableHeaderCell(i);
173: }
174:
175: super .removeAllElementsBase();
176: }
177:
178: public boolean isUsePatternMarkupToRender() {
179: return super .isUsePatternMarkupToRenderBase();
180: }
181:
182: public void setUsePatternMarkupToRender(boolean value) {
183: super .setUsePatternMarkupToRenderBase(value);
184: }
185:
186: public void setEnabled(boolean b) {
187: this .enabled = b;
188: }
189:
190: public boolean isEnabled() {
191: return enabled;
192: }
193: }
|