CloneSet548


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
62240.954type_declarations
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
16425
plugins/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/ImageDescriptorRegistry.java
26226
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/ImageDescriptorRegistry.java
Clone Instance
1
Line Count
64
Source Line
25
Source File
plugins/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/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();
                                }
                                             } );
                        }
                                   } );
        }
}




Clone Instance
2
Line Count
62
Source Line
26
Source File
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(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();
                        }
                                     } );
        }
}




Clone AbstractionParameter Count: 4Parameter Bindings

/**
 * 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 Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#8fcebc20]]
SWTUtil 
12[[#8fcebc20]]
JDIDebugUIPlugin 
21[[#8fcebba0]]
"Allocating image for wrong display." 
22[[#8fcebba0]]
DebugUIMessages.ImageDescriptorRegistry_Allocating_image_for_wrong_display_1 
31[[#8fcebb40]]
disposeExec 
32[[#8fcebb40]]
asyncExec 
41[[#8fcebac0]]
dispose() 
42[[#8fcebac0]]
fDisplay.disposeExec(new Runnable() {
                       public void run() {
                         dispose();
                       }
                     } )