Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » EMF & GEF, 1:1 mapping between model object and EditParts
EMF & GEF, 1:1 mapping between model object and EditParts [message #175766] Wed, 06 April 2005 09:52 Go to next message
Eclipse UserFriend
Originally posted by: kvdijken.tiscali.nl

In EMF one can use cross document resources. These cross document
resources are stored in the container resources as a URI to an external
resources. When this URI needs to be resolved into actual data, EMF looks
it up if if has been loaded allready, and if it has been, returns a
reference to the allready present instance of the requested data, it does
not create a new data object with the same data in it as the previous
loaded instance.

This poses difficulties when using an EMF data model with GEF, as GEF
expects a 1:1 mapping between model objects and EditParts (via the
EditPartRegistry).

In our application a user created a second cross document resource in the
root model object, which is translated to a Layer figure in the GEF
editor. In the GEF editor this Layer showed exactly as the data which was
loaded at first instance (only with different visualizations, that's why
the user created the second cross document reference). When creating new
model objects in the resource (any reference to it), Figures for these
objects appear in both Layers ,this is good. The EditParts for both Layers
are listeners on the same resource, to which this new model object is
added. Upon removal of an object in this resource however, it is only
removed from one of the Layers, because the EditParts perform a lookup in
the global editpartregistry, which cannot handle two editparts for one
model object. Because of this, in only one of the layers the figure for
the model object is deleted, but not in the other, as an editpart cannot
be determined.

In our application I checked if this 1:1 mapping between model objects and
editparts will give troubles, but I do not think it will. Also, in this
application I can perform the lookup of the needed editpart in a different
way (implement a custom editpartregistry), which will give correct
results. Still, it does not feel good.

- did anyone else come across this problem, and how did they solve it?
- is it a fundamental problem with integrating EMF and GEF in one
application?

Koen
Re: EMF & GEF, 1:1 mapping between model object and EditParts [message #175793 is a reply to message #175766] Wed, 06 April 2005 14:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

I thought GEF placed the relationship between models and editparts onto
your editpart factory?

CL


Koen van Dijken wrote:
> In EMF one can use cross document resources. These cross document
> resources are stored in the container resources as a URI to an external
> resources. When this URI needs to be resolved into actual data, EMF
> looks it up if if has been loaded allready, and if it has been, returns
> a reference to the allready present instance of the requested data, it
> does not create a new data object with the same data in it as the
> previous loaded instance.
>
> This poses difficulties when using an EMF data model with GEF, as GEF
> expects a 1:1 mapping between model objects and EditParts (via the
> EditPartRegistry).
>
> In our application a user created a second cross document resource in
> the root model object, which is translated to a Layer figure in the GEF
> editor. In the GEF editor this Layer showed exactly as the data which
> was loaded at first instance (only with different visualizations, that's
> why the user created the second cross document reference). When creating
> new model objects in the resource (any reference to it), Figures for
> these objects appear in both Layers ,this is good. The EditParts for
> both Layers are listeners on the same resource, to which this new model
> object is added. Upon removal of an object in this resource however, it
> is only removed from one of the Layers, because the EditParts perform a
> lookup in the global editpartregistry, which cannot handle two editparts
> for one model object. Because of this, in only one of the layers the
> figure for the model object is deleted, but not in the other, as an
> editpart cannot be determined.
>
> In our application I checked if this 1:1 mapping between model objects
> and editparts will give troubles, but I do not think it will. Also, in
> this application I can perform the lookup of the needed editpart in a
> different way (implement a custom editpartregistry), which will give
> correct results. Still, it does not feel good.
>
> - did anyone else come across this problem, and how did they solve it?
> - is it a fundamental problem with integrating EMF and GEF in one
> application?
>
> Koen
>
>
Re: EMF & GEF, 1:1 mapping between model object and EditParts [message #175872 is a reply to message #175793] Wed, 06 April 2005 18:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kvdijken.tiscali.nl

Maybe my explanation of this phenomenon was not very clear:

With EMF a document tree is built, of which several branches can originate
from cross document resources. Usually these cross document resources are
different, but nothing prohibits them from being the same. In that case EMF
returns the same instances of that document subtree for both (same) cross
document resources. When this document tree is traversed via
EditPart#getModelChildren() the same model object may be encountered twice,
although it is in different logical places in the tree. So, in fact the tree
which is traversed is not a strict tree. In this case we end up with one
model object (in several different logical places in the 'tree'), with two
EditParts.

Koen





"CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
news:d30rka$muq$1@news.eclipse.org...
>I thought GEF placed the relationship between models and editparts onto
>your editpart factory?
>
> CL
>
>
> Koen van Dijken wrote:
>> In EMF one can use cross document resources. These cross document
>> resources are stored in the container resources as a URI to an external
>> resources. When this URI needs to be resolved into actual data, EMF looks
>> it up if if has been loaded allready, and if it has been, returns a
>> reference to the allready present instance of the requested data, it does
>> not create a new data object with the same data in it as the previous
>> loaded instance.
>>
>> This poses difficulties when using an EMF data model with GEF, as GEF
>> expects a 1:1 mapping between model objects and EditParts (via the
>> EditPartRegistry).
>>
>> In our application a user created a second cross document resource in the
>> root model object, which is translated to a Layer figure in the GEF
>> editor. In the GEF editor this Layer showed exactly as the data which was
>> loaded at first instance (only with different visualizations, that's why
>> the user created the second cross document reference). When creating new
>> model objects in the resource (any reference to it), Figures for these
>> objects appear in both Layers ,this is good. The EditParts for both
>> Layers are listeners on the same resource, to which this new model object
>> is added. Upon removal of an object in this resource however, it is only
>> removed from one of the Layers, because the EditParts perform a lookup in
>> the global editpartregistry, which cannot handle two editparts for one
>> model object. Because of this, in only one of the layers the figure for
>> the model object is deleted, but not in the other, as an editpart cannot
>> be determined.
>>
>> In our application I checked if this 1:1 mapping between model objects
>> and editparts will give troubles, but I do not think it will. Also, in
>> this application I can perform the lookup of the needed editpart in a
>> different way (implement a custom editpartregistry), which will give
>> correct results. Still, it does not feel good.
>>
>> - did anyone else come across this problem, and how did they solve it?
>> - is it a fundamental problem with integrating EMF and GEF in one
>> application?
>>
>> Koen
>>
Re: EMF & GEF, 1:1 mapping between model object and EditParts [message #175896 is a reply to message #175766] Wed, 06 April 2005 19:53 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
You can wrap your business model into two different view models, and then
each of those view models would have its own EditPart. I'm just
brainstorming here. The best approach would be to avoid this situation if
you can. Using two separate viewers would be much better.

"Koen van Dijken" <kvdijken@tiscali.nl> wrote in message
news:db8f6e9a8d416119420aa911d06c2416$1@www.eclipse.org...
> In EMF one can use cross document resources. These cross document
> resources are stored in the container resources as a URI to an external
> resources. When this URI needs to be resolved into actual data, EMF looks
> it up if if has been loaded allready, and if it has been, returns a
> reference to the allready present instance of the requested data, it does
> not create a new data object with the same data in it as the previous
> loaded instance.
>
> This poses difficulties when using an EMF data model with GEF, as GEF
> expects a 1:1 mapping between model objects and EditParts (via the
> EditPartRegistry).
>
> In our application a user created a second cross document resource in the
> root model object, which is translated to a Layer figure in the GEF
> editor. In the GEF editor this Layer showed exactly as the data which was
> loaded at first instance (only with different visualizations, that's why
> the user created the second cross document reference). When creating new
> model objects in the resource (any reference to it), Figures for these
> objects appear in both Layers ,this is good. The EditParts for both Layers
> are listeners on the same resource, to which this new model object is
> added. Upon removal of an object in this resource however, it is only
> removed from one of the Layers, because the EditParts perform a lookup in
> the global editpartregistry, which cannot handle two editparts for one
> model object. Because of this, in only one of the layers the figure for
> the model object is deleted, but not in the other, as an editpart cannot
> be determined.
>
> In our application I checked if this 1:1 mapping between model objects and
> editparts will give troubles, but I do not think it will. Also, in this
> application I can perform the lookup of the needed editpart in a different
> way (implement a custom editpartregistry), which will give correct
> results. Still, it does not feel good.
>
> - did anyone else come across this problem, and how did they solve it?
> - is it a fundamental problem with integrating EMF and GEF in one
> application?
>
> Koen
>
>
Re: EMF & GEF, 1:1 mapping between model object and EditParts [message #175912 is a reply to message #175872] Wed, 06 April 2005 20:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

If you are modelling a 'tree' then you should have a heirachy. I don't
think there is a problem with multiple use of the same model, so long as
they have different parents. In your tree each of these models have
different parents, so make sure it is the same in your Editpart heirarchy.

Of course things will get interesting if the model is modified through
one parent as it will cause a modification of appearance in the other.
Positioning could become tricky.

CL


Koen van Dijken wrote:
> Maybe my explanation of this phenomenon was not very clear:
>
> With EMF a document tree is built, of which several branches can originate
> from cross document resources. Usually these cross document resources are
> different, but nothing prohibits them from being the same. In that case EMF
> returns the same instances of that document subtree for both (same) cross
> document resources. When this document tree is traversed via
> EditPart#getModelChildren() the same model object may be encountered twice,
> although it is in different logical places in the tree. So, in fact the tree
> which is traversed is not a strict tree. In this case we end up with one
> model object (in several different logical places in the 'tree'), with two
> EditParts.
>
> Koen
>
>
>
>
>
> "CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
> news:d30rka$muq$1@news.eclipse.org...
>
>>I thought GEF placed the relationship between models and editparts onto
>>your editpart factory?
>>
>>CL
>>
>>
>>Koen van Dijken wrote:
>>
>>>In EMF one can use cross document resources. These cross document
>>>resources are stored in the container resources as a URI to an external
>>>resources. When this URI needs to be resolved into actual data, EMF looks
>>>it up if if has been loaded allready, and if it has been, returns a
>>>reference to the allready present instance of the requested data, it does
>>>not create a new data object with the same data in it as the previous
>>>loaded instance.
>>>
>>>This poses difficulties when using an EMF data model with GEF, as GEF
>>>expects a 1:1 mapping between model objects and EditParts (via the
>>>EditPartRegistry).
>>>
>>>In our application a user created a second cross document resource in the
>>>root model object, which is translated to a Layer figure in the GEF
>>>editor. In the GEF editor this Layer showed exactly as the data which was
>>>loaded at first instance (only with different visualizations, that's why
>>>the user created the second cross document reference). When creating new
>>>model objects in the resource (any reference to it), Figures for these
>>>objects appear in both Layers ,this is good. The EditParts for both
>>>Layers are listeners on the same resource, to which this new model object
>>>is added. Upon removal of an object in this resource however, it is only
>>>removed from one of the Layers, because the EditParts perform a lookup in
>>>the global editpartregistry, which cannot handle two editparts for one
>>>model object. Because of this, in only one of the layers the figure for
>>>the model object is deleted, but not in the other, as an editpart cannot
>>>be determined.
>>>
>>>In our application I checked if this 1:1 mapping between model objects
>>>and editparts will give troubles, but I do not think it will. Also, in
>>>this application I can perform the lookup of the needed editpart in a
>>>different way (implement a custom editpartregistry), which will give
>>>correct results. Still, it does not feel good.
>>>
>>>- did anyone else come across this problem, and how did they solve it?
>>>- is it a fundamental problem with integrating EMF and GEF in one
>>>application?
>>>
>>>Koen
>>>
>
>
Re: EMF & GEF, 1:1 mapping between model object and EditParts [message #175929 is a reply to message #175912] Wed, 06 April 2005 21:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kvdijken.tiscali.nl

"CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
news:d31h76$sg8$1@news.eclipse.org...
> If you are modelling a 'tree' then you should have a heirachy. I don't
> think there is a problem with multiple use of the same model, so long as
> they have different parents. In your tree each of these models have
> different parents, so make sure it is the same in your Editpart heirarchy.
>

Indeed, this is easy, but when you want to find the EditPart which belongs
to a model object (through the use of
EditPartViewer#getEditPartRegistry()#get(modelObject)) you will get only
one EditPart returned instead of all the EditParts which map to the same
model object. This is because the EditPartRegistry is designed to be a 1:1
mapping between EditParts and model objects.



> Of course things will get interesting if the model is modified through one
> parent as it will cause a modification of appearance in the other.
> Positioning could become tricky.
>

This works fine in our application, modify the model object in one of the
parents, and because both parents are listeners on their children, both
parents will update their children. So both model objects in the viewer will
get updated. Positioning is not important in our case, they will be painted
(partially) on top of each other, with different visualizations, which show
through each other by using transparency.



> CL
>
>
> Koen van Dijken wrote:
>> Maybe my explanation of this phenomenon was not very clear:
>>
>> With EMF a document tree is built, of which several branches can
>> originate from cross document resources. Usually these cross document
>> resources are different, but nothing prohibits them from being the same.
>> In that case EMF returns the same instances of that document subtree for
>> both (same) cross document resources. When this document tree is
>> traversed via EditPart#getModelChildren() the same model object may be
>> encountered twice, although it is in different logical places in the
>> tree. So, in fact the tree which is traversed is not a strict tree. In
>> this case we end up with one model object (in several different logical
>> places in the 'tree'), with two EditParts.
>>
>> Koen
>>
>>
>>
>>
>>
>> "CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
>> news:d30rka$muq$1@news.eclipse.org...
>>
>>>I thought GEF placed the relationship between models and editparts onto
>>>your editpart factory?
>>>
>>>CL
>>>
>>>
>>>Koen van Dijken wrote:
>>>
>>>>In EMF one can use cross document resources. These cross document
>>>>resources are stored in the container resources as a URI to an external
>>>>resources. When this URI needs to be resolved into actual data, EMF
>>>>looks it up if if has been loaded allready, and if it has been, returns
>>>>a reference to the allready present instance of the requested data, it
>>>>does not create a new data object with the same data in it as the
>>>>previous loaded instance.
>>>>
>>>>This poses difficulties when using an EMF data model with GEF, as GEF
>>>>expects a 1:1 mapping between model objects and EditParts (via the
>>>>EditPartRegistry).
>>>>
>>>>In our application a user created a second cross document resource in
>>>>the root model object, which is translated to a Layer figure in the GEF
>>>>editor. In the GEF editor this Layer showed exactly as the data which
>>>>was loaded at first instance (only with different visualizations, that's
>>>>why the user created the second cross document reference). When creating
>>>>new model objects in the resource (any reference to it), Figures for
>>>>these objects appear in both Layers ,this is good. The EditParts for
>>>>both Layers are listeners on the same resource, to which this new model
>>>>object is added. Upon removal of an object in this resource however, it
>>>>is only removed from one of the Layers, because the EditParts perform a
>>>>lookup in the global editpartregistry, which cannot handle two editparts
>>>>for one model object. Because of this, in only one of the layers the
>>>>figure for the model object is deleted, but not in the other, as an
>>>>editpart cannot be determined.
>>>>
>>>>In our application I checked if this 1:1 mapping between model objects
>>>>and editparts will give troubles, but I do not think it will. Also, in
>>>>this application I can perform the lookup of the needed editpart in a
>>>>different way (implement a custom editpartregistry), which will give
>>>>correct results. Still, it does not feel good.
>>>>
>>>>- did anyone else come across this problem, and how did they solve it?
>>>>- is it a fundamental problem with integrating EMF and GEF in one
>>>>application?
>>>>
>>>>Koen
>>>>
>>
Re: EMF & GEF, 1:1 mapping between model object and EditParts [message #175945 is a reply to message #175929] Thu, 07 April 2005 02:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Koen van Dijken wrote:
> "CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
> news:d31h76$sg8$1@news.eclipse.org...
>
>>If you are modelling a 'tree' then you should have a heirachy. I don't
>>think there is a problem with multiple use of the same model, so long as
>>they have different parents. In your tree each of these models have
>>different parents, so make sure it is the same in your Editpart heirarchy.
>>
>
>
> Indeed, this is easy, but when you want to find the EditPart which belongs
> to a model object (through the use of
> EditPartViewer#getEditPartRegistry()#get(modelObject)) you will get only
> one EditPart returned instead of all the EditParts which map to the same
> model object. This is because the EditPartRegistry is designed to be a 1:1
> mapping between EditParts and model objects.
>
>

interesting. I never had use for the registry as I use my models to get
info on the models mostly. Does this cause something to break?


CL
Re: EMF & GEF, 1:1 mapping between model object and EditParts [message #175953 is a reply to message #175929] Thu, 07 April 2005 02:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Koen van Dijken wrote:
> "CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
> news:d31h76$sg8$1@news.eclipse.org...
>
>>If you are modelling a 'tree' then you should have a heirachy. I don't
>>think there is a problem with multiple use of the same model, so long as
>>they have different parents. In your tree each of these models have
>>different parents, so make sure it is the same in your Editpart heirarchy.
>>
>
>
> Indeed, this is easy, but when you want to find the EditPart which belongs
> to a model object (through the use of
> EditPartViewer#getEditPartRegistry()#get(modelObject)) you will get only
> one EditPart returned instead of all the EditParts which map to the same
> model object. This is because the EditPartRegistry is designed to be a 1:1
> mapping between EditParts and model objects.
>
>
>


I also just remembered that I have 2 editparts using the same model, but
they have 2 different parent editparts and are also in 2 seperate
Editors. Perhaps that Is why I don't see any issue since i have
seperate editors.

CL
Re: EMF & GEF, 1:1 mapping between model object and EditParts [message #176206 is a reply to message #175766] Fri, 08 April 2005 15:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

If you need one model to have two editparts, then you can do several things:

1) Only register one of the editparts
2) Only register the first editpart
3) Customize register to associate a model to a List of editparts, as needed
Re: EMF & GEF, 1:1 mapping between model object and EditParts [message #176240 is a reply to message #176206] Fri, 08 April 2005 16:44 Go to previous message
Eclipse UserFriend
Originally posted by: kvdijken.tiscali.nl

"Randy Hudson" <none@us.ibm.com> wrote in message
news:d367rn$5bf$1@news.eclipse.org...
> If you need one model to have two editparts, then you can do several
> things:
>
> 1) Only register one of the editparts
> 2) Only register the first editpart

This happens automatically, when registering the second the registration of
the first one is lost.

> 3) Customize register to associate a model to a List of editparts, as
> needed

Yes, that is indeed what i have done. Would it be usefull (for other
developers) to post a feature request for a 1:n mapping between model
objects and EditParts, or would this be too specific? Personally I think
other developers (especially when using the mix of EMF and GEF) might
benefit from this too. In that case, nearly all tools which use this mapping
through the EditPartRegistry might need to be slightly changed however.

Thanks,

Koen


>
>
Previous Topic:Multiple selection in ComboBoxPropertyDescriptor
Next Topic:Property sheet problems with MPE
Goto Forum:
  


Current Time: Sun Jan 29 20:13:49 GMT 2023

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

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

Back to the top