1 7 package com.genimen.djeneric.tools.modeler.extenteditor; 8 9 import java.awt.Color ; 10 import java.awt.Component ; 11 12 import javax.swing.JTable ; 13 import javax.swing.table.DefaultTableCellRenderer ; 14 15 import com.genimen.djeneric.repository.DjExtent; 16 17 public class InheritanceIndicationRenderer extends DefaultTableCellRenderer 18 { 19 private static final long serialVersionUID = 1L; 20 public final static Color LIGHT_GRAY = new Color (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 getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, 35 int row, int column) 36 { 37 38 Component 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 |