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.admin.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).getNameFromModel().equals(ADMINNAME)) {
102:
103: icon = Tools.createAppletImageIcon(PATH_TO_ADMIN_GRP_ICON,
104: "");
105:
106: setIcon(icon);
107:
108: setText(((Group) value).getNameFromModel());
109:
110: } else if (value instanceof Group
111: && (((Group) value).getNameFromModel()
112: .equals(GUESTNAME) || ((Group) value)
113: .getNameFromModel().equals(DEVNAME))) {
114:
115: icon = Tools.createAppletImageIcon(
116: PATH_TO_DEFAULT_GRP_ICON, "");
117:
118: setIcon(icon);
119:
120: setText(((Group) value).getNameFromModel());
121:
122: } else if (value instanceof Group) {
123:
124: icon = Tools.createAppletImageIcon(PATH_TO_OTHER_GRP_ICON,
125: "");
126:
127: setIcon(icon);
128:
129: setText(((Group) value).getNameFromModel());
130:
131: } else {
132:
133: setIcon(null);
134:
135: setText((value == null) ? "" : value.toString());
136:
137: }
138:
139: setEnabled(list.isEnabled());
140:
141: setFont(list.getFont());
142:
143: setBorder((cellHasFocus) ? UIManager
144: .getBorder("List.focusCellHighlightBorder")
145: : noFocusBorder);
146:
147: return this ;
148:
149: } // Fin de la m?thode getListCellRendererComponent/5
150:
151: } // Fin de la classe GroupListRenderer
|