[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.newcomer] Re: Deprecated Platform.find
|
- From: Ric Wright <riwright@xxxxxxxxx>
- Date: Sun, 22 Feb 2009 10:02:54 -0800
- Newsgroups: eclipse.newcomer
- Organization: EclipseCorner
- Thread-index: AcmVFQ6v4SnmL4tFIEC6tebFEpbcAgAArn4+
- Thread-topic: Deprecated Platform.find
- User-agent: Microsoft-Entourage/12.15.0.081119
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
>