package com.interpress_project.modernshare.client.view.remotefs;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

import com.interpress_project.modernshare.client.controller.actions.ImageFactory;
import com.interpress_project.modernshare.client.controller.model.ISVNFileItem;
import com.interpress_project.modernshare.client.controller.model.SVNFile;
import com.interpress_project.modernshare.client.controller.model.SVNFolder;
import com.interpress_project.modernshare.client.controller.model.SVNRoot;

public class RemoteFileTreeLabelProvider extends LabelProvider {
	/**
	 * getText
	 * @param element Object
	 * @return String
	 */
	public String getText(Object element) {
		ISVNFileItem item = (ISVNFileItem) element;
		String name = item.getName();
		if (element instanceof SVNRoot) {
			return name;
		}
		return name;
	}

	/**
	 * getImage
	 * @param element Object
	 * @return Image
	 */
	public Image getImage(Object element) {
		Image image = null;

		if (element instanceof SVNRoot) {
			image = ImageFactory.getInstance().getImage("repository");
		}
		else if (element instanceof SVNFolder) {
			image = ImageFactory.getInstance().getImage("rfolder");
		}
		else if (element instanceof SVNFile) {
			image = ImageFactory.getInstance().getImage("rfile");
		}
		return image;
	}
}
