Class LazyResourceManager
- java.lang.Object
-
- org.eclipse.jface.resource.ResourceManager
-
- org.eclipse.jface.resource.LazyResourceManager
-
@NoReference public class LazyResourceManager extends ResourceManager
A LRU based ResourceManager Wrapper. Not to be used by clients.
-
-
Constructor Summary
Constructors Constructor Description LazyResourceManager(int cacheSize, ResourceManager parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectcreate(DeviceResourceDescriptor descriptor)Returns the resource described by the given descriptor.voiddestroy(DeviceResourceDescriptor descriptor)Deallocates a resource previously allocated byResourceManager.create(DeviceResourceDescriptor).Objectfind(DeviceResourceDescriptor descriptor)Returns a previously allocated resource associated with the given descriptor, or null if none exists yet.protected ImagegetDefaultImage()Returns the default image that will be returned in the event that the intended image is missing.DevicegetDevice()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, dispose, disposeExec, get
-
-
-
-
Constructor Detail
-
LazyResourceManager
public LazyResourceManager(int cacheSize, ResourceManager parent)- Parameters:
cacheSize- the lru cache sizeparent- ResourceManager
-
-
Method Detail
-
getDevice
public Device getDevice()
Description copied from class:ResourceManagerReturns the Device for which this ResourceManager will create resources- Specified by:
getDevicein classResourceManager- Returns:
- the Device associated with this ResourceManager
-
getDefaultImage
protected Image getDefaultImage()
Description copied from class:ResourceManagerReturns the default image that will be returned in the event that the intended image is missing.- Specified by:
getDefaultImagein classResourceManager- Returns:
- a default image that will be returned in the event that the intended image is missing.
-
create
public Object create(DeviceResourceDescriptor descriptor)
Description copied from class:ResourceManagerReturns 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 this method should have a corresponding call toResourceManager.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-livedLocalResourceManagers, 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.
- Specified by:
createin classResourceManager- Parameters:
descriptor- descriptor for the resource to allocate- Returns:
- the newly allocated resource (not null)
-
destroy
public void destroy(DeviceResourceDescriptor descriptor)
Description copied from class:ResourceManagerDeallocates a resource previously allocated byResourceManager.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.- Specified by:
destroyin classResourceManager- Parameters:
descriptor- identifier for the resource
-
find
public Object find(DeviceResourceDescriptor descriptor)
Description copied from class:ResourceManagerReturns a previously allocated resource associated with the given descriptor, or null if none exists yet.- Specified by:
findin classResourceManager- Parameters:
descriptor- descriptor to find- Returns:
- a previously allocated resource for the given descriptor or null if none.
-
-