KickJava   Java API By Example, From Geeks To Geeks.

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


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.core.resourceloader.ImageLoader;
27 import org.columba.mail.gui.table.model.MessageNode;
28 import org.columba.mail.message.ColumbaHeader;
29 import org.columba.mail.resourceloader.MailImageLoader;
30 import org.columba.mail.util.MailResourceLoader;
31 import org.columba.ristretto.message.Flags;
32
33 public class StatusRenderer extends DefaultLabelRenderer {
34
35     boolean bool;
36
37     ImageIcon JavaDoc image2;
38
39     ImageIcon JavaDoc image3;
40
41     ImageIcon JavaDoc image5;
42
43     ImageIcon JavaDoc image6;
44
45     ImageIcon JavaDoc image7;
46
47     public StatusRenderer() {
48         super();
49
50         setHorizontalAlignment(SwingConstants.CENTER);
51
52         image2 = MailImageLoader.getSmallIcon("message-mail-replied.png");
53         image3 = ImageLoader.getSmallIcon("user-trash.png");
54
55         image5 = MailImageLoader.getSmallIcon("message-mail-read.png");
56         image6 = MailImageLoader.getSmallIcon("message-mail-unread.png");
57         image7 = MailImageLoader.getSmallIcon("edit.png");
58     }
59
60     public Component JavaDoc getTableCellRendererComponent(JTable JavaDoc table, Object JavaDoc value,
61             boolean isSelected, boolean hasFocus, int row, int column) {
62         super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
63                 row, column);
64
65         if (value == null) {
66             setIcon(null);
67
68             return this;
69         }
70
71         setText("");
72
73         if (value instanceof String JavaDoc) {
74             System.out
75                     .println("statusrenderer-> instanceof String not expected");
76
77             return this;
78         }
79
80         Flags flags = ((ColumbaHeader) ((MessageNode) value).getHeader())
81                 .getFlags();
82
83         if (flags.getDeleted()) {
84             setIcon(image3);
85
86             setToolTipText(MailResourceLoader.getString("header", "column",
87                     "expunged"));
88         } else if (flags.getAnswered()) {
89             setIcon(image2);
90             setToolTipText(MailResourceLoader.getString("header", "column",
91                     "answered"));
92         } else if (flags.getDraft()) {
93             setIcon(image7);
94             setToolTipText(MailResourceLoader.getString("header", "column",
95                     "draft"));
96         } else if (!flags.getSeen()) {
97             setIcon(image6);
98             setToolTipText(MailResourceLoader.getString("header", "column",
99                     "unread"));
100         } else if (flags.getSeen()) {
101             setIcon(image5);
102             setToolTipText(MailResourceLoader.getString("header", "column",
103                     "read"));
104         } else {
105             setIcon(null);
106         }
107
108         return this;
109     }
110 }
Popular Tags