[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.newcomer] Re: Deprecated Platform.find

You've got it right. FileLocator is the blessed replacement for the Platform.find* methods.
--



Ric Wright wrote:
Googling around, I found this code:

@Override
protected void initializeImageRegistry(ImageRegistry registry)
{ super.initializeImageRegistry(registry);
Bundle bundle = Platform.getBundle(PLUGIN_ID);
ImageDescriptor myImage =
ImageDescriptor.createFromURL(FileLocator.find(bundle, new Path(
"icons/sample.gif"), null));
registry.put(IMAGE_ID, myImage);
}


Which Eclipse is happier with.  Is this the blessed way of doing this?  It
works, anyway.  And, foolish me, it wasn't hitting the breakpoint because
Eclipse was being "lazy" and only called the routine when I actually tried
to load the image in question.

Ric

On 2/22/09 9:43 AM, in article C5C6CEBB.1C4E1%riwright@xxxxxxxxx, "Ric
Wright" <riwright@xxxxxxxxx> wrote:

I wanted to learn how to use the ImageRegistry with a plugin.  I found this
in Eclipsepedia (at
http://wiki.eclipse.org/FAQ_How_do_I_create_an_image_registry_for_my_plug-in
%3F):

   public class ExamplesPlugin extends AbstractUIPlugin {
      public static final String PLUGIN_ID = "org.eclipse.faq.examples";
      public static final String IMAGE_ID = "sample.image";
      ...
      protected void initializeImageRegistry(ImageRegistry registry) {
         Bundle bundle = Platform.getBundle(PLUGIN_ID);
         IPath path = new Path("icons/sample.gif");
         URL url = Platform.find(bundle, path);
         ImageDescriptor desc = ImageDescriptor.createFromURL(url);
         registry.put(IMAGE_ID, desc);
      }
   }

However, if I enter the code in my plugin, Eclipse tells me that
Platform.find is deprecated.  Moreover, the article says
initializeImageRegistry() will be called when the plugin is initialized, but
that doesn't appear to be true - a breakpoint there is never hit.

What's the right way to do this?

TIA, Ric