Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » What is the rigth way of getting an ImageDescriptor?
What is the rigth way of getting an ImageDescriptor? [message #184568] Sun, 25 January 2004 11:51 Go to next message
Eclipse UserFriend
Originally posted by: IanPLang.yahoo.com

I am new to Eclipse and am experimenting with RCP - very cool. Now that I
have done some work on menus and a view I want to get my applicaiton image
in the title bar. If I can load the image everthing is fine. The trouble
is I cannot seem to get an ImageDescrptor in a good way. At first I used
a hard coded path just to see if I could get images in the app's title bar
- worked fine. Then I looked around to find the right way to load them
and found an article "Using Images in the Eclipse UI". I decided that the
image registry would not be appropriate for these images since they will
be used once for the application's title bar. So I decided to use code
like this (as recomended by the article):
private static ImageDescriptor image;
static {
URL url = null;
try {
url = new URL(MyPlugin.getInstance().getDescriptor().getInstallURL(),
"images/my_action.gif");
} catch (MalformedURLException e) {
}
image = ImageDescriptor.createFromURL(url);
}

I looked at the documentation for the methods used and found that
Plugin.getDescriptor() is going to be depricated - so much for that.

Then I poked around the API docs and found
AbstractUIPlugin.imageDescriptorFromPlugin which seemed to fit the bill.
So I tried code like this:
ImageDescriptor descAppImage16 =
AbstractUIPlugin.imageDescriptorFromPlugin (MY_PLUGIN_ID,
"images/MyApp16.gif"); //$NON-NLS-1$

Where the images directory is under my plug-in's directory. It did not
work! I looked at the contents of the resulting URLImageDescriptor and
found its path was "/plugin/com.lang.app_0.1.0/images/MyApp16.gif". Which
is good except for the "0.1.0" stuck in there. I tried renaming my
plug-in's folder to add the "0.1.0" but that did not work either.

What is wrong with what I am doing? What is the right way?

Thanks,

IL
Re: What is the rigth way of getting an ImageDescriptor? [message #185418 is a reply to message #184568] Tue, 27 January 2004 09:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: IanPLang.yahoo.com

I found out what was wrong myself: When I saw the "_0.1.0" I stopped
reading. Closer inspection reveled my mistake. I had created a "icons"
directory on disk and was trying to load from a non existent "images"
directory - oops.

So I am assuming that AbstractUIPlugin.imageDescriptorFromPlugin is the
right way to go about loading images - unless someone here tells me
different.

IL

Ian Lang wrote:

<snip>
> Then I poked around the API docs and found
> AbstractUIPlugin.imageDescriptorFromPlugin which seemed to fit the bill.
> So I tried code like this:
> ImageDescriptor descAppImage16 =
> AbstractUIPlugin.imageDescriptorFromPlugin (MY_PLUGIN_ID,
> "images/MyApp16.gif"); //$NON-NLS-1$

> Where the images directory is under my plug-in's directory. It did not
> work! I looked at the contents of the resulting URLImageDescriptor and
> found its path was "/plugin/com.lang.app_0.1.0/images/MyApp16.gif". Which
> is good except for the "0.1.0" stuck in there. I tried renaming my
> plug-in's folder to add the "0.1.0" but that did not work either.

> What is wrong with what I am doing? What is the right way?
Re: What is the rigth way of getting an ImageDescriptor? [message #185774 is a reply to message #184568] Tue, 27 January 2004 17:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: John_Arthorne.oti.com_

You can continue to use the code from the article. If this API is
deprecated it will happen *after* the Eclipse 3.0 release. Even then,
it is likely it won't actually be removed for a long time (if ever).
Nearer to the Eclipse 3.0 release I will update the article with the
"official" recommended approach for 3.0.
--

Ian Lang wrote:
> I am new to Eclipse and am experimenting with RCP - very cool. Now that I
> have done some work on menus and a view I want to get my applicaiton image
> in the title bar. If I can load the image everthing is fine. The trouble
> is I cannot seem to get an ImageDescrptor in a good way. At first I used
> a hard coded path just to see if I could get images in the app's title bar
> - worked fine. Then I looked around to find the right way to load them
> and found an article "Using Images in the Eclipse UI". I decided that the
> image registry would not be appropriate for these images since they will
> be used once for the application's title bar. So I decided to use code
> like this (as recomended by the article):
> private static ImageDescriptor image;
> static {
> URL url = null;
> try {
> url = new URL(MyPlugin.getInstance().getDescriptor().getInstallURL(),
> "images/my_action.gif");
> } catch (MalformedURLException e) {
> }
> image = ImageDescriptor.createFromURL(url);
> }
>
> I looked at the documentation for the methods used and found that
> Plugin.getDescriptor() is going to be depricated - so much for that.
>
> Then I poked around the API docs and found
> AbstractUIPlugin.imageDescriptorFromPlugin which seemed to fit the bill.
> So I tried code like this:
> ImageDescriptor descAppImage16 =
> AbstractUIPlugin.imageDescriptorFromPlugin (MY_PLUGIN_ID,
> "images/MyApp16.gif"); //$NON-NLS-1$
>
> Where the images directory is under my plug-in's directory. It did not
> work! I looked at the contents of the resulting URLImageDescriptor and
> found its path was "/plugin/com.lang.app_0.1.0/images/MyApp16.gif". Which
> is good except for the "0.1.0" stuck in there. I tried renaming my
> plug-in's folder to add the "0.1.0" but that did not work either.
>
> What is wrong with what I am doing? What is the right way?
>
> Thanks,
>
> IL
>
>
>
Re: What is the rigth way of getting an ImageDescriptor? [message #185798 is a reply to message #185774] Tue, 27 January 2004 19:19 Go to previous message
Eclipse UserFriend
Originally posted by: IanPLang.yahoo.com

Thanks for the info - I look forward to reading the update.

IL

John Arthorne wrote:

> You can continue to use the code from the article. If this API is
> deprecated it will happen *after* the Eclipse 3.0 release. Even then,
> it is likely it won't actually be removed for a long time (if ever).
> Nearer to the Eclipse 3.0 release I will update the article with the
> "official" recommended approach for 3.0.
> --
Previous Topic:Eclipse 3.0 M6 Update Manager
Next Topic:[ANN] CodePro v2.3.2 Release - 425+ Audit Rules & Metrics
Goto Forum:
  


Current Time: Sat May 10 12:53:29 EDT 2025

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

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

Back to the top