package eu.scasefp7.eclipse.core.ui.navigator;

import java.net.URL;

import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.ILightweightLabelDecorator;
import org.eclipse.jface.viewers.LabelProvider;
import org.osgi.framework.Bundle;

import eu.scasefp7.eclipse.core.ui.Activator;
import eu.scasefp7.eclipse.core.ui.ScaseUiConstants;
import eu.scasefp7.eclipse.core.ui.SharedImages;

public class ProjectFolderLabelProvider extends LabelProvider implements ILightweightLabelDecorator {
 
	@Override
	public void decorate(Object resource, IDecoration decoration) {
		if(resource instanceof IFolder){      
			IProject project = ((IFolder)resource).getProject();
			String modelsPath = "";
			String outputPath = "";
			String reqPath = "";
			String comPath = "";
			String resourcePath = ((IFolder) resource).getFullPath().toString();
			
			try {
				comPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.COMPOSITIONS_FOLDER));
				reqPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.REQUIREMENTS_FOLDER));
				modelsPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.MODELS_FOLDER));
				outputPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.OUTPUT_FOLDER));
			} catch (CoreException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if(resourcePath.equals(comPath) || resourcePath.equals(reqPath) || resourcePath.equals(modelsPath) || resourcePath.equals(outputPath) ){
				decoration.addOverlay(Activator.getImageDescriptor("icons/obj16/s-case_8.png"), IDecoration.TOP_RIGHT);
			}
		}
		
	}


}
@@ -47,32 +47,8 @@
 %0D%0A%0D%0A
-import java.net.URL;%0D%0A%0D%0A
 impo
@@ -184,51 +184,8 @@
 n;%0D%0A
-import org.eclipse.core.runtime.Platform;%0D%0A
 impo
@@ -232,60 +232,8 @@
 e;%0D%0A
-import org.eclipse.jface.resource.ImageDescriptor;%0D%0A
 impo
@@ -389,43 +389,8 @@
 er;%0D
-%0Aimport org.osgi.framework.Bundle;%0D
 %0A%0D%0Ai
@@ -493,58 +493,138 @@
 s;%0D%0A
-import eu.scasefp7.eclipse.core.ui.SharedImages;%0D%0A
+%0D%0A/**%0D%0A * Decorates the project folders with S-CASE icon overlay.%0D%0A * %0D%0A * @author Leonora Gaspar%0D%0A * @author Marin Orlic%0D%0A *%0D%0A */
 %0D%0Apu
@@ -1560,66 +1560,60 @@
 %09%09%09%09
-// TODO Auto-generated catch block%0D%0A%09%09%09%09e.printStackTrace(
+Activator.log(%22Unable to get project properties.%22, e
 );%0D%0A
@@ -1889,11 +1889,9 @@
 %0D%0A%09%7D%0D%0A%0D%0A
-%0D%0A
 %7D

Add logging to label decorator