Class BooleanRadioButtonHandler
- java.lang.Object
-
- net.sf.jguiraffe.gui.builder.components.AbstractCompositeComponentHandler<T,Boolean>
-
- net.sf.jguiraffe.gui.builder.components.model.AbstractRadioButtonHandler<Boolean>
-
- net.sf.jguiraffe.examples.tutorial.viewset.BooleanRadioButtonHandler
-
- All Implemented Interfaces:
CompositeComponentHandler<Boolean,Boolean>
,ComponentHandler<Boolean>
public class BooleanRadioButtonHandler extends AbstractRadioButtonHandler<Boolean>
A specialized
ComponentHandler
implementation for a radio button group with only two elements.This handler implementation is used for the radio button group which defines the sort direction. It can be either ascending or descending. For demonstration purposes we map these values to a boolean flag (true means descending, false means ascending). It would also be possible to use an enumeration type instead. This class mainly demonstrates how a custom component handler for radio buttons can be created.
- Version:
- $Id: BooleanRadioButtonHandler.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description BooleanRadioButtonHandler()
Creates a new instance ofBooleanRadioButtonHandler
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
getButtonIndex(Boolean value)
Returns the index of the button with the specified value.protected Boolean
getDataForButton(int idx)
Returns the value of the radio button with the specified index.-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.model.AbstractRadioButtonHandler
getData, getUnselectedData, getUnselectedIndex, setData
-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.AbstractCompositeComponentHandler
addHandler, getChildHandler, getChildHandlerCount, getChildHandlerIndex, getChildHandlerNameAt, getChildHandlerNames, getChildHandlers, getComponent, getOuterComponent, getType, isEnabled, setEnabled
-
-
-
-
Method Detail
-
getButtonIndex
protected int getButtonIndex(Boolean value)
Returns the index of the button with the specified value. This method maps data values of the radio group to specific radio buttons. Because in our example true represents the descending button we return the corresponding index.- Specified by:
getButtonIndex
in classAbstractRadioButtonHandler<Boolean>
- Parameters:
value
- the data value of the radio group- Returns:
- the index of the selected radio button
-
getDataForButton
protected Boolean getDataForButton(int idx)
Returns the value of the radio button with the specified index. This method determines the data value for the whole radio group based on the selected radio button. Here we return true if and only if the descending radio button is selected.- Specified by:
getDataForButton
in classAbstractRadioButtonHandler<Boolean>
- Parameters:
idx
- the index of the selected radio button- Returns:
- the corresponding value for the whole radio group
-
-