KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > webui > list > DefaultWebListCellRenderer


1 /*
2 Copyright (c) 2003 eInnovation Inc. All rights reserved
3
4 This library is free software; you can redistribute it and/or modify it under the terms
5 of the GNU Lesser General Public License as published by the Free Software Foundation;
6 either version 2.1 of the License, or (at your option) any later version.
7
8 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 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 /**
21  * This renderer renders <code>{@link DefaultWebListNode}</code>s.
22  *
23  * @author Eric Galluzzo
24  */

25 public class DefaultWebListCellRenderer implements WebListCellRenderer
26 {
27     public static final QName NODE_QNAME = new QName("node", WebList.WEB_LIST_NAMESPACE);
28     public static final QName NAME_QNAME = new QName("name", WebList.WEB_LIST_NAMESPACE);
29
30     /**
31      * Constructor for DefaultWebListCellRenderer.
32      */

33     public DefaultWebListCellRenderer()
34     {
35         super();
36     }
37
38     /* (non-Javadoc)
39      * @see WebListCellRenderer#getListCellElement(WebList, Object, DocumentFactory)
40      */

41     public Element getListCellElement(WebList inList, Object JavaDoc inValue, DocumentFactory inFactory)
42     {
43         Element elem = inFactory.createElement(NODE_QNAME);
44         DefaultWebListNode node = (DefaultWebListNode) inValue;
45
46         Element nameElem = inFactory.createElement(NAME_QNAME);
47         nameElem.setText(node.getName());
48         elem.add(nameElem);
49
50         if (node.getURL() != null)
51         {
52             elem.addAttribute("url", node.getURL());
53         }
54
55         if (node.getIconURL() != null)
56         {
57             elem.addAttribute("icon-url", node.getIconURL());
58         }
59
60         return elem;
61     }
62 }
63
Popular Tags