Bug 277873 [CSS] Exception handling for illegal color name
bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/converters/CSSValueSWTColorConverterImpl.java
import org.w3c.dom.css.RGBColor;
/**
 * CSS Value converter to convert :
 * <ul>
 * <li>CSS Value to {@link Color}</li>.
 * <li>{@link Color} to String CSS Value</li>
 * </ul>
 * 
 * @version 1.0.0
 * @author <a href="mailto:angelo.zerr@gmail.com">Angelo ZERR</a>
 * 
 */
public class CSSValueSWTColorConverterImpl extends AbstractCSSValueConverter {
	public static final ICSSValueConverter INSTANCE = new CSSValueSWTColorConverterImpl();
	public CSSValueSWTColorConverterImpl() {
		super(Color.class);
	}
	public Object convert(CSSValue value, CSSEngine engine, Object context)
			throws Exception {
		Display display = (Display) context;
		return CSSSWTColorHelper.getSWTColor(value, display);
	}
	public String convert(Object value, CSSEngine engine, Object context,
			ICSSValueConverterConfig config) throws Exception {
		Color color = (Color) value;
		RGBColor rgbColor = CSSSWTColorHelper.getRGBColor(color);
		return CSS2ColorHelper.getColorStringValue(rgbColor, config);
	}
}