Skip to content

Commit 6852f28

Browse files
committed
Handle both the nbres and nbresloc protocols in the new ImageUtilities.loadImage(URI) method.
1 parent a60c0f8 commit 6852f28

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

platform/openide.util.ui/src/org/openide/util/ImageUtilities.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,17 @@ public static final Image loadImage(String resource, boolean localized) {
211211
}
212212

213213
/**
214-
* Load an image from a URI/URL. If the URI uses the {@code nbresloc} protocol, it is loaded
215-
* using the resource loading mechanism provided by {@link #loadImage(java.lang.String)}. This
214+
* Load an image from a URI/URL. If the URI uses the {@code nbresloc} or {@code nbres}
215+
* protocols, it is loaded using the resource loading mechanism provided by
216+
* {@link #loadImage(String,boolean)}, with and without localization, respectively. This
216217
* includes handling of SVG icons and dark mode variations.
217218
*
218219
* <p>This method is intended for use only when a URL or URI must be used instead of a resource
219220
* path, e.g. in the implementation of pre-existing NetBeans APIs. External URLs should be
220221
* avoided, as they may be disallowed in the future. Do not use this method for new code; prefer
221222
* image loading by resource paths instead (e.g. {@link #loadImage(String)}).
222223
*
223-
* @param uri the URI of the image, possibly with the nbresloc protocol
224+
* @param uri the URI of the image, possibly with the nbresloc or nbres protocol
224225
* @return the loaded image, or either null or an uninitialized image if the image was not
225226
* available
226227
* @since 7.36
@@ -230,6 +231,9 @@ public static final Image loadImage(URI uri) {
230231
String scheme = uri.getScheme();
231232
if (scheme.equals("nbresloc")) { // NOI18N
232233
// Apply our dedicated handling logic. Omit the initial slash of the path.
234+
return loadImage(uri.getPath().substring(1), true);
235+
} else if (scheme.equals("nbres")) { // NOI18N
236+
// Same except with localized = false.
233237
return loadImage(uri.getPath().substring(1), false);
234238
} else {
235239
if (!(scheme.equals("file") ||

0 commit comments

Comments
 (0)