Forum Controls
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

Java, the OLPC, and community responsibility

The "One Laptop Per Child" project has a great device ready to ship, but there's no Java on there. Let's think about working together to put Java on OLPC!
Replies: 45 - Pages: 4   [ 1 2 3 4 | Next ]
Threads: [ Previous | Next ]
  Click to reply to this thread Reply

EMF databinding TableViewer

At 11:13 AM on Aug 7, 2008, Axel Nitert wrote:

Hi guys,

I am currently struggling with Toms approach of using databinding for
1:n TableViewers.
I have (or at least I think I have) followed the instructions and almost
copied the example of Tom (thanks for the great work).
My problem is that the list remains empty and I would very much
appreciate any hint about what I'm doing wrong or how I can debug this.

Here is the code of the View Part:

public void createPartControl(Composite parent) {
super.createPartControl(parent);

// my small example model
Domain dn = DomainFactory.eINSTANCE.createDomain();
Person p = DomainFactory.eINSTANCE.createPerson();
dn.getPersons().add(p);

// create the viewer
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL |
SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL,
true, true, 1, 1));

// set up the table
Table table = viewer.getTable();
TableLayout layout = new TableLayout();
table.setLayout(layout);
table.setHeaderVisible(true);
table.setLinesVisible(true);

// Define one exmaple column Columns
TableViewerColumn viewerColumn;
viewerColumn = new TableViewerColumn(viewer, SWT.NONE);

// for simplification I use the standard labelprovider
viewerColumn.setLabelProvider(new ColumnLabelProvider());
viewerColumn.getColumn().setText("Last Name, First Name");
viewerColumn.getColumn().setWidth(200);
viewerColumn.getColumn().setMoveable(true);

// Content Provider
ObservableListContentProvider contentProvider = new
ObservableListContentProvider();
viewer.setContentProvider(contentProvider);

// set input
IObservableList list = EMFObservables.observeList(dn,
DomainPackage.Literals.PERSON__SEMESTERS);
viewer.setInput(list);

}

Thanks for your help.
Axel
  Click to reply to this thread Reply
1. At 11:58 AM on Aug 7, 2008, Tom Schindl Javalobby Junkies wrote:

Re: EMF databinding TableViewer

Axel Nitert schrieb:
> Hi guys,
>
> I am currently struggling with Toms approach of using databinding for
> 1:n TableViewers.
> I have (or at least I think I have) followed the instructions and almost
> copied the example of Tom (thanks for the great work).
> My problem is that the list remains empty and I would very much
> appreciate any hint about what I'm doing wrong or how I can debug this.
>
> Here is the code of the View Part:
>
> public void createPartControl(Composite parent) {
> super.createPartControl(parent);
>
> // my small example model
> Domain dn = DomainFactory.eINSTANCE.createDomain();
> Person p = DomainFactory.eINSTANCE.createPerson();
> dn.getPersons().add(p);
>
> // create the viewer
> viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL |
> SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
> viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL,
> true, true, 1, 1));
>
> // set up the table
> Table table = viewer.getTable();
> TableLayout layout = new TableLayout();
> table.setLayout(layout);
> table.setHeaderVisible(true);
> table.setLinesVisible(true);
>
> // Define one exmaple column Columns
> TableViewerColumn viewerColumn;
> viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
>
> // for simplification I use the standard labelprovider
> viewerColumn.setLabelProvider(new ColumnLabelProvider());
> viewerColumn.getColumn().setText("Last Name, First Name");
> viewerColumn.getColumn().setWidth(200);
> viewerColumn.getColumn().setMoveable(true);
>
> // Content Provider
> ObservableListContentProvider contentProvider = new
> ObservableListContentProvider();
> viewer.setContentProvider(contentProvider);
>
> // set input
> IObservableList list = EMFObservables.observeList(dn,
> DomainPackage.Literals.PERSON__SEMESTERS);
> viewer.setInput(list);
>
> }

My guess is that you are getting an exception in your error-log but you
have not been running under -consoleLog because the feature you want to
observe DOMAIN__PERSONS-Feature or am I missing something obvious (I
make the assumption from the title of the column 'Last Name, First Name' ).

My guess of your model looks like this:

Domain
1 - n Person
1 - n Semesters

Is that correct? So what would you like to represent in the viewer?

The list of persons => The viewer is the master
The semsters of a person => The viewer is the detail and you need to use
a EMFObservable#observeDetailList.

So taking this together I think you need to modify your code from above
like this:

--------8 // set input
IObservableList list = EMFObservables.observeList(
dn,
DomainPackage.Literals.DOMAIN__PERSONS);

viewer.setInput(list);

IObservableValue master = ViewerObservables.observeSingleSelection(viewer);

// The detail viewer
TableViewer semesterViewer = new TableViewer(....);

TableViewerColumn c = ......

ObservableListContentProvider contentProvider2 = new
ObservableListContentProvider();
semesterViewer.setContentProvider(contentProvider2);

IObservableList detailList = EMFObservables.observeDetailList(
Realm.getDefault(),
master
DomainPackage.Literals.PERSON__SEMESTERS);
semesterViewer.setInput(detailList);

--------8
This is untested code and based on the assumptions I made from your code
so it might be inaccurate :-)

Tom


--
B e s t S o l u t i o n . at
--------------------------------------------------------------------
Tom Schindl JFace-Committer
--------------------------------------------------------------------
  Click to reply to this thread Reply
2. At 12:46 PM on Aug 7, 2008, Axel Nitert wrote:

Re: EMF databinding TableViewer

