KickJava   Java API By Example, From Geeks To Geeks.

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


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 import javax.swing.SwingConstants JavaDoc;
23
24 import org.columba.mail.gui.table.model.MessageNode;
25 import org.columba.mail.resourceloader.MailImageLoader;
26 import org.columba.mail.util.MailResourceLoader;
27
28
29 public class AttachmentRenderer extends DefaultLabelRenderer {
30     boolean bool;
31     ImageIcon JavaDoc image1;
32
33     public AttachmentRenderer() {
34         super();
35
36         setHorizontalAlignment(SwingConstants.CENTER);
37
38         image1 = MailImageLoader.getSmallIcon("attachment-col.png");
39
40     }
41
42     public Component JavaDoc getTableCellRendererComponent(JTable JavaDoc table, Object JavaDoc value,
43         boolean isSelected, boolean hasFocus, int row, int column) {
44         super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
45             row, column);
46
47         if (value == null) {
48             setIcon(null);
49
50             return this;
51         }
52
53         setText("");
54         
55         boolean hasAttachment = ((Boolean JavaDoc) ((MessageNode) value).getHeader()
56                                             .get("columba.attachment")).booleanValue();
57
58         if (hasAttachment) {
59             setIcon(image1);
60
61             setToolTipText(MailResourceLoader.getString("header", "column",
62                     "attachment"));
63         } else {
64             setIcon(null);
65         }
66
67         return this;
68     }
69 }
70
Popular Tags