use of org.eclipse.core.databinding.observable.value.IObservableValue in project translationstudio8 by heartsome.
the class ConverterUtil method bindValue.
/**
* 对下拉列表和转换器列表进行绑定
* @param context
* @param comboViewer
* @param model
* ;
*/
public static void bindValue(DataBindingContext context, ComboViewer comboViewer, ConverterViewModel model) {
// ViewerSupport.bind(comboViewer, BeansObservables.observeList(
// model, "supportTypes", String.class),
// Properties.selfValue(String.class));
//
//
// context.bindValue(ViewersObservables
// .observeSingleSelection(comboViewer), BeansObservables
// .observeValue(model,
// "selectedType"));
// ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider();
comboViewer.setContentProvider(new ArrayContentProvider());
comboViewer.setComparator(new ViewerComparator());
// IObservableMap[] attributeMaps = BeansObservables.observeMaps(
// viewerContentProvider.getKnownElements(),
// ConverterBean.class, new String[] { "description" });
// comboViewer.setLabelProvider(new ObservableMapLabelProvider(
// attributeMaps));
// comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class));
comboViewer.setInput(model.getSupportTypes());
IViewerObservableValue selection = ViewersObservables.observeSingleSelection(comboViewer);
IObservableValue observableValue = BeansObservables.observeDetailValue(selection, PROPERTIES_NAME, null);
context.bindValue(observableValue, BeansObservables.observeValue(model, PROPERTIES_SELECTED_TYPE));
}
Aggregations