Search in sources :

Example 6 with IObservableValue

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));
}
Also used : ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) IViewerObservableValue(org.eclipse.jface.databinding.viewers.IViewerObservableValue)

Aggregations

IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)6 DataBindingContext (org.eclipse.core.databinding.DataBindingContext)5 MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)2 ProjectInfoBean (net.heartsome.cat.common.bean.ProjectInfoBean)1 IViewerObservableValue (org.eclipse.jface.databinding.viewers.IViewerObservableValue)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1