Tom Schindl schrieb:
> Axel Nitert schrieb:
>> Hi guys,
>>
>> I am currently struggling with Toms approach of using databinding for
>> 1:n TableViewers.
>> I have (or at least I think I have) followed the instructions and
>> almost copied the example of Tom (thanks for the great work).
>> My problem is that the list remains empty and I would very much
>> appreciate any hint about what I'm doing wrong or how I can debug this.
>>
>> Here is the code of the View Part:
>>
>> public void createPartControl(Composite parent) {
>> super.createPartControl(parent);
>> // my small example model Domain dn =
>> DomainFactory.eINSTANCE.createDomain();
>> Person p = DomainFactory.eINSTANCE.createPerson();
>> dn.getPersons().add(p);
>> // create the viewer viewer = new TableViewer(parent,
>> SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER |
>> SWT.FULL_SELECTION);
>> viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL,
>> true, true, 1, 1));
>>
>> // set up the table
>> Table table = viewer.getTable();
>> TableLayout layout = new TableLayout();
>> table.setLayout(layout);
>> table.setHeaderVisible(true);
>> table.setLinesVisible(true);
>> // Define one exmaple column Columns
>> TableViewerColumn viewerColumn;
>> viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
>>
>> // for simplification I use the standard labelprovider
>> viewerColumn.setLabelProvider(new ColumnLabelProvider());
>> viewerColumn.getColumn().setText("Last Name, First Name");
>> viewerColumn.getColumn().setWidth(200);
>> viewerColumn.getColumn().setMoveable(true);
>> // Content Provider ObservableListContentProvider
>> contentProvider = new ObservableListContentProvider();
>> viewer.setContentProvider(contentProvider);
>>
>> // set input
>> IObservableList list = EMFObservables.observeList(dn,
>> DomainPackage.Literals.PERSON__SEMESTERS);
>> viewer.setInput(list);
>> }
>
> My guess is that you are getting an exception in your error-log but you
> have not been running under -consoleLog because the feature you want to
> observe DOMAIN__PERSONS-Feature or am I missing something obvious (I
> make the assumption from the title of the column 'Last Name, First Name' ).
>
> My guess of your model looks like this:
>
> Domain
> 1 - n Person
> 1 - n Semesters
>
> Is that correct? So what would you like to represent in the viewer?
>
> The list of persons => The viewer is the master
> The semsters of a person => The viewer is the detail and you need to use
> a EMFObservable#observeDetailList.
>
> So taking this together I think you need to modify your code from above
> like this:
>
> --------8 > // set input
> IObservableList list = EMFObservables.observeList(
> dn,
> DomainPackage.Literals.DOMAIN__PERSONS);
>
> viewer.setInput(list);
>
> IObservableValue master = ViewerObservables.observeSingleSelection(viewer);
>
> // The detail viewer
> TableViewer semesterViewer = new TableViewer(....);
>
> TableViewerColumn c = ......
>
> ObservableListContentProvider contentProvider2 = new
> ObservableListContentProvider();
> semesterViewer.setContentProvider(contentProvider2);
>
> IObservableList detailList = EMFObservables.observeDetailList(
> Realm.getDefault(),
> master
> DomainPackage.Literals.PERSON__SEMESTERS);
> semesterViewer.setInput(detailList);
>
> --------8 >
> This is untested code and based on the assumptions I made from your code
> so it might be inaccurate :-)
>
> Tom
>
>

Hi Tom,

thanks for the answer. The issue that I am struggling with is more
complex. I want to use the observable list with an EMF linked to a
database (TENEO, Hibernate). In order to narrow down the issue I have
reduced the code and this is why I left PERSON__SEMESTERS in the list.

You are totally right when I replace then code

IObservableList list = EMFObservables.observeList(dn,
DomainPackage.Literals.PERSON__SEMESTERS);

with
IObservableList list = EMFObservables.observeList(dn,
DomainPackage.Literals.DOMAIN__PERSONS);

my example works fine.

NOW, back to the original issue. If I use the same code with a


// this prints 3 elements
System.out.println(DomainUtil.getRoot().getPersons().size());

IObservableList list = EMFObservables.observeList(DomainUtil.getRoot(),
DomainPackage.Literals.DOMAIN__PERSONS);

viewer.setInput(list);

The list is still empty and I do not get any exceptions (I have now
-consoleLog switched on ;-) ).

The method DomainUtil.getRoot simply returns the root object that was
create with the following code (the resource is a hibernate teneo resource):

