public Image decorateImage( Image image, Object element ) {
if( disposed ) return null;
if (!(element instanceof IResolve))
return null;
IResolve resolve = (IResolve) element;
if (images.containsKey(element)) {
LabelData data = images.get(element);
// if data is null then it is being loaded already so return
if (data == null)
return null;
}
// look image up in registry to see if it is already loaded
ImageRegistry imageRegistry = CatalogUIPlugin.getDefault().getImageRegistry();
Image i;
synchronized (imageRegistry) {
i = imageRegistry.get(resolve.getIdentifier().toString());
// if it is loaded and not disposed then we're good, return it.
if( i!=null && !i.isDisposed()){
return i;
}
if (i!=null && i.isDisposed() )
imageRegistry.remove(resolve.getIdentifier().toString());
}
// we tried to look up a cached version... If not around and viewer doesn't want decorated images then we'll return.
if( !resolve.getID().isLocal() && !decorateImages ){
return null;
}
// put an element in the map so that it will not be loaded again.
images.put(resolve, null);