Package org.eclipse.m2m.atl.adt.ui.text
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
FieldsModifier and TypeFieldDescriptionprotected 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.keyTable
is a hash map regrouping the string key of the color and the effective RGB color associated with. -
Constructor Summary
ConstructorsConstructorDescriptionCreates 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 TypeMethodDescriptionAdds in the table a new color.void
Remembers the given color specification under the given key.void
dispose()
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
unbindColor
(String key) Forgets the color specification remembered under the given key.
-
Field Details
-
displayTable
protected Map<org.eclipse.swt.widgets.Display,Map<org.eclipse.swt.graphics.RGB, displayTableorg.eclipse.swt.graphics.Color>> displayTable
stores a map for each display found. -
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
Adds in the table a new color.- Parameters:
key
- the string key representing the colorrgb
- the RGB color associated to the color- Returns:
- the new object inserted in the table
-
bindColor
Remembers the given color specification under the given key.- Parameters:
key
- the color keyrgb
- 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 interfaceorg.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 interfaceorg.eclipse.jface.text.source.ISharedTextColors
- See Also:
-
ISharedTextColors.getColor(org.eclipse.swt.graphics.RGB)
-
getColor
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
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
Forgets the color specification remembered under the given key.- Parameters:
key
- the color key
-