Jump to: navigation, search

Difference between revisions of "FAQ How do I use images defined by other plug-ins?"

 
m
 
Line 1: Line 1:
In general, you should not rely on images defined in other plug-ins as they
+
In general, you should not rely on images defined in other plug-ins as they could be changed or removed at any time.  The exception to this rule is an image that has been declared by a plug-in as an API.  The convention is to create an interface called <tt>ISharedImages</tt> that defines IDs for all images that you want to declare as API. Several plug-ins, including <tt>org.eclipse.ui.workbench</tt>, <tt>org.eclipse.jdt.ui</tt>, and <tt>org.eclipse.team.ui</tt>, declare such an <tt>ISharedImages</tt> class.  Here is an example snippet that options the folder icon from the workbench&#146;s shared image API:
could be changed or removed at any time.  The exception
+
 
to this rule is an image that has been declared by a plug-in as an API.  The  
+
convention is to create an interface called <tt>ISharedImages</tt> that defines
+
IDs for all images that you want to declare as API. Several plug-ins,  
+
including <tt>org.eclipse.ui.workbench</tt>, <tt>org.eclipse.jdt.ui</tt>,  
+
and <tt>org.eclipse.team.ui</tt>,
+
declare such an <tt>ISharedImages</tt> class.  Here is an example snippet
+
that options the folder icon from the workbench&#146;s shared image API:
+
 
<pre>
 
<pre>
 
   IWorkbench workbench = PlatformUI.getWorkbench();
 
   IWorkbench workbench = PlatformUI.getWorkbench();
Line 14: Line 7:
 
</pre>
 
</pre>
  
If you want to share images from your plug-in as API, you should
+
If you want to share images from your plug-in as API, you should define your own <tt>ISharedImages</tt> class with constants for all the images you want to make public.
define your own <tt>ISharedImages</tt> class with constants for all
+
the images you want to make public.
+
  
 
== See Also: ==
 
== See Also: ==
 +
*[[FAQ How do I create an image registry for my plug-in?]]
  
[[FAQ_How_do_I_create_an_image_registry_for_my_plug-in%3F]]
+
{{Template:FAQ_Tagline}}
 
+
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
+

Latest revision as of 20:54, 30 May 2006

In general, you should not rely on images defined in other plug-ins as they could be changed or removed at any time. The exception to this rule is an image that has been declared by a plug-in as an API. The convention is to create an interface called ISharedImages that defines IDs for all images that you want to declare as API. Several plug-ins, including org.eclipse.ui.workbench, org.eclipse.jdt.ui, and org.eclipse.team.ui, declare such an ISharedImages class. Here is an example snippet that options the folder icon from the workbench’s shared image API:

   IWorkbench workbench = PlatformUI.getWorkbench();
   ISharedImages images = workbench.getSharedImages();
   Image image = images.getImage(ISharedImages.IMG_OBJ_FOLDER);

If you want to share images from your plug-in as API, you should define your own ISharedImages class with constants for all the images you want to make public.

See Also:


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.