try {
resource.load(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}

if (resource.getContents().size()>0) {
root = (Domain)resource.getContents().get(0);
}

Do you have any idea what can make the difference here?

By the way thanks for the master detail code this is one of the next
viewers that I am going to create.

Best regards
Axel



  Click to reply to this thread Reply
3. At 1:58 PM on Aug 7, 2008, Tom Schindl Javalobby Junkies wrote:

Re: EMF databinding TableViewer

This certainly looks like a teneo/proxy issue? I guess simply asking for
the for size of a list won't materialize it but I really really have no
idea what's going on here, I've never used teneo myself but if the code
you posted previously works it must be some issue with teneo or proxies.

Did you tried steping through the code with a debugger to see what's
really going on? The only thing you now know is that databinding works
appropiately and the problem is some where else :-(

Tom

Axel Nitert schrieb:
> Tom Schindl schrieb:
>> Axel Nitert schrieb:
>>> Hi guys,
>>>
>>> I am currently struggling with Toms approach of using databinding for
>>> 1:n TableViewers.
>>> I have (or at least I think I have) followed the instructions and
>>> almost copied the example of Tom (thanks for the great work).
>>> My problem is that the list remains empty and I would very much
>>> appreciate any hint about what I'm doing wrong or how I can debug this.
>>>
>>> Here is the code of the View Part:
>>>
>>> public void createPartControl(Composite parent) {
>>> super.createPartControl(parent);
>>> // my small example model Domain dn =
>>> DomainFactory.eINSTANCE.createDomain();
>>> Person p = DomainFactory.eINSTANCE.createPerson();
>>> dn.getPersons().add(p);
>>> // create the viewer viewer = new TableViewer(parent,
>>> SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER |
>>> SWT.FULL_SELECTION);
>>> viewer.getControl().setLayoutData(new GridData(SWT.FILL,
>>> SWT.FILL, true, true, 1, 1));
>>>
>>> // set up the table
>>> Table table = viewer.getTable();
>>> TableLayout layout = new TableLayout();
>>> table.setLayout(layout);
>>> table.setHeaderVisible(true);
>>> table.setLinesVisible(true);
>>> // Define one exmaple column Columns
>>> TableViewerColumn viewerColumn;
>>> viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
>>>
>>> // for simplification I use the standard labelprovider
>>> viewerColumn.setLabelProvider(new ColumnLabelProvider());
>>> viewerColumn.getColumn().setText("Last Name, First Name");
>>> viewerColumn.getColumn().setWidth(200);
>>> viewerColumn.getColumn().setMoveable(true);
>>> // Content Provider ObservableListContentProvider
>>> contentProvider = new ObservableListContentProvider();
>>> viewer.setContentProvider(contentProvider);
>>>
>>> // set input
>>> IObservableList list = EMFObservables.observeList(dn,
>>> DomainPackage.Literals.PERSON__SEMESTERS);
>>> viewer.setInput(list);
>>> }
>>
>> My guess is that you are getting an exception in your error-log but
>> you have not been running under -consoleLog because the feature you
>> want to observe DOMAIN__PERSONS-Feature or am I missing something
>> obvious (I make the assumption from the title of the column 'Last
>> Name, First Name' ).
>>
>> My guess of your model looks like this:
>>
>> Domain
>> 1 - n Person
>> 1 - n Semesters
>>
>> Is that correct? So what would you like to represent in the viewer?
>>
>> The list of persons => The viewer is the master
>> The semsters of a person => The viewer is the detail and you need to
>> use a EMFObservable#observeDetailList.
>>
>> So taking this together I think you need to modify your code from
>> above like this:
>>
>> --------8 >> // set input
>> IObservableList list = EMFObservables.observeList(
>> dn,
>> DomainPackage.Literals.DOMAIN__PERSONS);
>>
>> viewer.setInput(list);
>>
>> IObservableValue master =
>> ViewerObservables.observeSingleSelection(viewer);
>>
>> // The detail viewer
>> TableViewer semesterViewer = new TableViewer(....);
>>
>> TableViewerColumn c = ......
>>
>> ObservableListContentProvider contentProvider2 = new
>> ObservableListContentProvider();
>> semesterViewer.setContentProvider(contentProvider2);
>>
>> IObservableList detailList = EMFObservables.observeDetailList(
>> Realm.getDefault(),
>> master
>> DomainPackage.Literals.PERSON__SEMESTERS);
>> semesterViewer.setInput(detailList);
>>
>> --------8 >>
>> This is untested code and based on the assumptions I made from your
>> code so it might be inaccurate :-)
>>
>> Tom
>>
>>
>
> Hi Tom,
>
> thanks for the answer. The issue that I am struggling with is more
> complex. I want to use the observable list with an EMF linked to a
> database (TENEO, Hibernate). In order to narrow down the issue I have
> reduced the code and this is why I left PERSON__SEMESTERS in the list.
>
> You are totally right when I replace then code
>
> IObservableList list = EMFObservables.observeList(dn,
> DomainPackage.Literals.PERSON__SEMESTERS);
>
> with
> IObservableList list = EMFObservables.observeList(dn,
> DomainPackage.Literals.DOMAIN__PERSONS);
>
> my example works fine.
>
> NOW, back to the original issue. If I use the same code with a
>
>
> // this prints 3 elements
> System.out.println(DomainUtil.getRoot().getPersons().size());
>
> IObservableList list = EMFObservables.observeList(DomainUtil.getRoot(),
> DomainPackage.Literals.DOMAIN__PERSONS);
>
> viewer.setInput(list);
>
> The list is still empty and I do not get any exceptions (I have now
> -consoleLog switched on ;-) ).
>
> The method DomainUtil.getRoot simply returns the root object that was
> create with the following code (the resource is a hibernate teneo
> resource):
>
> try {
> resource.load(Collections.EMPTY_MAP);
> } catch (IOException e) {
> e.printStackTrace();
> }
>
> if (resource.getContents().size()>0) {
> root = (Domain)resource.getContents().get(0);
> }
>
> Do you have any idea what can make the difference here?
>
> By the way thanks for the master detail code this is one of the next
> viewers that I am going to create.
>
> Best regards
> Axel
>
>
>


--
B e s t S o l u t i o n . at
--------------------------------------------------------------------
Tom Schindl JFace-Committer
--------------------------------------------------------------------
  Click to reply to this thread Reply
4. At 2:41 PM on Aug 7, 2008, Axel Nitert wrote:

Re: EMF databinding TableViewer

Tom,

thanks for the reply.

I agree that it obviously has got something to do with teneo. I tried to
go through the code using the debugger but the thing is that I have no
idea what happens after I call setInput. I thought that the
ContenProviders method getElements should be called. But it isn't.

Do you have an additional hint where the best place would be to set the
breakpoint?

The IObeservableList looks good as far as I can see. there are three
elements in the list.

May be I'll have a look at the teneo forum. It could be a bug with the
setup I chose.

Teneo is really a great framework to persist the EMF model to a
relational database without spending too much time with matching fields
to table columns.

Thanks and best regards
Axel



