package interactivefeaturelocator.views;

import interactivefeaturelocator.model.TreeModel;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TreeNode;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;

public class ViewLabelProvider extends LabelProvider {
	
	public String getText(Object obj) {
		if (obj instanceof TreeNode) {
			return ((TreeNode) obj).getValue().toString();
		}
		return "";
	}
	
	public Image getImage(Object obj) {
		String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
		TreeModel model = null;
		if (obj instanceof TreeNode) {
			model = (TreeModel)((TreeNode) obj).getValue();
			if (model.getType() == 1) {
				imageKey = ISharedImages.IMG_OBJ_FOLDER;
			} else if (model.getType() == 2) {
				imageKey = ISharedImages.IMG_OBJ_FILE;
			}
			return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
		}
		
		return null;
	}
}
