ユーザーによる SWT リスト・ウィジェット項目選択後の入力フィールドの更新
パレットを使用して、SWT リスト・ウィジェットを変換に追加します。RcpTransformation クラスの postRender() メソッドをオーバーライドします。postRender() メソッドに、以下のコードを追加します。
//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());
}
});
注: factoryを解決できない場合は、その宣言を変換に追加します。例:
private HostScreenModelAdapterFactory factory;