001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.mail.gui.table.plugins;
019:
020: import java.awt.Component;
021:
022: import javax.swing.ImageIcon;
023: import javax.swing.JTable;
024: import javax.swing.SwingConstants;
025:
026: import org.columba.core.resourceloader.ImageLoader;
027: import org.columba.mail.gui.table.model.MessageNode;
028: import org.columba.mail.message.ColumbaHeader;
029: import org.columba.mail.resourceloader.MailImageLoader;
030: import org.columba.mail.util.MailResourceLoader;
031: import org.columba.ristretto.message.Flags;
032:
033: public class StatusRenderer extends DefaultLabelRenderer {
034:
035: boolean bool;
036:
037: ImageIcon image2;
038:
039: ImageIcon image3;
040:
041: ImageIcon image5;
042:
043: ImageIcon image6;
044:
045: ImageIcon image7;
046:
047: public StatusRenderer() {
048: super ();
049:
050: setHorizontalAlignment(SwingConstants.CENTER);
051:
052: image2 = MailImageLoader
053: .getSmallIcon("message-mail-replied.png");
054: image3 = ImageLoader.getSmallIcon("user-trash.png");
055:
056: image5 = MailImageLoader.getSmallIcon("message-mail-read.png");
057: image6 = MailImageLoader
058: .getSmallIcon("message-mail-unread.png");
059: image7 = MailImageLoader.getSmallIcon("edit.png");
060: }
061:
062: public Component getTableCellRendererComponent(JTable table,
063: Object value, boolean isSelected, boolean hasFocus,
064: int row, int column) {
065: super .getTableCellRendererComponent(table, value, isSelected,
066: hasFocus, row, column);
067:
068: if (value == null) {
069: setIcon(null);
070:
071: return this ;
072: }
073:
074: setText("");
075:
076: if (value instanceof String) {
077: System.out
078: .println("statusrenderer-> instanceof String not expected");
079:
080: return this ;
081: }
082:
083: Flags flags = ((ColumbaHeader) ((MessageNode) value)
084: .getHeader()).getFlags();
085:
086: if (flags.getDeleted()) {
087: setIcon(image3);
088:
089: setToolTipText(MailResourceLoader.getString("header",
090: "column", "expunged"));
091: } else if (flags.getAnswered()) {
092: setIcon(image2);
093: setToolTipText(MailResourceLoader.getString("header",
094: "column", "answered"));
095: } else if (flags.getDraft()) {
096: setIcon(image7);
097: setToolTipText(MailResourceLoader.getString("header",
098: "column", "draft"));
099: } else if (!flags.getSeen()) {
100: setIcon(image6);
101: setToolTipText(MailResourceLoader.getString("header",
102: "column", "unread"));
103: } else if (flags.getSeen()) {
104: setIcon(image5);
105: setToolTipText(MailResourceLoader.getString("header",
106: "column", "read"));
107: } else {
108: setIcon(null);
109: }
110:
111: return this;
112: }
113: }
|