Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » keep connections consistent(changing an element implies changing all the references to it)
keep connections consistent [message #519140] Sun, 07 March 2010 01:49 Go to next message
daniele Mising name is currently offline daniele Mising nameFriend
Messages: 48
Registered: July 2009
Member
I'm sure that the solution is in this forum... but I can't find it. Maybe I found the wrong words... However, here is my new problem:

I have this piece of ecore_diagram
http://yfrog.com/0bhelpgzp
(if image isn't visible.. http://img11.imageshack.us/img11/2752/helpgz.png)

and an example of the relative omm

<OPUS:Map>
  <contiene xsi:type="OPUS:PuntoDiStoccaggio" PKNome="Buf_nnn" >
    <giacenze quantita="10" relativa_all_item="//@ha_item.0"/>
  </contiene>
  <ha_item nome="PF_1"  pds_default="//@contiene.0"/> 
</OPUS:Map>


PuntoDiStoccaggio is visible on the editor (it has his EditPart) while item not.
If I change the name of the item (ha_item nome="PF_2"), I want that PuntoDiStoccaggio sees immediately the changes, as if i delete the item, i want that the connection with PuntoDiStoccaggio will delete automatically. But it's not so.
How could I do?

Thanks for the time you're wasting for me.


[Updated on: Sun, 07 March 2010 01:54]

Report message to a moderator

Re: keep connections consistent. notification needed? [message #519146 is a reply to message #519140] Sun, 07 March 2010 10:34 Go to previous messageGo to next message
daniele Mising name is currently offline daniele Mising nameFriend
Messages: 48
Registered: July 2009
Member
I tried to set names of resources as ID, and use the name as EKey too for link, but nothing.. same issue.


Maybe I need notifications? I really don't know how they work and what good are them to...

[Updated on: Mon, 08 March 2010 07:36]

Report message to a moderator

Re: keep connections consistent [message #519319 is a reply to message #519140] Mon, 08 March 2010 14:08 Go to previous messageGo to next message
daniele Mising name is currently offline daniele Mising nameFriend
Messages: 48
Registered: July 2009
Member
I try to explain better my problem.

MAP contains ITEM and PDS (puntoDiStoccaggio).
PDS contains GIACENZA
GIACENZA has a link with ITEM

ITEM and GIACENZA are not graphical elements, I don't create them by drag&drop but programaticaly.


well, let the first item has the name="PF_1"

if I do map.getItem().setName("PF_2") I change its name.
but if I do map.getPds().getGiacenza.getRelativa_all_item().getName() it's still =PF_1

How could I do so that if I change properties of an ITEM, this modifications are updated also in the GIACENZE's ITEM ? (that should be the same item...)
Re: keep connections consistent [message #519346 is a reply to message #519319] Mon, 08 March 2010 10:08 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29646
Registered: July 2009
Senior Member
Daniele,

Comments below.

daniele wrote:
> I try to explain better my problem.
>
> MAP contains ITEM and PDS (puntoDiStoccaggio).
> PDS contains GIACENZA
> GIACENZA has a link with ITEM
>
> ITEM and GIACENZA are not graphical elements, I don't create them by
> drag&drop but programaticaly.
>
>
> well, let the first item has the name="PF_1"
>
> if I do map.getItem().setName("PF_2") I change its name.
> but if I do map.getPds().getGiacenza.getRelativa_all_item().getName()
> it's still =PF_1
It sounds like this isn't really the same object but rather a different
instance.
>
> How could I do so that if I change properties of an ITEM, this
> modifications are updated also in the GIACENZE's ITEM ? (that should
> be the same item...)
If they're the same object, you'd not have this problem, and if they're
different objects, then it's correct for them not to both change at once.
Re: keep connections consistent [message #519352 is a reply to message #519346] Mon, 08 March 2010 15:15 Go to previous messageGo to next message
daniele Mising name is currently offline daniele Mising nameFriend
Messages: 48
Registered: July 2009
Member
they should be the same object.... I don't understand why changements affect only one occurrence....

I do (in a write transaction)

map.getPds().getGiacenze().add (map.getItem())


and in the .omm file, the relation is correctly saved
(see giacenze relativa_all_item="//@ha_item.0"/)

Quote:

<OPUS:Map>
<contiene xsi:type="OPUS:PuntoDiStoccaggio" PKNome="Buf_nnn" >
<giacenze quantita="10" relativa_all_item="//@ha_item.0"/>
</contiene>
<ha_item nome="PF_1" pds_default="//@contiene.0"/>





But if I try to save the editor after changing an item's name (i.e. from PF_1 to PF_2),
it don't let me save, rising an error like "giacenza has PF_1 that is not contained anywhere" ..

Re: keep connections consistent [message #519386 is a reply to message #519352] Mon, 08 March 2010 12:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29646
Registered: July 2009
Senior Member
Daniele,

If they were the same object, it wouldn't be possible for that one
object to have two different values. So they must be two different
object and in that case you should expect to have to change they both.
Why you'd have two objects when you expect only one is hard to explain
from the details you've provided. The debugger is likely to help
investigate the details.


daniele wrote:
> they should be the same object.... I don't understand why changements
> affect only one occurrence....
>
> I do (in a write transaction)
>
> map.getPds().getGiacenze().add (map.getItem())
>
>
> and in the .omm file, the relation is correctly saved (see giacenze
> relativa_all_item="//@ha_item.0"/)
>
> Quote:
>> <OPUS:Map>
>> <contiene xsi:type="OPUS:PuntoDiStoccaggio" PKNome="Buf_nnn" >
>> <giacenze quantita="10" relativa_all_item="//@ha_item.0"/>
>> </contiene>
>> <ha_item nome="PF_1" pds_default="//@contiene.0"/>
>
>
>
>
> But if I try to save the editor after changing an item's name (i.e.
> from PF_1 to PF_2),
> it don't let me save, rising an error like "giacenza has PF_1 that is
> not contained anywhere" ..
>
>
Re: keep connections consistent [message #519608 is a reply to message #519386] Tue, 09 March 2010 13:11 Go to previous message
daniele Mising name is currently offline daniele Mising nameFriend
Messages: 48
Registered: July 2009
Member
I found my shit.

when I changed an ITEM, I did

Quote:

public void change_item (Item old_item, Item new_item) {
BasicEList list = new BasicEList();
list.addAll(map.getHa_Item());
for (int i=0; i < list.size(); i++){
if (list.get(i) == old_item)
/* -----> */ { list.set(i, new_item) } // <---------
}
EditingDomain editingDomain = this.getEditingDomain();
EReference feature = OPUS.OPUSPackage.eINSTANCE.getMap_Ha_item();
editingDomain.getCommandStack().execute(
SetCommand.create(editingDomain, map, feature , list) );
}




of course list.set(i) REMOVE the element at i, and put a new one...

so is the solution create a write transaction for each attribute of an item, writing directly the new attributes? something like that

Quote:
EReference feature = XXX.XXXPackage.eINSTANCE.getItem_Ha_fornitore();
editingDomain.getCommandStack().execute(
SetCommand.create(editingDomain, item_i, feature , item_nuovo.getHa_fornitore()) );
feature = XXX.XXXPackagePackage.eINSTANCE.getItem_Ha_bom();
editingDomain.getCommandStack().execute(
SetCommand.create(editingDomain, item_i, feature , item_nuovo.getHa_bom()) );
feature = XXX.XXXPackageSPackage.eINSTANCE.getItem_Ha_path_item();
editingDomain.getCommandStack().execute(
SetCommand.create(editingDomain, item_i, feature , item_nuovo.getHa_path_item()) );

...


it's quite tedious..

[Updated on: Tue, 09 March 2010 13:18]

Report message to a moderator

Previous Topic:Mapping UI with domain models
Next Topic:get the length of an arrow (association connector)
Goto Forum:
  


Current Time: Tue Nov 13 02:44:38 GMT 2018

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

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

Back to the top