/*
 * generated by Xtext 2.25.0
 */
package org.etsi.mts.tdl.ui.labeling;

import com.google.inject.Inject;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider;
import org.etsi.mts.tdl.Annotation;
import org.etsi.mts.tdl.Comment;
import org.etsi.mts.tdl.Element;
import org.etsi.mts.tdl.Extension;

/**
 * Provides labels for EObjects.
 * 
 * See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#label-provider
 */
public class TDLtxiLabelProvider extends DefaultEObjectLabelProvider {

	@Inject
	public TDLtxiLabelProvider(AdapterFactoryLabelProvider delegate) {
		super(delegate);
	}

	String text(Element element) {
		if (element.getName() != null) {
			return element.eClass().getName()+" : "+element.getName();
		} else if (element instanceof Extension) {
			return element.eClass().getName()+" : "+((Extension) element).getExtending().getName();
		} else if (element instanceof Comment) {
			return element.eClass().getName()+" : "+((Comment) element).getBody();
		} else if (element instanceof Annotation) {
			return element.eClass().getName()+" : "+((Annotation) element).getKey().getName()+"="+((Annotation) element).getValue();
		}
		return element.eClass().getName();
	}

	// Labels and icons can be computed like this:
	
//	String text(Greeting ele) {
//		return "A greeting to " + ele.getName();
//	}
//
//	String image(Greeting ele) {
//		return "Greeting.gif";
//	}
}
