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.core.ItsNatException;
021: import org.itsnat.impl.comp.ItsNatElementComponentImpl;
022: import org.itsnat.impl.core.domutil.ElementListImpl;
023: import org.itsnat.impl.core.domutil.ListElementInfoMasterImpl;
024: import org.w3c.dom.Element;
025: import org.w3c.dom.Node;
026:
027: /**
028: *
029: * @author jmarranz
030: */
031: public abstract class ItsNatListBasedUIImpl extends
032: ItsNatElementComponentUIImpl {
033: protected ElementListImpl elementList;
034:
035: /**
036: * Creates a new instance of ItsNatListBasedUIImpl
037: */
038: public ItsNatListBasedUIImpl(ItsNatElementComponentImpl parentComp) {
039: super (parentComp);
040: }
041:
042: public void setNewElementValueAt(int index, Object anObject,
043: Element optionElem) {
044: // Está siendo creado el objeto, por tanto no está seleccionado por defecto (y del foco no nos ocupamos: false)
045: setElementValueAt(index, anObject, false, false, optionElem,
046: true);
047: }
048:
049: public abstract Element getContentElementAt(int index);
050:
051: protected Element getContentElementAtBase(int index) {
052: Element optionElem = getElementAt(index);
053: if (optionElem == null)
054: return null;
055: return getContentElementAt(index, optionElem);
056: }
057:
058: public abstract Element getContentElementAt(int index,
059: Element optionElem);
060:
061: public abstract void setElementValueAt(int index, Object anObject,
062: boolean isSelected, boolean cellHasFocus,
063: Element optionElem, boolean isNew);
064:
065: public abstract void setElementValueAt(int index, Object anObject,
066: boolean isSelected, boolean cellHasFocus);
067:
068: protected void setElementValueAtBase(int index, Object anObject,
069: boolean isSelected, boolean cellHasFocus) {
070: Element optionElem = getElementAt(index);
071: if (optionElem == null)
072: throw new ItsNatException("Index out of bounds: " + index);
073: setElementValueAt(index, anObject, isSelected, cellHasFocus,
074: optionElem, false);
075: }
076:
077: public abstract boolean isEmpty();
078:
079: protected boolean isEmptyBase() {
080: return elementList.isEmpty();
081: }
082:
083: public abstract int getLength();
084:
085: protected int getLengthBase() {
086: return elementList.getLength();
087: }
088:
089: public abstract void setLength(int len);
090:
091: protected void setLengthBase(int len) {
092: elementList.setLength(len);
093: }
094:
095: public abstract Element getElementAt(int index);
096:
097: protected Element getElementAtBase(int index) {
098: return elementList.getElementAt(index);
099: }
100:
101: public abstract ItsNatListBasedCellUIImpl createItsNatListCellUI(
102: ListElementInfoMasterImpl elementInfo);
103:
104: public ItsNatListBasedCellUIImpl getItsNatListBasedCellUI(
105: ListElementInfoMasterImpl elementInfo) {
106: if (elementInfo == null)
107: return null;
108:
109: ItsNatListBasedCellUIImpl elementUI = (ItsNatListBasedCellUIImpl) elementInfo
110: .getAuxObject();
111: if (elementUI == null) {
112: elementUI = createItsNatListCellUI(elementInfo);
113: elementInfo.setAuxObject(elementUI);
114: }
115: return elementUI;
116: }
117:
118: public ItsNatListBasedCellUIImpl getItsNatListBasedCellUIAt(
119: int index) {
120: ListElementInfoMasterImpl elemInfo = (ListElementInfoMasterImpl) elementList
121: .getListElementInfoAt(index);
122: return getItsNatListBasedCellUI(elemInfo);
123: }
124:
125: public ItsNatListBasedCellUIImpl getItsNatListBasedCellUIFromNode(
126: Node node) {
127: ListElementInfoMasterImpl elemInfo = (ListElementInfoMasterImpl) elementList
128: .getListElementInfoFromNode(node);
129: return getItsNatListBasedCellUI(elemInfo);
130: }
131:
132: public abstract Element insertElementAt(int index, Object anObject);
133:
134: protected Element insertElementAtBase(int index, Object anObject) {
135: Element newElem = elementList.insertElementAt(index);
136: setNewElementValueAt(index, anObject, newElem);
137: return newElem;
138: }
139:
140: public abstract Element removeElementAt(int index);
141:
142: protected Element removeElementAtBase(int index) {
143: return elementList.removeElementAt(index);
144: }
145:
146: public abstract void removeElementRange(int fromIndex, int toIndex);
147:
148: protected void removeElementRangeBase(int fromIndex, int toIndex) {
149: elementList.removeElementRange(fromIndex, toIndex);
150: }
151:
152: public abstract void removeAllElements();
153:
154: protected void removeAllElementsBase() {
155: elementList.removeAllElements();
156: }
157:
158: public abstract boolean isUsePatternMarkupToRender();
159:
160: protected boolean isUsePatternMarkupToRenderBase() {
161: return elementList.isUsePatternMarkupToRender();
162: }
163:
164: public abstract void setUsePatternMarkupToRender(boolean value);
165:
166: protected void setUsePatternMarkupToRenderBase(boolean value) {
167: elementList.setUsePatternMarkupToRender(value);
168: }
169: }
|