/**
 * @author tyl
 * @Action  ini
 * 2011-3-15
 */
package cn.com.origin.autocodemanager.common.treetable;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;
import cn.com.origin.autocodemanager.common.tree.AbstractTreeData;

public class ORTreeTableLabelProvider implements ITableLabelProvider {
	public Image getColumnImage(Object element, int columnIndex) {
		if (element instanceof AbstractTreeData) {
			AbstractTreeData codeTreeData = (AbstractTreeData) element;
			if (columnIndex == 0) {
				return codeTreeData.getImage();
			}
		}
		return null;
	}

	public String getColumnText(Object element, int coumnIndex) {
		if (element instanceof AbstractTreeData) {
			try {
				AbstractTreeData codeTreeData = (AbstractTreeData) element;
				if ((codeTreeData == null) || (codeTreeData.getPackCodeNodeInfo() == null)) {
					return "";
				}
				switch (coumnIndex) {
				case 0:
					return codeTreeData.getPackCodeNodeInfo().getNode_name();
				case 1:
					return codeTreeData.getPackCodeNodeInfo().getNode_value();
				case 2:
					return codeTreeData.getPackCodeNodeInfo().getNode_desc();
				case 3:
					if (codeTreeData.getPackCodeNodeInfo().isDefaultSelected) {
						return "تا";
					} else {
						return "·ٌ";
					}
				case 4:
					return codeTreeData.getPackCodeNodeInfo().getRule_node();
				case 5:
					if (codeTreeData.getPackCodeNodeInfo().is_lock) {
						return "تا";
					} else {
						return "·ٌ";
					}
				case 6:
					return codeTreeData.getPackCodeNodeInfo().getCreate_date();
				case 7:
					return codeTreeData.getPackCodeNodeInfo().getCreate_user();
				case 8:
					return codeTreeData.getPackCodeNodeInfo().getLast_revise_date();
				case 9:
					return codeTreeData.getPackCodeNodeInfo().getLast_revise_user();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return "";
	}

	public void addListener(ILabelProviderListener arg0) {

	}

	public void dispose() {

	}

	public boolean isLabelProperty(Object obj, String obj1) {
		return false;
	}

	public void removeListener(ILabelProviderListener arg0) {

	}

}
