01: /*
02: * Copyright (C) 2005-2007 JasperSoft http://www.jaspersoft.com
03: *
04: * This program is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * This program is distributed WITHOUT ANY WARRANTY; and without the
10: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: * See the GNU General Public License for more details.
12: *
13: * You should have received a copy of the GNU General Public License
14: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
15: * or write to:
16: *
17: * Free Software Foundation, Inc.,
18: * 59 Temple Place - Suite 330,
19: * Boston, MA USA 02111-1307
20: *
21: *
22: * ProblemIconTableCellRenderer.java
23: *
24: * Created on February 27, 2007, 1:25 PM
25: *
26: * To change this template, choose Tools | Template Manager
27: * and open the template in the editor.
28: */
29:
30: package it.businesslogic.ireport.gui.logpane;
31:
32: import javax.swing.ImageIcon;
33: import javax.swing.JLabel;
34: import javax.swing.table.DefaultTableCellRenderer;
35:
36: /**
37: *
38: * @author gtoffoli
39: */
40: public class ProblemIconTableCellRenderer extends
41: DefaultTableCellRenderer {
42:
43: static ImageIcon errorIcon;
44: static ImageIcon infoIcon;
45: static ImageIcon warningIcon;
46:
47: public ProblemIconTableCellRenderer() {
48: super ();
49: if (errorIcon == null)
50: errorIcon = new javax.swing.ImageIcon(
51: getClass()
52: .getResource(
53: "/it/businesslogic/ireport/icons/problems/error.png"));
54: if (infoIcon == null)
55: infoIcon = new javax.swing.ImageIcon(
56: getClass()
57: .getResource(
58: "/it/businesslogic/ireport/icons/problems/information.png"));
59: if (warningIcon == null)
60: warningIcon = new javax.swing.ImageIcon(
61: getClass()
62: .getResource(
63: "/it/businesslogic/ireport/icons/problems/warning.png"));
64: }
65:
66: public java.awt.Component getTableCellRendererComponent(
67: javax.swing.JTable table, Object value, boolean isSelected,
68: boolean hasFocus, int row, int column) {
69:
70: java.awt.Component retValue;
71:
72: retValue = super .getTableCellRendererComponent(table, value,
73: isSelected, hasFocus, row, column);
74:
75: if (value != null && value instanceof ProblemItem) {
76: ProblemItem pi = (ProblemItem) value;
77: ((JLabel) retValue).setText("");
78: if (pi.getProblemType() == pi.ERROR)
79: ((JLabel) retValue).setIcon(errorIcon);
80: if (pi.getProblemType() == pi.INFORMATION)
81: ((JLabel) retValue).setIcon(infoIcon);
82: if (pi.getProblemType() == pi.WARNING)
83: ((JLabel) retValue).setIcon(warningIcon);
84:
85: }
86:
87: return retValue;
88: }
89: }
|