Previous CloneSet | Next CloneSet | Back to Main Report |
Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
---|---|---|---|---|
62 | 2 | 4 | 0.954 | type_declarations |
Clone Abstraction | Parameter Bindings |
Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
---|---|---|---|
1 | 64 | 25 | plugins/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/ImageDescriptorRegistry.java |
2 | 62 | 26 | plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/ImageDescriptorRegistry.java |
| ||||
/** * A registry that maps <code>ImageDescriptors</code> to <code>Image</code>. */ public class ImageDescriptorRegistry { private HashMap fRegistry = new HashMap(10); private Display fDisplay; /** * Creates a new image descriptor registry for the current or default display, * respectively. */ public ImageDescriptorRegistry() { this(JDIDebugUIPlugin.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 display the display the images managed by this registry are allocated for */ public ImageDescriptorRegistry(Display display) { fDisplay = display; Assert.isNotNull(fDisplay); hookDisplay(); } /** * Returns the image associated 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 <code>null</code> * 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); if (result != null) return result; Assert.isTrue(fDisplay == JDIDebugUIPlugin.getStandardDisplay(), DebugUIMessages.ImageDescriptorRegistry_Allocating_image_for_wrong_display_1); result = descriptor.createImage(); if (result != null) fRegistry.put(descriptor, result); return result; } /** * Disposes all images managed by this registry. */ public void dispose() { for (Iterator iter = fRegistry.values().iterator(); iter.hasNext();) { Image image = (Image) iter.next(); image.dispose(); } fRegistry.clear(); } private void hookDisplay() { fDisplay.asyncExec(new Runnable() { public void run() { fDisplay.disposeExec(new Runnable() { public void run() { dispose(); } } ); } } ); } } |
| ||||
/** * A registry that maps <code>ImageDescriptors</code> to <code>Image</code>. */ public class ImageDescriptorRegistry { private HashMap fRegistry = new HashMap(10); private Display fDisplay; /** * 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 display the display the images managed by this registry are allocated for */ public ImageDescriptorRegistry(Display display) { fDisplay = display; Assert.isNotNull(fDisplay); hookDisplay(); } /** * Returns the image associated 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 <code>null</code> * 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); if (result != null) return result; 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; } /** * Disposes all images managed by this registry. */ public void dispose() { 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(); } } ); } } |
| |||
/** * A registry that maps <code>ImageDescriptors</code> to <code>Image</code>. */ public class ImageDescriptorRegistry { private HashMap fRegistry = new HashMap(10); private Display fDisplay; /** * Creates a new image descriptor registry for the current or default display, * respectively. */ public ImageDescriptorRegistry() { this( [[#variable8fcebc20]].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 display the display the images managed by this registry are allocated for */ public ImageDescriptorRegistry(Display display) { fDisplay = display; Assert.isNotNull(fDisplay); hookDisplay(); } /** * Returns the image associated 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 <code>null</code> * 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); if (result != null) return result; Assert.isTrue(fDisplay == [[#variable8fcebc20]].getStandardDisplay(), [[#variable8fcebba0]]); //$NON-NLS-1$ result = descriptor.createImage(); if (result != null) fRegistry.put(descriptor, result); return result; } /** * Disposes all images managed by this registry. */ public void dispose() { for (Iterator iter = fRegistry.values().iterator(); iter.hasNext();) { Image image = (Image) iter.next(); image.dispose(); } fRegistry.clear(); } private void hookDisplay() { fDisplay. [[#variable8fcebb40]](new Runnable() { public void run() { [[#variable8fcebac0]]; } } ); } } |
CloneAbstraction |
Parameter Index | Clone Instance | Parameter Name | Value |
---|---|---|---|
1 | 1 | [[#8fcebc20]] | SWTUtil |
1 | 2 | [[#8fcebc20]] | JDIDebugUIPlugin |
2 | 1 | [[#8fcebba0]] | "Allocating image for wrong display." |
2 | 2 | [[#8fcebba0]] | DebugUIMessages.ImageDescriptorRegistry_Allocating_image_for_wrong_display_1 |
3 | 1 | [[#8fcebb40]] | disposeExec |
3 | 2 | [[#8fcebb40]] | asyncExec |
4 | 1 | [[#8fcebac0]] | dispose() |
4 | 2 | [[#8fcebac0]] | fDisplay.disposeExec(new Runnable() { public void run() { dispose(); } } ) |