com.aptana.ide.core.ui
Class ColorPair

java.lang.Object
  extended by com.aptana.ide.core.ui.ColorPair

public class ColorPair
extends java.lang.Object

A ColorPair is a combination of a foreground and a background color.

Author:
Ingo Muschenetz

Field Summary
static ColorPair COLOR_DEFAULT_DEFAULT
          The default-default value for color preferences (black, RGB(0,0,0)).
 
Constructor Summary
ColorPair(org.eclipse.swt.graphics.RGB foregroundColor, org.eclipse.swt.graphics.RGB backgroundColor)
          Creates a new instance of ColorPair
 
Method Summary
static ColorPair asColorPair(java.lang.String value)
          Converts the given value into an SWT RGB color value.
static java.lang.String asString(ColorPair value)
          Converts the given SWT RGB color pair value object to a string.
 org.eclipse.swt.graphics.RGB getBackgroundColor()
          Returns the background color of this pair
static ColorPair getColorPair(org.eclipse.jface.preference.IPreferenceStore store, java.lang.String name)
          Returns the current value of the color-valued preference with the given name in the given preference store.
static ColorPair getDefaultColorPair(org.eclipse.jface.preference.IPreferenceStore store, java.lang.String name)
          Returns the default value for the color-valued preference with the given name in the given preference store.
 org.eclipse.swt.graphics.RGB getForegroundColor()
          Returns the foreground color of this pair
 void setBackgroundColor(org.eclipse.swt.graphics.RGB backgroundColor)
          Set the background color
static void setDefault(org.eclipse.jface.preference.IPreferenceStore store, java.lang.String name, ColorPair value)
          Sets the default value of the preference with the given name in the given preference store.
 void setForegroundColor(org.eclipse.swt.graphics.RGB foregroundColor)
          Sets the foreground color
static void setValue(org.eclipse.jface.preference.IPreferenceStore store, java.lang.String name, ColorPair value)
          Sets the current value of the preference with the given name in the given preference store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLOR_DEFAULT_DEFAULT

public static final ColorPair COLOR_DEFAULT_DEFAULT
The default-default value for color preferences (black, RGB(0,0,0)).

Constructor Detail

ColorPair

public ColorPair(org.eclipse.swt.graphics.RGB foregroundColor,
                 org.eclipse.swt.graphics.RGB backgroundColor)
Creates a new instance of ColorPair

Parameters:
foregroundColor -
backgroundColor -
Method Detail

getBackgroundColor

public org.eclipse.swt.graphics.RGB getBackgroundColor()
Returns the background color of this pair

Returns:
The background color

setBackgroundColor

public void setBackgroundColor(org.eclipse.swt.graphics.RGB backgroundColor)
Set the background color

Parameters:
backgroundColor -

getForegroundColor

public org.eclipse.swt.graphics.RGB getForegroundColor()
Returns the foreground color of this pair

Returns:
The foreground color

setForegroundColor

public void setForegroundColor(org.eclipse.swt.graphics.RGB foregroundColor)
Sets the foreground color

Parameters:
foregroundColor -

getColorPair

public static ColorPair getColorPair(org.eclipse.jface.preference.IPreferenceStore store,
                                     java.lang.String name)
Returns the current value of the color-valued preference with the given name in the given preference store. Returns the default-default value (COLOR_DEFAULT_DEFAULT) if there is no preference with the given name, or if the current value cannot be treated as a color.

Parameters:
store - the preference store
name - the name of the preference
Returns:
the color-valued preference

getDefaultColorPair

public static ColorPair getDefaultColorPair(org.eclipse.jface.preference.IPreferenceStore store,
                                            java.lang.String name)
Returns the default value for the color-valued preference with the given name in the given preference store. Returns the default-default value (COLOR_DEFAULT_DEFAULT) is no default preference with the given name, or if the default value cannot be treated as a color.

Parameters:
store - the preference store
name - the name of the preference
Returns:
the default value of the preference

setDefault

public static void setDefault(org.eclipse.jface.preference.IPreferenceStore store,
                              java.lang.String name,
                              ColorPair value)
Sets the default value of the preference with the given name in the given preference store.

Parameters:
store - the preference store
name - the name of the preference
value - the new default value of the preference

asString

public static java.lang.String asString(ColorPair value)
Converts the given SWT RGB color pair value object to a string.

The string representation of an RGB color pair value has the form red,green,blue where red, green, and blue are string representations of integers. The two colors are separated by the form foreground;background

Parameters:
value - the RGB color pair value object
Returns:
the string representing the given RGB color value pair

asColorPair

public static ColorPair asColorPair(java.lang.String value)
                             throws org.eclipse.jface.resource.DataFormatException
Converts the given value into an SWT RGB color value. This method fails if the value does not represent an RGB color value.

A valid RGB color value representation is a string of the form red,green,blue where red, green, and blue are valid ints. ColorPairs are a combination of two colors, separated (in string form), be a ';'

Parameters:
value - the value to be converted
Returns:
the value as an RGB color value
Throws:
org.eclipse.jface.resource.DataFormatException - if the given value does not represent an RGB color value

setValue

public static void setValue(org.eclipse.jface.preference.IPreferenceStore store,
                            java.lang.String name,
                            ColorPair value)
Sets the current value of the preference with the given name in the given preference store.

Parameters:
store - the preference store
name - the name of the preference
value - the new current value of the preference