/*
#=======================================================================================================
#
#                   Copyright (c) 2007 Origin Enterprise Solution LTD.
#
#=======================================================================================================
# File description:  TableColorRender.java
#=======================================================================================================
#	 Date	       time   	   Name	 Action	   Description of Change
#	2011-11-22      下午03:46:31    zyn  	Ini	            初始化文件
#=======================================================================================================
 */
package cn.com.teamcenter.rac.form;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;

public class ORTableColorRender implements TableCellRenderer {
	//
	public static final DefaultTableCellRenderer	DEFAULT_RENDERER	= new DefaultTableCellRenderer();

	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
		Component renderer = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
		
			if (value != null&& value instanceof String) {
				Color foreground = table.getForeground();
				Color background = table.getBackground();
				
				if(column == 1){
					if (((String) value).contains("有延期风险")) {
						background = Color.YELLOW;
					} else if(((String) value).contains("已拖期")||((String) value).equals("拖期")) {
						background = Color.RED;
					} else if(((String) value).contains("暂停")) {
						background = Color.GRAY;
					}
				}
				renderer.setForeground(foreground);
				renderer.setBackground(background);
			}
		
		return renderer;
	}
}


