001: /*
002: * SalomeTMF is a Test Management Framework
003: * Copyright (C) 2005 France Telecom R&D
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * @author Mikael MARCHE, Fayçal SOUGRATI, Vincent PAUTRET
020: *
021: * Contact: mikael.marche@rd.francetelecom.com
022: */
023:
024: package org.objectweb.salome_tmf.ihm.models;
025:
026: import java.awt.Component;
027:
028: import javax.swing.DefaultListCellRenderer;
029: import javax.swing.Icon;
030: import javax.swing.JList;
031: import javax.swing.UIManager;
032:
033: import org.objectweb.salome_tmf.api.ApiConstants;
034: import org.objectweb.salome_tmf.data.Group;
035: import org.objectweb.salome_tmf.ihm.IHMConstants;
036: import org.objectweb.salome_tmf.ihm.tools.Tools;
037:
038: /**
039:
040: * Classe qui d?finit le renderer pour les listes de groupes
041:
042: * @author teaml039
043:
044: * @version : 0.1
045:
046: */
047:
048: public class GroupListRenderer extends DefaultListCellRenderer
049: implements ApiConstants, IHMConstants {
050:
051: /**
052:
053: * S?parateur de fichier
054:
055: */
056:
057: //private final String fileSeparator = "/" ;
058:
059: /**
060:
061: * M?thode qui red?finit le renderer des ?l?ments de la liste
062:
063: * @param list la liste concern?e
064:
065: * @param value l'objet dans la liste
066:
067: * @param index indice de l'objet trait?
068:
069: * @param iseSelected s'il est s?lectionn? ou non
070:
071: * @param cellHasFocus s'il a le focus
072:
073: */
074:
075: public Component getListCellRendererComponent(JList list,
076: Object value, int index,
077:
078: boolean isSelected,
079:
080: boolean cellHasFocus) {
081:
082: if (isSelected) {
083:
084: setBackground(list.getSelectionBackground());
085:
086: setForeground(list.getSelectionForeground());
087:
088: }
089:
090: else {
091:
092: setBackground(list.getBackground());
093:
094: setForeground(list.getForeground());
095:
096: }
097:
098: Icon icon;
099:
100: if (value instanceof Group
101: && ((Group) value).getName().equals(ADMINNAME)) {
102:
103: icon = Tools.createAppletImageIcon(PATH_TO_ADMIN_GRP_ICON,
104: "");
105:
106: setIcon(icon);
107:
108: setText(((Group) value).getName());
109:
110: } else if (value instanceof Group
111: && (((Group) value).getName().equals(GUESTNAME) || ((Group) value)
112: .getName().equals(DEVNAME))) {
113:
114: icon = Tools.createAppletImageIcon(
115: PATH_TO_DEFAULT_GRP_ICON, "");
116:
117: setIcon(icon);
118:
119: setText(((Group) value).getName());
120:
121: } else if (value instanceof Group) {
122:
123: icon = Tools.createAppletImageIcon(PATH_TO_OTHER_GRP_ICON,
124: "");
125:
126: setIcon(icon);
127:
128: setText(((Group) value).getName());
129:
130: } else {
131:
132: setIcon(null);
133:
134: setText((value == null) ? "" : value.toString());
135:
136: }
137:
138: setEnabled(list.isEnabled());
139:
140: setFont(list.getFont());
141:
142: setBorder((cellHasFocus) ? UIManager
143: .getBorder("List.focusCellHighlightBorder")
144: : noFocusBorder);
145:
146: return this ;
147:
148: } // Fin de la m?thode getListCellRendererComponent/5
149:
150: } // Fin de la classe GroupListRenderer
|