01: /*
02: * This file is not part of the ItsNat framework.
03: *
04: * Original source code use and closed source derivatives are authorized
05: * to third parties with no restriction or fee.
06: * The original source code is owned by the author.
07: *
08: * This program is distributed AS IS in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: *
12: * Author: Jose Maria Arranz Santamaria
13: * (C) Innowhere Software Services S.L., Spanish company, year 2007
14: */
15:
16: package org.itsnat.feashow.features.components.xmlcomp;
17:
18: import javax.swing.DefaultListModel;
19: import org.itsnat.comp.ItsNatComponentManager;
20: import org.itsnat.comp.ItsNatList;
21: import org.itsnat.comp.ItsNatListCellRenderer;
22: import org.itsnat.comp.free.ItsNatFreeListMultSel;
23: import org.itsnat.core.domutil.ItsNatDOMUtil;
24: import org.itsnat.core.domutil.ItsNatTreeWalker;
25: import org.w3c.dom.Element;
26:
27: public class CDListRenderer implements ItsNatListCellRenderer {
28: public final static CDListRenderer SINGLETON = new CDListRenderer();
29:
30: public CDListRenderer() {
31: }
32:
33: public void renderListCell(ItsNatList list, int index,
34: Object value, boolean isSelected, boolean cellHasFocus,
35: Element cellElem, boolean isNew) {
36: CompactDisc cd = (CompactDisc) value;
37:
38: Element titleElem = ItsNatTreeWalker
39: .getFirstChildElement(cellElem);
40: ItsNatDOMUtil.setTextContent(titleElem, cd.getTitle());
41: Element artistElem = ItsNatTreeWalker
42: .getNextSiblingElement(titleElem);
43: ItsNatDOMUtil.setTextContent(artistElem, cd.getArtist());
44: Element songsElem = ItsNatTreeWalker
45: .getNextSiblingElement(artistElem);
46:
47: ItsNatComponentManager compMgr = list
48: .getItsNatComponentManager();
49: ItsNatFreeListMultSel comp = (ItsNatFreeListMultSel) compMgr
50: .createItsNatComponent(songsElem, "freeListMultSel",
51: null);
52: comp.setItsNatListCellRenderer(SongListRenderer.SINGLETON);
53: DefaultListModel model = (DefaultListModel) comp.getListModel();
54: for (int i = 0; i < cd.getSongCount(); i++)
55: model.addElement(cd.getSong(i));
56: }
57:
58: public void unrenderListCell(ItsNatList list, int index,
59: Element cellContentElem) {
60: }
61: }
|