Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problem with databinding
Problem with databinding [message #421347] Tue, 05 August 2008 11:13 Go to next message
Mario Cervera is currently offline Mario CerveraFriend
Messages: 66
Registered: July 2009
Member
Hi everybody.

I want to bind a feature of an EObject (type List) to a Table of JFace
so that the table shows the elements of the List (using a TableViewer).
Is it possible? I've managed to bind features (of any type but
collections) to swt widgets but I can't seem to make it in this case.

Any help or code snippet would be appreciated.

Thanks in advance.

Mario.
Re: Problem with databinding [message #421352 is a reply to message #421347] Tue, 05 August 2008 13:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010607020001090805050306
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Mario,

I don't have much experience with how to use data binding. Hopefully
there is a snippet in here that will help:

http://wiki.eclipse.org/JFace_Data_Binding/Snippets

Probably you already found those though. Are you trying to show the
whole list as a value in just one cell?


Mario Cervera wrote:
> Hi everybody.
>
> I want to bind a feature of an EObject (type List) to a Table of JFace
> so that the table shows the elements of the List (using a
> TableViewer). Is it possible? I've managed to bind features (of any
> type but collections) to swt widgets but I can't seem to make it in
> this case.
>
> Any help or code snippet would be appreciated.
>
> Thanks in advance.
>
> Mario.

--------------010607020001090805050306
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Mario,<br>
<br>
I don't have much experience with how to use data binding.&nbsp; Hopefully
there is a snippet in here that will help:<br>
<blockquote><a
href="http://wiki.eclipse.org/JFace_Data_Binding/Snippets">http://wiki.eclipse.org/JFace_Data_Binding/Snippets</a><br>
</blockquote>
Probably you already found those though.&nbsp;&nbsp; Are you trying to show the
whole list as a value in just one cell?<br>
<br>
<br>
Mario Cervera wrote:
<blockquote cite="mid:g79ck8$drc$1@build.eclipse.org" type="cite">Hi
everybody.
<br>
<br>
I want to bind a feature of an EObject (type List) to a Table of JFace
so that the table shows the elements of the List (using a TableViewer).
Is it possible? I've managed to bind features (of any type but
collections) to swt widgets but I can't seem to make it in this case.
<br>
<br>
Any help or code snippet would be appreciated.
<br>
<br>
Thanks in advance.
<br>
<br>
Mario.
<br>
</blockquote>
</body>
</html>

