package hiro.yoshioka.ast.sql.view;

import hiro.yoshioka.ast.sql.AbsSimpleNode;
import hiro.yoshioka.util.ColorNameEnum;
import hiro.yoshioka.util.ColorUtil;
import hiro.yoshioka.util.StringUtil;

import org.eclipse.jface.viewers.ITableColorProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;

public class ASTTreeLabelProvider extends LabelProvider implements
		ITableColorProvider, ITableLabelProvider {

	public String getText(Object arg0) {
		return ((AbsSimpleNode) arg0).toString(StringUtil.EMPTY_STRING);
	}

	public Image getImage(Object element) {
		return null;
	}

	public Color getBackground(Object element, int columnIndex) {
		return null;
	}

	public Color getForeground(Object element, int columnIndex) {
		AbsSimpleNode node = (AbsSimpleNode) element;
		if (node.fInfomation != null) {
			return ColorUtil.getColor(ColorNameEnum.CHANGE);
		}
		return null;
	}

	public Image getColumnImage(Object element, int columnIndex) {
		// TODO Auto-generated method stub
		return null;
	}

	public String getColumnText(Object element, int columnIndex) {
		AbsSimpleNode node = (AbsSimpleNode) element;
		if (node.fInfomation != null) {
			return node.fInfomation.getLineMessage();
		}
		return ((AbsSimpleNode) element).toString(StringUtil.EMPTY_STRING);
	}

}