Bug 534629 - [CSS] CSS engine does not support loading of scaled images

The CSS engine does not support loading of scaled images automatically,
i.e. images with @2x.png for example are ignored.

Change-Id: I4499f1fc71e555b9f03f657f605422e0ab7bcc9b
Signed-off-by: minnist <eklipse@posteo.net>
diff --git a/bundles/org.eclipse.e4.ui.css.swt/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.ui.css.swt/META-INF/MANIFEST.MF
index 6a36863..1377e96 100644
--- a/bundles/org.eclipse.e4.ui.css.swt/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.ui.css.swt/META-INF/MANIFEST.MF
@@ -30,5 +30,6 @@
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-Activator: org.eclipse.e4.ui.internal.css.swt.CSSActivator
 Bundle-ActivationPolicy: lazy
-Import-Package: org.w3c.dom.css
+Import-Package: org.eclipse.jface.resource,
+ org.w3c.dom.css
 Automatic-Module-Name: org.eclipse.e4.ui.css.swt
diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTImageHelper.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTImageHelper.java
index 120e0bd..54acb36 100644
--- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTImageHelper.java
+++ b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTImageHelper.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2015 Angelo Zerr and others.
+ * Copyright (c) 2008, 2018 Angelo Zerr and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -11,9 +11,10 @@
  *******************************************************************************/
 package org.eclipse.e4.ui.css.swt.helpers;
 
-import java.io.IOException;
-import java.io.InputStream;
+import java.net.URL;
 import org.eclipse.e4.ui.css.core.util.resources.IResourcesLocatorManager;
+import org.eclipse.e4.ui.css.core.utils.StringUtils;
+import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.swt.graphics.Device;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.widgets.Button;
@@ -50,30 +51,12 @@
 	private static Image loadImageFromURL(Device device, String path,
 			IResourcesLocatorManager manager) throws Exception {
 		Image result = null;
-		InputStream in = null;
-		try {
-			// URL url = new URL(path);
-			in = manager.getInputStream(path);
-			if (in != null) {
-				result = new Image(device, in);
-			}
-			// } catch (IOException e) {
-			// e.printStackTrace();
-			// return null;
-			// } catch (SWTException e) {
-			// if (e.code != SWT.ERROR_INVALID_IMAGE) {
-			// throw e;
-			// }
-		} finally {
-			try {
-				if (in != null) {
-					in.close();
-				}
-			} catch (IOException e) {
-				// e.printStackTrace();
-				throw e;
-			}
+
+		String s = manager.resolve(path);
+		if (!StringUtils.isEmpty(s)) {
+			result = ImageDescriptor.createFromURL(new URL(s)).createImage();
 		}
+
 		return result;
 	}