com.tssap.util.ui.image
Class SapIdeUtilImages

java.lang.Object
  |
  +--com.tssap.util.ui.image.SapIdeUtilImages

public class SapIdeUtilImages
extends java.lang.Object

This central utility class implements several methods that return either image descriptors or SWT images for direct display in the UI. You can access a method from this class whether you are using Workbench icons from the Eclipse standard, SAP standard icons, or your graphics from a specific plug-in.

In the SWT program model there is a difference between images (SWT images) and image descriptors

See Also:
ImageDescriptor, Image, org.eclipse.jface.resource.ImageRegistry

Field Summary
static java.lang.String DEFAULT_ICONS_DIRECTORY
           
 
Constructor Summary
SapIdeUtilImages()
           
 
Method Summary
static org.eclipse.swt.graphics.Image createImageFromIconsDirectory(org.eclipse.core.runtime.IPluginDescriptor pluginDescriptor, java.lang.String filePath)
          This method returns an SWT image, if you specify a plug-in descriptor and the name of the graphic file you want.
static org.eclipse.swt.graphics.Image createImageFromIconsDirectory(java.lang.String pluginId, java.lang.String filePath)
           
static org.eclipse.jface.resource.ImageDescriptor getImageDescriptorFromIconsDirectory(org.eclipse.core.runtime.IPluginDescriptor pluginDescriptor, java.lang.String filePath)
          This method does basically the same as createImageFromIconsDirectory.
static org.eclipse.jface.resource.ImageDescriptor getImageDescriptorFromIconsDirectory(java.lang.String pluginId, java.lang.String filePath)
           
static org.eclipse.swt.graphics.Image getImageFromIconsDirectory(org.eclipse.core.runtime.IPluginDescriptor pluginDescriptor, java.lang.String filePath)
          This method does basically the same as createImageFromIconsDirectory.
static org.eclipse.swt.graphics.Image getImageFromIconsDirectory(java.lang.String pluginId, java.lang.String filePath)
           
static org.eclipse.swt.graphics.Image getSapImage(ISapImage sapImage)
          This method returns an image instance of a standard SAP icon.
static org.eclipse.jface.resource.ImageDescriptor getSapImageDescriptor(ISapImage sapImage)
          This method does basically the same as getSapImage.
static org.eclipse.swt.graphics.Image getWorkbenchImage(java.lang.String symbolicName)
          This method returns an image instance of an Eclipse Workbench standard icon.
static org.eclipse.jface.resource.ImageDescriptor getWorkbenchImageDescriptor(java.lang.String symbolicName)
          This method returns an image descriptor of an Eclipse Workbench standard icon.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ICONS_DIRECTORY

public static final java.lang.String DEFAULT_ICONS_DIRECTORY
Constructor Detail

SapIdeUtilImages

public SapIdeUtilImages()
Method Detail

getWorkbenchImageDescriptor

public static org.eclipse.jface.resource.ImageDescriptor getWorkbenchImageDescriptor(java.lang.String symbolicName)
This method returns an image descriptor of an Eclipse Workbench standard icon.
Parameters:
symbolicName - symbolic name defined in IWorkbenchGraphicConstants
Returns:
image descriptor of image
See Also:
getWorkbenchImage(String)

getWorkbenchImage

public static org.eclipse.swt.graphics.Image getWorkbenchImage(java.lang.String symbolicName)
This method returns an image instance of an Eclipse 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().

Example:

 	Image myImage = SapIdeUtilImages.getWorkbenchImage(ISapSharedImages.IMG_OBJ_FOLDER);
 
Parameters:
symbolicName - symbolic name defined in IWorkbenchGraphicConstants
Returns:
created image (does not need to be disposed !)
See Also:
org.eclipse.ui.internal.IWorkbenchGraphicConstants

createImageFromIconsDirectory

public static org.eclipse.swt.graphics.Image createImageFromIconsDirectory(org.eclipse.core.runtime.IPluginDescriptor pluginDescriptor,
                                                                           java.lang.String filePath)
