Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » [HiDPI icons] How to migrate from ImageDescriptor#createFromFile to #createFromURL?
[HiDPI icons] How to migrate from ImageDescriptor#createFromFile to #createFromURL? [message #1740762] Thu, 18 August 2016 10:41 Go to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Hi,

I want to make use of the HiDPI icon support added in Neon. Now, my code creates ImageDescriptors using ImageDescriptor#createFromFile(Class, URL) rather than ImageDescriptor#createFromURL(URL). Unfortunately, the former method does not search for available HiDPI icons; only the latter does (as documented in the Neon release notes).

Hence, I have to migrate from createFromFile(Class, URL) to createFromURL(URL), but am at a loss as to how to convert my Class + URL to an absolute URL of the form bundleentry://.../path apprently required by ImageDescriptor#createFromURL(URL).

Any pointers on how to do this migration are hence greatly appreciated.

Andreas
Re: [HiDPI icons] How to migrate from ImageDescriptor#createFromFile to #createFromURL? [message #1740766 is a reply to message #1740762] Thu, 18 August 2016 11:27 Go to previous messageGo to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Made some progress using org.osgi.framework.FrameworkUtil#getBundle(Class) and org.eclipse.ui.internal.util.BundleUtility#find(Bundle, String). The latter is unfortunately marked as internal. If someone has an idea how to avoid BundleUtility, I'd like to hear it.
Re: [HiDPI icons] How to migrate from ImageDescriptor#createFromFile to #createFromURL? [message #1740777 is a reply to message #1740762] Thu, 18 August 2016 13:26 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 772
Registered: January 2012
Senior Member

I think you must mean ImageDescriptor.createFromFile(Class, String), not URL.

If your class a.b.c.C is in bundle B, and the image name is F, then use:

platform:/plugin/B/a/b/c/F


That's assuming your bundle follows the normal layout, where the classes are laid out from the root of the bundle.

Brian.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: [HiDPI icons] How to migrate from ImageDescriptor#createFromFile to #createFromURL? [message #1740778 is a reply to message #1740777] Thu, 18 August 2016 13:39 Go to previous messageGo to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Brian de Alwis wrote on Thu, 18 August 2016 09:26
I think you must mean ImageDescriptor.createFromFile(Class, String), not URL.

Right. That was a copy-and-paste error.

Quote:
If your class a.b.c.C is in bundle B, and the image name is F, then use:

platform:/plugin/B/a/b/c/F


That's assuming your bundle follows the normal layout, where the classes are laid out from the root of the bundle.

I was hoping to avoid hard-coding the bundle name (in addition to the path); createFromFile's use of Class instances is very convenient in this respect.

But you are right: platform:/ URIs work, although they are less convenient than using createFromFile.

FWIW, is there any reason why createFromFile doesn't search for @2x images? That ImageDescriptor#createFromURL is the only method that got HiDPI-enabled with Neon seems like an oversight to me.
Re: [HiDPI icons] How to migrate from ImageDescriptor#createFromFile to #createFromURL? [message #1740816 is a reply to message #1740778] Thu, 18 August 2016 17:05 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 772
Registered: January 2012
Senior Member

I don't know why createFromFile() was not updated. Patches welcome, of course Smile

Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: [HiDPI icons] How to migrate from ImageDescriptor#createFromFile to #createFromURL? [message #1740858 is a reply to message #1740816] Fri, 19 August 2016 07:29 Go to previous message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Brian de Alwis wrote on Thu, 18 August 2016 13:05
I don't know why createFromFile() was not updated. Patches welcome, of course Smile

Of course. Not sure whether I'm familiar enough with the ImageDescriptor code to do this, though.

But I've filled Bug 499964 at least, so this issue doesn't get lost.
Previous Topic:[Databinding/E4] Binding of nested properties
Next Topic:Add Scroller to a long JFace MenuManager
Goto Forum:
  


Current Time: Sun Sep 23 21:34:26 GMT 2018

Powered by FUDForum. Page generated in 0.02534 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top