eclipse-rcptt

Clicking the radio button is not updating the layout when using databinding in RCPTT


As you can see from the image, the Right button is checked but the label says LEFT AREA which should be RIGHT AREA

Right button is checked but left area label is still shown

Script used in RCPTT

get-button Right | click

Here's the sample snippet of the ui. When a button is checked, a label will show up saying which button is clicked.

DataBindingContext dataBindingContext = new DataBindingContext();

IObservableValue<Boolean> left = new WritableValue<>( true, Boolean.class );
IObservableValue<Boolean> right = new WritableValue<>( false, Boolean.class );

Composite sampleComposite = new Composite( parent, SWT.NONE );
sampleComposite.setLayout( GridLayoutFactory.fillDefaults().numColumns( 2 ).create() );

Button leftBtn = new Button( sampleComposite, SWT.RADIO );
leftBtn.setText( "Left" );
dataBindingContext.bindValue( WidgetProperties.buttonSelection().observe( leftBtn ), left );

Button rightBtn = new Button( sampleComposite, SWT.RADIO );
rightBtn.setText( "Right" );
dataBindingContext.bindValue( WidgetProperties.buttonSelection().observe( rightBtn ), right );

StackLayout stackLayout = new StackLayout();
Composite stackComposite = new Composite( sampleComposite, SWT.NONE );
    stackComposite.setLayout( stackLayout );

Label leftLbl = new Label( stackComposite, SWT.NONE );
leftLbl.setText( "LEFT AREA" );

Label rightLbl = new Label( stackComposite, SWT.NONE );
rightLbl.setText( "RIGHT AREA" );

ISideEffect.create( () -> {
    stackLayout.topControl = left.getValue() ? leftLbl : rightLbl;
    stackComposite.layout();
} );

Solution

  • I was able to fix this issue by creating my own custom ecl command that sends selection event and deselect every radio button in the same composite and just select the target radio button. looks like aut is not deselecting the surrounding radio button when you use click command