Eclipse Platform
Release 3.1

org.eclipse.jface.resource
Class DeviceResourceManager

java.lang.Object
  extended byorg.eclipse.jface.resource.ResourceManager
      extended byorg.eclipse.jface.resource.AbstractResourceManager
          extended byorg.eclipse.jface.resource.DeviceResourceManager

public final class DeviceResourceManager
extends org.eclipse.jface.resource.AbstractResourceManager

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).

Since:
3.1
See Also:
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 create(...).
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeviceResourceManager

public DeviceResourceManager(Device device)
Creates a new registry for the given device.

Parameters:
device - device to manage
Method Detail

getDevice

public Device getDevice()
Description copied from class: ResourceManager
Returns the Device for which this ResourceManager will create resources

Specified by:
getDevice in class ResourceManager
Returns:
the Device associated with this ResourceManager

allocate

protected Object allocate(DeviceResourceDescriptor descriptor)
                   throws DeviceResourceException
Description copied from class: org.eclipse.jface.resource.AbstractResourceManager
Called the first time a resource is requested. Should allocate and return a resource of the correct type.

Parameters:
descriptor - identifier for the resource to allocate
Returns:
the newly allocated resource
Throws:
DeviceResourceException

deallocate

protected void deallocate(Object resource,
                          DeviceResourceDescriptor descriptor)
Description copied from class: org.eclipse.jface.resource.AbstractResourceManager
Called the last time a resource is dereferenced. Should release any resources reserved by allocate(...).

Parameters:
resource - resource being deallocated
descriptor - identifier for the resource

getDefaultImage

protected Image getDefaultImage()
Description copied from class: ResourceManager
Returns the default image that will be returned in the event that the intended image is missing.

Specified by:
getDefaultImage in class ResourceManager
Returns:
a default image that will be returned in the event that the intended image is missing.

dispose

public void dispose()
Description copied from class: org.eclipse.jface.resource.AbstractResourceManager
Deallocates any resources allocated by this registry that have not yet been deallocated.


create

public final Object create(DeviceResourceDescriptor descriptor)
                    throws DeviceResourceException
Description copied from class: ResourceManager
Returns the resource described by the given descriptor. If the resource already exists, the reference count is incremented and the exiting resource is returned. Otherwise, a new resource is allocated. Every call to create(...) should have a corresponding call to dispose(...).

Specified by:
create in class ResourceManager
Parameters:
descriptor - descriptor for the resource to allocate
Returns:
the newly allocated resource (not null)
Throws:
DeviceResourceException - if unable to allocate the resource

destroy

public final void destroy(DeviceResourceDescriptor descriptor)
Description copied from class: ResourceManager
Deallocates a resource previously allocated by create(...). 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.

Specified by:
destroy in class ResourceManager
Parameters:
descriptor - identifier for the resource

find

public Object find(DeviceResourceDescriptor descriptor)
Description copied from class: ResourceManager
Returns a previously allocated resource associated with the given descriptor, or null if none exists yet.

Specified by:
find in class ResourceManager
Parameters:
descriptor - descriptor to find
Returns:
a previously allocated resource for the given descriptor or null if none.

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.