Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Scout/Concepts/RadioButtonGroup
Scout |
Wiki Home |
Website |
Download • Git |
Community |
Forums • Blog • Twitter • G+ |
Bugzilla |
Bugzilla |
Specific type of value field to propose a choice between a limited number of possibilities.
Description
The RadioButtonGroup can be used to show a CodeType or a LookupCall as RadioButtons. A RadioButtonGroup is a normal value field with parameterized type <T>
.
Only one of the RadioButtons can be selected.
Another possibility is to define the radio Button as Inner-Class: RadioButton. In this case, the value of the field is defined in each RadioButton with the RadioValue property.
A RadioButtonGroup can also contain some other fields in the group (as inner class).
Example
Here is some code to propose to choose between three colors (red, green and blue):
public class ColorGroup extends AbstractRadioButtonGroup<String> { @Override protected String getConfiguredLabel() { return TEXTS.get("Color"); } @Order(10.0) public class RedButton extends AbstractRadioButton { @Override protected String getConfiguredLabel() { return TEXTS.get("Red"); } @Override protected Object getConfiguredRadioValue() { return "RED"; } } @Order(20.0) public class GreenButton extends AbstractRadioButton { @Override protected String getConfiguredLabel() { return TEXTS.get("Green"); } @Override protected Object getConfiguredRadioValue() { return "GREEN"; } } @Order(30.0) public class BlueButton extends AbstractRadioButton { @Override protected String getConfiguredLabel() { return TEXTS.get("Blue"); } @Override protected Object getConfiguredRadioValue() { return "BLUE"; } } }
The value can be set directly:
getColorGroup().setValue("RED");
where getColorGroup() is the convienece function add by the Scout SDK to get the ColorGroup field:
public ColorGroup getColorGroup() { return getFieldByClass(ColorGroup.class); }
Of course, as for any other value field, it is possible to use the formData:
formData.getColorGroup().setValue("BLUE");
Another possibility to create the radio button is to use a code type. Here we use YesOrNoCodeType:
public class YesOrNoGroup extends AbstractRadioButtonGroup<Boolean> { @Override protected String getConfiguredLabel() { return TEXTS.get("YesOrNo"); } @Override protected Class<? extends ICodeType> getConfiguredCodeType() { return YesOrNoCodeType.class; } }
The <T>
of AbstractRadioButtonGroup
needs to match the Id returned by the Code.
The value can also be set directly or with the formData:
getFieldByClass(YesOrNoGroup.class).setValue(Boolean.FALSE) formData.getYesOrNoGroup().setValue(Boolean.TRUE);
Screenshot
RAP | SWT | Swing | Swing Rayo |
---|---|---|---|
![]() |
![]() |
![]() |
![]() |
Properties
Defined with getConfiguredXxxxxx() methods.
See also the Field and the Value field pages for the properties that all fields have in common.
Events
Defined with execXxxxxx() methods.
See also the Field and the Value field pages for the events that all fields have in common.