Tom Schindl schrieb:
> This certainly looks like a teneo/proxy issue? I guess simply asking for
> the for size of a list won't materialize it but I really really have no
> idea what's going on here, I've never used teneo myself but if the code
> you posted previously works it must be some issue with teneo or proxies.
>
> Did you tried steping through the code with a debugger to see what's
> really going on? The only thing you now know is that databinding works
> appropiately and the problem is some where else :-(
>
> Tom
>
> Axel Nitert schrieb:
>> Tom Schindl schrieb:
>>> Axel Nitert schrieb:
>>>> Hi guys,
>>>>
>>>> I am currently struggling with Toms approach of using databinding
>>>> for 1:n TableViewers.
>>>> I have (or at least I think I have) followed the instructions and
>>>> almost copied the example of Tom (thanks for the great work).
>>>> My problem is that the list remains empty and I would very much
>>>> appreciate any hint about what I'm doing wrong or how I can debug this.
>>>>
>>>> Here is the code of the View Part:
>>>>
>>>> public void createPartControl(Composite parent) {
>>>> super.createPartControl(parent);
>>>> // my small example model Domain dn =
>>>> DomainFactory.eINSTANCE.createDomain();
>>>> Person p = DomainFactory.eINSTANCE.createPerson();
>>>> dn.getPersons().add(p);
>>>> // create the viewer viewer = new TableViewer(parent,
>>>> SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER |
>>>> SWT.FULL_SELECTION);
>>>> viewer.getControl().setLayoutData(new GridData(SWT.FILL,
>>>> SWT.FILL, true, true, 1, 1));
>>>>
>>>> // set up the table
>>>> Table table = viewer.getTable();
>>>> TableLayout layout = new TableLayout();
>>>> table.setLayout(layout);
>>>> table.setHeaderVisible(true);
>>>> table.setLinesVisible(true);
>>>> // Define one exmaple column Columns
>>>> TableViewerColumn viewerColumn;
>>>> viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
>>>>
>>>> // for simplification I use the standard labelprovider
>>>> viewerColumn.setLabelProvider(new ColumnLabelProvider());
>>>> viewerColumn.getColumn().setText("Last Name, First Name");
>>>> viewerColumn.getColumn().setWidth(200);
>>>> viewerColumn.getColumn().setMoveable(true);
>>>> // Content Provider ObservableListContentProvider
>>>> contentProvider = new ObservableListContentProvider();
>>>> viewer.setContentProvider(contentProvider);
>>>>
>>>> // set input
>>>> IObservableList list = EMFObservables.observeList(dn,
>>>> DomainPackage.Literals.PERSON__SEMESTERS);
>>>> viewer.setInput(list);
>>>> }
>>>
>>> My guess is that you are getting an exception in your error-log but
>>> you have not been running under -consoleLog because the feature you
>>> want to observe DOMAIN__PERSONS-Feature or am I missing something
>>> obvious (I make the assumption from the title of the column 'Last
>>> Name, First Name' ).
>>>
>>> My guess of your model looks like this:
>>>
>>> Domain
>>> 1 - n Person
>>> 1 - n Semesters
>>>
>>> Is that correct? So what would you like to represent in the viewer?
>>>
>>> The list of persons => The viewer is the master
>>> The semsters of a person => The viewer is the detail and you need to
>>> use a EMFObservable#observeDetailList.
>>>
>>> So taking this together I think you need to modify your code from
>>> above like this:
>>>
>>> --------8 >>> // set input
>>> IObservableList list = EMFObservables.observeList(
>>> dn,
>>> DomainPackage.Literals.DOMAIN__PERSONS);
>>>
>>> viewer.setInput(list);
>>>
>>> IObservableValue master =
>>> ViewerObservables.observeSingleSelection(viewer);
>>>
>>> // The detail viewer
>>> TableViewer semesterViewer = new TableViewer(....);
>>>
>>> TableViewerColumn c = ......
>>>
>>> ObservableListContentProvider contentProvider2 = new
>>> ObservableListContentProvider();
>>> semesterViewer.setContentProvider(contentProvider2);
>>>
>>> IObservableList detailList = EMFObservables.observeDetailList(
>>> Realm.getDefault(),
>>> master
>>> DomainPackage.Literals.PERSON__SEMESTERS);
>>> semesterViewer.setInput(detailList);
>>>
>>> --------8 >>>
>>> This is untested code and based on the assumptions I made from your
>>> code so it might be inaccurate :-)
>>>
>>> Tom
>>>
>>>
>>
>> Hi Tom,
>>
>> thanks for the answer. The issue that I am struggling with is more
>> complex. I want to use the observable list with an EMF linked to a
>> database (TENEO, Hibernate). In order to narrow down the issue I have
>> reduced the code and this is why I left PERSON__SEMESTERS in the list.
>>
>> You are totally right when I replace then code
>>
>> IObservableList list = EMFObservables.observeList(dn,
>> DomainPackage.Literals.PERSON__SEMESTERS);
>>
>> with
>> IObservableList list = EMFObservables.observeList(dn,
>> DomainPackage.Literals.DOMAIN__PERSONS);
>>
>> my example works fine.
>>
>> NOW, back to the original issue. If I use the same code with a
>>
>>
>> // this prints 3 elements
>> System.out.println(DomainUtil.getRoot().getPersons().size());
>>
>> IObservableList list =
>> EMFObservables.observeList(DomainUtil.getRoot(),
>> DomainPackage.Literals.DOMAIN__PERSONS);
>>
>> viewer.setInput(list);
>>
>> The list is still empty and I do not get any exceptions (I have now
>> -consoleLog switched on ;-) ).
>>
>> The method DomainUtil.getRoot simply returns the root object that was
>> create with the following code (the resource is a hibernate teneo
>> resource):
>>
>> try {
>> resource.load(Collections.EMPTY_MAP);
>> } catch (IOException e) {
>> e.printStackTrace();
>> }
>> if (resource.getContents().size()>0) {
>> root = (Domain)resource.getContents().get(0);
>> }
>>
>> Do you have any idea what can make the difference here?
>>
>> By the way thanks for the master detail code this is one of the next
>> viewers that I am going to create.
>>
>> Best regards
>> Axel
>>
>>
>>
>
>
  Click to reply to this thread Reply
5. At 3:56 PM on Aug 7, 2008, Ed Merks wrote:

Re: EMF databinding TableViewer

Axel,

I don't see anything obviously wrong. Generally Teneo will just surface
things in a transparent way so everything ought to be working nicely.


