Class ResourceManager
- java.lang.Object
-
- org.eclipse.emf.ecp.cdo.internal.ui.SWTResourceManager
-
- org.eclipse.emf.ecp.cdo.internal.ui.ResourceManager
-
public class ResourceManager extends SWTResourceManager
Utility class for managing OS resources associated with SWT/JFace controls such as colors, fonts, images, etc. !!! IMPORTANT !!! Application code must explicitly invoke thedispose()
method to release the operating system resources managed by cached objects when those objects and OS resources are no longer needed (e.g. on application shutdown) This class may be freely distributed as part of any application or plugin.- Author:
- scheglov_ke, Dan Rubel
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ResourceManager.PluginResourceProvider
Provider for plugin resources, used by WindowBuilder at design time.
-
Field Summary
-
Fields inherited from class org.eclipse.emf.ecp.cdo.internal.ui.SWTResourceManager
BOTTOM_LEFT, BOTTOM_RIGHT, LAST_CORNER_KEY, TOP_LEFT, TOP_RIGHT
-
-
Constructor Summary
Constructors Constructor Description ResourceManager()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static org.eclipse.swt.graphics.Image
decorateImage(org.eclipse.swt.graphics.Image baseImage, org.eclipse.swt.graphics.Image decorator)
Returns anImage
composed of a base image decorated by another image.static org.eclipse.swt.graphics.Image
decorateImage(org.eclipse.swt.graphics.Image baseImage, org.eclipse.swt.graphics.Image decorator, int corner)
Returns anImage
composed of a base image decorated by another image.static void
dispose()
Dispose of cached objects and their underlying OS resources.static void
disposeImages()
Dispose all of the cached images.static org.eclipse.swt.graphics.Image
getImage(org.eclipse.jface.resource.ImageDescriptor descriptor)
Returns anImage
based on the specifiedImageDescriptor
.static org.eclipse.jface.resource.ImageDescriptor
getImageDescriptor(java.lang.Class<?> clazz, java.lang.String path)
Returns anImageDescriptor
stored in the file at the specified path relative to the specified class.static org.eclipse.jface.resource.ImageDescriptor
getImageDescriptor(java.lang.String path)
Returns anImageDescriptor
stored in the file at the specified path.static org.eclipse.swt.graphics.Image
getPluginImage(java.lang.Object plugin, java.lang.String name)
Deprecated.UsegetPluginImage(String, String)
instead.static org.eclipse.swt.graphics.Image
getPluginImage(java.lang.String symbolicName, java.lang.String path)
Returns anImage
based on aBundle
and resource entry path.static org.eclipse.jface.resource.ImageDescriptor
getPluginImageDescriptor(java.lang.Object plugin, java.lang.String name)
Deprecated.UsegetPluginImageDescriptor(String, String)
instead.static org.eclipse.jface.resource.ImageDescriptor
getPluginImageDescriptor(java.lang.String symbolicName, java.lang.String path)
Returns anImageDescriptor
based on aBundle
and resource entry path.-
Methods inherited from class org.eclipse.emf.ecp.cdo.internal.ui.SWTResourceManager
disposeColors, disposeCursors, disposeFonts, getBoldFont, getColor, getColor, getColor, getCursor, getFont, getFont, getImage, getImage, getImage
-
-
-
-
Method Detail
-
getImageDescriptor
public static org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(java.lang.Class<?> clazz, java.lang.String path)
Returns anImageDescriptor
stored in the file at the specified path relative to the specified class.- Parameters:
clazz
- theClass
relative to which to find the image descriptor.path
- the path to the image file.- Returns:
- the
ImageDescriptor
stored in the file at the specified path.
-
getImageDescriptor
public static org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(java.lang.String path)
Returns anImageDescriptor
stored in the file at the specified path.- Parameters:
path
- the path to the image file.- Returns:
- the
ImageDescriptor
stored in the file at the specified path.
-
getImage
public static org.eclipse.swt.graphics.Image getImage(org.eclipse.jface.resource.ImageDescriptor descriptor)
Returns anImage
based on the specifiedImageDescriptor
.- Parameters:
descriptor
- theImageDescriptor
for theImage
.- Returns:
- the
Image
based on the specifiedImageDescriptor
.
-
decorateImage
public static org.eclipse.swt.graphics.Image decorateImage(org.eclipse.swt.graphics.Image baseImage, org.eclipse.swt.graphics.Image decorator)
Returns anImage
composed of a base image decorated by another image.- Parameters:
baseImage
- the baseImage
that should be decorated.decorator
- theImage
to decorate the base image.- Returns:
Image
The resulting decorated image.
-
decorateImage
public static org.eclipse.swt.graphics.Image decorateImage(org.eclipse.swt.graphics.Image baseImage, org.eclipse.swt.graphics.Image decorator, int corner)
Returns anImage
composed of a base image decorated by another image.- Parameters:
baseImage
- the baseImage
that should be decorated.decorator
- theImage
to decorate the base image.corner
- the corner to place decorator image.- Returns:
- the resulting decorated
Image
.
-
disposeImages
public static void disposeImages()
Dispose all of the cached images.
-
getPluginImage
@Deprecated public static org.eclipse.swt.graphics.Image getPluginImage(java.lang.Object plugin, java.lang.String name)
Deprecated.UsegetPluginImage(String, String)
instead.Returns anImage
based on a plugin and file path.- Parameters:
plugin
- the pluginObject
containing the imagename
- the path to the image within the plugin- Returns:
- the
Image
stored in the file at the specified path
-
getPluginImage
public static org.eclipse.swt.graphics.Image getPluginImage(java.lang.String symbolicName, java.lang.String path)
Returns anImage
based on aBundle
and resource entry path.- Parameters:
symbolicName
- the symbolic name of theBundle
.path
- the path of the resource entry.- Returns:
- the
Image
stored in the file at the specified path.
-
getPluginImageDescriptor
@Deprecated public static org.eclipse.jface.resource.ImageDescriptor getPluginImageDescriptor(java.lang.Object plugin, java.lang.String name)
Deprecated.UsegetPluginImageDescriptor(String, String)
instead.Returns anImageDescriptor
based on a plugin and file path.- Parameters:
plugin
- the pluginObject
containing the image.name
- the path to th eimage within the plugin.- Returns:
- the
ImageDescriptor
stored in the file at the specified path.
-
getPluginImageDescriptor
public static org.eclipse.jface.resource.ImageDescriptor getPluginImageDescriptor(java.lang.String symbolicName, java.lang.String path)
Returns anImageDescriptor
based on aBundle
and resource entry path.- Parameters:
symbolicName
- the symbolic name of theBundle
.path
- the path of the resource entry.- Returns:
- the
ImageDescriptor
based on aBundle
and resource entry path.
-
dispose
public static void dispose()
Dispose of cached objects and their underlying OS resources. This should only be called when the cached objects are no longer needed (e.g. on application shutdown).
-
-