01: /*
02: * Lucane - a collaborative platform
03: * Copyright (C) 2005 Vincent Fiack <vfiack@mail15.com>
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
19: package org.lucane.client.acl;
20:
21: import java.awt.Component;
22:
23: import javax.swing.DefaultListCellRenderer;
24: import javax.swing.ImageIcon;
25: import javax.swing.JLabel;
26: import javax.swing.JList;
27:
28: import org.lucane.common.acl.AclInfo;
29: import org.lucane.common.concepts.Concept;
30: import org.lucane.common.concepts.GroupConcept;
31: import org.lucane.common.concepts.UserConcept;
32: import org.lucane.client.Client;
33:
34: public class AclRenderer extends DefaultListCellRenderer {
35: private ImageIcon userIcon;
36: private ImageIcon groupIcon;
37:
38: public AclRenderer() {
39: this .userIcon = Client.getImageIcon("user.png");
40: this .groupIcon = Client.getImageIcon("group.png");
41: }
42:
43: public Component getListCellRendererComponent(JList list,
44: Object value, int index, boolean isSelected,
45: boolean cellHasFocus) {
46: Component c = super .getListCellRendererComponent(list, value,
47: index, isSelected, cellHasFocus);
48: JLabel label = (JLabel) c;
49: Concept concept = (Concept) value;
50:
51: if (concept instanceof GroupConcept)
52: label.setIcon(groupIcon);
53: else if (concept instanceof UserConcept)
54: label.setIcon(userIcon);
55:
56: label.setText(concept.getName());
57:
58: return label;
59: }
60: }
|