de.matthiasmann.twl.model
Class OptionBooleanModel

java.lang.Object
  extended by de.matthiasmann.twl.model.AbstractOptionModel
      extended by de.matthiasmann.twl.model.OptionBooleanModel
All Implemented Interfaces:
BooleanModel, WithRunnableCallback

public class OptionBooleanModel
extends AbstractOptionModel

A BooleanModel which is true when the underlying IntegerModel 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 IntegerModel to another value. Eg by setting another OptionBooleanModel working on the same IntegerModel to true.


Field Summary
protected  int optionCode
           
protected  IntegerModel optionState
           
 
Constructor Summary
OptionBooleanModel(IntegerModel optionState, int optionCode)
          Creates a new OptionBooleanModel with the specified IntegerModel and option code.
 
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 IntegerModel is set to the option code of this OptionBooleanModel.
 
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 IntegerModel optionState

optionCode

protected final int optionCode
Constructor Detail

OptionBooleanModel

public OptionBooleanModel(IntegerModel optionState,
                          int optionCode)
Creates a new OptionBooleanModel with the specified IntegerModel and option code.

Parameters:
optionState - the IntegerModel which stores the current active option
optionCode - the option code of this option in the IntegerModel
Method Detail

getValue

public boolean getValue()

setValue

public void setValue(boolean value)
If value is true, then the underlying IntegerModel is set to the option code of this OptionBooleanModel. 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