/*******************************************************************************
 * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the LGPL 3.0
 * which accompanies this distribution, and is available at
 * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
 *
 * Contributors:
 *     Faiez Zalila - initial API and implementation and/or initial documentation
 *     Jorge Enrique Gutierrez Zuluaga
 *******************************************************************************/
package com.irtsaintexupery.fiacre.simulator.marking;

import org.eclipse.core.resources.IResource;
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.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;

public class FileDecorator extends LabelProvider implements ILightweightLabelDecorator {
	
	public static final String ICON = "/icons/sample.gif";
	private static Font font = new Font(null, "Arial", 10, 0);
	private static Color color = new Color(null, 0, 0, 255);
	
	@Override
	public void decorate(Object resource, IDecoration decoration) {
		int markers = MarkerFactory.findMarkers((IResource) resource).size();
		if (MarkingController.file == resource) {
			decoration.addOverlay(ImageDescriptor.createFromFile(FileDecorator.class, ICON), IDecoration.TOP_RIGHT);
			decoration.addPrefix("");
			decoration.addSuffix(" - running ");
			decoration.setFont(font);
			decoration.setForegroundColor(color);
		}
	}

}
