moe moe - 1 year ago 76
Java Question

How to remove an entry from the Eclipse ColorRegistry?

I use the Eclipse ColorRegistry to manage user generated Colors in an RCP Application.

Because the Colors and Keys are User generated, there is also the possibility for the user to change the color that is associated with a key or to remove the key / color combination entirely. However the

class only has a
method to write or replace a color, but no remove method.

Is there a way to remove a color from the registry?

(The only workaround I came up with would be to replace the color with a default value, but I would prefer a clean solution.)

Answer Source

In short: no there is no way to remove an entry from the ColorRegistry.

You could use a Map or similar custom data structure instead to store named colors. If it is likely that many names point to the same color, you may want to use ColorDescriptors or RGBs and a ResourceManager as the backing color store to avoid creating duplicate colors.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download