Updating an input field after the user selects a SWT List widget item
Using the palette, add a SWT List widget to your transformation.
Override the postRender() method of the RcpTransformation
class. Add the following code to the postRender() method:
//retrieve a model adapter that is bound to a host field at position 1527.
//assuming that the list widget will update the field at this position on the host.
final IModelAdapter modelAdapter = factory.getFieldAdapter(1527);
list.addSelectionListener(new SelectionListener()
{
public void widgetDefaultSelected(SelectionEvent event) {
}
//when an item in the list is selected, update the field at position 1527
//with the value of selected item.
public void widgetSelected(SelectionEvent event) {
modelAdapter.setValue(list.getData(list.
getItem(list.getSelectionIndex())).toString());
}
});
Note: If factory cannot be resolved, add a declaration
for it to the transformation. For example:
private HostScreenModelAdapterFactory factory;