Skip to main content

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.

Jump to: navigation, search

Scout/Concepts/RadioButtonGroup

< Scout‎ | Concepts
Revision as of 03:33, 15 April 2013 by Jeremie.bresson.unblu.com (Talk | contribs) (Description)

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.

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).

Note.png
TODO
Merge from 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):

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";
    }
  }
}

Corresponding screenshot: Scout Color RadioGroup.png

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
Scout 3.8 RadioButtonGroup RAP.png Scout 3.8 RadioButtonGroup SWT.png Scout 3.8 RadioButtonGroup Swing.png Scout 3.8 RadioButtonGroup Swing Rayo.png

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

Copyright © Eclipse Foundation, Inc. All Rights Reserved.