Bug 79909 [JFace] Localized resource registries for JFace
Please provide improved JFace support for managing SWT resources, with the following properties: - A registry can allocate and deallocate SWT resources given a descriptor - Resources are reference-counted and shared, allowing different objects with equivalent descriptors to share resources. - Everything in the registry can be deallocated with one function call - The registry should support an open-ended set of resources (and should initially support, at minimum, Images, Fonts, Colors) - It should be possible to create a "local registry" that behaves like a regular registry but actually shares its resources with a global registry. For example, the workbench could offer a local registry as a service to views and editors. This would allow views and editors to safely allocate and deallocate SWT resources without any chance of leaking.
bundles/org.eclipse.jface/src/org/eclipse/jface/resource/ColorRegistry.java
}
    /**
     * Adds (or replaces) a color to this color registry under the given 
     * symbolic name.
     * <p>
     * A property change event is reported whenever the mapping from a symbolic
     * name to a color changes. The source of the event is this registry; the
     * property name is the symbolic color name.
     * </p>
     * 
     * @param symbolicName the symbolic color name
     * @param colorData an <code>RGB</code> object
     * @param update - fire a color mapping changed if true. False if this
     *            method is called from the get method as no setting has
     *            changed.
     */
    private void put(String symbolicName, RGB colorData, boolean update) {
        Assert.isNotNull(symbolicName);
        Assert.isNotNull(colorData);
        RGB existing = (RGB) stringToRGB.get(symbolicName);
        if (colorData.equals(existing))
            return;
        Color oldColor = (Color) stringToColor.remove(symbolicName);
        stringToRGB.put(symbolicName, colorData);
        if (update)
            fireMappingChanged(symbolicName, existing, colorData);
        if (oldColor != null)
            staleColors.add(oldColor);
    }
}