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.modules.admin.users;
14:
15: import org.dom4j.DocumentFactory;
16: import org.dom4j.Element;
17: import org.dom4j.Namespace;
18: import org.dom4j.QName;
19:
20: import com.openedit.users.User;
21: import com.openedit.webui.list.WebList;
22: import com.openedit.webui.list.WebListCellRenderer;
23:
24: /**
25: * This renderer renders <code>{@link User}</code>s.
26: *
27: * @author Eric Galluzzo
28: */
29: public class UserListCellRenderer implements WebListCellRenderer {
30: public static final Namespace USER_NAMESPACE = DocumentFactory
31: .getInstance().createNamespace("user",
32: "http://www.wspublisher.com/xmlns/User");
33: public static final QName USER_QNAME = DocumentFactory
34: .getInstance().createQName("user", USER_NAMESPACE);
35: public static final QName USER_NAME_QNAME = DocumentFactory
36: .getInstance().createQName("userName", USER_NAMESPACE);
37:
38: /**
39: * Constructor for UserListCellRenderer.
40: */
41: public UserListCellRenderer() {
42: super ();
43: }
44:
45: /* (non-Javadoc)
46: * @see WebListCellRenderer#getListCellElement(WebList, Object, DocumentFactory)
47: */
48: public Element getListCellElement(WebList inList, Object inValue,
49: DocumentFactory inFactory) {
50: Element elem = inFactory.createElement(USER_QNAME);
51: User user = (User) inValue;
52: Element userNameElem = DocumentFactory.getInstance()
53: .createElement(USER_NAME_QNAME);
54: userNameElem.setText(user.getUserName());
55: elem.add(userNameElem);
56:
57: return elem;
58: }
59: }
|