01: /*
02: Copyright (c) 2003 eInnovation Inc. All rights reserved
03:
04: This library is free software; you can redistribute it and/or modify it under the terms
05: of the GNU Lesser General Public License as published by the Free Software Foundation;
06: either version 2.1 of the License, or (at your option) any later version.
07:
08: This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
09: without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: See the GNU Lesser General Public License for more details.
11: */
12:
13: package com.openedit.webui.list;
14:
15: import org.dom4j.DocumentFactory;
16: import org.dom4j.Element;
17: import org.dom4j.QName;
18:
19: /**
20: * This renderer renders <code>{@link DefaultWebListNode}</code>s.
21: *
22: * @author Eric Galluzzo
23: */
24: public class DefaultWebListCellRenderer implements WebListCellRenderer {
25: public static final QName NODE_QNAME = new QName("node",
26: WebList.WEB_LIST_NAMESPACE);
27: public static final QName NAME_QNAME = new QName("name",
28: WebList.WEB_LIST_NAMESPACE);
29:
30: /**
31: * Constructor for DefaultWebListCellRenderer.
32: */
33: public DefaultWebListCellRenderer() {
34: super ();
35: }
36:
37: /* (non-Javadoc)
38: * @see WebListCellRenderer#getListCellElement(WebList, Object, DocumentFactory)
39: */
40: public Element getListCellElement(WebList inList, Object inValue,
41: DocumentFactory inFactory) {
42: Element elem = inFactory.createElement(NODE_QNAME);
43: DefaultWebListNode node = (DefaultWebListNode) inValue;
44:
45: Element nameElem = inFactory.createElement(NAME_QNAME);
46: nameElem.setText(node.getName());
47: elem.add(nameElem);
48:
49: if (node.getURL() != null) {
50: elem.addAttribute("url", node.getURL());
51: }
52:
53: if (node.getIconURL() != null) {
54: elem.addAttribute("icon-url", node.getIconURL());
55: }
56:
57: return elem;
58: }
59: }
|