--------------010607020001090805050306--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problem with databinding [message #421362 is a reply to message #421347] Tue, 05 August 2008 15:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tskaufma.gmail.com

Hello,

Assuming viewer is a TableViewer, eObject is your EObject, and
eStructuralFeature is your feature do:

ObservableListContentProvider contentProvider = new
ObservableListContentProvider(); // this is from JFace Databinding
viewer.setContentProvider(contentProvider);
viewer.setInput(EMFObservables.observeList(eObject, eStructuralFeature));

This uses a default LabelProvider which uses the Object's toString method.
If this is acceptable, your good to go.
Otherwise, try doing

IObserableMap[] columnMaps = new IObservableMap[numOfColumns];

then for each attribute you want displayed in a column do:

columnMaps[i] =
EMFObservables.observeMap(contentProvider.getKnownElements() , eAttribute);

where contentProvider is from above, and eAttribute is the attribute of the
Object in the list you want to display is the ith column.
Then:
viewer.setLabelProvider(new ObservableMapLabelProvider(columnMaps));

I hope this helps,
Trevor Kaufman

"Mario Cervera" <mcervera@integranova.com> wrote in message
news:g79ck8$drc$1@build.eclipse.org...
> Hi everybody.
>
> I want to bind a feature of an EObject (type List) to a Table of JFace so
> that the table shows the elements of the List (using a TableViewer). Is it
> possible? I've managed to bind features (of any type but collections) to
> swt widgets but I can't seem to make it in this case.
>
> Any help or code snippet would be appreciated.
>
> Thanks in advance.
>
> Mario.
Re: Problem with databinding [message #421372 is a reply to message #421352] Wed, 06 August 2008 07:33 Go to previous messageGo to next message
Mario Cervera is currently offline Mario CerveraFriend
Messages: 66
Registered: July 2009
Member
Hi Ed,

No, I was trying to show the elements of the list as items of the table,
I've already solved it :-)

Ed Merks escribió:
> Mario,
>
> I don't have much experience with how to use data binding. Hopefully
> there is a snippet in here that will help:
>
> http://wiki.eclipse.org/JFace_Data_Binding/Snippets
>
> Probably you already found those though. Are you trying to show the
> whole list as a value in just one cell?
>
>
> Mario Cervera wrote:
>> Hi everybody.
>>
>> I want to bind a feature of an EObject (type List) to a Table of JFace
>> so that the table shows the elements of the List (using a
>> TableViewer). Is it possible? I've managed to bind features (of any
>> type but collections) to swt widgets but I can't seem to make it in
>> this case.
>>
>> Any help or code snippet would be appreciated.
>>
>> Thanks in advance.
>>
>> Mario.
Re: Problem with databinding [message #421373 is a reply to message #421362] Wed, 06 August 2008 07:36 Go to previous messageGo to next message
Mario Cervera is currently offline Mario CerveraFriend
Messages: 66
Registered: July 2009
Member
Thank you so much, that was very helpful.

Now I am trying to add elements to my list just by adding items to the
table (that is, without using commands). The same idea as when you bind
a EAttribute of type String to a Text and modify the attribute by
writting on the Text. I've had problems so far but I'll keep trying.

Thanks again

Mario

Trevor Kaufman escribió:
> Hello,
>
> Assuming viewer is a TableViewer, eObject is your EObject, and
> eStructuralFeature is your feature do:
>
> ObservableListContentProvider contentProvider = new
> ObservableListContentProvider(); // this is from JFace Databinding
> viewer.setContentProvider(contentProvider);
> viewer.setInput(EMFObservables.observeList(eObject, eStructuralFeature));
>
> This uses a default LabelProvider which uses the Object's toString
> method. If this is acceptable, your good to go.
> Otherwise, try doing
>
> IObserableMap[] columnMaps = new IObservableMap[numOfColumns];
>
> then for each attribute you want displayed in a column do:
>
> columnMaps[i] =
> EMFObservables.observeMap(contentProvider.getKnownElements() , eAttribute);
>
> where contentProvider is from above, and eAttribute is the attribute of
> the Object in the list you want to display is the ith column.
> Then:
> viewer.setLabelProvider(new ObservableMapLabelProvider(columnMaps));
>
> I hope this helps,
> Trevor Kaufman
>
> "Mario Cervera" <mcervera@integranova.com> wrote in message
> news:g79ck8$drc$1@build.eclipse.org...
>> Hi everybody.
>>
>> I want to bind a feature of an EObject (type List) to a Table of JFace
>> so that the table shows the elements of the List (using a
>> TableViewer). Is it possible? I've managed to bind features (of any
>> type but collections) to swt widgets but I can't seem to make it in
>> this case.
>>
>> Any help or code snippet would be appreciated.
>>
>> Thanks in advance.
>>
>> Mario.
>
Re: Problem with databinding [message #421374 is a reply to message #421373] Wed, 06 August 2008 07:43 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
How do you add the elements? You should only modify the original EList
and then ObservalListContentProvider will update the viewer.

Tom

Mario Cervera schrieb:
> Thank you so much, that was very helpful.
>
> Now I am trying to add elements to my list just by adding items to the
> table (that is, without using commands). The same idea as when you bind
> a EAttribute of type String to a Text and modify the attribute by
> writting on the Text. I've had problems so far but I'll keep trying.
>
> Thanks again
>
> Mario
>
> Trevor Kaufman escribió:
>> Hello,
>>
>> Assuming viewer is a TableViewer, eObject is your EObject, and
>> eStructuralFeature is your feature do:
>>
>> ObservableListContentProvider contentProvider = new
>> ObservableListContentProvider(); // this is from JFace Databinding
>> viewer.setContentProvider(contentProvider);
>> viewer.setInput(EMFObservables.observeList(eObject,
>> eStructuralFeature));
>>
>> This uses a default LabelProvider which uses the Object's toString
>> method. If this is acceptable, your good to go.
>> Otherwise, try doing
>>
>> IObserableMap[] columnMaps = new IObservableMap[numOfColumns];
>>
>> then for each attribute you want displayed in a column do:
>>
>> columnMaps[i] =
>> EMFObservables.observeMap(contentProvider.getKnownElements() ,
>> eAttribute);
>>
>> where contentProvider is from above, and eAttribute is the attribute
>> of the Object in the list you want to display is the ith column.
>> Then:
>> viewer.setLabelProvider(new ObservableMapLabelProvider(columnMaps));
>>
>> I hope this helps,
>> Trevor Kaufman
>>
>> "Mario Cervera" <mcervera@integranova.com> wrote in message
>> news:g79ck8$drc$1@build.eclipse.org...
>>> Hi everybody.
>>>
>>> I want to bind a feature of an EObject (type List) to a Table of
>>> JFace so that the table shows the elements of the List (using a
>>> TableViewer). Is it possible? I've managed to bind features (of any
>>> type but collections) to swt widgets but I can't seem to make it in
>>> this case.
>>>
>>> Any help or code snippet would be appreciated.
>>>
>>> Thanks in advance.
>>>
>>> Mario.
>>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Problem with databinding [message #421375 is a reply to message #421374] Wed, 06 August 2008 07:56 Go to previous messageGo to next message
Mario Cervera is currently offline Mario CerveraFriend
Messages: 66
Registered: July 2009
Member
My idea is the following:

Imagine I have an EObject which has a feature of type String, then in my
editor I want to modify the value of this feature by writting on a text
box. I can do it using databinding very easily.

Now I have a feature of type List and the widget where I am showing the
content is a TableViewer, I should be able to modify the list by adding
(tableViewer.add(object)) or removing items from the Table, shouldn't I?
If I modify the EList directly I need a write transaction so I need to
use Commands which I want to avoid.

Thanks.

Mario


Tom Schindl escribió:
> How do you add the elements? You should only modify the original EList
> and then ObservalListContentProvider will update the viewer.
>
> Tom
>
> Mario Cervera schrieb:
>> Thank you so much, that was very helpful.
>>
>> Now I am trying to add elements to my list just by adding items to the
>> table (that is, without using commands). The same idea as when you
>> bind a EAttribute of type String to a Text and modify the attribute by
>> writting on the Text. I've had problems so far but I'll keep trying.
>>
>> Thanks again
>>
>> Mario
>>
>> Trevor Kaufman escribió:
>>> Hello,
>>>
>>> Assuming viewer is a TableViewer, eObject is your EObject, and
>>> eStructuralFeature is your feature do:
>>>
>>> ObservableListContentProvider contentProvider = new
>>> ObservableListContentProvider(); // this is from JFace Databinding
>>> viewer.setContentProvider(contentProvider);
>>> viewer.setInput(EMFObservables.observeList(eObject,
>>> eStructuralFeature));
>>>
>>> This uses a default LabelProvider which uses the Object's toString
>>> method. If this is acceptable, your good to go.
>>> Otherwise, try doing
>>>
>>> IObserableMap[] columnMaps = new IObservableMap[numOfColumns];
>>>
>>> then for each attribute you want displayed in a column do:
>>>
>>> columnMaps[i] =
>>> EMFObservables.observeMap(contentProvider.getKnownElements() ,
>>> eAttribute);
>>>
>>> where contentProvider is from above, and eAttribute is the attribute
>>> of the Object in the list you want to display is the ith column.
>>> Then:
>>> viewer.setLabelProvider(new ObservableMapLabelProvider(columnMaps));
>>>
>>> I hope this helps,
>>> Trevor Kaufman
>>>
>>> "Mario Cervera" <mcervera@integranova.com> wrote in message
>>> news:g79ck8$drc$1@build.eclipse.org...
>>>> Hi everybody.
>>>>
>>>> I want to bind a feature of an EObject (type List) to a Table of
>>>> JFace so that the table shows the elements of the List (using a
>>>> TableViewer). Is it possible? I've managed to bind features (of any
>>>> type but collections) to swt widgets but I can't seem to make it in
>>>> this case.
>>>>
>>>> Any help or code snippet would be appreciated.
>>>>
>>>> Thanks in advance.
>>>>
>>>> Mario.
>>>
>
>
Re: Problem with databinding [message #421376 is a reply to message #421375] Wed, 06 August 2008 08:01 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Mario Cervera schrieb:
> My idea is the following:
>
> Imagine I have an EObject which has a feature of type String, then in my
> editor I want to modify the value of this feature by writting on a text
> box. I can do it using databinding very easily.
>
> Now I have a feature of type List and the widget where I am showing the
> content is a TableViewer, I should be able to modify the list by adding
> (tableViewer.add(object)) or removing items from the Table, shouldn't I?
> If I modify the EList directly I need a write transaction so I need to
> use Commands which I want to avoid.

That's not correct tableViewer#add()/remove() won't modify the
underlying data structure the way is always model => View in JFace-Viewers.

You are never forced to use commands (another reason way the view =>
model does work where from should the TableViewer know which command it
should execute). You don't have to use a command if don't want to
myEObject#getMyList()#add() allows you to add the element and the
databinding framework keeps your TableViewer in sync with your model.

Tom

--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Problem with databinding [message #421377 is a reply to message #421376] Wed, 06 August 2008 08:12 Go to previous messageGo to next message
Mario Cervera is currently offline Mario CerveraFriend
Messages: 66
Registered: July 2009
Member
I see your point and sounds nice but if I do myEObject#getMyList()#add()
I get:

java.lang.IllegalStateException: Cannot modify resource set without a
write transaction
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
at
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
at
org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:255)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:300)
at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:6 26)

