diff --git a/bundles/org.eclipse.jface/META-INF/MANIFEST.MF b/bundles/org.eclipse.jface/META-INF/MANIFEST.MF index 47bd323cd19..c0a6a166d28 100644 --- a/bundles/org.eclipse.jface/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.jface/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jface;singleton:=true -Bundle-Version: 3.35.200.qualifier +Bundle-Version: 3.36.0.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.jface, diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/ImageDescriptor.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/ImageDescriptor.java index 1a529975466..23071678e1f 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/ImageDescriptor.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/ImageDescriptor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2023 IBM Corporation and others. + * Copyright (c) 2000, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -205,25 +205,47 @@ public static ImageDescriptor createFromURLSupplier(boolean useMissingImage, Sup } /** - * Convenient method to create an ImageDescriptor from an URI + * Convenient method to create an ImageDescriptor from an URI. * - * Delegates to ImageDescriptor createFromURL + * Delegates to {@link ImageDescriptor#createFromURL(URL)}. Important + * This method should only be used when it's guaranteed that the given + * {@link URI} is also a valid {@link URL}, in order to avoid the + * {@link MalformedURLException} thrown by {@link URI#toURL()}. + * + * If the URI is {@code null} or not a valid {@link URL}, then an image from + * {@link #getMissingImageDescriptor()} will be returned. * * @param uriIconPath The URI of the image file. * @return a new image descriptor * - * @since 3.19 + * @since 3.36 */ - public ImageDescriptor imageDescriptorFromURI(URI uriIconPath) { + public static ImageDescriptor createFromURI(URI uriIconPath) { try { - return ImageDescriptor.createFromURL(new URL(uriIconPath.toString())); - } catch (MalformedURLException | NullPointerException e) { + return ImageDescriptor.createFromURL(uriIconPath != null ? uriIconPath.toURL() : null); + } catch (MalformedURLException e) { // return the missing image placeholder to indicate // the incorrect call without interfering with the user flow return getMissingImageDescriptor(); } } + /** + * Convenient method to create an ImageDescriptor from an URI + * + * Delegates to ImageDescriptor createFromURL + * + * @param uriIconPath The URI of the image file. + * @return a new image descriptor + * + * @since 3.19 + * @deprecated Use {@link #createFromURI(URI)} instead. + */ + @Deprecated(since = "3.36", forRemoval = true) + public ImageDescriptor imageDescriptorFromURI(URI uriIconPath) { + return createFromURI(uriIconPath); + } + @Override public Object createResource(Device device) throws DeviceResourceException { Image result = createImage(false, device);