X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/viewsupport/ImageDescriptorRegistry.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/viewsupport/ImageDescriptorRegistry.java index ae34a4c..4b3f09b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/viewsupport/ImageDescriptorRegistry.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/viewsupport/ImageDescriptorRegistry.java @@ -7,58 +7,66 @@ package net.sourceforge.phpdt.internal.ui.viewsupport; import java.util.HashMap; import java.util.Iterator; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; - import net.sourceforge.phpdt.internal.ui.util.SWTUtil; + import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.Assert; +//incastrix +//import org.eclipse.jface.text.Assert; +import org.eclipse.core.runtime.Assert; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; /** * A registry that maps ImageDescriptors to Image. */ public class ImageDescriptorRegistry { - private HashMap fRegistry= new HashMap(10); + private HashMap fRegistry = new HashMap(10); + private Display fDisplay; - + /** - * Creates a new image descriptor registry for the current or default display, - * respectively. + * Creates a new image descriptor registry for the current or default + * display, respectively. */ public ImageDescriptorRegistry() { this(SWTUtil.getStandardDisplay()); } - + /** * Creates a new image descriptor registry for the given display. All images * managed by this registry will be disposed when the display gets disposed. * - * @param diaplay the display the images managed by this registry are allocated for + * @param diaplay + * the display the images managed by this registry are allocated + * for */ public ImageDescriptorRegistry(Display display) { - fDisplay= display; + fDisplay = display; Assert.isNotNull(fDisplay); hookDisplay(); } - + /** * Returns the image assiciated with the given image descriptor. * - * @param descriptor the image descriptor for which the registry manages an image - * @return the image associated with the image descriptor or null - * if the image descriptor can't create the requested image. + * @param descriptor + * the image descriptor for which the registry manages an image + * @return the image associated with the image descriptor or + * null if the image descriptor can't create the + * requested image. */ public Image get(ImageDescriptor descriptor) { if (descriptor == null) - descriptor= ImageDescriptor.getMissingImageDescriptor(); - - Image result= (Image)fRegistry.get(descriptor); + descriptor = ImageDescriptor.getMissingImageDescriptor(); + + Image result = (Image) fRegistry.get(descriptor); if (result != null) return result; - - Assert.isTrue(fDisplay == SWTUtil.getStandardDisplay(), "Allocating image for wrong display."); //$NON-NLS-1$ - result= descriptor.createImage(); + + Assert.isTrue(fDisplay == SWTUtil.getStandardDisplay(), + "Allocating image for wrong display."); //$NON-NLS-1$ + result = descriptor.createImage(); if (result != null) fRegistry.put(descriptor, result); return result; @@ -66,21 +74,20 @@ public class ImageDescriptorRegistry { /** * Disposes all images managed by this registry. - */ + */ public void dispose() { - for (Iterator iter= fRegistry.values().iterator(); iter.hasNext(); ) { - Image image= (Image)iter.next(); + for (Iterator iter = fRegistry.values().iterator(); iter.hasNext();) { + Image image = (Image) iter.next(); image.dispose(); } fRegistry.clear(); } - + private void hookDisplay() { fDisplay.disposeExec(new Runnable() { public void run() { dispose(); - } + } }); } } -