KickJava   Java API By Example, From Geeks To Geeks.

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


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