KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > table > plugins > PriorityRenderer


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.mail.gui.table.plugins;
17
18 import java.awt.Component JavaDoc;
19
20 import javax.swing.ImageIcon JavaDoc;
21 import javax.swing.JTable JavaDoc;
22
23 import org.columba.mail.gui.table.model.MessageNode;
24 import org.columba.mail.resourceloader.MailImageLoader;
25 import org.columba.mail.util.MailResourceLoader;
26
27
28 public class PriorityRenderer extends DefaultLabelRenderer {
29     private ImageIcon JavaDoc image1 = MailImageLoader.getSmallIcon(
30             "priority-high.png");
31     private ImageIcon JavaDoc image2 = null;
32     private ImageIcon JavaDoc image3 = null;
33     private ImageIcon JavaDoc image4 = MailImageLoader.getSmallIcon("priority-low.png");
34
35     public PriorityRenderer() {
36         super();
37     }
38
39     public Component JavaDoc getTableCellRendererComponent(JTable JavaDoc table, Object JavaDoc value,
40         boolean isSelected, boolean hasFocus, int row, int column) {
41         super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
42             row, column);
43
44         if (value == null) {
45             setText("");
46
47             return this;
48         }
49
50         setText("");
51         
52         Integer JavaDoc priority = (Integer JavaDoc) ((MessageNode) value).getHeader().get("columba.priority");
53
54         Integer JavaDoc in = priority;
55
56         if (in == null) {
57             return this;
58         }
59
60         int i = in.intValue();
61
62         if (i == 1) {
63             //setForeground( Color.red );
64
//setText("!!");
65
setIcon(image1);
66
67             setToolTipText(MailResourceLoader.getString("header", "column",
68                     "priority_highest"));
69         } else if (i == 2) {
70             //setForeground( Color.red );
71
setIcon(image2);
72             setToolTipText(MailResourceLoader.getString("header", "column",
73                     "priority_high"));
74
75             //setText("!");
76
} else if (i == 3) {
77             setIcon(null);
78         } else if (i == 4) {
79             //eteTextForeground( Color.blue );
80
setIcon(image3);
81             setToolTipText(MailResourceLoader.getString("header", "column",
82                     "priority_low"));
83
84             //setText("!");
85
} else if (i == 5) {
86             //setForeground( Color.blue );
87
setIcon(image4);
88             setToolTipText(MailResourceLoader.getString("header", "column",
89                     "priority_lowest"));
90
91             //setText("!!");
92
}
93
94         return this;
95     }
96 }
97
Popular Tags