Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Question about ImageDescriptor
Question about ImageDescriptor [message #775900] Fri, 06 January 2012 22:25 Go to next message
Josh Davis is currently offline Josh DavisFriend
Messages: 20
Registered: August 2011
Junior Member
Is it possible to get a URL from an ImageDescriptor?

I am asking this because we have a bunch of ImageDescriptors in our code that I would like to use when setting the image on a toolbar (this is the e4 MToolBar)

When I create a new MToolItem for the toolbar I have to set the image using setIconURI(String). I haven't been able to find a way to get the URL from a ImageDescriptor. It looks like there is a URLImageDescriptor but its a protected class and as far as I can tell there is no way to get that underlying URL.
Re: Question about ImageDescriptor [message #777012 is a reply to message #775900] Mon, 09 January 2012 16:42 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Depends on where you are starting from. A valid URL for an image that can be used in extension attributes, for example, is platform:/plugin/<plugin.id>/iconPath/icon.png See http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fplatform-scheme-uri.html

If the only thing you have is the URLImageDescriptor, there's no supported API to turn that back into a string, especially a string that can be persisted reliably. We hacked through it in eclipse 4.2 using org.eclipse.ui.internal.menus.MenuHelper.getIconURI(ImageDescriptor, IEclipseContext)

PW




Re: Question about ImageDescriptor [message #777014 is a reply to message #777012] Mon, 09 January 2012 16:46 Go to previous message
Josh Davis is currently offline Josh DavisFriend
Messages: 20
Registered: August 2011
Junior Member
Can I use the MenuHelper?
I couldn't find getIconURI(ImageDescriptor, IEclipseContext)

I did find this...
MenuHelper.getImageUrl(imageDescriptor);

I get the discourage access warning when I try to use it.


This is what I am trying to do. I need to take the ImageDescriptor and convert it to a url so that I can use it to create a MMenuItem.

Edit: getIconURI(...) is there, I just didn't see at first because it is package-private

[Updated on: Mon, 09 January 2012 16:59]

Report message to a moderator

Previous Topic:I can't dismiss the content proposal pop-up
Next Topic:JFace close button
Goto Forum:
  


Current Time: Sat Dec 20 18:51:04 GMT 2014

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

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