This method returns an SWT image, if you specify a plug-in descriptor and the name of the graphic file you want. However, this only works if the graphic file is stored in the icons folder of the addressed plug-in (that is, the image provider). Since the location of the graphic file is ascertained relative to the plug-in, you must specify the plug-in descriptor as a parameter. A plug-in descriptor gets the information about the plug-in that is stored in the associated plugin.xml file.

Exammple:

 Image myImage = SapIdeUtilImages.createImageFromIconsDirectory(MyPlugin.getInstance().getDescriptor(),"xyz/my_icon.gif"));
 
Note: The image has to be disposed afterwards !
Parameters:
pluginDescriptor - the descriptor of the plugin
filePath - path to image file (without /icons prefix which is added automatically).
Returns:
the created image.

createImageFromIconsDirectory

public static org.eclipse.swt.graphics.Image createImageFromIconsDirectory(java.lang.String pluginId,
                                                                           java.lang.String filePath)
See Also:
Plugin descriptor is computed by using the given id.

getImageDescriptorFromIconsDirectory

public static org.eclipse.jface.resource.ImageDescriptor getImageDescriptorFromIconsDirectory(org.eclipse.core.runtime.IPluginDescriptor pluginDescriptor,
                                                                                              java.lang.String filePath)
This method does basically the same as createImageFromIconsDirectory. The physical image is not created here, but only the image descriptor of the image is computed.
Parameters:
pluginDescriptor - the descriptor of the plugin
filePath - path to image file (without /icons prefix which is added automatically).
Returns:
ImageDescriptor
See Also:
createImageFromIconsDirectory(IPluginDescriptor, String)

getImageDescriptorFromIconsDirectory

public static org.eclipse.jface.resource.ImageDescriptor getImageDescriptorFromIconsDirectory(java.lang.String pluginId,
                                                                                              java.lang.String filePath)
See Also:
Plugin descriptor is computed by using the given id.

getImageFromIconsDirectory

public static org.eclipse.swt.graphics.Image getImageFromIconsDirectory(org.eclipse.core.runtime.IPluginDescriptor pluginDescriptor,
                                                                        java.lang.String filePath)
This method does basically the same as createImageFromIconsDirectory.

The difference is, that the created image is stored in the image registry!

Parameters:
pluginDescriptor - the descriptor of the plugin
filePath - path to image file (without /icons prefix which is added automatically).
Returns:
Image
See Also:
createImageFromIconsDirectory(IPluginDescriptor, String)

getImageFromIconsDirectory

public static org.eclipse.swt.graphics.Image getImageFromIconsDirectory(java.lang.String pluginId,
                                                                        java.lang.String filePath)
See Also:
Plugin descriptor is computed by using the given id.

getSapImage

public static org.eclipse.swt.graphics.Image getSapImage(ISapImage sapImage)
This method returns an image instance of a standard SAP icon. Every standard SAP icon has an associated constant stored in the SapImage class. You can then obtain the icon you want from this resource pool using the constant. The getSapImage method first access an image registry and creates a new instance of the image if there is none available in this registry. If the access to the physical resource fails, a default image is returned. It is displayed as a red rectangle in the UI.

Example:

 myToolbar.addToolBarButton(SapIdeUtilImages.getSapImage(SapImage.ICON_REFERENCE_LIST));
 
Parameters:
sapImage - symbolic constant of SapImage (defined in SapImage)
Returns:
the sap image
See Also:
SapImage

getSapImageDescriptor

public static org.eclipse.jface.resource.ImageDescriptor getSapImageDescriptor(ISapImage sapImage)
This method does basically the same as getSapImage. The physical image is not created here, but only the image descriptor of the image is computed.
Parameters:
sapImage - symbolic constant of SapImage (defined in SapImage)
Returns:
the image descriptor
See Also:
SapImage, SapIdeUtilImages#getSapImage(SapImage)


Copyright © 2005 SAP AG. All Rights Reserved.