/*
 * Copyright (C) 2005 NTT DATA Corporation
 * 
 */
package org.postgresforest.tool.view;

import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.postgresforest.tool.ForestToolPlugin;
import org.postgresforest.tool.bean.MenuNode;

/**
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class MenuLabelProvider extends LabelProvider {
	
	public String getText(Object element) {
		return ((MenuNode) element).getContent();
	}

	/* (非 Javadoc)
	 * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
	 */
	public Image getImage(Object element) {
		ImageRegistry registry = ForestToolPlugin.getDefault().getImageRegistry();
		// TODO 自動生成されたメソッド・スタブ
		String imagekey = ((MenuNode) element).getImageKey();
		if(imagekey != null){
			return registry.getDescriptor(imagekey).createImage();
		}
		return null;
	}
}