..............

:(

What can I do??

Mario

Tom Schindl escribió:
> Mario Cervera schrieb:
>> My idea is the following:
>>
>> Imagine I have an EObject which has a feature of type String, then in
>> my editor I want to modify the value of this feature by writting on a
>> text box. I can do it using databinding very easily.
>>
>> Now I have a feature of type List and the widget where I am showing
>> the content is a TableViewer, I should be able to modify the list by
>> adding (tableViewer.add(object)) or removing items from the Table,
>> shouldn't I? If I modify the EList directly I need a write transaction
>> so I need to use Commands which I want to avoid.
>
> That's not correct tableViewer#add()/remove() won't modify the
> underlying data structure the way is always model => View in JFace-Viewers.
>
> You are never forced to use commands (another reason way the view =>
> model does work where from should the TableViewer know which command it
> should execute). You don't have to use a command if don't want to
> myEObject#getMyList()#add() allows you to add the element and the
> databinding framework keeps your TableViewer in sync with your model.
>
> Tom
>
Re: Problem with databinding [message #421378 is a reply to message #421377] Wed, 06 August 2008 08:40 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Ok. You are using a TransactionEditingDomain then I think you need to
use Commands but I'm not an expert in this :-)

Tom

Mario Cervera schrieb:
> I see your point and sounds nice but if I do myEObject#getMyList()#add()
> I get:
>
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
>
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>
> at
> org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:255)
>
> at
> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:300)
>
> at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:6 26)
>
> .............
>
> :(
>
> What can I do??
>
> Mario
>
> Tom Schindl escribió:
>> Mario Cervera schrieb:
>>> My idea is the following:
>>>
>>> Imagine I have an EObject which has a feature of type String, then in
>>> my editor I want to modify the value of this feature by writting on a
>>> text box. I can do it using databinding very easily.
>>>
>>> Now I have a feature of type List and the widget where I am showing
>>> the content is a TableViewer, I should be able to modify the list by
>>> adding (tableViewer.add(object)) or removing items from the Table,
>>> shouldn't I? If I modify the EList directly I need a write
>>> transaction so I need to use Commands which I want to avoid.
>>
>> That's not correct tableViewer#add()/remove() won't modify the
>> underlying data structure the way is always model => View in
>> JFace-Viewers.
>>
>> You are never forced to use commands (another reason way the view =>
>> model does work where from should the TableViewer know which command
>> it should execute). You don't have to use a command if don't want to
>> myEObject#getMyList()#add() allows you to add the element and the
>> databinding framework keeps your TableViewer in sync with your model.
>>
>> Tom
>>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Problem with databinding [message #421379 is a reply to message #421378] Wed, 06 August 2008 09:05 Go to previous messageGo to next message
Mario Cervera is currently offline Mario CerveraFriend
Messages: 66
Registered: July 2009
Member
Ok I think will use commands... doesn't matter. Thanks for all your help :)

Mario

Tom Schindl escribió:
> Ok. You are using a TransactionEditingDomain then I think you need to
> use Commands but I'm not an expert in this :-)
>
> Tom
>
> Mario Cervera schrieb:
>> I see your point and sounds nice but if I do
>> myEObject#getMyList()#add() I get:
>>
>> java.lang.IllegalStateException: Cannot modify resource set without a
>> write transaction
>> at
>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
>>
>> at
>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
>>
>> at
>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
>>
>> at
>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
>>
>> at
>> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>>
>> at
>> org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:255)
>>
>> at
>> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:300)
>>
>> at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:6 26)
>>
>> .............
>>
>> :(
>>
>> What can I do??
>>
>> Mario
>>
>> Tom Schindl escribió:
>>> Mario Cervera schrieb:
>>>> My idea is the following:
>>>>
>>>> Imagine I have an EObject which has a feature of type String, then
>>>> in my editor I want to modify the value of this feature by writting
>>>> on a text box. I can do it using databinding very easily.
>>>>
>>>> Now I have a feature of type List and the widget where I am showing
>>>> the content is a TableViewer, I should be able to modify the list by
>>>> adding (tableViewer.add(object)) or removing items from the Table,
>>>> shouldn't I? If I modify the EList directly I need a write
>>>> transaction so I need to use Commands which I want to avoid.
>>>
>>> That's not correct tableViewer#add()/remove() won't modify the
>>> underlying data structure the way is always model => View in
>>> JFace-Viewers.
>>>
>>> You are never forced to use commands (another reason way the view =>
>>> model does work where from should the TableViewer know which command
>>> it should execute). You don't have to use a command if don't want to
>>> myEObject#getMyList()#add() allows you to add the element and the
>>> databinding framework keeps your TableViewer in sync with your model.
>>>
>>> Tom
>>>
>
>
Re: Problem with databinding [message #421390 is a reply to message #421379] Wed, 06 August 2008 11:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Mario,

Yes, without using commands in some way, you'd not be able to undo your
changes. If you add to the observing list though, the commands are made
for you automatically, which I think is what you wanted. So if you
used EMFEditObservables.observeList, modified that list, and then
disposed that list, this would do the trick I think...


Mario Cervera wrote:
> Ok I think will use commands... doesn't matter. Thanks for all your
> help :)
>
> Mario
>
> Tom Schindl escribió:
>> Ok. You are using a TransactionEditingDomain then I think you need to
>> use Commands but I'm not an expert in this :-)
>>
>> Tom
>>
>> Mario Cervera schrieb:
>>> I see your point and sounds nice but if I do
>>> myEObject#getMyList()#add() I get:
>>>
>>> java.lang.IllegalStateException: Cannot modify resource set without
>>> a write transaction
>>> at
>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
>>>
>>> at
>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
>>>
>>> at
>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
>>>
>>> at
>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
>>>
>>> at
>>> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>>>
>>> at
>>> org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:255)
>>>
>>> at
>>> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:300)
>>>
>>> at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:6 26)
>>>
>>> .............
>>>
>>> :(
>>>
>>> What can I do??
>>>
>>> Mario
>>>
>>> Tom Schindl escribió:
>>>> Mario Cervera schrieb:
>>>>> My idea is the following:
>>>>>
>>>>> Imagine I have an EObject which has a feature of type String, then
>>>>> in my editor I want to modify the value of this feature by
>>>>> writting on a text box. I can do it using databinding very easily.
>>>>>
>>>>> Now I have a feature of type List and the widget where I am
>>>>> showing the content is a TableViewer, I should be able to modify
>>>>> the list by adding (tableViewer.add(object)) or removing items
>>>>> from the Table, shouldn't I? If I modify the EList directly I need
>>>>> a write transaction so I need to use Commands which I want to avoid.
>>>>
>>>> That's not correct tableViewer#add()/remove() won't modify the
>>>> underlying data structure the way is always model => View in
>>>> JFace-Viewers.
>>>>
>>>> You are never forced to use commands (another reason way the view
>>>> => model does work where from should the TableViewer know which
>>>> command it should execute). You don't have to use a command if
>>>> don't want to
>>>> myEObject#getMyList()#add() allows you to add the element and the
>>>> databinding framework keeps your TableViewer in sync with your model.
>>>>
>>>> Tom
>>>>
>>
>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problem with databinding [message #421392 is a reply to message #421390] Wed, 06 August 2008 12:14 Go to previous message
Mario Cervera is currently offline Mario CerveraFriend
Messages: 66
Registered: July 2009
Member
Cool! It worked! thank you :D

Mario

Ed Merks escribió:
> Mario,
>
> Yes, without using commands in some way, you'd not be able to undo your
> changes. If you add to the observing list though, the commands are made
> for you automatically, which I think is what you wanted. So if you
> used EMFEditObservables.observeList, modified that list, and then
> disposed that list, this would do the trick I think...
>
>
> Mario Cervera wrote:
>> Ok I think will use commands... doesn't matter. Thanks for all your
>> help :)
>>
>> Mario
>>
>> Tom Schindl escribió:
>>> Ok. You are using a TransactionEditingDomain then I think you need to
>>> use Commands but I'm not an expert in this :-)
>>>
>>> Tom
>>>
>>> Mario Cervera schrieb:
>>>> I see your point and sounds nice but if I do
>>>> myEObject#getMyList()#add() I get:
>>>>
>>>> java.lang.IllegalStateException: Cannot modify resource set without
>>>> a write transaction
>>>> at
>>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
>>>>
>>>> at
>>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
>>>>
>>>> at
>>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
>>>>
>>>> at
>>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
>>>>
>>>> at
>>>> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:255)
>>>>
>>>> at
>>>> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:300)
>>>>
>>>> at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:6 26)
>>>>
>>>> .............
>>>>
>>>> :(
>>>>
>>>> What can I do??
>>>>
>>>> Mario
>>>>
>>>> Tom Schindl escribió:
>>>>> Mario Cervera schrieb:
>>>>>> My idea is the following:
>>>>>>
>>>>>> Imagine I have an EObject which has a feature of type String, then
>>>>>> in my editor I want to modify the value of this feature by
>>>>>> writting on a text box. I can do it using databinding very easily.
>>>>>>
>>>>>> Now I have a feature of type List and the widget where I am
>>>>>> showing the content is a TableViewer, I should be able to modify
>>>>>> the list by adding (tableViewer.add(object)) or removing items
>>>>>> from the Table, shouldn't I? If I modify the EList directly I need
>>>>>> a write transaction so I need to use Commands which I want to avoid.
>>>>>
>>>>> That's not correct tableViewer#add()/remove() won't modify the
>>>>> underlying data structure the way is always model => View in
>>>>> JFace-Viewers.
>>>>>
>>>>> You are never forced to use commands (another reason way the view
>>>>> => model does work where from should the TableViewer know which
>>>>> command it should execute). You don't have to use a command if
>>>>> don't want to
>>>>> myEObject#getMyList()#add() allows you to add the element and the
>>>>> databinding framework keeps your TableViewer in sync with your model.
>>>>>
>>>>> Tom
>>>>>
>>>
>>>
Previous Topic:How can I create URI that refers to in-memory byte array stream?
Next Topic:Re: Very Important : How to load lazily any element which is there in containment relationship
Goto Forum:
  


Current Time: Fri Apr 26 23:03:44 GMT 2024

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

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

Back to the top