package de.tuberlin.uebb.emodelica.model;

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

import de.tuberlin.uebb.emodelica.Images;
import de.tuberlin.uebb.modelica.im.impl.nodes.ClassNode;
import de.tuberlin.uebb.modelica.im.nodes.EClassType;
import de.tuberlin.uebb.modelica.im.nodes.ENodeFlags;
import de.tuberlin.uebb.modelica.im.nodes.IVarDefNode;


public class ModelLabelProvider extends LabelProvider {

	public String getText(Object obj) {
		return obj.toString() + "[" + obj.getClass().getSimpleName() + "]";
	}
	public Image getImage(Object obj) {
		if (obj instanceof IVarDefNode) {
			IVarDefNode node = (IVarDefNode)obj;
			if (node.getFlags().contains(ENodeFlags.PUBLIC))
				return Images.PUBLIC_FIELD_DESCRIPTOR.createImage();
			else
				return Images.PRIVATE_FIELD_DESCRIPTOR.createImage();
		}
		
		if (obj instanceof ClassNode) {
			ClassNode classNode = (ClassNode)obj;
			if (classNode.getClassType().equals(EClassType.CLASS))
				return Images.CLASS_IMAGE_DESCRIPTOR.createImage();
			if (classNode.getClassType().equals(EClassType.PACKAGE))
				return Images.PKG_IMAGE_DESCRIPTOR.createImage();			
		}
		
		String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
		return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
	}
}


@@ -784,21 +784,24 @@
 eFlags.P
-UBLIC
+ROTECTED
 ))%0A%09%09%09%09r
@@ -818,13 +818,14 @@
 es.P
-UBLIC
+RIVATE
 _FIE
@@ -872,38 +872,37 @@
 %09return Images.P
-RIVATE
+UBLIC
 _FIELD_DESCRIPTO

Fix the PUBLIC/PROTECTED icons