Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create static variant of ImageDescriptor.imageDescriptorFromURI() #2416

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.jface/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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.100.qualifier
Bundle-Version: 3.36.0.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.jface,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -205,25 +205,50 @@ 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)}. <em>Important</em>
* 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) {
if (uriIconPath == null) {
return getMissingImageDescriptor();
}
try {
return ImageDescriptor.createFromURL(new URL(uriIconPath.toString()));
} catch (MalformedURLException | NullPointerException e) {
return ImageDescriptor.createFromURL(uriIconPath.toURL());
} 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);
Expand Down
Loading