I am developing an eclipse 4 RCP application using SWT/JFace. One of the UI screens presents a table and an associated view that displays information from the selected row. I have successfuly set up data binding to display the information for the selected row in the display area. The method used is shown below.
IObservableValue selection = ViewersObservables.observeSingleSelection(tableView);
IObservableValue detailObservable = BeansObservables.observeDetailValue(selection, "myField", MyClass.class);
IObservableValue widgetValue = SWTObservables.observeText(messagePane.getMyFieldControl());
DataBindingUtil.getContext().bindValue(widgetValue, detailObservable);
messagePane is a Composite class extension that will be re-used in various ways in the application. The class provides getter methods for each control that I need to bind data to. DataBindingUtil is a helper class to make some of the tedious data binding tasks easier.
The UI screen described also has some navigation buttons that allow the user to move to the front/end of the current list of messages, as well as moving to the prior/next message. The logic attached to these buttons changes the table selection, but the data binding does not follow suit. I need to physically click on the desired row for the message display fields to update.
As an example:
Button toStartBtn = new Button(comp, SWT.NONE);
toStartBtn.setText("First");
toStartBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (!model.getMessageList().isEmpty()) {
tableView.getTable().setSelection(0);
}
}
});
Why does the data binding not work in this case? Is there a subtle correction I need to make in how the data binding is done or how the table selection is changed? Something else?