Pregunta

I have a comboviewer, and i need to have the databinding on it, so that the combo selection is automatically updated in the Model.

Also i need to add the combo items dynamically (to the exisitng combo items). With databinding how can i acheive this?

As am new to databinding, please point me to some good tutorial on comboviewer databinding with dynamic items (combo items).

The below code is for binding the comboviewer selection to the model:

final IObservableValue entityComboObservable = ViewersObservables.
observeSingleSelection(myComboViewer);        
final IObservableValue modelSelectedEntityObservable = BeansObservables.
observeValue (cmpObj, Company.EMP_SELCTION);        
bindingCntxt.bindValue(modelSelectedEntityObservable, entityComboObservable); 

where "cmpObj" is my model object which contains the list of objects which will be set as the input to the comboviewer

¿Fue útil?

Solución

You can do something like

 comboViewer.setContentProvider(new ObservableListContentProvider());
 comboViewer.setLabelProvider(labelProvider);
 // input must be a List
 comboViewer.setInput(input);
 IViewerObservableValue swtObs = ViewersObservables.observeSingleSelection(comboViewer);

Now create a model-ovservable and bind it with swtObs

Otros consejos

you need to use below input observable.

org.eclipse.jface.databinding.viewers.ViewersObservables.observeInput(Viewer)

bind input observable with the ListObservable.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top