01: /*
02: * ConstraintCellRenderer.java
03: *
04: * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License
08: * as published by the Free Software Foundation; either version 2
09: * of the License, or any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19: *
20: */
21:
22: package org.executequery.gui.table;
23:
24: import java.awt.Color;
25: import java.awt.Component;
26: import javax.swing.ImageIcon;
27: import javax.swing.JLabel;
28: import javax.swing.JTable;
29: import javax.swing.table.TableCellRenderer;
30: import org.executequery.GUIUtilities;
31: import org.executequery.gui.browser.ColumnConstraint;
32:
33: /* ----------------------------------------------------------
34: * CVS NOTE: Changes to the CVS repository prior to the
35: * release of version 3.0.0beta1 has meant a
36: * resetting of CVS revision numbers.
37: * ----------------------------------------------------------
38: */
39:
40: /**
41: *
42: * @author Takis Diakoumis
43: * @version $Revision: 1.5 $
44: * @date $Date: 2006/09/06 09:30:58 $
45: */
46: public class ConstraintCellRenderer extends JLabel implements
47: TableCellRenderer {
48:
49: private static ImageIcon deleteImage;
50: private static ImageIcon newImage;
51:
52: static {
53: deleteImage = GUIUtilities.loadIcon("MarkDeleted16.gif", true);
54: newImage = GUIUtilities.loadIcon("MarkNew16.gif", true);
55: }
56:
57: /** Creates a new instance of ConstraintCellRenderer */
58: public ConstraintCellRenderer() {
59: }
60:
61: public Component getTableCellRendererComponent(JTable table,
62: Object value, boolean isSelected, boolean hasFocus,
63: int row, int column) {
64:
65: ColumnConstraint cc = (ColumnConstraint) value;
66: if (cc.isMarkedDeleted()) {
67: setIcon(deleteImage);
68: setToolTipText("This value marked to be dropped");
69: } else if (cc.isNewConstraint()) {
70: setIcon(newImage);
71: setToolTipText("This value marked new");
72: } else {
73: setIcon(null);
74: }
75:
76: setBackground(Color.WHITE);
77: setHorizontalAlignment(JLabel.CENTER);
78: return this;
79: }
80:
81: }
|