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.ItsNatList;
017: import org.itsnat.comp.ItsNatListCellRenderer;
018: import org.itsnat.comp.ui.ItsNatListCellUI;
019: import org.itsnat.comp.ui.ItsNatListUI;
020: import org.itsnat.impl.comp.ItsNatElementComponentImpl;
021: import org.itsnat.impl.core.domutil.ListElementInfoMasterImpl;
022: import org.w3c.dom.Element;
023: import org.w3c.dom.Node;
024:
025: /**
026: *
027: * @author jmarranz
028: */
029: public abstract class ItsNatListUIImpl extends ItsNatListBasedUIImpl
030: implements ItsNatListUI {
031:
032: /**
033: * Creates a new instance of ItsNatListUIImpl
034: */
035: public ItsNatListUIImpl(ItsNatElementComponentImpl parentComp) {
036: super (parentComp);
037: }
038:
039: public ItsNatList getItsNatList() {
040: return (ItsNatList) parentComp;
041: }
042:
043: public ItsNatListCellRenderer getItsNatListCellRenderer() {
044: return getItsNatList().getItsNatListCellRenderer();
045: }
046:
047: public void setElementValueAt(int index, Object anObject,
048: boolean isSelected, boolean cellHasFocus,
049: Element optionElem, boolean isNew) {
050: Element contentElem = getContentElementAt(index, optionElem);
051: elementList.prepareRendering(contentElem, isNew);
052:
053: ItsNatListCellRenderer renderer = getItsNatListCellRenderer();
054: if (renderer != null)
055: renderer.renderListCell(getItsNatList(), index, anObject,
056: isSelected, cellHasFocus, contentElem, isNew);
057: }
058:
059: public ItsNatListBasedCellUIImpl createItsNatListCellUI(
060: ListElementInfoMasterImpl elementInfo) {
061: return new ItsNatListCellUIImpl(elementInfo, this );
062: }
063:
064: public ItsNatListCellUI getItsNatListCellUIAt(int index) {
065: return (ItsNatListCellUI) getItsNatListBasedCellUIAt(index);
066: }
067:
068: public ItsNatListCellUI getItsNatListCellUIFromNode(Node node) {
069: return (ItsNatListCellUI) getItsNatListBasedCellUIFromNode(node);
070: }
071:
072: public Element getContentElementAt(int index) {
073: return super .getContentElementAtBase(index);
074: }
075:
076: public void setElementValueAt(int index, Object anObject,
077: boolean isSelected, boolean cellHasFocus) {
078: super .setElementValueAtBase(index, anObject, isSelected,
079: cellHasFocus);
080: }
081:
082: public boolean isEmpty() {
083: return super .isEmptyBase();
084: }
085:
086: public int getLength() {
087: return super .getLengthBase();
088: }
089:
090: public void setLength(int len) {
091: super .setLengthBase(len);
092: }
093:
094: public Element getElementAt(int index) {
095: return super .getElementAtBase(index);
096: }
097:
098: public Element insertElementAt(int index, Object anObject) {
099: return super .insertElementAtBase(index, anObject);
100: }
101:
102: public void unrenderList(int index) {
103: ItsNatListCellRenderer renderer = getItsNatListCellRenderer();
104: if (renderer == null)
105: return;
106:
107: Element optionElem = getElementAt(index);
108: if (optionElem == null)
109: return;
110:
111: Element contentElem = getContentElementAt(index, optionElem);
112: renderer.unrenderListCell(getItsNatList(), index, contentElem);
113: }
114:
115: public Element removeElementAt(int index) {
116: unrenderList(index);
117:
118: return super .removeElementAtBase(index);
119: }
120:
121: public void removeElementRange(int fromIndex, int toIndex) {
122: ItsNatListCellRenderer renderer = getItsNatListCellRenderer();
123: if (renderer != null) {
124: for (int i = fromIndex; i <= toIndex; i++)
125: unrenderList(i);
126: }
127:
128: super .removeElementRangeBase(fromIndex, toIndex);
129: }
130:
131: public void removeAllElements() {
132: ItsNatListCellRenderer renderer = getItsNatListCellRenderer();
133: if (renderer != null) {
134: int len = getLength();
135: for (int i = 0; i < len; i++)
136: unrenderList(i);
137: }
138:
139: super .removeAllElementsBase();
140: }
141:
142: public boolean isUsePatternMarkupToRender() {
143: return super .isUsePatternMarkupToRenderBase();
144: }
145:
146: public void setUsePatternMarkupToRender(boolean value) {
147: super.setUsePatternMarkupToRenderBase(value);
148: }
149: }
|