de.matthiasmann.twl.model
Class OptionEnumModel<T extends java.lang.Enum<T>>

java.lang.Object
  extended by de.matthiasmann.twl.model.AbstractOptionModel
      extended by de.matthiasmann.twl.model.OptionEnumModel<T>
Type Parameters:
T - The enum class
All Implemented Interfaces:
BooleanModel, WithRunnableCallback

public class OptionEnumModel<T extends java.lang.Enum<T>>
extends AbstractOptionModel

A BooleanModel which is true when the underlying EnumModel has the specified option code. This can be used for radio/option buttons. It is not possible to set this BooleanModel to false. It can only be set to false by setting the underlying EnumModel to another value. Eg by setting another OptionEnumModel working on the same EnumModel to true.


Field Summary
protected  T optionCode
           
protected  EnumModel<T> optionState
           
 
Constructor Summary
OptionEnumModel(EnumModel<T> optionState, T optionCode)
           
 
Method Summary
 boolean getValue()
           
protected  void installSrcCallback(java.lang.Runnable cb)
           
protected  void removeSrcCallback(java.lang.Runnable cb)
           
 void setValue(boolean value)
          If value is true, then the underlying EnumModel is set to the option code of this OptionEnumModel.
 
Methods inherited from class de.matthiasmann.twl.model.AbstractOptionModel
addCallback, removeCallback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

optionState

protected final EnumModel<T extends java.lang.Enum<T>> optionState

optionCode

protected final T extends java.lang.Enum<T> optionCode
Constructor Detail

OptionEnumModel

public OptionEnumModel(EnumModel<T> optionState,
                       T optionCode)
Method Detail

getValue

public boolean getValue()

setValue

public void setValue(boolean value)
If value is true, then the underlying EnumModel is set to the option code of this OptionEnumModel. if value if false then nothing happens.

Parameters:
value - the new value of this BooleanModel

installSrcCallback

protected void installSrcCallback(java.lang.Runnable cb)
Specified by:
installSrcCallback in class AbstractOptionModel

removeSrcCallback

protected void removeSrcCallback(java.lang.Runnable cb)
Specified by:
removeSrcCallback in class AbstractOptionModel