Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » [Databinding] Tableviewer only updates new entries([Databinding] Tableviewer only updates new entries)
icon5.gif  [Databinding] Tableviewer only updates new entries [message #1703234] Wed, 29 July 2015 15:16 Go to next message
Code Monkey is currently offline Code MonkeyFriend
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 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
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
Re: [Databinding] Tableviewer only updates new entries [message #1703543 is a reply to message #1703375] Sun, 02 August 2015 22:52 Go to previous message
Code Monkey is currently offline Code MonkeyFriend
Messages: 4
Registered: December 2010
Junior Member
Thanks for your reply Tom!

I thought I am already using a ObservableMapLabelProvider because the bind method of the ViewerSupport -Class already creates this for me:

public static void bind(StructuredViewer viewer, IObservableList input,	IValueProperty[] labelProperties) {
		ObservableListContentProvider contentProvider = new ObservableListContentProvider();
		if (viewer.getInput() != null)
			viewer.setInput(null);
		viewer.setContentProvider(contentProvider);
		viewer.setLabelProvider(new ObservableMapLabelProvider(Properties
				.observeEach(contentProvider.getKnownElements(),
						labelProperties)));
		if (input != null)
			viewer.setInput(input);
}


Werner
Previous Topic:How to trigger updateMarker for TextEditor from code
Next Topic:how to convert eclipse plug-in project to java project
Goto Forum:
  


Current Time: Thu Apr 25 10:41:30 GMT 2024

Powered by FUDForum. Page generated in 0.03343 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top