Databing with viewer input [message #897320] |
Mon, 23 July 2012 15:13 |
|
Hello,
I am binding an TableViewer to my model, which contains a List of Objects.
The List is converted, by a Converter in the UpdateStrategy to a List of TableRowItem Objects, so that my model can be shown in the viewer.
IObservableValue observableViewerValue = ViewerProperties.input() .observe(tableViewer);
IObservableValue observableModelValue = ...IObservableValue form model...
...creation of the targetToModel and modelToTarget UpdateStrategies...
this.dataBindingContext.bindValue(observableViewerValue ,observableModelValue, targetToModel, modelToTarget);
With that code the input of the TableViewer is correctly filled by the converted model.
My Question is how to update the TableViewers input, when the input is changed with the org.eclipse.jface.databinding.viewers.ObservableValueEditingSupport.
In the ObservableValueEditingSupport itself you have to return an IObservableValue in the doCreateElementObservable method.
I added an IValueChangeListener to that IObservableValue and realized that the Values are updated in the TableRowItem, which I mentioned before.
But it seems that the input of the viewer is only affected internally inside the TableRowItem, so that the model(observableModelValue in the sample code), which is bound to the input of the TableViewer, is not updated.
How do I trigger an update to the model which is bound to the input of the TableViewer?
Using...
Object input = viewer.getInput();
viewer.setInput(input);
... does not update the model, which is bound to the input of the viewer
Best regards,
Simon
|
|
|
|
Re: Databing with viewer input [message #897384 is a reply to message #897380] |
Mon, 23 July 2012 21:49 |
|
Thanks for the reply Jan Krakora,
I am already using the ObservableListContentProvider for the TableViewer.
It updates the TableRowItems, which are passed as input via the binding, but not the model of the input binding is not updated.
So I got 2 different kinds of bindings:
1. Model, which is converted to a List of TableRowItems(by the UpdateStrategys Converter) in order to be shown as input of the TableViewer via ViewerProperties.input().observe(tableViewer)
2. TableRowItems, which internally contain the different columns of the TableViewer, which can be edited by an org.eclipse.jface.databinding.viewers.ObservableValueEditingSupport. So the CellEditor in the ObservableValueEditingSupport updates the TableRowItems correctly, but the model in the first binding is not informed, when an TableRowItem is changed.
So what I want is to trigger an update on the input model of the first binding, when a TableRowItem of the second binding is modified.
I'd like to update from target to model with the ViewerProperties.input().observe(tableViewer) binding.
I hope my needs are clear, otherwise I can offer more information.
Thanks in advance.
Best regards,
Simon
|
|
|
|
Powered by
FUDForum. Page generated in 0.06060 seconds