Class AtlColorManager

java.lang.Object
org.eclipse.m2m.atl.adt.ui.text.AtlColorManager
All Implemented Interfaces:
org.eclipse.jface.text.source.ISharedTextColors

public class AtlColorManager extends Object implements org.eclipse.jface.text.source.ISharedTextColors
This manager allows to share colors. A color is represented as a couple of a string and an RGB value.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Map<org.eclipse.swt.widgets.Display,Map<org.eclipse.swt.graphics.RGB,org.eclipse.swt.graphics.Color>>
    displayTable stores a map for each display found.
    protected HashMap<String,org.eclipse.swt.graphics.RGB>
    keyTable is a hash map regrouping the string key of the color and the effective RGB color associated with.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new color manager setting to auto dispose it when the display is disposed.
    AtlColorManager(boolean adodd)
    Creates a new color manager setting the auto dispose on display dispose mode with the given parameter.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(String key, org.eclipse.swt.graphics.RGB rgb)
    Adds in the table a new color.
    void
    bindColor(String key, org.eclipse.swt.graphics.RGB rgb)
    Remembers the given color specification under the given key.
    void
    protected void
    dispose(org.eclipse.swt.widgets.Display display)
    Disposes the color manager with the values from the display.
    org.eclipse.swt.graphics.Color
    Gets the color resource matching the color string.
    org.eclipse.swt.graphics.Color
    getColor(org.eclipse.swt.graphics.RGB rgb)
    Removes from the table the color given by the string key.
    void
    Forgets the color specification remembered under the given key.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • displayTable

      protected Map<org.eclipse.swt.widgets.Display,Map<org.eclipse.swt.graphics.RGB,org.eclipse.swt.graphics.Color>> displayTable
      displayTable stores a map for each display found.
    • keyTable

      protected HashMap<String,org.eclipse.swt.graphics.RGB> keyTable
      keyTable is a hash map regrouping the string key of the color and the effective RGB color associated with.
  • Constructor Details

    • AtlColorManager

      public AtlColorManager()
      Creates a new color manager setting to auto dispose it when the display is disposed.
    • AtlColorManager

      public AtlColorManager(boolean adodd)
      Creates a new color manager setting the auto dispose on display dispose mode with the given parameter.
      Parameters:
      adodd - the auto dispose on display dispose mode
  • Method Details

    • add

      public Object add(String key, org.eclipse.swt.graphics.RGB rgb)
      Adds in the table a new color.
      Parameters:
      key - the string key representing the color
      rgb - the RGB color associated to the color
      Returns:
      the new object inserted in the table
    • bindColor

      public void bindColor(String key, org.eclipse.swt.graphics.RGB rgb)
      Remembers the given color specification under the given key.
      Parameters:
      key - the color key
      rgb - the color specification
      Throws:
      UnsupportedOperationException - if there is already a color specification remembered under the given key
    • dispose

      public void dispose()
      Specified by:
      dispose in interface org.eclipse.jface.text.source.ISharedTextColors
      See Also:
      • ISharedTextColors.dispose()
    • dispose

      protected void dispose(org.eclipse.swt.widgets.Display display)
      Disposes the color manager with the values from the display.
      Parameters:
      display - the display to use
    • getColor

      public org.eclipse.swt.graphics.Color getColor(org.eclipse.swt.graphics.RGB rgb)
      Specified by:
      getColor in interface org.eclipse.jface.text.source.ISharedTextColors
      See Also:
      • ISharedTextColors.getColor(org.eclipse.swt.graphics.RGB)
    • getColor

      public org.eclipse.swt.graphics.Color getColor(String color)
      Gets the color resource matching the color string.
      Parameters:
      color - the key string of the color
      Returns:
      the matching color associated to the color key
    • remove

      public Object remove(String key)
      Removes from the table the color given by the string key.
      Parameters:
      key - the string key of the color
      Returns:
      the object removed from the table
    • unbindColor

      public void unbindColor(String key)
      Forgets the color specification remembered under the given key.
      Parameters:
      key - the color key