01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
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;
19:
20: import javax.swing.ImageIcon;
21: import javax.swing.JTable;
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: public class PriorityRenderer extends DefaultLabelRenderer {
28: private ImageIcon image1 = MailImageLoader
29: .getSmallIcon("priority-high.png");
30: private ImageIcon image2 = null;
31: private ImageIcon image3 = null;
32: private ImageIcon image4 = MailImageLoader
33: .getSmallIcon("priority-low.png");
34:
35: public PriorityRenderer() {
36: super ();
37: }
38:
39: public Component getTableCellRendererComponent(JTable table,
40: Object value, boolean isSelected, boolean hasFocus,
41: int row, int column) {
42: super .getTableCellRendererComponent(table, value, isSelected,
43: hasFocus, row, column);
44:
45: if (value == null) {
46: setText("");
47:
48: return this ;
49: }
50:
51: setText("");
52:
53: Integer priority = (Integer) ((MessageNode) value).getHeader()
54: .get("columba.priority");
55:
56: Integer in = priority;
57:
58: if (in == null) {
59: return this ;
60: }
61:
62: int i = in.intValue();
63:
64: if (i == 1) {
65: //setForeground( Color.red );
66: //setText("!!");
67: setIcon(image1);
68:
69: setToolTipText(MailResourceLoader.getString("header",
70: "column", "priority_highest"));
71: } else if (i == 2) {
72: //setForeground( Color.red );
73: setIcon(image2);
74: setToolTipText(MailResourceLoader.getString("header",
75: "column", "priority_high"));
76:
77: //setText("!");
78: } else if (i == 3) {
79: setIcon(null);
80: } else if (i == 4) {
81: //eteTextForeground( Color.blue );
82: setIcon(image3);
83: setToolTipText(MailResourceLoader.getString("header",
84: "column", "priority_low"));
85:
86: //setText("!");
87: } else if (i == 5) {
88: //setForeground( Color.blue );
89: setIcon(image4);
90: setToolTipText(MailResourceLoader.getString("header",
91: "column", "priority_lowest"));
92:
93: //setText("!!");
94: }
95:
96: return this;
97: }
98: }
|