Bug 572002: [Runtime] Remove use of deprecated API

Change-Id: I0c0ee056d57e521a28a9225a86a0490310be0744
diff --git a/ecommons.waltable/org.eclipse.statet.ecommons.waltable.core/src/org/eclipse/statet/ecommons/waltable/util/GUIHelper.java b/ecommons.waltable/org.eclipse.statet.ecommons.waltable.core/src/org/eclipse/statet/ecommons/waltable/util/GUIHelper.java
index 68655ce..80cd72b 100644
--- a/ecommons.waltable/org.eclipse.statet.ecommons.waltable.core/src/org/eclipse/statet/ecommons/waltable/util/GUIHelper.java
+++ b/ecommons.waltable/org.eclipse.statet.ecommons.waltable.core/src/org/eclipse/statet/ecommons/waltable/util/GUIHelper.java
@@ -23,7 +23,6 @@
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.widgets.Display;
 
@@ -125,13 +124,6 @@
 		return image;
 	}
 
-	public static Image getImage(final ImageData data) {
-		if( JFaceResources.getImage(data.toString()) == null ) {
-			JFaceResources.getImageRegistry().put(data.toString(), ImageDescriptor.createFromImageData(data));
-		}
-		return JFaceResources.getImage(data.toString());
-	}
-	
 	private static URL getImageUrl(final String imageName) {
 		for (final String dir : IMAGE_DIRS) {
 			for (final String ext : IMAGE_EXTENSIONS) {
diff --git a/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/ECommonsDebugUIImageDescriptor.java b/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/ECommonsDebugUIImageDescriptor.java
index 25525aa..782d363 100644
--- a/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/ECommonsDebugUIImageDescriptor.java
+++ b/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/ECommonsDebugUIImageDescriptor.java
@@ -14,19 +14,21 @@
 
 package org.eclipse.statet.ecommons.debug.ui;
 
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
+import static org.eclipse.statet.jcommons.lang.ObjectUtils.nonNullAssert;
+
 import org.eclipse.jface.resource.CompositeImageDescriptor;
 import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.ImageData;
 import org.eclipse.swt.graphics.Point;
-import org.eclipse.ui.statushandlers.StatusManager;
+
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
 
 
 /**
  * A ECommonsDebugUIImageDescriptor consists of a main icon and several adornments. The adornments
  * are computed according to flags set on creation of the descriptor.
  */
+@NonNullByDefault
 public class ECommonsDebugUIImageDescriptor extends CompositeImageDescriptor {
 	
 //	/** Flag to render the is out of synch adornment */
@@ -71,20 +73,10 @@
 //	public final static int SYNCHRONIZED=				0x4000;
 	
 	
-	private static ImageData getImageData(final ImageDescriptor descriptor) {
-		ImageData data= descriptor.getImageData(); // getImageData can return null
-		if (data == null) {
-			data= DEFAULT_IMAGE_DATA;
-			StatusManager.getManager().handle(new Status(IStatus.WARNING, ECommonsDebugUI.BUNDLE_ID,
-					"Image data not available: " + descriptor.toString() )); //$NON-NLS-1$
-		}
-		return data;
-	}
-	
-	
 	private final ImageDescriptor baseImage;
 	private final int flags;
-	private final Point size;
+	
+	private @Nullable Point size;
 	
 	
 	/**
@@ -94,20 +86,9 @@
 	 * @param flags flags indicating which adornments are to be rendered
 	 * 
 	 */
-	public ECommonsDebugUIImageDescriptor(final ImageDescriptor baseImage, final int flags,
-			final Point size) {
-		if (baseImage == null) {
-			throw new NullPointerException("baseImage");
-		}
-		this.baseImage= baseImage;
+	public ECommonsDebugUIImageDescriptor(final ImageDescriptor baseImage, final int flags) {
+		this.baseImage= nonNullAssert(baseImage);
 		this.flags= flags;
-		if (size != null) {
-			this.size= size;
-		}
-		else {
-			final ImageData data= getImageData(baseImage);
-			this.size= new Point(data.width, data.height);
-		}
 	}
 	
 	
@@ -121,12 +102,18 @@
 	
 	@Override
 	protected final Point getSize() {
-		return this.size;
+		var size= this.size;
+		if (size == null) {
+			final var data= createCachedImageDataProvider(getBaseImage());
+			size= new Point(data.getWidth(), data.getHeight());
+			this.size= size;
+		}
+		return size;
 	}
 	
 	@Override
 	protected void drawCompositeImage(final int width, final int height) {
-		{	final ImageData data= getImageData(getBaseImage());
+		{	final var data= createCachedImageDataProvider(getBaseImage());
 			drawImage(data, 0, 0);
 		}
 		
@@ -143,11 +130,11 @@
 		if ((flags & (INSTALLED | SCRIPT)) == INSTALLED) {
 			final int x= 0;
 			int y= getSize().y;
-			final ImageData data= getImageData(commonsUIResources.getImageDescriptor(
+			final var data= createCachedImageDataProvider(commonsUIResources.getImageDescriptor(
 					((flags & ENABLED) != 0) ?
 							ECommonsDebugUIResources.OVR_BREAKPOINT_INSTALLED :
 							ECommonsDebugUIResources.OVR_BREAKPOINT_INSTALLED_DISABLED ));
-			y-= data.height;
+			y-= data.getHeight();
 			drawImage(data, x, y);
 		}
 //		if ((flags & CAUGHT) != 0) {
@@ -184,7 +171,7 @@
 		if ((flags & CONDITIONAL) != 0) {
 			final int x= 0;
 			final int y= 0;
-			final ImageData data= getImageData(commonsUIResources.getImageDescriptor(
+			final var data= createCachedImageDataProvider(commonsUIResources.getImageDescriptor(
 					((flags & ENABLED) != 0) ?
 							ECommonsDebugUIResources.OVR_BREAKPOINT_CONDITIONAL :
 							ECommonsDebugUIResources.OVR_BREAKPOINT_CONDITIONAL_DISABLED ));
@@ -193,24 +180,24 @@
 		if ((flags & ENTRY) != 0) {
 			int x= getSize().x;
 			final int y= 0;
-			final ImageData data= getImageData(commonsUIResources.getImageDescriptor(
+			final var data= createCachedImageDataProvider(commonsUIResources.getImageDescriptor(
 					((flags & ENABLED) != 0) ?
 							ECommonsDebugUIResources.OVR_METHOD_BREAKPOINT_ENTRY :
 							ECommonsDebugUIResources.OVR_METHOD_BREAKPOINT_ENTRY_DISABLED ));
-			x-= data.width;
+			x-= data.getWidth();
 			x-= 1;
 			drawImage(data, x, y);
 		}
 		if ((flags & EXIT) != 0){
 			int x= getSize().x;
 			int y= getSize().y;
-			final ImageData data= getImageData(commonsUIResources.getImageDescriptor(
+			final var data= createCachedImageDataProvider(commonsUIResources.getImageDescriptor(
 					((flags & ENABLED) != 0) ?
 							ECommonsDebugUIResources.OVR_METHOD_BREAKPOINT_EXIT :
 							ECommonsDebugUIResources.OVR_METHOD_BREAKPOINT_EXIT_DISABLED ));
-			x-= data.width;
+			x-= data.getWidth();
 			x-= 1;
-			y-= data.height;
+			y-= data.getHeight();
 			drawImage(data, x, y);
 		}
 	}
@@ -218,19 +205,18 @@
 	
 	@Override
 	public int hashCode() {
-		return (this.baseImage.hashCode() ^ this.flags) + this.size.hashCode();
+		return (this.baseImage.hashCode() ^ this.flags);
 	}
 	
 	@Override
-	public boolean equals(final Object obj) {
+	public boolean equals(final @Nullable Object obj) {
 		if (this == obj) {
 			return true;
 		}
 		if (obj != null && getClass().equals(obj.getClass())) {
-			final ECommonsDebugUIImageDescriptor other= (ECommonsDebugUIImageDescriptor) obj;
+			final ECommonsDebugUIImageDescriptor other= (ECommonsDebugUIImageDescriptor)obj;
 			return (this.baseImage.equals(other.baseImage)
-					&& this.flags == other.flags
-					&& this.size.equals(other.size) );
+					&& this.flags == other.flags );
 		}
 		return false;
 	}
diff --git a/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/ECommonsDebugUIResources.java b/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/ECommonsDebugUIResources.java
index e7d359d..8f6fee2 100644
--- a/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/ECommonsDebugUIResources.java
+++ b/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/ECommonsDebugUIResources.java
@@ -14,14 +14,14 @@
 
 package org.eclipse.statet.ecommons.debug.ui;
 
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.swt.graphics.Image;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
 
+import org.eclipse.statet.ecommons.ui.util.UIResources;
 import org.eclipse.statet.internal.ecommons.debug.ui.ECommonsDebugUIPlugin;
 
 
-public class ECommonsDebugUIResources {
+@NonNullByDefault
+public class ECommonsDebugUIResources extends UIResources {
 	
 	
 	private static final String NS= "org.eclipse.statet.ecommons.debug"; //$NON-NLS-1$
@@ -46,19 +46,9 @@
 	public static final ECommonsDebugUIResources INSTANCE= new ECommonsDebugUIResources();
 	
 	
-	private final ImageRegistry registry;
-	
-	
 	private ECommonsDebugUIResources() {
-		this.registry= ECommonsDebugUIPlugin.getInstance().getImageRegistry();
+		super(ECommonsDebugUIPlugin.getInstance().getImageRegistry());
 	}
 	
-	public ImageDescriptor getImageDescriptor(final String id) {
-		return this.registry.getDescriptor(id);
-	}
-	
-	public Image getImage(final String id) {
-		return this.registry.get(id);
-	}
 	
 }
diff --git a/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/mpbv/BrowserDropAdapter.java b/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/mpbv/BrowserDropAdapter.java
index 8b3ff5c..8678b5b 100644
--- a/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/mpbv/BrowserDropAdapter.java
+++ b/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/mpbv/BrowserDropAdapter.java
@@ -14,7 +14,7 @@
 
 package org.eclipse.statet.ecommons.ui.mpbv;
 
-import java.io.File;
+import java.nio.file.Path;
 
 import org.eclipse.swt.browser.Browser;
 import org.eclipse.swt.dnd.DND;
@@ -72,13 +72,16 @@
 	
 	@Override
 	public void drop(final DropTargetEvent event) {
-		final String[] files= (String[]) event.data;
-		if (files == null || files.length == 0) {
+		final String[] urls= (String[])event.data;
+		final String url0= (urls != null && urls.length > 0) ? urls[0] : null;
+		if (url0 == null) {
 			return;
 		}
 		try {
-			final File f= new File(files[0]);
-			this.browser.setUrl(f.toURL().toExternalForm());
+			final Path path= Path.of(url0);
+			if (path.isAbsolute()) {
+				this.browser.setUrl(path.toUri().toString());
+			}
 		}
 		catch (final Exception e) {}
 	}
diff --git a/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/workbench/IWorkbenchPerspectiveElements.java b/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/workbench/IWorkbenchPerspectiveElements.java
index 2db2794..d06d316 100644
--- a/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/workbench/IWorkbenchPerspectiveElements.java
+++ b/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/workbench/IWorkbenchPerspectiveElements.java
@@ -21,8 +21,6 @@
 	
 	
 	String PROJECT_EXPLORER_VIEW = IPageLayout.ID_PROJECT_EXPLORER;
-	@SuppressWarnings("deprecation")
-	String RESOURCE_NAVIGATOR_VIEW = IPageLayout.ID_RES_NAV;
 	
 	String TASKS_VIEW = IPageLayout.ID_TASK_LIST;
 	String PROBLEM_VIEW = IPageLayout.ID_PROBLEM_VIEW;