01: /*
02: * SalomeTMF is a Test Management Framework
03: * Copyright (C) 2005 France Telecom R&D
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 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: * @author Mikael MARCHE, Fayçal SOUGRATI, Vincent PAUTRET
20: *
21: * Contact: mikael.marche@rd.francetelecom.com
22: */
23:
24: package org.objectweb.salome_tmf.ihm.admin.models;
25:
26: import java.awt.Component;
27:
28: import javax.swing.DefaultListCellRenderer;
29: import javax.swing.Icon;
30: import javax.swing.JList;
31: import javax.swing.ListCellRenderer;
32: import javax.swing.UIManager;
33:
34: import org.objectweb.salome_tmf.api.ApiConstants;
35: import org.objectweb.salome_tmf.api.Util;
36: import org.objectweb.salome_tmf.data.AdminProjectData;
37: import org.objectweb.salome_tmf.data.User;
38: import org.objectweb.salome_tmf.ihm.IHMConstants;
39: import org.objectweb.salome_tmf.ihm.tools.Tools;
40:
41: /**
42: * Classe qui d?finit le renderer pour les listes d'utilisateurs
43: */
44: public class UserListRenderer extends DefaultListCellRenderer implements
45: ListCellRenderer, ApiConstants, IHMConstants {
46:
47: /**
48: * Le s?parateur de fichier
49: */
50: /**
51: * M?thode qui red?finit le renderer des ?l?ments de la liste
52: * @param list la liste concern?e
53: * @param value l'objet dans la liste
54: * @param index indice dans la liste
55: * @param isSelected si l'objet est s?lectionn?
56: * @param cellHasFocus si le focus est sur la cellule
57: */
58: public Component getListCellRendererComponent(JList list,
59: Object value, int index, boolean isSelected,
60: boolean cellHasFocus) {
61: if (isSelected) {
62: setBackground(list.getSelectionBackground());
63: setForeground(list.getSelectionForeground());
64: } else {
65: setBackground(list.getBackground());
66: setForeground(list.getForeground());
67: }
68: Icon icon;
69: if (value instanceof User) {
70: icon = Tools.createAppletImageIcon(PATH_TO_ADMIN_ICON, "");
71: setIcon(icon);
72: setText(((User) value).getLoginFromModel() + " / "
73: + ((User) value).getLastNameFromModel() + " "
74: + ((User) value).getFirstNameFromModel());
75: } else if (value instanceof Icon) {
76: setIcon((Icon) value);
77: setText("");
78: } else {
79: setIcon(null);
80: setText((value == null) ? "" : value.toString());
81: }
82:
83: setEnabled(list.isEnabled());
84: setFont(list.getFont());
85: setBorder((cellHasFocus) ? UIManager
86: .getBorder("List.focusCellHighlightBorder")
87: : noFocusBorder);
88:
89: return this ;
90:
91: } // Fin de la m?thode getListCellRendererComponent/5
92: } // Fin de la classe UserListRenderer
|