|
Eclipse Platform Release 3.3 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jface.resource.ResourceManager
org.eclipse.jface.resource.AbstractResourceManager
org.eclipse.jface.resource.DeviceResourceManager
Manages SWT resources for a particular device.
IMPORTANT: in most cases clients should use a LocalResourceManager
instead of a
DeviceResourceManager
. To create a resource manager on a particular display,
use new LocalResourceManager(JFaceResources.getResources(myDisplay))
.
DeviceResourceManager
should only be used directly when managing
resources for a device other than a Display (such as a printer).
LocalResourceManager
Constructor Summary | |
---|---|
DeviceResourceManager(Device device)
Creates a new registry for the given device. |
Method Summary | |
---|---|
protected Object |
allocate(DeviceResourceDescriptor descriptor)
Called the first time a resource is requested. |
Object |
create(DeviceResourceDescriptor descriptor)
Returns the resource described by the given descriptor. |
protected void |
deallocate(Object resource,
DeviceResourceDescriptor descriptor)
Called the last time a resource is dereferenced. |
void |
destroy(DeviceResourceDescriptor descriptor)
Deallocates a resource previously allocated by AbstractResourceManager.create(DeviceResourceDescriptor) .
|
void |
dispose()
Deallocates any resources allocated by this registry that have not yet been deallocated. |
Object |
find(DeviceResourceDescriptor descriptor)
Returns a previously allocated resource associated with the given descriptor, or null if none exists yet. |
protected Image |
getDefaultImage()
Returns the default image that will be returned in the event that the intended image is missing. |
Device |
getDevice()
Returns the Device for which this ResourceManager will create resources |
Methods inherited from class org.eclipse.jface.resource.ResourceManager |
---|
cancelDisposeExec, createColor, createColor, createFont, createImage, createImageWithDefault, destroyColor, destroyColor, destroyFont, destroyImage, disposeExec, get |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DeviceResourceManager(Device device)
device
- device to manageMethod Detail |
public Device getDevice()
ResourceManager
getDevice
in class ResourceManager
protected Object allocate(DeviceResourceDescriptor descriptor) throws DeviceResourceException
org.eclipse.jface.resource.AbstractResourceManager
descriptor
- identifier for the resource to allocate
DeviceResourceException
- Thrown when allocation of an SWT device resource failsprotected void deallocate(Object resource, DeviceResourceDescriptor descriptor)
org.eclipse.jface.resource.AbstractResourceManager
resource
- resource being deallocateddescriptor
- identifier for the resourceprotected Image getDefaultImage()
ResourceManager
getDefaultImage
in class ResourceManager
public void dispose()
org.eclipse.jface.resource.AbstractResourceManager
public final Object create(DeviceResourceDescriptor descriptor) throws DeviceResourceException
ResourceManager
ResourceManager.destroy(DeviceResourceDescriptor)
.
If the resource is intended to live for entire lifetime of the resource manager,
a subsequent call to ResourceManager.destroy(DeviceResourceDescriptor)
may be omitted and the
resource will be cleaned up when the resource manager is disposed. This pattern
is useful for short-lived LocalResourceManager
s, but should never be used
with the global resource manager since doing so effectively leaks the resource.
The resources returned from this method are reference counted and may be shared
internally with other resource managers. They should never be disposed outside of the
ResourceManager framework, or it will cause exceptions in other code that shares
them. For example, never call Resource.dispose()
on anything returned from this method.
Callers may safely downcast the result to the resource type associated with the descriptor. For example, when given an ImageDescriptor, the return value of this method will always be an Image.
create
in class ResourceManager
descriptor
- descriptor for the resource to allocate
DeviceResourceException
- if unable to allocate the resourcepublic final void destroy(DeviceResourceDescriptor descriptor)
ResourceManager
ResourceManager.create(DeviceResourceDescriptor)
.
Descriptors are compared by equality, not identity. If the same resource was
created multiple times, this may decrement a reference count rather than
disposing the actual resource.
destroy
in class ResourceManager
descriptor
- identifier for the resourcepublic Object find(DeviceResourceDescriptor descriptor)
ResourceManager
find
in class ResourceManager
descriptor
- descriptor to find
|
Eclipse Platform Release 3.3 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2007. All rights reserved.