public abstract class ResourceManager extends Object
ResourceManager handles correct allocation and disposal of resources. It differs from the various JFace *Registry classes, which also map symbolic IDs onto resources. In general, you should use a *Registry class to map IDs onto descriptors, and use a ResourceManager to convert the descriptors into real Images/Fonts/etc.
Constructor and Description |
---|
ResourceManager() |
Modifier and Type | Method and Description |
---|---|
void |
cancelDisposeExec(Runnable r)
Cancels a runnable that was previously scheduled with
disposeExec . |
abstract Object |
create(DeviceResourceDescriptor descriptor)
Returns the resource described by the given descriptor.
|
Color |
createColor(ColorDescriptor descriptor)
Allocates a color, given a color descriptor.
|
Color |
createColor(RGB descriptor)
Allocates a color, given its RGB values.
|
Font |
createFont(FontDescriptor descriptor)
Returns the Font described by the given FontDescriptor.
|
Image |
createImage(ImageDescriptor descriptor)
Creates an image, given an image descriptor.
|
Image |
createImageWithDefault(ImageDescriptor descriptor)
Creates an image, given an image descriptor.
|
abstract void |
destroy(DeviceResourceDescriptor descriptor)
Deallocates a resource previously allocated by create(...).
|
void |
destroyColor(ColorDescriptor descriptor)
Undoes everything that was done by a call to createColor(...).
|
void |
destroyColor(RGB descriptor)
Undoes everything that was done by a call to createColor(...).
|
void |
destroyFont(FontDescriptor descriptor)
Undoes everything that was done by a previous call to createFont().
|
void |
destroyImage(ImageDescriptor descriptor)
Undoes everything that was done by createImage(...).
|
void |
dispose()
Disposes any remaining resources allocated by this manager.
|
void |
disposeExec(Runnable r)
Causes the
run() method of the runnable to
be invoked just before the receiver is disposed. |
abstract Object |
find(DeviceResourceDescriptor descriptor)
Returns a previously allocated resource associated with the given descriptor, or
null if none exists yet.
|
protected abstract Image |
getDefaultImage()
Returns the default image that will be returned in the event that the intended
image is missing.
|
abstract Device |
getDevice()
Returns the Device for which this ResourceManager will create resources
|
public abstract Device getDevice()
public abstract Object create(DeviceResourceDescriptor descriptor) throws DeviceResourceException
descriptor
- descriptor for the resource to allocateDeviceResourceException
- if unable to allocate the resourcepublic abstract void destroy(DeviceResourceDescriptor descriptor)
descriptor
- identifier for the resourcepublic final Image createImage(ImageDescriptor descriptor) throws DeviceResourceException
descriptor
- descriptor for the image to createDeviceResourceException
- if unable to allocate the Imagepublic final Image createImageWithDefault(ImageDescriptor descriptor)
descriptor
- descriptor for the image to createprotected abstract Image getDefaultImage()
public final void destroyImage(ImageDescriptor descriptor)
descriptor
- identifier for the image to disposepublic final Color createColor(ColorDescriptor descriptor) throws DeviceResourceException
descriptor
- descriptor for the color to createDeviceResourceException
- if unable to create the colorpublic final Color createColor(RGB descriptor) throws DeviceResourceException
descriptor
- descriptor for the color to createDeviceResourceException
- if unable to create the colorpublic final void destroyColor(RGB descriptor)
descriptor
- RGB value of the color to disposepublic final void destroyColor(ColorDescriptor descriptor)
descriptor
- identifier for the color to disposepublic final Font createFont(FontDescriptor descriptor) throws DeviceResourceException
descriptor
- description of the font to createDeviceResourceException
- if unable to create the fontpublic final void destroyFont(FontDescriptor descriptor)
descriptor
- description of the font to destroypublic void dispose()
public abstract Object find(DeviceResourceDescriptor descriptor)
descriptor
- descriptor to findpublic void disposeExec(Runnable r)
run()
method of the runnable to
be invoked just before the receiver is disposed. The runnable
can be subsequently cancelled by a call to cancelDisposeExec
.r
- runnable to execute.public void cancelDisposeExec(Runnable r)
disposeExec
.
Has no effect if the given runnable was not previously registered with
disposeExec.r
- runnable to cancelGuidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.