Axel Nitert wrote:
> Tom,
>
> thanks for the reply.
>
> I agree that it obviously has got something to do with teneo. I tried
> to go through the code using the debugger but the thing is that I have
> no idea what happens after I call setInput. I thought that the
> ContenProviders method getElements should be called. But it isn't.
>
> Do you have an additional hint where the best place would be to set
> the breakpoint?
>
> The IObeservableList looks good as far as I can see. there are three
> elements in the list.
>
> May be I'll have a look at the teneo forum. It could be a bug with the
> setup I chose.
>
> Teneo is really a great framework to persist the EMF model to a
> relational database without spending too much time with matching
> fields to table columns.
>
> Thanks and best regards
> Axel
>
>
>
> Tom Schindl schrieb:
>> This certainly looks like a teneo/proxy issue? I guess simply asking
>> for the for size of a list won't materialize it but I really really
>> have no idea what's going on here, I've never used teneo myself but
>> if the code you posted previously works it must be some issue with
>> teneo or proxies.
>>
>> Did you tried steping through the code with a debugger to see what's
>> really going on? The only thing you now know is that databinding
>> works appropiately and the problem is some where else :-(
>>
>> Tom
>>
>> Axel Nitert schrieb:
>>> Tom Schindl schrieb:
>>>> Axel Nitert schrieb:
>>>>> Hi guys,
>>>>>
>>>>> I am currently struggling with Toms approach of using databinding
>>>>> for 1:n TableViewers.
>>>>> I have (or at least I think I have) followed the instructions and
>>>>> almost copied the example of Tom (thanks for the great work).
>>>>> My problem is that the list remains empty and I would very much
>>>>> appreciate any hint about what I'm doing wrong or how I can debug
>>>>> this.
>>>>>
>>>>> Here is the code of the View Part:
>>>>>
>>>>> public void createPartControl(Composite parent) {
>>>>> super.createPartControl(parent);
>>>>> // my small example model Domain dn =
>>>>> DomainFactory.eINSTANCE.createDomain();
>>>>> Person p = DomainFactory.eINSTANCE.createPerson();
>>>>> dn.getPersons().add(p);
>>>>> // create the viewer viewer = new
>>>>> TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL |
>>>>> SWT.BORDER | SWT.FULL_SELECTION);
>>>>> viewer.getControl().setLayoutData(new GridData(SWT.FILL,
>>>>> SWT.FILL, true, true, 1, 1));
>>>>>
>>>>> // set up the table
>>>>> Table table = viewer.getTable();
>>>>> TableLayout layout = new TableLayout();
>>>>> table.setLayout(layout);
>>>>> table.setHeaderVisible(true);
>>>>> table.setLinesVisible(true);
>>>>> // Define one exmaple column Columns
>>>>> TableViewerColumn viewerColumn;
>>>>> viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
>>>>>
>>>>> // for simplification I use the standard labelprovider
>>>>> viewerColumn.setLabelProvider(new ColumnLabelProvider());
>>>>> viewerColumn.getColumn().setText("Last Name, First Name");
>>>>> viewerColumn.getColumn().setWidth(200);
>>>>> viewerColumn.getColumn().setMoveable(true);
>>>>> // Content Provider
>>>>> ObservableListContentProvider contentProvider = new
>>>>> ObservableListContentProvider();
>>>>> viewer.setContentProvider(contentProvider);
>>>>>
>>>>> // set input
>>>>> IObservableList list = EMFObservables.observeList(dn,
>>>>> DomainPackage.Literals.PERSON__SEMESTERS);
>>>>> viewer.setInput(list);
>>>>> }
>>>>
>>>> My guess is that you are getting an exception in your error-log but
>>>> you have not been running under -consoleLog because the feature you
>>>> want to observe DOMAIN__PERSONS-Feature or am I missing something
>>>> obvious (I make the assumption from the title of the column 'Last
>>>> Name, First Name' ).
>>>>
>>>> My guess of your model looks like this:
>>>>
>>>> Domain
>>>> 1 - n Person
>>>> 1 - n Semesters
>>>>
>>>> Is that correct? So what would you like to represent in the viewer?
>>>>
>>>> The list of persons => The viewer is the master
>>>> The semsters of a person => The viewer is the detail and you need
>>>> to use a EMFObservable#observeDetailList.
>>>>
>>>> So taking this together I think you need to modify your code from
>>>> above like this:
>>>>
>>>> --------8 >>>> // set input
>>>> IObservableList list = EMFObservables.observeList(
>>>> dn,
>>>> DomainPackage.Literals.DOMAIN__PERSONS);
>>>>
>>>> viewer.setInput(list);
>>>>
>>>> IObservableValue master =
>>>> ViewerObservables.observeSingleSelection(viewer);
>>>>
>>>> // The detail viewer
>>>> TableViewer semesterViewer = new TableViewer(....);
>>>>
>>>> TableViewerColumn c = ......
>>>>
>>>> ObservableListContentProvider contentProvider2 = new
>>>> ObservableListContentProvider();
>>>> semesterViewer.setContentProvider(contentProvider2);
>>>>
>>>> IObservableList detailList = EMFObservables.observeDetailList(
>>>> Realm.getDefault(),
>>>> master
>>>> DomainPackage.Literals.PERSON__SEMESTERS);
>>>> semesterViewer.setInput(detailList);
>>>>
>>>> --------8 >>>>
>>>> This is untested code and based on the assumptions I made from your
>>>> code so it might be inaccurate :-)
>>>>
>>>> Tom
>>>>
>>>>
>>>
>>> Hi Tom,
>>>
>>> thanks for the answer. The issue that I am struggling with is more
>>> complex. I want to use the observable list with an EMF linked to a
>>> database (TENEO, Hibernate). In order to narrow down the issue I
>>> have reduced the code and this is why I left PERSON__SEMESTERS in
>>> the list.
>>>
>>> You are totally right when I replace then code
>>>
>>> IObservableList list = EMFObservables.observeList(dn,
>>> DomainPackage.Literals.PERSON__SEMESTERS);
>>>
>>> with
>>> IObservableList list = EMFObservables.observeList(dn,
>>> DomainPackage.Literals.DOMAIN__PERSONS);
>>>
>>> my example works fine.
>>>
>>> NOW, back to the original issue. If I use the same code with a
>>>
>>>
>>> // this prints 3 elements
>>> System.out.println(DomainUtil.getRoot().getPersons().size());
>>>
>>> IObservableList list =
>>> EMFObservables.observeList(DomainUtil.getRoot(),
>>> DomainPackage.Literals.DOMAIN__PERSONS);
If you print out the DomainUtil.getRoot() list it's not empty? It's
really a list of Domain instances?
>>>
>>> viewer.setInput(list);
Should the observable list really be the input? Probably dumb question....
>>>
>>> The list is still empty and I do not get any exceptions (I have now
>>> -consoleLog switched on ;-) ).
>>>
>>> The method DomainUtil.getRoot simply returns the root object that
>>> was create with the following code (the resource is a hibernate
>>> teneo resource):
>>>
>>> try {
>>> resource.load(Collections.EMPTY_MAP);
>>> } catch (IOException e) {
>>> e.printStackTrace();
>>> }
>>> if (resource.getContents().size()>0) {
>>> root = (Domain)resource.getContents().get(0);
>>> }
>>>
>>> Do you have any idea what can make the difference here?
>>>
>>> By the way thanks for the master detail code this is one of the next
>>> viewers that I am going to create.
>>>
>>> Best regards
>>> Axel
>>>
>>>
>>>
>>
>>
  Click to reply to this thread Reply
6. At 4:37 PM on Aug 7, 2008, Axel Nitert wrote:

Re: EMF databinding TableViewer

Ed,

I was successfully using the following content and label providers before:

viewer.setContentProvider(new
AdapterFactoryContentProvider(editingDomain.getAdapterFactory()));
viewer.setLabelProvider(new
AdapterFactoryLabelProvider(editingDomain.getAdapterFactory()));

and set the input with:

viewer.setInput(new
ItemProvider("Persons",null,DomainUtil.getRoot().getPersons()));

This was working great except that the view didn't update when adding or
removing persons in the model.

Back to your questions:

// this prints 3 elements
System.out.println(DomainUtil.getRoot().getPersons().size());

IObservableList list = EMFObservables.observeList(DomainUtil.getRoot(),
DomainPackage.Literals.DOMAIN__PERSONS);

If you print out the DomainUtil.getRoot() list it's not empty? It's
really a list of Domain instances?

-> Well, getRoot() returns one single element: the Domain. The domain
itself has a method called getPersons(). It's a 1:n relation. I thought
that I have to create the observablelist with the code mentioned above.
May be I am doing something wrong here.

viewer.setInput(list);

Should the observable list really be the input? Probably dumb question....

-> I don't know another way to show the person list of the Domain object.

Any further suffestion for debugging?

Best regards
Axel


