Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » MPEs, GEF & Visual/Model information separation
MPEs, GEF & Visual/Model information separation [message #171044] Tue, 08 March 2005 21:43 Go to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Here's a scenario right now I'm battling with that I'd like some advice
on. Currently, visual information is stored along with our business
model (ie., x,y,width,height).

The problem is, say you have an MPE with two graphical viewers... Let's
call them Editors A and B.

Now imagine you have two GenericEditParts X,Y that share the same model.
GenericEditPart X resides in Editor A
GenericEditPart Y resides in Editor B

If you move GenericEditPart X in Editor A, what happens is the model is
updated and notifies both the GenericEditParts it is attatched to, to move.

This isn't the desired behavior, I want each editparts visual
information (that is, width height, x,y) to be seperate from the model.

What is the best way of going around doing this? How are people dealing
with seperating out the view information from the model?

Cheers,

~ Chris
Re: MPEs, GEF & Visual/Model information separation [message #171061 is a reply to message #171044] Tue, 08 March 2005 22:25 Go to previous messageGo to next message
Fabian Wolf is currently offline Fabian WolfFriend
Messages: 96
Registered: July 2009
Member
Chris Aniszczyk wrote:

> Here's a scenario right now I'm battling with that I'd like some advice
> on. Currently, visual information is stored along with our business
> model (ie., x,y,width,height).
>
> The problem is, say you have an MPE with two graphical viewers... Let's
> call them Editors A and B.
>
> Now imagine you have two GenericEditParts X,Y that share the same model.
> GenericEditPart X resides in Editor A
> GenericEditPart Y resides in Editor B
>
> If you move GenericEditPart X in Editor A, what happens is the model is
> updated and notifies both the GenericEditParts it is attatched to, to
> move.
>
> This isn't the desired behavior, I want each editparts visual
> information (that is, width height, x,y) to be seperate from the model.
>
> What is the best way of going around doing this? How are people dealing
> with seperating out the view information from the model?

Hi Chris,

the way we did it was having two models. One, let's call it core-model and
one model dealing with the graphical information.

Two or more models (the graphical ones) can then have the same core-model
object - that means, they share the same business information or whatever
data you're dealing with.

The core models we made available through a static lookup table.

Another idea that comes to mind... a master and slave model. The first
object (of a certain type) placed on the editor is automatically set to be
the master model. All the following ones (representing the same object) are
set to be the slaves and query the master for the shared data.
This however requires the slaves to carry information on how to find their
master or they need to walk through the whole object list,.... :(

I'd prefer the first way... but maybe there are some patterns already
available...

HTH though

Fabian
Re: MPEs, GEF & Visual/Model information separation [message #171131 is a reply to message #171061] Wed, 09 March 2005 07:21 Go to previous messageGo to next message
Barry Lay is currently offline Barry LayFriend
Messages: 48
Registered: July 2009
Member
> Chris Aniszczyk wrote:
>
>>If you move GenericEditPart X in Editor A, what happens is the model is
>>updated and notifies both the GenericEditParts it is attatched to, to
>>move.
>>
>>This isn't the desired behavior, I want each editparts visual
>>information (that is, width height, x,y) to be seperate from the model.
>>
>>What is the best way of going around doing this? How are people dealing
>>with seperating out the view information from the model?

Chris,

What gets updated in the model depends to some extent on what you want
to persist. If you make the change you mention, save, exit, then reopen
the editor what do you expect to see? If you want both editors to show
the same view as before you may need to find a way to save both sets of
graphical state data. If you don't care or can determine the graphical
position another way then you could implement an intermediate model
layer that sits between the "official" business model and the one that
your edit parts are querying for the location. It is difficult to
suggest how exactly to go about this without a bit more detail of your
design - it may be sufficient to create a superclass for your model
elements that includes the graphical details for all of the editors you
have but doesn't participate in the load or save operation. If you are
using EMF for your model you can make these attributes transient so that
they don't show up in the saved file.

Barry
Re: MPEs, GEF & Visual/Model information separation [message #171146 is a reply to message #171131] Wed, 09 March 2005 14:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Barry Lay wrote:
>> Chris Aniszczyk wrote:
>>
>>> If you move GenericEditPart X in Editor A, what happens is the model is
>>> updated and notifies both the GenericEditParts it is attatched to, to
>>> move.
>>>
>>> This isn't the desired behavior, I want each editparts visual
>>> information (that is, width height, x,y) to be seperate from the model.
>>>
>>> What is the best way of going around doing this? How are people dealing
>>> with seperating out the view information from the model?
>
>
> Chris,
>
> What gets updated in the model depends to some extent on what you want
> to persist. If you make the change you mention, save, exit, then reopen
> the editor what do you expect to see? If you want both editors to show
> the same view as before you may need to find a way to save both sets of
> graphical state data. If you don't care or can determine the graphical
> position another way then you could implement an intermediate model
> layer that sits between the "official" business model and the one that
> your edit parts are querying for the location. It is difficult to
> suggest how exactly to go about this without a bit more detail of your
> design - it may be sufficient to create a superclass for your model
> elements that includes the graphical details for all of the editors you
> have but doesn't participate in the load or save operation. If you are
> using EMF for your model you can make these attributes transient so that
> they don't show up in the saved file.
>
> Barry

Yes, I'm using EMF for the model underneath. What I think I've decided
is to have editparts contain two models. One the business model and the
other the visual model (which is just another emf model)
EditPart
- getModel()
- getVisualModel()

This gives me the ability to share, and not share diagram/visual related
information for each model.

The thing is, I already separated out my business model to be based off
of a "diagram" model so the change I'm going to do is just to strip the
diagram information from the business model and have it seperate.

Thanks for the feedback guys.

Cheers,

~ Chris
Re: MPEs, GEF & Visual/Model information separation [message #171340 is a reply to message #171044] Fri, 11 March 2005 05:44 Go to previous message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Chris Aniszczyk wrote:
> Here's a scenario right now I'm battling with that I'd like some advice
> on. Currently, visual information is stored along with our business
> model (ie., x,y,width,height).
>
> The problem is, say you have an MPE with two graphical viewers... Let's
> call them Editors A and B.
>
> Now imagine you have two GenericEditParts X,Y that share the same model.
> GenericEditPart X resides in Editor A
> GenericEditPart Y resides in Editor B
>
> If you move GenericEditPart X in Editor A, what happens is the model is
> updated and notifies both the GenericEditParts it is attatched to, to move.
>
> This isn't the desired behavior, I want each editparts visual
> information (that is, width height, x,y) to be seperate from the model.
>
> What is the best way of going around doing this? How are people dealing
> with seperating out the view information from the model?
>
> Cheers,
>
> ~ Chris

Is this really a model at all? I went through this and decided that the
presentation is as important as the data itself. If the data is
correct, but presented wrong is just as bad as if the data were wrong.
Thus i made my visuals part of my main model.

You have have is really not part of the model at all. Sounds like what
Eclipse tends to store with mementos. Like tree open close state,
project open state. Stuff that can be rebuilt from the model if lost.

so you can have seperate visual 'models' that are persisted with the
workbench with mementos. That should work, unless this visual stuff
actually needs to be persisted long term in which case i am confused.


CL
Previous Topic:removal of toolbar from logic example
Next Topic:Survey on Understanding Code
Goto Forum:
  


Current Time: Thu Sep 19 23:32:24 GMT 2024

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

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

Back to the top