Home » Eclipse Projects » JFace » [Databinding] Tableviewer only updates new entries([Databinding] Tableviewer only updates new entries)
[Databinding] Tableviewer only updates new entries [message #1703234] |
Wed, 29 July 2015 15:16 |
Code Monkey Messages: 4 Registered: December 2010 |
Junior Member |
|
|
Hello!
Databinding experts - please help me out! I have problems with a view that contains a read-only tableviewer for selection and a details form to edit the selected values. This is pretty much standard Master/Detail I guess. Most of it works except one annoying thing:
When I edit data that already existed, the changes are not reflected in the tableviewer until I do a refresh. When I add a new entry to the List, then the changes are updated in the tableviewer after every keypress. Question is: What am I doing wrong? I do not see the difference between a new instance and a existing one. The data are loaded via Eclipselink from the database.
I run it as a RAP Application. Could it be there is a bug in RAP Databinding?
this is the code for binding the viewer to the model
ViewerSupport.bind(auftragsforschungViewer, projektAuftragsforschungWList,
BeanProperties.values(Auftraggeber.class,new String[] { "bezeichnung", "projektnr", "ansprechperson", "notiz" }));
if (projektAuftragsforschungWList != null) auftragsforschungViewer.setInput(projektAuftragsforschungWList);
auftragsforschungSelection = ViewersObservables.observeSingleSelection(auftragsforschungViewer);
IObservableValue guiAuftragsforschungGeberText = WidgetProperties.text(SWT.Modify).observe(auftragsforschungAuftraggeberText);
IObservableValue guiAuftragsforschungAnsprechpersonText = WidgetProperties.text(SWT.Modify).observe(auftragsforschungAnsprechpersonText);
IObservableValue guiAuftragsforschungProjektnrText = WidgetProperties.text(SWT.Modify).observe(auftragsforschungProjektnrText);
IObservableValue guiAuftragsforschungNotizText = WidgetProperties.text(SWT.Modify).observe(auftragsforschungNotizText);
// binding der detail ansicht zu aktuellen auswahl in der tabelle
bindingContext.bindValue(guiAuftragsforschungGeberText, BeansObservables.observeDetailValue(auftragsforschungSelection, "bezeichnung", String.class));
bindingContext.bindValue(guiAuftragsforschungAnsprechpersonText, BeansObservables.observeDetailValue(auftragsforschungSelection, "ansprechperson", String.class));
bindingContext.bindValue(guiAuftragsforschungProjektnrText, BeansObservables.observeDetailValue(auftragsforschungSelection, "projektnr", String.class));
bindingContext.bindValue(guiAuftragsforschungNotizText, BeansObservables.observeDetailValue(auftragsforschungSelection, "notiz", String.class));
projektAuftragsforschungWList is a nested property ("auftraggebers") in a projekt object. It is as List which contains objects of type Auftraggeber.class and is declared like this:
IObservableList projektAuftragsforschungWList = BeansObservables.observeDetailList(projektWValue, "auftraggebers", Auftraggeber.class);
When I add a new instance of Auftraggeber to this List, then the tableviewer is updated. If I change existing data that where loaded from DB then a refresh is needed.
I have digged through all TableViewer and Databindig examples that exists. Debugging did not help either.
Any advice would be highly appreciated.
Thanks for reading this.
Werner
|
|
|
Re: [Databinding] Tableviewer only updates new entries [message #1703375 is a reply to message #1703234] |
Fri, 31 July 2015 07:53 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
You need to use an ObservableMapLabelProvider.
Tom
On 29.07.15 17:16, Code Monkey wrote:
> Hello!
>
> Databinding experts - please help me out! I have problems with a view
> that contains a read-only tableviewer for selection and a details form
> to edit the selected values. This is pretty much standard Master/Detail
> I guess. Most of it works except one annoying thing:
>
> When I edit data that already existed, the changes are not reflected in
> the tableviewer until I do a refresh. When I add a new entry to the
> List, then the changes are updated in the tableviewer after every
> keypress. Question is: What am I doing wrong? I do not see the
> difference between a new instance and a existing one. The data are
> loaded via Eclipselink from the database. I run it as a RAP Application.
> Could it be there is a bug in RAP Databinding?
>
> this is the code for binding the viewer to the model
>
> ViewerSupport.bind(auftragsforschungViewer, projektAuftragsforschungWList,
> BeanProperties.values(Auftraggeber.class,new String[] {
> "bezeichnung", "projektnr", "ansprechperson", "notiz" }));
>
> if (projektAuftragsforschungWList != null)
> auftragsforschungViewer.setInput(projektAuftragsforschungWList);
>
> auftragsforschungSelection =
> ViewersObservables.observeSingleSelection(auftragsforschungViewer);
>
> IObservableValue guiAuftragsforschungGeberText =
> WidgetProperties.text(SWT.Modify).observe(auftragsforschungAuftraggeberText);
>
> IObservableValue guiAuftragsforschungAnsprechpersonText =
> WidgetProperties.text(SWT.Modify).observe(auftragsforschungAnsprechpersonText);
>
> IObservableValue guiAuftragsforschungProjektnrText =
> WidgetProperties.text(SWT.Modify).observe(auftragsforschungProjektnrText);
> IObservableValue guiAuftragsforschungNotizText =
> WidgetProperties.text(SWT.Modify).observe(auftragsforschungNotizText);
>
> // binding der detail ansicht zu aktuellen auswahl in der tabelle
> bindingContext.bindValue(guiAuftragsforschungGeberText,
> BeansObservables.observeDetailValue(auftragsforschungSelection,
> "bezeichnung", String.class));
> bindingContext.bindValue(guiAuftragsforschungAnsprechpersonText,
> BeansObservables.observeDetailValue(auftragsforschungSelection,
> "ansprechperson", String.class));
> bindingContext.bindValue(guiAuftragsforschungProjektnrText,
> BeansObservables.observeDetailValue(auftragsforschungSelection,
> "projektnr", String.class));
> bindingContext.bindValue(guiAuftragsforschungNotizText,
> BeansObservables.observeDetailValue(auftragsforschungSelection, "notiz",
> String.class));
>
>
> projektAuftragsforschungWList is a nested property ("auftraggebers") in
> a projekt object. It is as List which contains objects of type
> Auftraggeber.class and is declared like this:
>
> IObservableList projektAuftragsforschungWList =
> BeansObservables.observeDetailList(projektWValue, "auftraggebers",
> Auftraggeber.class);
>
> When I add a new instance of Auftraggeber to this List, then the
> tableviewer is updated. If I change existing data that where loaded from
> DB then a refresh is needed.
> I have digged through all TableViewer and Databindig examples that
> exists. Debugging did not help either.
> Any advice would be highly appreciated.
>
> Thanks for reading this.
>
> Werner
|
|
| |
Goto Forum:
Current Time: Thu Apr 25 04:06:16 GMT 2024
Powered by FUDForum. Page generated in 0.03809 seconds
|