package pt.ist.renderers;
import pt.ist.renderers.components.HtmlLabel;
import pt.ist.renderers.components.HtmlRadioButton;
import pt.ist.renderers.components.HtmlRadioButtonList;
import pt.ist.renderers.components.HtmlSimpleValueComponent;
import pt.ist.renderers.components.HtmlText;
/**
* The EnumRadioInputRenderer
provides a way of doing the
* input of an enum value by using a list of radio buttons. All the values
* of that enum are presented as a radio button and the use can choose
* one of the values.
*
*
* Example:
*
*
* @author cfgi
*/
public class EnumRadioInputRenderer extends EnumInputRenderer {
@Override
protected void addEnumElement(Enum enumerate, HtmlSimpleValueComponent holder, Enum oneEnum, String description) {
HtmlRadioButtonList radioList = (HtmlRadioButtonList) holder;
HtmlText descriptionComponent = new HtmlText(description);
HtmlLabel label = new HtmlLabel();
label.setBody(descriptionComponent);
HtmlRadioButton radioButton = radioList.addOption(label, oneEnum.toString());
label.setFor(radioButton);
if (oneEnum.equals(enumerate)) {
radioButton.setChecked(true);
}
}
@Override
protected HtmlSimpleValueComponent createInputContainerComponent(Enum enumerate) {
return new HtmlRadioButtonList();
}
}