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 Marche Mikael
20: *
21: * Contact: mikael.marche@rd.francetelecom.com
22: */
23:
24: package salomeTMF_plug.requirements.ihm;
25:
26: import java.awt.Color;
27: import java.awt.Component;
28:
29: import javax.swing.DefaultListCellRenderer;
30: import javax.swing.ImageIcon;
31: import javax.swing.JList;
32:
33: import salomeTMF_plug.requirements.data.ReqFilter;
34: import salomeTMF_plug.requirements.data.ReqLeaf;
35:
36: public class PriorityListCellRenderer extends DefaultListCellRenderer {
37: static ImageIcon ReqLeafIncon;
38: static {
39: java.net.URL imgURL = RequirementTree.class
40: .getResource("/salomeTMF_plug/requirements/resources/images/req.png");
41: if (imgURL != null) {
42: ReqLeafIncon = new ImageIcon(imgURL);
43: } else {
44: ReqLeafIncon = null;
45: }
46: }
47:
48: public Component getListCellRendererComponent(JList list,
49: Object value, int index, boolean isSelected,
50: boolean cellHasFocus) {
51: super .getListCellRendererComponent(list, value, index,
52: isSelected, cellHasFocus);
53:
54: if (value instanceof ReqLeaf) {
55: ReqLeaf pReqLeaf = (ReqLeaf) value;
56: if (ReqLeafIncon != null) {
57: setIcon(ReqLeafIncon);
58: }
59: setText(pReqLeaf.getLongName());
60: if (pReqLeaf.getPriorityFromModel() == ReqFilter.P_HIGHT) {
61: setForeground(Color.red);
62: } else if (pReqLeaf.getPriorityFromModel() == ReqFilter.P_MEDIUM) {
63: setForeground(Color.blue);
64: } else {
65: setForeground(Color.gray);
66: }
67: }
68: return this;
69: }
70: }
|