KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > genimen > djeneric > tools > modeler > extenteditor > InheritanceIndicationRenderer


1 /*
2  * Created on 17-okt-2003
3  *
4  * To change the template for this generated file go to Window - Preferences -
5  * Java - Code Generation - Code and Comments
6  */

7 package com.genimen.djeneric.tools.modeler.extenteditor;
8
9 import java.awt.Color JavaDoc;
10 import java.awt.Component JavaDoc;
11
12 import javax.swing.JTable JavaDoc;
13 import javax.swing.table.DefaultTableCellRenderer JavaDoc;
14
15 import com.genimen.djeneric.repository.DjExtent;
16
17 public class InheritanceIndicationRenderer extends DefaultTableCellRenderer JavaDoc
18 {
19   private static final long serialVersionUID = 1L;
20   public final static Color JavaDoc LIGHT_GRAY = new Color JavaDoc(235, 235, 235);
21
22   public static final int PROPERTY = 0;
23   public static final int RELATION = 1;
24
25   DjExtent _extent;
26   int _type;
27
28   public InheritanceIndicationRenderer(DjExtent extent, int type)
29   {
30     _extent = extent;
31     _type = type;
32   }
33
34   public Component JavaDoc getTableCellRendererComponent(JTable JavaDoc table, Object JavaDoc value, boolean isSelected, boolean hasFocus,
35                                                  int row, int column)
36   {
37
38     Component JavaDoc component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
39
40     boolean inherited = false;
41
42     if (_type == PROPERTY)
43     {
44       inherited = _extent.isInherited(_extent.getProperty(row));
45     }
46     else if (_type == RELATION)
47     {
48       inherited = _extent.isInherited(_extent.getMasterRelation(row));
49     }
50     if (inherited)
51     {
52       component.setBackground(LIGHT_GRAY);
53     }
54     else
55     {
56       if (isSelected) component.setBackground(table.getSelectionBackground());
57       else component.setBackground(table.getBackground());
58     }
59
60     return component;
61   }
62
63 }
Popular Tags