Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Possible to avoid loading images twice?
Possible to avoid loading images twice? [message #559196] Wed, 15 September 2010 18:22 Go to next message
Eclipse UserFriend
I have an icon that I want to use for a view (i.e. appear in the tab), and also in certain table cells. For former, I need to reference the icon in the plugin.xml. For latter, I need to add the icon to an ImageRegistry that is managed by the plugin.

Is Eclipse smart enough to not load the image twice? Or is there another solution that avoids loading the image twice? Would be neat if I could declare all my resources in the plugin.xml rather than having to manage them explicitly with ImageRegistries etc...
Re: Possible to avoid loading images twice? [message #559340 is a reply to message #559196] Thu, 16 September 2010 07:44 Go to previous message
Eclipse UserFriend
Eric Jain wrote:
> I have an icon that I want to use for a view (i.e. appear in the tab),
> and also in certain table cells. For former, I need to reference the
> icon in the plugin.xml. For latter, I need to add the icon to an
> ImageRegistry that is managed by the plugin.
>
> Is Eclipse smart enough to not load the image twice? Or is there another
> solution that avoids loading the image twice? Would be neat if I could
> declare all my resources in the plugin.xml rather than having to manage
> them explicitly with ImageRegistries etc...
>

Most Extension Points that load an icon use something like
AbstractUIPlugin.imageDescriptorFromPlugin(extendingPluginId , icon).

Then when the Image is needed, they use something like:

LocalResourceManager localManager
= new LocalResourceManager(JFaceResources.getResources());
Image image = localManager.createImageWithDefault(imageDescriptor)


When the object managing the image (label provider, decorator,
contribution item) is disposed it does a localManager.dispose() to clean
up any images it created. They are reference counted and managed by the
main JFaceResources manager.

You can do the same, and the image will only be loaded once.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
Previous Topic:Problems extending org.eclipse.compare
Next Topic:How to externalize strings for fragment's resources
Goto Forum:
  


Current Time: Wed Jul 23 02:59:02 EDT 2025

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

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

Back to the top