COSMOS ${releaseVersion} resource-modeling Project
Internal API Specification

org.eclipse.cosmos.rm.smlif.internal.editor
Class ImageManager

java.lang.Object
  extended by org.eclipse.cosmos.rm.smlif.internal.editor.ImageManager
Direct Known Subclasses:
SMLImages

public abstract class ImageManager
extends java.lang.Object

Manages the images and image descriptors implementing an efficient cache. This implementations caches these objects in a ImageRegistry instance.

Before using an instance of this class it is necessary to invoke the #initialize() method.

Since:
0.0.1

Field Summary
static java.lang.String T_LCL
           
static java.lang.String T_OBJ
           
static java.lang.String T_OVR
           
static java.lang.String T_TOOL
           
static java.lang.String T_VIEW
           
static java.lang.String T_WIZBAN
           
 
Constructor Summary
ImageManager()
           
 
Method Summary
protected  boolean add(java.lang.String key, org.eclipse.jface.resource.ImageDescriptor imageDescriptor)
          Adds an image descriptor to this image manager.
protected  org.eclipse.jface.resource.ImageDescriptor add(java.lang.String prefix, java.lang.String name)
          Creates an image descriptor for a given image directory prefix and image name adding it to the image registry.
protected  org.eclipse.jface.resource.ImageDescriptor add(java.lang.String prefixType, java.lang.String prefix, java.lang.String name)
          Creates an image descriptor for a given image directory prefix, directory type and image name adding it to the image registry.
protected abstract  void addImages()
          Subclasses are supposed to add all the images to this manager in this method implementation.
protected  void checkImages()
          Checks if the images are loaded in the cache.
protected  org.eclipse.jface.resource.ImageDescriptor createImageDescriptor(java.lang.String prefix, java.lang.String name)
          Creates an image descriptor for a given image directory prefix and image name.
 org.eclipse.swt.graphics.Image getImage(java.lang.String key)
          Returns the image associated to a key.
 org.eclipse.swt.graphics.Image getImage(java.lang.String prefixType, java.lang.String key)
          Returns the image associated to a prefix type and key.
 org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(java.lang.String key)
          Returns the image descriptor associated to a key.
 org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(java.lang.String prefixType, java.lang.String key)
          Returns the image descriptor associated to a prefix type and key.
 void initialize(java.net.URL iconBaseURL, org.eclipse.jface.resource.ImageRegistry imageRegistry)
          Initializes this image manager.
static void initializeImages(ImageManager imageManager, org.eclipse.ui.plugin.AbstractUIPlugin uiPlugin)
           
 boolean isInitialized()
          Indicates whether this image manager was initialized.
protected  java.net.URL makeIconFileURL(java.lang.String prefix, java.lang.String name)
          Creates a URL for a given image directory prefix and image name.
 void setImageDescriptors(org.eclipse.jface.action.IAction action, java.lang.String name)
          Sets all the image descriptors of a given action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

T_LCL

public static final java.lang.String T_LCL
See Also:
Constant Field Values

T_TOOL

public static final java.lang.String T_TOOL
See Also:
Constant Field Values

T_VIEW

public static final java.lang.String T_VIEW
See Also:
Constant Field Values

T_OBJ

public static final java.lang.String T_OBJ
See Also:
Constant Field Values

T_OVR

public static final java.lang.String T_OVR
See Also:
Constant Field Values

T_WIZBAN

public static final java.lang.String T_WIZBAN
See Also:
Constant Field Values
Constructor Detail

ImageManager

public ImageManager()
Method Detail

initialize

public void initialize(java.net.URL iconBaseURL,
                       org.eclipse.jface.resource.ImageRegistry imageRegistry)
Initializes this image manager. Nothing happens if this method is invoked after a previous initialization.

This method is not supposed to be invoked more than once.

Parameters:
iconBaseURL - The url to the plugin's icon base directory.
imageRegistry - The image registry to cache the images and image descriptors.

checkImages

