net.ctdp.rfdynhud.properties
Class EnumProperty<E extends java.lang.Enum<E>>

java.lang.Object
  extended by net.ctdp.rfdynhud.properties.Property
      extended by net.ctdp.rfdynhud.properties.EnumProperty<E>
Type Parameters:
E - the enum type

public class EnumProperty<E extends java.lang.Enum<E>>
extends Property

The EnumProperty serves for customizing a value from an enum.

Author:
Marvin Froehlich (CTDP)

Constructor Summary
EnumProperty(java.lang.String name, E defaultValue)
           
EnumProperty(java.lang.String name, E defaultValue, boolean readonly)
           
EnumProperty(java.lang.String name, java.lang.String nameForDisplay, E defaultValue)
           
EnumProperty(java.lang.String name, java.lang.String nameForDisplay, E defaultValue, boolean readonly)
           
 
Method Summary
 E getEnumValue()
          Gets the currently selected value.
 E getValue()
          Gets the current value fo this property.
 void loadValue(PropertyLoader loader, java.lang.String value)
          Loads the value from the configuration file.
protected  void onKeeperSet()
          
protected  void onValueChanged(E oldValue, E newValue)
          Invoked when the value has changed.
 boolean setEnumValue(E value)
          Sets the selected value.
protected  boolean setEnumValue(E value, boolean firstTime)
          Sets the selected value.
 void setValue(java.lang.Object value)
          Sets the new value for this property.
 
Methods inherited from class net.ctdp.rfdynhud.properties.Property
getButtonText, getButtonTooltip, getDocumentationSource, getEditorType, getKeeper, getName, getNameForDisplay, getValueForConfigurationFile, isMatchingKey, isReadOnly, onButtonClicked, quoteValueInConfigurationFile, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EnumProperty

public EnumProperty(java.lang.String name,
                    java.lang.String nameForDisplay,
                    E defaultValue,
                    boolean readonly)
Parameters:
name - the technical name used internally. See Property.getName().
nameForDisplay - the name displayed in the editor. See Property.getNameForDisplay(). If null is passed, the value of the name parameter is used.
defaultValue - the default value
readonly - read only property?

EnumProperty

public EnumProperty(java.lang.String name,
                    java.lang.String nameForDisplay,
                    E defaultValue)
Parameters:
name - the technical name used internally. See Property.getName().
nameForDisplay - the name displayed in the editor. See Property.getNameForDisplay(). If null is passed, the value of the name parameter is used.
defaultValue - the default value

EnumProperty

public EnumProperty(java.lang.String name,
                    E defaultValue,
                    boolean readonly)
Parameters:
name - the technical name used internally. See Property.getName(). 'nameForDisplay' is set to the same value.
defaultValue - the default value
readonly - read only property?

EnumProperty

public EnumProperty(java.lang.String name,
                    E defaultValue)
Parameters:
name - the technical name used internally. See Property.getName(). 'nameForDisplay' is set to the same value.
defaultValue - the default value
Method Detail

onKeeperSet

protected void onKeeperSet()

Overrides:
onKeeperSet in class Property

onValueChanged

protected void onValueChanged(E oldValue,
                              E newValue)
Invoked when the value has changed.

Parameters:
oldValue - the old value
newValue - the new value

setEnumValue

protected final boolean setEnumValue(E value,
                                     boolean firstTime)
Sets the selected value.

Parameters:
value - the new value
firstTime -
Returns:
changed?

setEnumValue

public final boolean setEnumValue(E value)
Sets the selected value.

Parameters:
value - the new value
Returns:
changed?

getEnumValue

public final E getEnumValue()
Gets the currently selected value.

Returns:
the currently selected value.

setValue

public void setValue(java.lang.Object value)
Sets the new value for this property.

Specified by:
setValue in class Property
Parameters:
value - the new value

getValue

public E getValue()
Gets the current value fo this property.

Specified by:
getValue in class Property
Returns:
the current value fo this property.

loadValue

public void loadValue(PropertyLoader loader,
                      java.lang.String value)
Loads the value from the configuration file.

Specified by:
loadValue in class Property
Parameters:
loader - the loader
value - the value to load