Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Retrieve properties when loading a diagram
Retrieve properties when loading a diagram [message #486283] Thu, 17 September 2009 07:09 Go to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello,

In my diagram, I have custom figures which represent some node properties
in a specific way. I am able to notify the custom figure when a property
change by overriding the handleNotificationEvent function in my
XYZEditPart. This works fine.
Now, my problem occurs when I load an existing diagram file: at that
point, the properties are already set and I don't receive any notification
event (which is logical, because the properties didn't change).
Is there a way to retrieve some properties in my EditPart to be able to
inform my custom figures ? Furthermore, where is the best place to put
this code, because my edit part should already be configured (so, putting
that in the constructor is probably a bad idea). In the activate method
maybe ?

Thanks
Cédric
Re: Retrieve properties when loading a diagram [message #486324 is a reply to message #486283] Thu, 17 September 2009 09:32 Go to previous messageGo to next message
Olivier Marot is currently offline Olivier MarotFriend
Messages: 14
Registered: September 2009
Junior Member
Hello Cédric,

Overriding notifyChanged(Notification notification) should give you a notification even at diagram creation.

Just be careful not to put too much operations in there, because it is called pretty often.
Re: Retrieve properties when loading a diagram [message #486344 is a reply to message #486283] Thu, 17 September 2009 11:28 Go to previous messageGo to next message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello Cédric,

Try modifying ???EditPart.activate() method.

-----------------
Alex Shatalin
Re: Retrieve properties when loading a diag ram [message #486351 is a reply to message #486324] Thu, 17 September 2009 11:36 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello Olivier, thanks for your answer.
I have overriden this function in all my edit parts but unfortunately, it
doesn't seem to be called when I open an existing diagram ("File" ->
"Open..."). I'm sure that the diagram that is loaded contains nodes for
which I modified some properties.
This function is correctly called when I change a property, but not when
the diagram is loaded from a file.

I was thinking of putting that code in the active method of my edit part
but I have no idea how to retrieve specific properties of my node from
within the edit part. And I'm not really sure if this is the best place
where to put this code.

Thanks
Cédric
Re: Retrieve properties when loading a diagram [message #486354 is a reply to message #486344] Thu, 17 September 2009 12:00 Go to previous message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello Alex, thanks for the answer.

That's what I was thinking too. The problem was that I was stuck on how to
retrieve the properties of the node from within my edit part.

I finally found a solution (I hope it is correct, but it works fine
anyway) by calling:
((View)basicGetModel()).getElement()

in my edit part. The getElement returns my model object associated with my
edit part (which I need to cast to the correct type). I can then simply
access the properties on this object.

Thanks for the help.
Cédric
Previous Topic:How can I create a circle and a square from a rectangle and an ellipse?
Next Topic:Changing the OpenDiagramBehaviour
Goto Forum:
  


Current Time: Thu Apr 18 19:52:01 GMT 2024

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

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

Back to the top