The Workbench plug-in from Eclipse offers a set of standard icons used
in different places in the Workbench, such as in toolbars or as action icons in
views.
You will almost certainly want to use some of these icons in your
plug-in, particularly those used to represent Workbench resources like folders,
files, and projects.
The getWorkbenchImage() method implemented by the SapIdeUtilImages UI class allows
you to access these image resources easily.
|
public
static Image getWorkbenchImage(String symbolicName) |
|
|
|
This method returns an image instance of a
Workbench standard icon. To identify the
image resource, symbolicName is passed as a string. This name is derived from the constant as it was
defined in the Workbench interface ISharedImages. getWorkbenchImage() fetches these image instances
from the share pool in the Workbench Registry. This
means that they do not need to be
released using dispose(). |
Procedure
1. Identify appropriate icons
The best way to identify icons is using the constant name specified in ISharedImages.
![]()
The screen shot
below displays all these standard icons:
![]()
2. Create image instances
To create an image object, simply call the getWorkbenchImage() method from the UI Toolkit class SapIdeUtilImages. To
identify the resource, specify the appropriate registry constant as a
parameter.
|
Image myImage =
SapIdeUtilImages.getWorkbenchImage(
ISapSharedImages.<IMAGE_REGISTRY_CONSTANT>); |
Example
The following lines of code display three standard Eclipse icons as
elements in a toolbar. The result looks like this:
![]()
|
myToolbar.addToolBarButton(SapIdeUtilImages.getWorkbenchImage( ISapSharedImages.IMG_OBJ_FOLDER)); myToolbar.addToolBarButton(SapIdeUtilImages.getWorkbenchImage( ISapSharedImages.IMG_OBJ_FILE)); myToolbar.addToolBarButton(SapIdeUtilImages.getWorkbenchImage( ISapSharedImages.IMG_OBJ_PROJECT)); |