Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Empty compartment after diagram reload
Empty compartment after diagram reload [message #535430] Sun, 23 May 2010 12:54 Go to next message
SebastianFriend
Messages: 8
Registered: May 2010
Junior Member
Hi,

I have a problem with a compartment which show a list of label based on a collection in the underlying model object. I extended the code corresponding CreationCommand which is generated by the GMF code generator, that way that it prepares the new model element with some predefined child elements in the collection.

I can now create a new diagram child using the palette creation tool, the figure appears on the diagram and the compartment is filled with labels, everything is fine up to now.
When I close the editor and reopen it, all labels in the compartment are still there,
but when I exit the editor, restart it all compartments are empty, although the underlying collection in the model element still hold the correct elements.
Now when I add an additional diagram element it show the label as before and when the editor is closed an reopened all labels in all compartment are visible again. This effect only happens when I add a new child to the diagram, without this, closing an reopening the editor does not bring back the labels in the compartments at all.

I debug the code of the CompartmentEditPart (and parents) a little bit to find the differences between adding a newly created element and loading it from the persistent state and found that the AbstractEditPart.refreshChildren() calls the method getModelChildren() which calls View.getVisibleChildren(). When the element is new the content of the transientChildren feature of the View instance is returned (persistentChildren is empty), when diagram is reloaded both the transientChildren and persistentChildren collection are empty and nothing is displayed.

As a workaround I built a transient "I'm-new-flag" in my model object and register a IEditPartListener with the DiagramEditPart which invokes the persistChildren method on my CompartmentEditPart each time a new one is added to diagram. In this case additional children information are stored in the diagram file.
This seems to work quite well, but it feels like a dirty hack.

So my question is, how can I force the runtime to persist the children automatically or to rebuilt the list of transientChildren correctly from the model elements collection.
I have other compartments defined where the child elements are created using the "normal" GMF-way (via the palette tools) and they work perfectly.

Since I am quite new to GMF I don't how to move from here, so any help or advice is greatly appreciated.

Regards,
Sebastian
Re: Empty compartment after diagram reload [message #535530 is a reply to message #535430] Mon, 24 May 2010 09:33 Go to previous messageGo to next message
login is currently offline loginFriend
Messages: 13
Registered: May 2010
Junior Member
How to remove the Compartment in GMF?
Re: Empty compartment after diagram reload [message #535689 is a reply to message #535430] Tue, 25 May 2010 09:35 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

see this topic: http://www.eclipse.org/forums/index.php?t=msg&goto=53134 1&#msg_531341

Regards


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: Empty compartment after diagram reload [message #535955 is a reply to message #535430] Wed, 26 May 2010 13:23 Go to previous message
SebastianFriend
Messages: 8
Registered: May 2010
Junior Member
Hi,

this helped a lot. It works now.

Thank you.
Sebastian
Previous Topic:Perspectives in single generated GMF editor
Next Topic:Class invoked when attribute value is changed
Goto Forum:
  


Current Time: Sun May 26 00:48:55 GMT 2024

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

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

Back to the top