Ed Merks schrieb:
> Axel,
>
> I don't see anything obviously wrong. Generally Teneo will just surface
> things in a transparent way so everything ought to be working nicely.
>
>
> Axel Nitert wrote:
>> Tom,
>>
>> thanks for the reply.
>>
>> I agree that it obviously has got something to do with teneo. I tried
>> to go through the code using the debugger but the thing is that I have
>> no idea what happens after I call setInput. I thought that the
>> ContenProviders method getElements should be called. But it isn't.
>>
>> Do you have an additional hint where the best place would be to set
>> the breakpoint?
>>
>> The IObeservableList looks good as far as I can see. there are three
>> elements in the list.
>>
>> May be I'll have a look at the teneo forum. It could be a bug with the
>> setup I chose.
>>
>> Teneo is really a great framework to persist the EMF model to a
>> relational database without spending too much time with matching
>> fields to table columns.
>>
>> Thanks and best regards
>> Axel
>>
>>
>>
>> Tom Schindl schrieb:
>>> This certainly looks like a teneo/proxy issue? I guess simply asking
>>> for the for size of a list won't materialize it but I really really
>>> have no idea what's going on here, I've never used teneo myself but
>>> if the code you posted previously works it must be some issue with
>>> teneo or proxies.
>>>
>>> Did you tried steping through the code with a debugger to see what's
>>> really going on? The only thing you now know is that databinding
>>> works appropiately and the problem is some where else :-(
>>>
>>> Tom
>>>
>>> Axel Nitert schrieb:
>>>> Tom Schindl schrieb:
>>>>> Axel Nitert schrieb:
>>>>>> Hi guys,
>>>>>>
>>>>>> I am currently struggling with Toms approach of using databinding
>>>>>> for 1:n TableViewers.
>>>>>> I have (or at least I think I have) followed the instructions and
>>>>>> almost copied the example of Tom (thanks for the great work).
>>>>>> My problem is that the list remains empty and I would very much
>>>>>> appreciate any hint about what I'm doing wrong or how I can debug
>>>>>> this.
>>>>>>
>>>>>> Here is the code of the View Part:
>>>>>>
>>>>>> public void createPartControl(Composite parent) {
>>>>>> super.createPartControl(parent);
>>>>>> // my small example model Domain dn =
>>>>>> DomainFactory.eINSTANCE.createDomain();
>>>>>> Person p = DomainFactory.eINSTANCE.createPerson();
>>>>>> dn.getPersons().add(p);
>>>>>> // create the viewer viewer = new
>>>>>> TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL |
>>>>>> SWT.BORDER | SWT.FULL_SELECTION);
>>>>>> viewer.getControl().setLayoutData(new GridData(SWT.FILL,
>>>>>> SWT.FILL, true, true, 1, 1));
>>>>>>
>>>>>> // set up the table
>>>>>> Table table = viewer.getTable();
>>>>>> TableLayout layout = new TableLayout();
>>>>>> table.setLayout(layout);
>>>>>> table.setHeaderVisible(true);
>>>>>> table.setLinesVisible(true);
>>>>>> // Define one exmaple column Columns
>>>>>> TableViewerColumn viewerColumn;
>>>>>> viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
>>>>>>
>>>>>> // for simplification I use the standard labelprovider
>>>>>> viewerColumn.setLabelProvider(new ColumnLabelProvider());
>>>>>> viewerColumn.getColumn().setText("Last Name, First Name");
>>>>>> viewerColumn.getColumn().setWidth(200);
>>>>>> viewerColumn.getColumn().setMoveable(true);
>>>>>> // Content Provider
>>>>>> ObservableListContentProvider contentProvider = new
>>>>>> ObservableListContentProvider();
>>>>>> viewer.setContentProvider(contentProvider);
>>>>>>
>>>>>> // set input
>>>>>> IObservableList list = EMFObservables.observeList(dn,
>>>>>> DomainPackage.Literals.PERSON__SEMESTERS);
>>>>>> viewer.setInput(list);
>>>>>> }
>>>>>
>>>>> My guess is that you are getting an exception in your error-log but
>>>>> you have not been running under -consoleLog because the feature you
>>>>> want to observe DOMAIN__PERSONS-Feature or am I missing something
>>>>> obvious (I make the assumption from the title of the column 'Last
>>>>> Name, First Name' ).
>>>>>
>>>>> My guess of your model looks like this:
>>>>>
>>>>> Domain
>>>>> 1 - n Person
>>>>> 1 - n Semesters
>>>>>
>>>>> Is that correct? So what would you like to represent in the viewer?
>>>>>
>>>>> The list of persons => The viewer is the master
>>>>> The semsters of a person => The viewer is the detail and you need
>>>>> to use a EMFObservable#observeDetailList.
>>>>>
>>>>> So taking this together I think you need to modify your code from
>>>>> above like this:
>>>>>
>>>>> --------8 >>>>> // set input
>>>>> IObservableList list = EMFObservables.observeList(
>>>>> dn,
>>>>> DomainPackage.Literals.DOMAIN__PERSONS);
>>>>>
>>>>> viewer.setInput(list);
>>>>>
>>>>> IObservableValue master =
>>>>> ViewerObservables.observeSingleSelection(viewer);
>>>>>
>>>>> // The detail viewer
>>>>> TableViewer semesterViewer = new TableViewer(....);
>>>>>
>>>>> TableViewerColumn c = ......
>>>>>
>>>>> ObservableListContentProvider contentProvider2 = new
>>>>> ObservableListContentProvider();
>>>>> semesterViewer.setContentProvider(contentProvider2);
>>>>>
>>>>> IObservableList detailList = EMFObservables.observeDetailList(
>>>>> Realm.getDefault(),
>>>>> master
>>>>> DomainPackage.Literals.PERSON__SEMESTERS);
>>>>> semesterViewer.setInput(detailList);
>>>>>
>>>>> --------8 >>>>>
>>>>> This is untested code and based on the assumptions I made from your
>>>>> code so it might be inaccurate :-)
>>>>>
>>>>> Tom
>>>>>
>>>>>
>>>>
>>>> Hi Tom,
>>>>
>>>> thanks for the answer. The issue that I am struggling with is more
>>>> complex. I want to use the observable list with an EMF linked to a
>>>> database (TENEO, Hibernate). In order to narrow down the issue I
>>>> have reduced the code and this is why I left PERSON__SEMESTERS in
>>>> the list.
>>>>
>>>> You are totally right when I replace then code
>>>>
>>>> IObservableList list = EMFObservables.observeList(dn,
>>>> DomainPackage.Literals.PERSON__SEMESTERS);
>>>>
>>>> with
>>>> IObservableList list = EMFObservables.observeList(dn,
>>>> DomainPackage.Literals.DOMAIN__PERSONS);
>>>>
>>>> my example works fine.
>>>>
>>>> NOW, back to the original issue. If I use the same code with a
>>>>
>>>>
>>>> // this prints 3 elements
>>>> System.out.println(DomainUtil.getRoot().getPersons().size());
>>>>
>>>> IObservableList list =
>>>> EMFObservables.observeList(DomainUtil.getRoot(),
>>>> DomainPackage.Literals.DOMAIN__PERSONS);
> If you print out the DomainUtil.getRoot() list it's not empty? It's
> really a list of Domain instances?
>>>>
>>>> viewer.setInput(list);
> Should the observable list really be the input? Probably dumb question....
>>>>
>>>> The list is still empty and I do not get any exceptions (I have now
>>>> -consoleLog switched on ;-) ).
>>>>
>>>> The method DomainUtil.getRoot simply returns the root object that
>>>> was create with the following code (the resource is a hibernate
>>>> teneo resource):
>>>>
>>>> try {
>>>> resource.load(Collections.EMPTY_MAP);
>>>> } catch (IOException e) {
>>>> e.printStackTrace();
>>>> }
>>>> if (resource.getContents().size()>0) {
>>>> root = (Domain)resource.getContents().get(0);
>>>> }
>>>>
>>>> Do you have any idea what can make the difference here?
>>>>
>>>> By the way thanks for the master detail code this is one of the next
>>>> viewers that I am going to create.
>>>>
>>>> Best regards
>>>> Axel
>>>>
>>>>
>>>>
>>>
>>>
  Click to reply to this thread Reply
