Home » Modeling » EMF » EMF databinding TableViewer
EMF databinding TableViewer [message #421466] |
Thu, 07 August 2008 15:13 |
Axel Nitert Messages: 13 Registered: July 2009 |
Junior Member |
|
|
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
|
|
|
Re: EMF databinding TableViewer [message #421469 is a reply to message #421466] |
Thu, 07 August 2008 15:58 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
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
------------------------------------------------------------ --------
|
|
|
Re: EMF databinding TableViewer [message #421471 is a reply to message #421469] |
Thu, 07 August 2008 16:46 |
Axel Nitert Messages: 13 Registered: July 2009 |
Junior Member |
|
|
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
|
|
|
Re: EMF databinding TableViewer [message #421477 is a reply to message #421471] |
Thu, 07 August 2008 17:58 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
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
------------------------------------------------------------ --------
|
|
|
Re: EMF databinding TableViewer [message #421481 is a reply to message #421477] |
Thu, 07 August 2008 18:41 |
Axel Nitert Messages: 13 Registered: July 2009 |
Junior Member |
|
|
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
>>
>>
>>
>
>
|
|
|
Re: EMF databinding TableViewer [message #421486 is a reply to message #421481] |
Thu, 07 August 2008 19:56 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
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
>>>
>>>
>>>
>>
>>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: EMF databinding TableViewer [message #421488 is a reply to message #421486] |
Thu, 07 August 2008 20:37 |
Axel Nitert Messages: 13 Registered: July 2009 |
Junior Member |
|
|
Ed,
I was successfully using the following content and label providers before:
viewer.setContentProvider(new
AdapterFactoryContentProvider(editingDomain.getAdapterFactor y()));
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
>>>>
>>>>
>>>>
>>>
>>>
|
|
|
Re: EMF databinding TableViewer [message #421490 is a reply to message #421488] |
Thu, 07 August 2008 20:52 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Axel,
Comments below.
Axel Nitert wrote:
> Ed,
>
> I was successfully using the following content and label providers
> before:
>
> viewer.setContentProvider(new
> AdapterFactoryContentProvider(editingDomain.getAdapterFactor y()));
> 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
>>>>>
>>>>>
>>>>>
>>>>
>>>>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | | | | | | | |
Re: EMF databinding TableViewer [message #421934 is a reply to message #421720] |
Mon, 18 August 2008 19:15 |
Axel Nitert Messages: 13 Registered: July 2009 |
Junior Member |
|
|
Hi Tom,
I didn't have much time to go through your code and unfortunately a
BundleException when I was trying to run the example (using Ganymede on
mac os and windows).
However, I was able to understand what the code is about and I have to
say that this is really a very interesting example which covers lots of
differenf aspects of a data based RCP application.
Honestly, I think it is even a bit too complex to go into the topic of
data binding. Going through the way of Datasource, DatasourceService,
PersistenceService and PersistenceRegistry really consumes a lot of time
without the appropriate examplanation.
So, I am really hoping that you are adding a great tutorial to this
excellent piece of code.
Now, self-interested as I am ;-) I would like to come back to my
original problem which I still wasn't able to solve.
But at least I think I found out what the problem is.
HibernatePersistableEList<E>(PersistableEList<E>).equals(Object) line: 550
EditingDomainEObjectObservableList(ObservableList).equals(Ob ject) line: 87
TableViewer(StructuredViewer).equals(Object, Object) line: 684
TableViewer(AbstractTableViewer).internalRefresh(Object, boolean) line: 631
TableViewer(AbstractTableViewer).internalRefresh(Object) line: 620
AbstractTableViewer$2.run() line: 576
The internally used PersistableEList is not equal to the
EditingDomainEObjectObservableList which prevents the function
internalRefresh from calling internalRefreshAll which then calls
getElements().
The code is still the same as in ther very beginning of my example and
it seems that this issue is really related to teneo.
May be, you have another idea why the two lists are different.
BTW, the function internalRefresh is called twice. 1. on
viewer.setLabelProvider which is then correctly calling
internalRefreshAll but without any data to display and then 2. on
setInput with the behaviour described above.
I will go on debugging but would really appreciate any additional help.
Thanks.
Axel
Tom Schindl schrieb:
> Hi Axel,
>
> Yesterday I proposed a talk about this tutorial for ESE. You can follow
> the submission here [1] or leave a comment.
>
> Tom
>
> [1] https://www.eclipsecon.org/submissions/view_talk.php?id=48
>
> Axel Nitert schrieb:
>> Tom, Ed,
>>
>> I will have a look into Toms EMF Data-Binding example. But this week I
>> am very busy. Either I find the solution myself or I will send you an
>> example which isolates the problem.
>>
>> It's great to have an example which combines all these fancy
>> technologies. May be I can add some ideas for Teneo to your example.
>>
>> Let's see. Thanks so far.
>>
>> Axel
>
>
|
|
|
Re: EMF databinding TableViewer [message #421938 is a reply to message #421934] |
Mon, 18 August 2008 19:47 |
Axel Nitert Messages: 13 Registered: July 2009 |
Junior Member |
|
|
Hi again,
I found a workaround after I wrote the last post. It simply came to my
mind after pressing save.
I have added a comparer to my TableViewer which looks like this:
IElementComparer elistComparer = new IElementComparer() {
public boolean equals(Object a, Object b) {
if (a instanceof EditingDomainEObjectObservableList
&& b instanceof EditingDomainEObjectObservableList) {
return a==b;
}
return a.equals(b);
}
public int hashCode(Object element) {
return element.hashCode();
}
};
And then of course I added viewer.setComparer(elistComparer).
I don't know if this is the best way but at least it solved my problem
so far.
What do you think?
Axel
Axel Nitert schrieb:
> Hi Tom,
>
> I didn't have much time to go through your code and unfortunately a
> BundleException when I was trying to run the example (using Ganymede on
> mac os and windows).
> However, I was able to understand what the code is about and I have to
> say that this is really a very interesting example which covers lots of
> differenf aspects of a data based RCP application.
>
> Honestly, I think it is even a bit too complex to go into the topic of
> data binding. Going through the way of Datasource, DatasourceService,
> PersistenceService and PersistenceRegistry really consumes a lot of time
> without the appropriate examplanation.
>
> So, I am really hoping that you are adding a great tutorial to this
> excellent piece of code.
>
>
> Now, self-interested as I am ;-) I would like to come back to my
> original problem which I still wasn't able to solve.
>
> But at least I think I found out what the problem is.
>
> HibernatePersistableEList<E>(PersistableEList<E>).equals(Object) line:
> 550
> EditingDomainEObjectObservableList(ObservableList).equals(Ob ject) line:
> 87
> TableViewer(StructuredViewer).equals(Object, Object) line: 684
> TableViewer(AbstractTableViewer).internalRefresh(Object, boolean) line:
> 631
> TableViewer(AbstractTableViewer).internalRefresh(Object) line: 620
> AbstractTableViewer$2.run() line: 576
>
> The internally used PersistableEList is not equal to the
> EditingDomainEObjectObservableList which prevents the function
> internalRefresh from calling internalRefreshAll which then calls
> getElements().
>
> The code is still the same as in ther very beginning of my example and
> it seems that this issue is really related to teneo.
>
> May be, you have another idea why the two lists are different.
>
> BTW, the function internalRefresh is called twice. 1. on
> viewer.setLabelProvider which is then correctly calling
> internalRefreshAll but without any data to display and then 2. on
> setInput with the behaviour described above.
>
> I will go on debugging but would really appreciate any additional help.
>
> Thanks.
> Axel
>
> Tom Schindl schrieb:
>> Hi Axel,
>>
>> Yesterday I proposed a talk about this tutorial for ESE. You can
>> follow the submission here [1] or leave a comment.
>>
>> Tom
>>
>> [1] https://www.eclipsecon.org/submissions/view_talk.php?id=48
>>
>> Axel Nitert schrieb:
>>> Tom, Ed,
>>>
>>> I will have a look into Toms EMF Data-Binding example. But this week
>>> I am very busy. Either I find the solution myself or I will send you
>>> an example which isolates the problem.
>>>
>>> It's great to have an example which combines all these fancy
>>> technologies. May be I can add some ideas for Teneo to your example.
>>>
>>> Let's see. Thanks so far.
>>>
>>> Axel
>>
>>
|
|
|
Re: EMF databinding TableViewer [message #421951 is a reply to message #421938] |
Tue, 19 August 2008 09:48 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Hi Axel,
I really need a sample project to track this down :-) What is the call
stack to get to internalRefresh(Object,boolean)?
Tom
Axel Nitert schrieb:
> Hi again,
>
> I found a workaround after I wrote the last post. It simply came to my
> mind after pressing save.
>
> I have added a comparer to my TableViewer which looks like this:
>
> IElementComparer elistComparer = new IElementComparer() {
>
> public boolean equals(Object a, Object b) {
> if (a instanceof EditingDomainEObjectObservableList
> && b instanceof EditingDomainEObjectObservableList) {
> return a==b;
> }
> return a.equals(b);
> }
>
> public int hashCode(Object element) {
> return element.hashCode();
> }
> };
>
> And then of course I added viewer.setComparer(elistComparer).
>
> I don't know if this is the best way but at least it solved my problem
> so far.
>
> What do you think?
>
> Axel
>
> Axel Nitert schrieb:
>> Hi Tom,
>>
>> I didn't have much time to go through your code and unfortunately a
>> BundleException when I was trying to run the example (using Ganymede
>> on mac os and windows).
>> However, I was able to understand what the code is about and I have to
>> say that this is really a very interesting example which covers lots
>> of differenf aspects of a data based RCP application.
>>
>> Honestly, I think it is even a bit too complex to go into the topic of
>> data binding. Going through the way of Datasource, DatasourceService,
>> PersistenceService and PersistenceRegistry really consumes a lot of
>> time without the appropriate examplanation.
>>
>> So, I am really hoping that you are adding a great tutorial to this
>> excellent piece of code.
>>
>>
>> Now, self-interested as I am ;-) I would like to come back to my
>> original problem which I still wasn't able to solve.
>>
>> But at least I think I found out what the problem is.
>>
>> HibernatePersistableEList<E>(PersistableEList<E>).equals(Object) line:
>> 550
>> EditingDomainEObjectObservableList(ObservableList).equals(Ob ject)
>> line: 87 TableViewer(StructuredViewer).equals(Object, Object) line:
>> 684 TableViewer(AbstractTableViewer).internalRefresh(Object,
>> boolean) line: 631
>> TableViewer(AbstractTableViewer).internalRefresh(Object) line: 620
>> AbstractTableViewer$2.run() line: 576
>> The internally used PersistableEList is not equal to the
>> EditingDomainEObjectObservableList which prevents the function
>> internalRefresh from calling internalRefreshAll which then calls
>> getElements().
>>
>> The code is still the same as in ther very beginning of my example and
>> it seems that this issue is really related to teneo.
>>
>> May be, you have another idea why the two lists are different.
>>
>> BTW, the function internalRefresh is called twice. 1. on
>> viewer.setLabelProvider which is then correctly calling
>> internalRefreshAll but without any data to display and then 2. on
>> setInput with the behaviour described above.
>>
>> I will go on debugging but would really appreciate any additional help.
>>
>> Thanks.
>> Axel
>>
>> Tom Schindl schrieb:
>>> Hi Axel,
>>>
>>> Yesterday I proposed a talk about this tutorial for ESE. You can
>>> follow the submission here [1] or leave a comment.
>>>
>>> Tom
>>>
>>> [1] https://www.eclipsecon.org/submissions/view_talk.php?id=48
>>>
>>> Axel Nitert schrieb:
>>>> Tom, Ed,
>>>>
>>>> I will have a look into Toms EMF Data-Binding example. But this week
>>>> I am very busy. Either I find the solution myself or I will send you
>>>> an example which isolates the problem.
>>>>
>>>> It's great to have an example which combines all these fancy
>>>> technologies. May be I can add some ideas for Teneo to your example.
>>>>
>>>> Let's see. Thanks so far.
>>>>
>>>> Axel
>>>
>>>
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
| | | | | | | |
Re: [Teneo] Violates List.equal()-contract [was Re: EMF databinding TableViewe] [message #422220 is a reply to message #422213] |
Tue, 26 August 2008 12:19 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Tom,
That's right, that's why Teneo violates the equals of a list implementation. I can make it so that
it does a real equals if the list has already been loaded but that only solves part of the issues.
Fyi, Hibernate also does equals on collections in a bit different way (uses the key of the owner and
the name of the efeature holding the collection).
I need to know a bit more about how the equals check is done.
Can you post the code snippet that does the equals on the elist (and the equals implementation of
the list wrapper)? What gets passed to the equals, the wrapped list or the wrapperlist?
gr. Martin
Tom Schindl wrote:
> Hi Axel,
>
> Thanks for the project. It's in fact a Teneo vs Standard-List definition
> problem. PersistableEList is breaking the List.equals-contract defined
> in the List-interface which defines the following:
>
> /**
> * Compares the specified object with this list for equality. Returns
> * <tt>true</tt> if and only if the specified object is also a list, both
> * lists have the same size, and all corresponding pairs of elements in
> * the two lists are <i>equal</i>. (Two elements <tt>e1</tt> and
> * <tt>e2</tt> are <i>equal</i> if <tt>(e1==null ? e2==null :
> * e1.equals(e2))</tt>.) In other words, two lists are defined to be
> * equal if they contain the same elements in the same order. This
> * definition ensures that the equals method works properly across
> * different implementations of the <tt>List</tt> interface.
> *
> * @param o the object to be compared for equality with this list.
> * @return <tt>true</tt> if the specified object is equal to this list.
> */
> boolean equals(Object o);
>
> But I think Teneo has good reasons to violate this contract because
> without violating LazyLoading would not work, I guess because the whole
> list has to materialized to compare to Lists (Am I right Martin?).
>
> IMHO there are multiple things to fix.
>
> a) Databinding uses a highly in effecient way to check the equality of
> its wrapped lists. I filed [1] and with this fix even Teneo-Lists
> work aproppiately.
>
> b) Teneos PersistableEList should IMHO at least use Object#hashCode() in
> its equal check if it can not fullfill the List#equals-contract so
> databindings design with WrappedLists would work too. If Databinding
> doesn't release a fix in time for 3.4.1 (whose deadline is already
> tomorrow I has Ed whether we could get a fix in the
> EMF-Observables-List)
>
> Tom
>
> [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=245183
>
>
> Tom Schindl schrieb:
>> Could please file a bug against EMF attach me to it? Please also post
>> the bug number to this thread.
>>
>> Tom
>>
>> Tom Schindl schrieb:
>>> Ah you need to use jface.databinding from 3.4.1-maint or head. The
>>> databinding guys fixed a bug in their implementation. I'll add a
>>> version to my MANIFEST.MF.
>>>
>>> Tom
>>>
>>> Axel Nitert schrieb:
>>>> Hi Tom,
>>>>
>>>> You are right the problem is solved now. But after configuring a new
>>>> data source I have opened the association administration and receive
>>>> the attached exception in the view on the right hand side.
>>>>
>>>> May be I am still doing something wrong.
>>>>
>>>> By the way I have finished preparing my example project which you
>>>> could use to check my original problem. I will send it to you via
>>>> email shortly.
>>>>
>>>> Thanks again
>>>> Axel
>>>>
>>>>
>>>> java.lang.NullPointerException
>>>> at
>>>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSettingDelegate (BasicEObjectImpl.java:1532)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1027)
>>>>
>>>> at
>>>> at.bestsolution.soccer.core.model.soccer.impl.SoccerImpl.eGe t(SoccerImpl.java:196)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1012)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1004)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:999)
>>>>
>>>> at
>>>> org.eclipse.emf.databinding.EObjectObservableMap.doGet(EObje ctObservableMap.java:83)
>>>>
>>>> at
>>>> org.eclipse.core.databinding.observable.map.ComputedObservab leMap$1.handleSetChange(ComputedObservableMap.java:52)
>>>>
>>>> at
>>>> org.eclipse.core.databinding.observable.set.SetChangeEvent.d ispatch(SetChangeEvent.java:61)
>>>>
>>>> at
>>>> org.eclipse.core.databinding.observable.ChangeManager.fireEv ent(ChangeManager.java:129)
>>>>
>>>> at
>>>> org.eclipse.core.databinding.observable.set.ObservableSet.fi reSetChange(ObservableSet.java:67)
>>>>
>>>> at
>>>> org.eclipse.core.internal.databinding.observable.Unmodifiabl eObservableSet.access$0(UnmodifiableObservableSet.java:1)
>>>>
>>>> at
>>>> org.eclipse.core.internal.databinding.observable.Unmodifiabl eObservableSet$1.handleSetChange(UnmodifiableObservableSet.j ava:30)
>>>>
>>>> at
>>>> org.eclipse.core.databinding.observable.set.SetChangeEvent.d ispatch(SetChangeEvent.java:61)
>>>>
>>>> at
>>>> org.eclipse.core.databinding.observable.ChangeManager.fireEv ent(ChangeManager.java:129)
>>>>
>>>> at
>>>> org.eclipse.core.databinding.observable.set.ObservableSet.fi reSetChange(ObservableSet.java:67)
>>>>
>>>> at
>>>> org.eclipse.core.internal.databinding.observable.masterdetai l.DetailObservableSet.access$1(DetailObservableSet.java:1)
>>>>
>>>> at
>>>> org.eclipse.core.internal.databinding.observable.masterdetai l.DetailObservableSet$1.handleSetChange(DetailObservableSet. java:42)
>>>>
>>>> at
>>>> org.eclipse.core.databinding.observable.set.SetChangeEvent.d ispatch(SetChangeEvent.java:61)
>>>>
>>>> at
>>>> org.eclipse.core.databinding.observable.ChangeManager.fireEv ent(ChangeManager.java:129)
>>>>
>>>> at
>>>> org.eclipse.core.databinding.observable.set.ObservableSet.fi reSetChange(ObservableSet.java:67)
>>>>
>>>> at
>>>> org.eclipse.core.databinding.observable.set.WritableSet.add( WritableSet.java:90)
>>>>
>>>> at
>>>> org.eclipse.core.internal.databinding.observable.masterdetai l.DetailObservableSet.add(DetailObservableSet.java:106)
>>>>
>>>> at
>>>> org.eclipse.jface.internal.databinding.viewers.ObservableCol lectionTreeContentProvider$TreeNode. <init>(ObservableCollectionTreeContentProvider.java:284)
>>>>
>>>> at
>>>> org.eclipse.jface.internal.databinding.viewers.ObservableCol lectionTreeContentProvider.getOrCreateNode(ObservableCollect ionTreeContentProvider.java:181)
>>>>
>>>> at
>>>> org.eclipse.jface.internal.databinding.viewers.ObservableCol lectionTreeContentProvider.getChildren(ObservableCollectionT reeContentProvider.java:162)
>>>>
>>>> at
>>>> org.eclipse.jface.internal.databinding.viewers.ObservableCol lectionTreeContentProvider.getElements(ObservableCollectionT reeContentProvider.java:158)
>>>>
>>>> at
>>>> org.eclipse.jface.databinding.viewers.ObservableListTreeCont entProvider.getElements(ObservableListTreeContentProvider.ja va:155)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.StructuredViewer.getRawChildren(St ructuredViewer.java:937)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.ColumnViewer.getRawChildren(Column Viewer.java:703)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.AbstractTreeViewer.getRawChildren( AbstractTreeViewer.java:1330)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.TreeViewer.getRawChildren(TreeView er.java:385)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.AbstractTreeViewer.getFilteredChil dren(AbstractTreeViewer.java:636)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.AbstractTreeViewer.getSortedChildr en(AbstractTreeViewer.java:602)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.AbstractTreeViewer$1.run(AbstractT reeViewer.java:799)
>>>>
>>>> at
>>>> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:70)
>>>> at
>>>> org.eclipse.jface.viewers.AbstractTreeViewer.createChildren( AbstractTreeViewer.java:776)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.TreeViewer.createChildren(TreeView er.java:634)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.AbstractTreeViewer.internalInitial izeTree(AbstractTreeViewer.java:1490)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.TreeViewer.internalInitializeTree( TreeViewer.java:823)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.AbstractTreeViewer$5.run(AbstractT reeViewer.java:1474)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.StructuredViewer.preservingSelecti on(StructuredViewer.java:1365)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.TreeViewer.preservingSelection(Tre eViewer.java:397)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.StructuredViewer.preservingSelecti on(StructuredViewer.java:1328)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.AbstractTreeViewer.inputChanged(Ab stractTreeViewer.java:1467)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.ContentViewer.setInput(ContentView er.java:251)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.StructuredViewer.setInput(Structur edViewer.java:1603)
>>>>
>>>> at
>>>> at.bestsolution.soccer.ui.associationadmin.AssociationAdmini strationViewPart.updateState(AssociationAdministrationViewPa rt.java:243)
>>>>
>>>> at
>>>> at.bestsolution.soccer.ui.associationadmin.AssociationAdmini strationViewPart.createPartControl(AssociationAdministration ViewPart.java:212)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.ViewReference.createPartHelper(ViewR eference.java:371)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.ViewReference.createPart(ViewReferen ce.java:230)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.Perspective.showView(Perspective.jav a:2127)
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.busyShowView(Workbench Page.java:1062)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage$19.run(WorkbenchPage.j ava:3773)
>>>> at
>>>> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:70)
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage .java:3770)
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage .java:3746)
>>>> at
>>>> at.bestsolution.soccer.ui.associationadmin.handler.OpenAssoc iationAdministrationHandler.execute(OpenAssociationAdministr ationHandler.java:22)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.handlers.HandlerProxy.execute(Handle rProxy.java:281)
>>>>
>>>> at
>>>> org.eclipse.core.commands.Command.executeWithChecks(Command. java:476)
>>>> at
>>>> org.eclipse.core.commands.ParameterizedCommand.executeWithCh ecks(ParameterizedCommand.java:508)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.handlers.HandlerService.executeComma nd(HandlerService.java:169)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.handlers.SlaveHandlerService.execute Command(SlaveHandlerService.java:247)
>>>>
>>>> at
>>>> org.eclipse.ui.menus.CommandContributionItem.handleWidgetSel ection(CommandContributionItem.java:619)
>>>>
>>>> at
>>>> org.eclipse.ui.menus.CommandContributionItem.access$10(Comma ndContributionItem.java:605)
>>>>
>>>> at
>>>> org.eclipse.ui.menus.CommandContributionItem$4.handleEvent(C ommandContributionItem.java:595)
>>>>
>>>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1561)
>>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1585)
>>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1570)
>>>> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 360)
>>>> at
>>>> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3474)
>>>> at
>>>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3064)
>>>> at
>>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
>>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
>>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
>>>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
>>>> at
>>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
>>>>
>>>> at
>>>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>>>> at
>>>> at.bestsolution.soccer.app.intro.Application.start(Applicati on.java:20)
>>>> at
>>>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:382)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>>>>
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>> at
>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>>>>
>>>> at
>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>>>>
>>>> at java.lang.reflect.Method.invoke(Method.java:585)
>>>> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
>>>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>>>> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
>>>> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>>>
>>>
>>
>>
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
| |
Re: [Teneo] Violates List.equal()-contract [was Re: EMF databinding TableViewe] [message #422222 is a reply to message #422221] |
Tue, 26 August 2008 13:24 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Tom,
Hmm, would it make sense that the ObservableList.equals would do something like this:
public boolean equals(Object o) {
getterCalled();
if( o == this ) {
return true;
}
if (o instanceof ObservableList) {
final List otherWrappedList = ((ObservableList)o).getWrappedList();
return wrappedList.equals(otherWrappedList);
}
return wrappedList.equals(o);
}
ObservableList does not have a getWrappedList method, but maybe something else can be used to get to
the wrappedList member.
So when equaling on a ObservableList, that if the wrappedLists of two ObservableLists are equal then
the ObservableLists are equal. I am not limited by any knowledge of ObservableList :-) but it seems
an okay definition imho.
What do you think?
gr. Martin
Tom Schindl wrote:
> Hi Martin,
>
> The code in question is shown in
> org/eclipse/core/databinding/observable/list/ObservableList. java
>
> Until now the code looked like this:
>
> ----------8<----------
> public boolean equals(Object o) {
> getterCalled();
> return wrappedList.equals(o);
> }
> ----------8<----------
>
>
> So when you have
>
> ObservableList a(ObservableList (id=140))
> a.wrappedList(PersistableEList(id=141))
>
> ObservableList b(ObservableList (id=140))
> b.wrappedList(PersistableEList(id=141))
>
> and you call a.equals(b) you'll get false because the code executed in
> then is
>
> wrappedList(PersistableEList(id=141)).equals(o(ObservableLis t (id=140)))
>
> which will result in false because of the equals definition in
> PersistableEList. Matt and Boris already approved the following change
> to the ObservableList#equals() for 3.4.1 (today is the last dev day for
> 3.4.1).
>
> ----------8<----------
> public boolean equals(Object o) {
> getterCalled();
> if( o == this ) {
> return true;
> }
> return wrappedList.equals(o);
> }
> ----------8<----------
>
> I also proposed a second patch (in the bug report 245183) where I was
> passing on the wrapped list but it looks like this won't make it in the
> general framework. This is not ideal because then we'll have the same
> problem we have before in cases like this:
>
> ----------8<----------
> ObservableList a(ObservableList (id=142))
> a.wrappedList(PersistableEList(id=141))
>
> ObservableList b(ObservableList (id=140))
> b.wrappedList(PersistableEList(id=141))
> ----------8<----------
>
> If the situation stays like this we have 2 possibilities:
>
> a) You rewrite the equals-method of PersistableEList like this:
>
> equals(Object o) {
> if( o == this ) {
> return true;
> } else if( o.hashCode() == this.hashCode() ) {
> return true;
> }
>
> // Maybe do the full compare when list is materialized
> return false;
> }
>
> b) We (Ed) overloads equals in
> org.eclipse.emf.databinding.EObjectObservableList and does what I
> proposed in https://bugs.eclipse.org/bugs/show_bug.cgi?id=245183#c2
>
>
> Tom
>
> Martin Taal schrieb:
>> Hi Tom,
>> That's right, that's why Teneo violates the equals of a list
>> implementation. I can make it so that it does a real equals if the
>> list has already been loaded but that only solves part of the issues.
>> Fyi, Hibernate also does equals on collections in a bit different way
>> (uses the key of the owner and the name of the efeature holding the
>> collection).
>>
>> I need to know a bit more about how the equals check is done.
>> Can you post the code snippet that does the equals on the elist (and
>> the equals implementation of the list wrapper)? What gets passed to
>> the equals, the wrapped list or the wrapperlist?
>>
>> gr. Martin
>>
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: [Teneo] Violates List.equal()-contract [was Re: EMF databinding TableViewe] [message #422223 is a reply to message #422222] |
Tue, 26 August 2008 13:32 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
It's quite easy to get access to the wrappedList because you can simply
do ((ObservableList)o).wrappedList which is protected so could also be
reach in subclasses too ;-)
And that's what I proposed in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=245183#c2 and Matt replied
in comment 3 voting against. I once more asked for clarification and
potential addition of this in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=245183#c17
I think we should continue discussion in the bug report because I don't
know if Boris and Matt are following this newsgroup.
Tom
Martin Taal schrieb:
> Hi Tom,
> Hmm, would it make sense that the ObservableList.equals would do
> something like this:
> public boolean equals(Object o) {
> getterCalled();
> if( o == this ) {
> return true;
> }
> if (o instanceof ObservableList) {
> final List otherWrappedList = ((ObservableList)o).getWrappedList();
> return wrappedList.equals(otherWrappedList);
> }
> return wrappedList.equals(o);
> }
>
> ObservableList does not have a getWrappedList method, but maybe
> something else can be used to get to the wrappedList member.
>
> So when equaling on a ObservableList, that if the wrappedLists of two
> ObservableLists are equal then the ObservableLists are equal. I am not
> limited by any knowledge of ObservableList :-) but it seems an okay
> definition imho.
>
> What do you think?
>
> gr. Martin
>
> Tom Schindl wrote:
>> Hi Martin,
>>
>> The code in question is shown in
>> org/eclipse/core/databinding/observable/list/ObservableList. java
>>
>> Until now the code looked like this:
>>
>> ----------8<----------
>> public boolean equals(Object o) {
>> getterCalled();
>> return wrappedList.equals(o);
>> }
>> ----------8<----------
>>
>>
>> So when you have
>>
>> ObservableList a(ObservableList (id=140))
>> a.wrappedList(PersistableEList(id=141))
>>
>> ObservableList b(ObservableList (id=140))
>> b.wrappedList(PersistableEList(id=141))
>>
>> and you call a.equals(b) you'll get false because the code executed in
>> then is
>>
>> wrappedList(PersistableEList(id=141)).equals(o(ObservableLis t (id=140)))
>>
>> which will result in false because of the equals definition in
>> PersistableEList. Matt and Boris already approved the following change
>> to the ObservableList#equals() for 3.4.1 (today is the last dev day
>> for 3.4.1).
>>
>> ----------8<----------
>> public boolean equals(Object o) {
>> getterCalled();
>> if( o == this ) {
>> return true;
>> }
>> return wrappedList.equals(o);
>> }
>> ----------8<----------
>>
>> I also proposed a second patch (in the bug report 245183) where I was
>> passing on the wrapped list but it looks like this won't make it in
>> the general framework. This is not ideal because then we'll have the
>> same problem we have before in cases like this:
>>
>> ----------8<----------
>> ObservableList a(ObservableList (id=142))
>> a.wrappedList(PersistableEList(id=141))
>>
>> ObservableList b(ObservableList (id=140))
>> b.wrappedList(PersistableEList(id=141))
>> ----------8<----------
>>
>> If the situation stays like this we have 2 possibilities:
>>
>> a) You rewrite the equals-method of PersistableEList like this:
>>
>> equals(Object o) {
>> if( o == this ) {
>> return true;
>> } else if( o.hashCode() == this.hashCode() ) {
>> return true;
>> }
>>
>> // Maybe do the full compare when list is materialized
>> return false;
>> }
>>
>> b) We (Ed) overloads equals in
>> org.eclipse.emf.databinding.EObjectObservableList and does what I
>> proposed in https://bugs.eclipse.org/bugs/show_bug.cgi?id=245183#c2
>>
>>
>> Tom
>>
>> Martin Taal schrieb:
>>> Hi Tom,
>>> That's right, that's why Teneo violates the equals of a list
>>> implementation. I can make it so that it does a real equals if the
>>> list has already been loaded but that only solves part of the issues.
>>> Fyi, Hibernate also does equals on collections in a bit different way
>>> (uses the key of the owner and the name of the efeature holding the
>>> collection).
>>>
>>> I need to know a bit more about how the equals check is done.
>>> Can you post the code snippet that does the equals on the elist (and
>>> the equals implementation of the list wrapper)? What gets passed to
>>> the equals, the wrapped list or the wrapperlist?
>>>
>>> gr. Martin
>>>
>>
>>
>
>
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
| | |
Re: [Teneo] Violates List.equal()-contract [was Re: EMF databinding TableViewe] [message #422256 is a reply to message #422223] |
Wed, 27 August 2008 12:47 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Just for the ones who are not described to the bug. Thanks to the quick
response of Matt and Boris a fix (which we are all happy with went) into
3.4.1.
Tom
Tom Schindl schrieb:
> It's quite easy to get access to the wrappedList because you can simply
> do ((ObservableList)o).wrappedList which is protected so could also be
> reach in subclasses too ;-)
>
> And that's what I proposed in
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=245183#c2 and Matt replied
> in comment 3 voting against. I once more asked for clarification and
> potential addition of this in
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=245183#c17
>
> I think we should continue discussion in the bug report because I don't
> know if Boris and Matt are following this newsgroup.
>
> Tom
>
>
> Martin Taal schrieb:
>> Hi Tom,
>> Hmm, would it make sense that the ObservableList.equals would do
>> something like this:
>> public boolean equals(Object o) {
>> getterCalled();
>> if( o == this ) {
>> return true;
>> }
>> if (o instanceof ObservableList) {
>> final List otherWrappedList =
>> ((ObservableList)o).getWrappedList();
>> return wrappedList.equals(otherWrappedList);
>> }
>> return wrappedList.equals(o);
>> }
>>
>> ObservableList does not have a getWrappedList method, but maybe
>> something else can be used to get to the wrappedList member.
>>
>> So when equaling on a ObservableList, that if the wrappedLists of two
>> ObservableLists are equal then the ObservableLists are equal. I am not
>> limited by any knowledge of ObservableList :-) but it seems an okay
>> definition imho.
>>
>> What do you think?
>>
>> gr. Martin
>>
>> Tom Schindl wrote:
>>> Hi Martin,
>>>
>>> The code in question is shown in
>>> org/eclipse/core/databinding/observable/list/ObservableList. java
>>>
>>> Until now the code looked like this:
>>>
>>> ----------8<----------
>>> public boolean equals(Object o) {
>>> getterCalled();
>>> return wrappedList.equals(o);
>>> }
>>> ----------8<----------
>>>
>>>
>>> So when you have
>>>
>>> ObservableList a(ObservableList (id=140))
>>> a.wrappedList(PersistableEList(id=141))
>>>
>>> ObservableList b(ObservableList (id=140))
>>> b.wrappedList(PersistableEList(id=141))
>>>
>>> and you call a.equals(b) you'll get false because the code executed
>>> in then is
>>>
>>> wrappedList(PersistableEList(id=141)).equals(o(ObservableLis t (id=140)))
>>>
>>> which will result in false because of the equals definition in
>>> PersistableEList. Matt and Boris already approved the following
>>> change to the ObservableList#equals() for 3.4.1 (today is the last
>>> dev day for 3.4.1).
>>>
>>> ----------8<----------
>>> public boolean equals(Object o) {
>>> getterCalled();
>>> if( o == this ) {
>>> return true;
>>> }
>>> return wrappedList.equals(o);
>>> }
>>> ----------8<----------
>>>
>>> I also proposed a second patch (in the bug report 245183) where I was
>>> passing on the wrapped list but it looks like this won't make it in
>>> the general framework. This is not ideal because then we'll have the
>>> same problem we have before in cases like this:
>>>
>>> ----------8<----------
>>> ObservableList a(ObservableList (id=142))
>>> a.wrappedList(PersistableEList(id=141))
>>>
>>> ObservableList b(ObservableList (id=140))
>>> b.wrappedList(PersistableEList(id=141))
>>> ----------8<----------
>>>
>>> If the situation stays like this we have 2 possibilities:
>>>
>>> a) You rewrite the equals-method of PersistableEList like this:
>>>
>>> equals(Object o) {
>>> if( o == this ) {
>>> return true;
>>> } else if( o.hashCode() == this.hashCode() ) {
>>> return true;
>>> }
>>>
>>> // Maybe do the full compare when list is materialized
>>> return false;
>>> }
>>>
>>> b) We (Ed) overloads equals in
>>> org.eclipse.emf.databinding.EObjectObservableList and does what I
>>> proposed in https://bugs.eclipse.org/bugs/show_bug.cgi?id=245183#c2
>>>
>>>
>>> Tom
>>>
>>> Martin Taal schrieb:
>>>> Hi Tom,
>>>> That's right, that's why Teneo violates the equals of a list
>>>> implementation. I can make it so that it does a real equals if the
>>>> list has already been loaded but that only solves part of the issues.
>>>> Fyi, Hibernate also does equals on collections in a bit different
>>>> way (uses the key of the owner and the name of the efeature holding
>>>> the collection).
>>>>
>>>> I need to know a bit more about how the equals check is done.
>>>> Can you post the code snippet that does the equals on the elist (and
>>>> the equals implementation of the list wrapper)? What gets passed to
>>>> the equals, the wrapped list or the wrapperlist?
>>>>
>>>> gr. Martin
>>>>
>>>
>>>
>>
>>
>
>
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
|
Goto Forum:
Current Time: Sat Sep 21 07:32:45 GMT 2024
Powered by FUDForum. Page generated in 0.08592 seconds
|