Skip to content

Commit d58f6ec

Browse files
committed
Create static variant of ImageDescriptor.imageDescriptorFromURI()
This method is intended to be used as a wrapper for createFromURL() to avoid having to deal with the checked MalformedURLException. However, this method is effectively unusable, as it requires the user to already have an instance of the ImageDescriptor they want to created. Instead, create a new, static createFromURI() method, mark the old method as deprecated and internally delegate to the new method. The old method was created as a response to Bug 559656 [1], in order to match the signature of IResourceUtilities. But because the latter is accessed via an OSGi service, it doesn't need to be static. Which is something that doesn't really work for image descriptors. [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=559656
1 parent 929564c commit d58f6ec

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

bundles/org.eclipse.jface/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.jface;singleton:=true
5-
Bundle-Version: 3.35.100.qualifier
5+
Bundle-Version: 3.36.0.qualifier
66
Bundle-Vendor: %providerName
77
Bundle-Localization: plugin
88
Export-Package: org.eclipse.jface,

bundles/org.eclipse.jface/src/org/eclipse/jface/resource/ImageDescriptor.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2023 IBM Corporation and others.
2+
* Copyright (c) 2000, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -212,9 +212,9 @@ public static ImageDescriptor createFromURLSupplier(boolean useMissingImage, Sup
212212
* @param uriIconPath The URI of the image file.
213213
* @return a new image descriptor
214214
*
215-
* @since 3.19
215+
* @since 3.36
216216
*/
217-
public ImageDescriptor imageDescriptorFromURI(URI uriIconPath) {
217+
public static ImageDescriptor createFromURI(URI uriIconPath) {
218218
try {
219219
return ImageDescriptor.createFromURL(new URL(uriIconPath.toString()));
220220
} catch (MalformedURLException | NullPointerException e) {
@@ -224,6 +224,22 @@ public ImageDescriptor imageDescriptorFromURI(URI uriIconPath) {
224224
}
225225
}
226226

227+
/**
228+
* Convenient method to create an ImageDescriptor from an URI
229+
*
230+
* Delegates to ImageDescriptor createFromURL
231+
*
232+
* @param uriIconPath The URI of the image file.
233+
* @return a new image descriptor
234+
*
235+
* @since 3.19
236+
* @deprecated Use {@link #createFromURI(URI)} instead.
237+
*/
238+
@Deprecated(since = "3.36", forRemoval = true)
239+
public ImageDescriptor imageDescriptorFromURI(URI uriIconPath) {
240+
return createFromURI(uriIconPath);
241+
}
242+
227243
@Override
228244
public Object createResource(Device device) throws DeviceResourceException {
229245
Image result = createImage(false, device);

0 commit comments

Comments
 (0)