- Direct Known Subclasses:
public abstract class DeviceResourceDescriptor extends ObjectInstances of this class can allocate and dispose SWT resources. Each instance describes a particular resource (such as a Color, Font, or Image) and can create and destroy that resource on demand. DeviceResourceDescriptors are managed by a ResourceRegistry.
Note: It is recommended that subclasses implement
#hashCode, so that clients, like decoration managers, can recognize when they have two equal descriptors at hand, e.g. decorating an identical object.
- See Also:
Constructors Modifier Constructor Description
DeviceResourceDescriptor()default constructor with shouldBeCached=false
All Methods Instance Methods Abstract Methods Modifier and Type Method Description
createResource(Device device)Creates the resource described by this descriptor
destroyResource(Object previouslyCreatedObject)Undoes everything that was done by a previous call to create(...), given the object that was returned by create(...).
public DeviceResourceDescriptor()default constructor with shouldBeCached=false
protected DeviceResourceDescriptor(boolean shouldBeCached)
shouldBeCached- Indicates if the resource instance described by the descriptor should to be kept by
ResourceManagereven if all references to the resource are lost (due to
Should return true for resources that are costly to create (for example by involving I/O Operation). Has only an effect if caching is enabled (see org.eclipse.jface.resource.JFaceResources#cacheSize). Caching relies on
Object.hashCode(). For equal DeviceResourceDescriptors the same Resource instance is returned by the
ResourceManagerinstance return by
JFaceResources.getResources(org.eclipse.swt.widgets.Display)as long as the cache is big enough to cache all resources.
Instances which equal (in terms of
Object.equals(Object)) must have the same shouldBeCached mode.
- See Also:
public abstract Object createResource(Device device)Creates the resource described by this descriptor
device- the Device on which to allocate the resource
- the newly allocated resource (not null)
DeviceResourceException- if unable to allocate the resource
public abstract void destroyResource(Object previouslyCreatedObject)Undoes everything that was done by a previous call to create(...), given the object that was returned by create(...).
previouslyCreatedObject- an object that was returned by an equal descriptor in a previous call to createResource(...).