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.
Difference between revisions of "Scout/Concepts/RadioButtonGroup"
m (→Description) |
(→Description) |
||
Line 7: | Line 7: | ||
== Description == | == Description == | ||
− | The RadioButtonGroup can be used to show a {{ScoutLink|Concepts|CodeType|CodeType}} or a {{ScoutLink|Concepts|LookupCall|LookupCall}} as RadioButtons. | + | The RadioButtonGroup can be used to show a {{ScoutLink|Concepts|CodeType|CodeType}} or a {{ScoutLink|Concepts|LookupCall|LookupCall}} as RadioButtons. A RadioButtonGroup is a normal {{ScoutLink|Concepts|ValueField|value field}} with parameterized type <code><T></code>. |
Only one of the RadioButtons can be selected. | Only one of the RadioButtons can be selected. | ||
− | + | Another possibility is to define the radio Button as Inner-Class: {{ScoutLink|Concepts|RadioButton}}. In this case, the value of the field is defined in each RadioButton with the {{ScoutProp|RadioValue}} property. | |
A RadioButtonGroup can also contain some other {{ScoutLink|Concepts|Field|fields}} in the group (as inner class). | A RadioButtonGroup can also contain some other {{ScoutLink|Concepts|Field|fields}} in the group (as inner class). | ||
− | {{note|TODO| | + | {{note|TODO|Merge from [http://www.eclipse.org/forums/index.php/mv/msg/247230/739550/#msg_739550 forum]: "list" of sections where a radio button is on the left and a group box or other field is on the right}} |
+ | |||
+ | |||
+ | === Example === | ||
+ | Here is some code to propose to choose between three colors (red, green and blue): | ||
+ | <source lang="java"> | ||
+ | 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"; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | Corresponding screenshot: | ||
+ | [[Image:Scout Color RadioGroup.png]] | ||
+ | |||
+ | The value can be set directly: | ||
+ | <source lang="java"> | ||
+ | getColorGroup().setValue("RED"); | ||
+ | </source> | ||
+ | where getColorGroup() is the convienece function add by the Scout SDK to get the ColorGroup field: | ||
+ | <source lang="java"> | ||
+ | public ColorGroup getColorGroup() { | ||
+ | return getFieldByClass(ColorGroup.class); | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | Of course, as for any other value field, it is possible to use the formData: | ||
+ | <source lang="java"> | ||
+ | formData.getColorGroup().setValue("BLUE"); | ||
+ | </source> | ||
+ | |||
+ | |||
+ | Another possibility to create the radio button is to use a code type. Here we use {{ScoutLink|Concepts|CodeType/Example|YesOrNoCodeType}}: | ||
+ | <source lang="java"> | ||
+ | public class YesOrNoGroup extends AbstractRadioButtonGroup<Boolean> { | ||
+ | |||
+ | @Override | ||
+ | protected String getConfiguredLabel() { | ||
+ | return TEXTS.get("YesOrNo"); | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | protected Class<? extends ICodeType> getConfiguredCodeType() { | ||
+ | return YesOrNoCodeType.class; | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | The <code><T></code> of <code>AbstractRadioButtonGroup</code> needs to match the {{ScoutProp|Id}} returned by the {{ScoutLink|Concepts|Code}}. | ||
+ | |||
+ | The value can also be set directly or with the formData: | ||
+ | <source lang="java"> | ||
+ | getFieldByClass(YesOrNoGroup.class).setValue(Boolean.FALSE) | ||
+ | formData.getYesOrNoGroup().setValue(Boolean.TRUE); | ||
+ | </source> | ||
== Screenshot == | == Screenshot == |
Revision as of 03:33, 15 April 2013
The Scout documentation has been moved to https://eclipsescout.github.io/.
Specific type of The Scout documentation has been moved to https://eclipsescout.github.io/. to propose a choice between a limited number of possibilities.
- implements: The Scout documentation has been moved to https://eclipsescout.github.io/.
- extends: The Scout documentation has been moved to https://eclipsescout.github.io/.
Description
The RadioButtonGroup can be used to show a The Scout documentation has been moved to https://eclipsescout.github.io/. or a The Scout documentation has been moved to https://eclipsescout.github.io/. as RadioButtons. A RadioButtonGroup is a normal The Scout documentation has been moved to https://eclipsescout.github.io/. with parameterized type <T>
.
Only one of the RadioButtons can be selected.
Another possibility is to define the radio Button as Inner-Class: The Scout documentation has been moved to https://eclipsescout.github.io/.. In this case, the value of the field is defined in each RadioButton with the The Scout documentation has been moved to https://eclipsescout.github.io/. property.
A RadioButtonGroup can also contain some other The Scout documentation has been moved to https://eclipsescout.github.io/. 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 The Scout documentation has been moved to https://eclipsescout.github.io/.:
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 The Scout documentation has been moved to https://eclipsescout.github.io/. returned by the The Scout documentation has been moved to https://eclipsescout.github.io/..
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 The Scout documentation has been moved to https://eclipsescout.github.io/. methods.
See also the The Scout documentation has been moved to https://eclipsescout.github.io/. and the The Scout documentation has been moved to https://eclipsescout.github.io/. pages for the properties that all fields have in common.
Events
Defined with The Scout documentation has been moved to https://eclipsescout.github.io/. methods.
See also the The Scout documentation has been moved to https://eclipsescout.github.io/. and the The Scout documentation has been moved to https://eclipsescout.github.io/. pages for the events that all fields have in common.
See Also
- The Scout documentation has been moved to https://eclipsescout.github.io/.
- The Scout documentation has been moved to https://eclipsescout.github.io/.
- The Scout documentation has been moved to https://eclipsescout.github.io/.