7. At 4:52 PM on Aug 7, 2008, Ed Merks wrote:

Re: EMF databinding TableViewer

Axel,

Comments below.

Axel Nitert wrote:
> Ed,
>
> I was successfully using the following content and label providers
> before:
>
> viewer.setContentProvider(new
> AdapterFactoryContentProvider(editingDomain.getAdapterFactory()));
> viewer.setLabelProvider(new
> AdapterFactoryLabelProvider(editingDomain.getAdapterFactory()));
>
> and set the input with:
>
> viewer.setInput(new
> ItemProvider("Persons",null,DomainUtil.getRoot().getPersons()));
>
> This was working great except that the view didn't update when adding
> or removing persons in the model.
It seems to me the input should have been the getRoot() object. What
happens if you did that instead? Does it show more than just the
persons list?
>
> Back to your questions:
>
> // this prints 3 elements
> System.out.println(DomainUtil.getRoot().getPersons().size());
>
> IObservableList list =
> EMFObservables.observeList(DomainUtil.getRoot(),
> DomainPackage.Literals.DOMAIN__PERSONS);
>
> If you print out the DomainUtil.getRoot() list it's not empty? It's
> really a list of Domain instances?
>
> -> Well, getRoot() returns one single element: the Domain. The domain
> itself has a method called getPersons(). It's a 1:n relation. I
> thought that I have to create the observablelist with the code
> mentioned above. May be I am doing something wrong here.
>
> viewer.setInput(list);
I'm not sure the viewer has any special support for an observable list;
maybe that's just my data binding ignorance.
>
> Should the observable list really be the input? Probably dumb
> question....
>
> -> I don't know another way to show the person list of the Domain object.
>
> Any further suffestion for debugging?
But a breakpoint some of the AdapteFactoryContentProvider methods like
getElements and getChildren. Likely you'll find the list is the
"object" passed in and it can't be adapted hence you get nothing in the
view...
>
> Best regards
> Axel
>
>
> Ed Merks schrieb:
>> Axel,
>>
>> I don't see anything obviously wrong. Generally Teneo will just
>> surface things in a transparent way so everything ought to be working
>> nicely.
>>
>>
>> Axel Nitert wrote:
>>> Tom,
>>>
>>> thanks for the reply.
>>>
>>> I agree that it obviously has got something to do with teneo. I
>>> tried to go through the code using the debugger but the thing is
>>> that I have no idea what happens after I call setInput. I thought
>>> that the ContenProviders method getElements should be called. But it
>>> isn't.
>>>
>>> Do you have an additional hint where the best place would be to set
>>> the breakpoint?
>>>
>>> The IObeservableList looks good as far as I can see. there are three
>>> elements in the list.
>>>
>>> May be I'll have a look at the teneo forum. It could be a bug with
>>> the setup I chose.
>>>
>>> Teneo is really a great framework to persist the EMF model to a
>>> relational database without spending too much time with matching
>>> fields to table columns.
>>>
>>> Thanks and best regards
>>> Axel
>>>
>>>
>>>
>>> Tom Schindl schrieb:
>>>> This certainly looks like a teneo/proxy issue? I guess simply
>>>> asking for the for size of a list won't materialize it but I really
>>>> really have no idea what's going on here, I've never used teneo
>>>> myself but if the code you posted previously works it must be some
>>>> issue with teneo or proxies.
>>>>
>>>> Did you tried steping through the code with a debugger to see
>>>> what's really going on? The only thing you now know is that
>>>> databinding works appropiately and the problem is some where else :-(
>>>>
>>>> Tom
>>>>
>>>> Axel Nitert schrieb:
>>>>> Tom Schindl schrieb:
>>>>>> Axel Nitert schrieb:
>>>>>>> Hi guys,
>>>>>>>
>>>>>>> I am currently struggling with Toms approach of using
>>>>>>> databinding for 1:n TableViewers.
>>>>>>> I have (or at least I think I have) followed the instructions
>>>>>>> and almost copied the example of Tom (thanks for the great work).
>>>>>>> My problem is that the list remains empty and I would very much
>>>>>>> appreciate any hint about what I'm doing wrong or how I can
>>>>>>> debug this.
>>>>>>>
>>>>>>> Here is the code of the View Part:
>>>>>>>
>>>>>>> public void createPartControl(Composite parent) {
>>>>>>> super.createPartControl(parent);
>>>>>>> // my small example model Domain dn =
>>>>>>> DomainFactory.eINSTANCE.createDomain();
>>>>>>> Person p = DomainFactory.eINSTANCE.createPerson();
>>>>>>> dn.getPersons().add(p);
>>>>>>> // create the viewer viewer = new
>>>>>>> TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL |
>>>>>>> SWT.BORDER | SWT.FULL_SELECTION);
>>>>>>> viewer.getControl().setLayoutData(new GridData(SWT.FILL,
>>>>>>> SWT.FILL, true, true, 1, 1));
>>>>>>>
>>>>>>> // set up the table
>>>>>>> Table table = viewer.getTable();
>>>>>>> TableLayout layout = new TableLayout();
>>>>>>> table.setLayout(layout);
>>>>>>> table.setHeaderVisible(true);
>>>>>>> table.setLinesVisible(true);
>>>>>>> // Define one exmaple column Columns
>>>>>>> TableViewerColumn viewerColumn;
>>>>>>> viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
>>>>>>>
>>>>>>> // for simplification I use the standard labelprovider
>>>>>>> viewerColumn.setLabelProvider(new ColumnLabelProvider());
>>>>>>> viewerColumn.getColumn().setText("Last Name, First Name");
>>>>>>> viewerColumn.getColumn().setWidth(200);
>>>>>>> viewerColumn.getColumn().setMoveable(true);
>>>>>>> // Content Provider
>>>>>>> ObservableListContentProvider contentProvider = new
>>>>>>> ObservableListContentProvider();
>>>>>>> viewer.setContentProvider(contentProvider);
>>>>>>>
>>>>>>> // set input
>>>>>>> IObservableList list = EMFObservables.observeList(dn,
>>>>>>> DomainPackage.Literals.PERSON__SEMESTERS);
>>>>>>> viewer.setInput(list);
>>>>>>> }
>>>>>>
>>>>>> My guess is that you are getting an exception in your error-log
>>>>>> but you have not been running under -consoleLog because the
>>>>>> feature you want to observe DOMAIN__PERSONS-Feature or am I
>>>>>> missing something obvious (I make the assumption from the title
>>>>>> of the column 'Last Name, First Name' ).
>>>>>>
>>>>>> My guess of your model looks like this:
>>>>>>
>>>>>> Domain
>>>>>> 1 - n Person
>>>>>> 1 - n Semesters
>>>>>>
>>>>>> Is that correct? So what would you like to represent in the viewer?
>>>>>>
>>>>>> The list of persons => The viewer is the master
>>>>>> The semsters of a person => The viewer is the detail and you need
>>>>>> to use a EMFObservable#observeDetailList.
>>>>>>
>>>>>> So taking this together I think you need to modify your code from
>>>>>> above like this:
>>>>>>
>>>>>> --------8 >>>>>> // set input
>>>>>> IObservableList list = EMFObservables.observeList(
>>>>>> dn,
>>>>>> DomainPackage.Literals.DOMAIN__PERSONS);
>>>>>>
>>>>>> viewer.setInput(list);
>>>>>>
>>>>>> IObservableValue master =
>>>>>> ViewerObservables.observeSingleSelection(viewer);
>>>>>>
>>>>>> // The detail viewer
>>>>>> TableViewer semesterViewer = new TableViewer(....);
>>>>>>
>>>>>> TableViewerColumn c = ......
>>>>>>
>>>>>> ObservableListContentProvider contentProvider2 = new
>>>>>> ObservableListContentProvider();
>>>>>> semesterViewer.setContentProvider(contentProvider2);
>>>>>>
>>>>>> IObservableList detailList = EMFObservables.observeDetailList(
>>>>>> Realm.getDefault(),
>>>>>> master
>>>>>> DomainPackage.Literals.PERSON__SEMESTERS);
>>>>>> semesterViewer.setInput(detailList);
>>>>>>
>>>>>> --------8 >>>>>>
>>>>>> This is untested code and based on the assumptions I made from
>>>>>> your code so it might be inaccurate :-)
>>>>>>
>>>>>> Tom
>>>>>>
>>>>>>
>>>>>
>>>>> Hi Tom,
>>>>>
>>>>> thanks for the answer. The issue that I am struggling with is more
>>>>> complex. I want to use the observable list with an EMF linked to a
>>>>> database (TENEO, Hibernate). In order to narrow down the issue I
>>>>> have reduced the code and this is why I left PERSON__SEMESTERS in
>>>>> the list.
>>>>>
>>>>> You are totally right when I replace then code
>>>>>
>>>>> IObservableList list = EMFObservables.observeList(dn,
>>>>> DomainPackage.Literals.PERSON__SEMESTERS);
>>>>>
>>>>> with
>>>>> IObservableList list = EMFObservables.observeList(dn,
>>>>> DomainPackage.Literals.DOMAIN__PERSONS);
>>>>>
>>>>> my example works fine.
>>>>>
>>>>> NOW, back to the original issue. If I use the same code with a
>>>>>
>>>>>
>>>>> // this prints 3 elements
>>>>> System.out.println(DomainUtil.getRoot().getPersons().size());
>>>>>
>>>>> IObservableList list =
>>>>> EMFObservables.observeList(DomainUtil.getRoot(),
>>>>> DomainPackage.Literals.DOMAIN__PERSONS);
>> If you print out the DomainUtil.getRoot() list it's not empty? It's
>> really a list of Domain instances?
>>>>>
>>>>> viewer.setInput(list);
>> Should the observable list really be the input? Probably dumb
>> question....
>>>>>
>>>>> The list is still empty and I do not get any exceptions (I have
>>>>> now -consoleLog switched on ;-) ).
>>>>>
>>>>> The method DomainUtil.getRoot simply returns the root object that
>>>>> was create with the following code (the resource is a hibernate
>>>>> teneo resource):
>>>>>
>>>>> try {
>>>>> resource.load(Collections.EMPTY_MAP);
>>>>> } catch (IOException e) {
>>>>> e.printStackTrace();
>>>>> }
>>>>> if (resource.getContents().size()>0) {
>>>>> root = (Domain)resource.getContents().get(0);
>>>>> }
>>>>>
>>>>> Do you have any idea what can make the difference here?
>>>>>
>>>>> By the way thanks for the master detail code this is one of the
>>>>> next viewers that I am going to create.
>>>>>
>>>>> Best regards
>>>>> Axel
>>>>>
>>>>>
>>>>>
>>>>
>>>>
  Click to reply to this thread Reply
8. At 3:08 AM on Aug 8, 2008, Tom Schindl Javalobby Junkies wrote:

Re: EMF databinding TableViewer

[...]
> viewer.setInput(list);
>
> Should the observable list really be the input? Probably dumb question....
>

Yes IObservableList is the correct one because
ObservableListContentProvider depends on it (the content provider
internally registers itself as change listener and updates the viewer
appropiately).

What really makes me think is that you say that getElements() method is
not called which is impossible or did I get that wrong?

Tom

--
B e s t S o l u t i o n . at
--------------------------------------------------------------------
Tom Schindl JFace-Committer
------------------