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.free;
015:
016: import org.itsnat.comp.ItsNatListCellRenderer;
017: import org.itsnat.comp.free.ItsNatFreeList;
018: import org.itsnat.comp.ui.ItsNatListUI;
019: import javax.swing.event.ListDataEvent;
020: import org.itsnat.comp.ItsNatListStructure;
021: import org.itsnat.core.ItsNatException;
022: import org.itsnat.core.event.ParamTransport;
023: import org.itsnat.core.NameValue;
024: import org.itsnat.impl.comp.*;
025: import org.w3c.dom.Element;
026: import org.w3c.dom.Node;
027:
028: /**
029: *
030: * @author jmarranz
031: */
032: public abstract class ItsNatFreeListImpl extends
033: ItsNatFreeElementComponentImpl implements ItsNatFreeList,
034: ItsNatListInternal {
035: protected ItsNatListCellRenderer renderer;
036:
037: /**
038: * Creates a new instance of ItsNatFreeListImpl
039: */
040: public ItsNatFreeListImpl(Element element,
041: ItsNatListStructure structure, NameValue[] artifacts,
042: ItsNatComponentManagerImpl componentMgr) {
043: super (element, artifacts, componentMgr);
044:
045: this .structure = structure; // Si es null se creará después una estructura por defecto
046:
047: setItsNatListCellRenderer(componentMgr
048: .createDefaultItsNatListCellRenderer());
049: }
050:
051: public Class getStructureClass() {
052: return ItsNatListStructure.class;
053: }
054:
055: public ItsNatListStructure getItsNatListStructure() {
056: return (ItsNatListStructure) structure;
057: }
058:
059: public Object createDefaultStructure() {
060: return getItsNatComponentManager()
061: .createDefaultItsNatListStructure();
062: }
063:
064: public void enableEventListeners() {
065: enableEventListener("click");
066: }
067:
068: public void bindDataModel() {
069: ItsNatListSharedImpl.bindDataModel(this );
070: }
071:
072: public void unbindDataModel() {
073: ItsNatListSharedImpl.unbindDataModel(this );
074: }
075:
076: public void syncUIWithDataModel() {
077: ItsNatListSharedImpl.syncUIWithDataModel(this );
078: }
079:
080: public ItsNatListUI getItsNatListUI() {
081: return (ItsNatListUI) compUI;
082: }
083:
084: public int indexOf(Object obj) {
085: return ItsNatListSharedImpl.indexOf(obj, getListModel());
086: }
087:
088: public ItsNatListCellRenderer getItsNatListCellRenderer() {
089: return renderer;
090: }
091:
092: public void setItsNatListCellRenderer(
093: ItsNatListCellRenderer renderer) {
094: this .renderer = renderer;
095: }
096:
097: public void intervalAdded(ListDataEvent e) {
098: ItsNatListSharedImpl.intervalAdded(this , e);
099: }
100:
101: public void intervalRemoved(ListDataEvent e) {
102: ItsNatListSharedImpl.intervalRemoved(this , e);
103: }
104:
105: public void contentsChanged(ListDataEvent e) {
106: ItsNatListSharedImpl.contentsChanged(this , e);
107: }
108:
109: public void insertElementAtInternal(int i, Object item) {
110: ItsNatListUI compUI = getItsNatListUI();
111: compUI.insertElementAt(i, item);
112: }
113:
114: public void removeAllElementsInternal() {
115: ItsNatListUI compUI = getItsNatListUI();
116: compUI.removeAllElements();
117: }
118:
119: public void removeElementRangeInternal(int fromIndex, int toIndex) {
120: ItsNatListUI compUI = getItsNatListUI();
121: compUI.removeElementRange(fromIndex, toIndex);
122: }
123:
124: }
|