protected void checkImages()
Checks if the images are loaded in the cache. The variable imagesWereLoaded is used to ensure that they won't be loaded more then once.


addImages

protected abstract void addImages()
Subclasses are supposed to add all the images to this manager in this method implementation.

The images should be added by invoking one the add methods.


add

protected org.eclipse.jface.resource.ImageDescriptor add(java.lang.String prefix,
                                                         java.lang.String name)
Creates an image descriptor for a given image directory prefix and image name adding it to the image registry.

Parameters:
prefix -
name -
Returns:
ImageDescriptor

add

protected org.eclipse.jface.resource.ImageDescriptor add(java.lang.String prefixType,
                                                         java.lang.String prefix,
                                                         java.lang.String name)
Creates an image descriptor for a given image directory prefix, directory type and image name adding it to the image registry.

This method is typically used to register action images. For example, to register clcl16/open.gif, dlcl16/open.gif and elcl16/open.gif client should execute

addManaged("c", T_LCL, "open.gif")
,
add("d", T_LCL, "open.gif")
and
add("e", T_LCL, "open.gif")
.

Parameters:
prefixType -
prefix -
name -
Returns:
ImageDescriptor

add

protected boolean add(java.lang.String key,
                      org.eclipse.jface.resource.ImageDescriptor imageDescriptor)
               throws java.lang.IllegalArgumentException
Adds an image descriptor to this image manager.

Parameters:
key -
imageDescriptor -
Returns:
true if the image descriptor was added of false if key or imageDescriptor is null or if the default image registry has already the specified key.
Throws:
java.lang.IllegalArgumentException - if the key already exists

createImageDescriptor

protected org.eclipse.jface.resource.ImageDescriptor createImageDescriptor(java.lang.String prefix,
                                                                           java.lang.String name)
Creates an image descriptor for a given image directory prefix and image name. The image prefix is appended to the base icon url

Parameters:
prefix -
name -
Returns:
ImageDescriptor

makeIconFileURL

protected java.net.URL makeIconFileURL(java.lang.String prefix,
                                       java.lang.String name)
                                throws java.net.MalformedURLException
Creates a URL for a given image directory prefix and image name.

Parameters:
prefix -
name -
Returns:
URL
Throws:
java.net.MalformedURLException

getImageDescriptor

public org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(java.lang.String key)
Returns the image descriptor associated to a key.

Parameters:
key -
Returns:
ImageDescriptor

getImage

public org.eclipse.swt.graphics.Image getImage(java.lang.String key)
Returns the image associated to a key. image registry.

Parameters:
key -
Returns:
Image

getImageDescriptor

public org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(java.lang.String prefixType,
                                                                     java.lang.String key)
Returns the image descriptor associated to a prefix type and key. The prefix type is the prefix of the directory such as "c", "d" and "e" in "cview16", "dview16" and "eview16".

Parameters:
prefixType -
key -
Returns:
ImageDescriptor

getImage

public org.eclipse.swt.graphics.Image getImage(java.lang.String prefixType,
                                               java.lang.String key)
Returns the image associated to a prefix type and key. The prefix type is the prefix of the directory such as "c", "d" and "e" in "cview16", "dview16" and "eview16".

Parameters:
prefixType -
key -
Returns:
ImageDescriptor

setImageDescriptors

public void setImageDescriptors(org.eclipse.jface.action.IAction action,
                                java.lang.String name)
Sets all the image descriptors of a given action. This method assumes the following convention:
  1. The prefix type "e" is used for the main image
  2. The prefix type "c" is used for the hover image
  3. The prefix type "d" is used for the disabled image

Parameters:
action -
name -

initializeImages

public static void initializeImages(ImageManager imageManager,
                                    org.eclipse.ui.plugin.AbstractUIPlugin uiPlugin)

isInitialized

public boolean isInitialized()
Indicates whether this image manager was initialized.

Returns:
the initialization state

COSMOS ${releaseVersion} resource-modeling Project
Internal API Specification