Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to save both model and diagram in the same file from "File - Save as" menu
How to save both model and diagram in the same file from "File - Save as" menu [message #482593] Thu, 27 August 2009 08:17 Go to next message
Jerome Correnoz is currently offline Jerome CorrenozFriend
Messages: 80
Registered: July 2009
Member
Hi all,

In our gmfgen, we've set the "Same file for diagram and model" to 'true'.
It works fine but when editing a diagram, then using the "File > Save As"
menu, it saves only the diagram part in the file. The model is referred
from it but I would like that both diagram and model are saved in the same
file.

Does anyone know how to do it ? Is there any method to override ?

Regards,
Jerome
Re: How to save both model and diagram in the same file from "File - Save as" menu [message #482613 is a reply to message #482593] Thu, 27 August 2009 09:43 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Jerome,

You need to modify ???DocumentProvider.doSaveDocument() [if (info == null)
branch].

-----------------
Alex Shatalin
Re: How to save both model and diagram in the same file from "File - Save as" menu [message #482703 is a reply to message #482613] Thu, 27 August 2009 15:20 Go to previous messageGo to next message
Jerome Correnoz is currently offline Jerome CorrenozFriend
Messages: 80
Registered: July 2009
Member
Hi Alex,

Thanks for your answer.

I have to override the branch code in if (info == null). My understanding
is that I have to replace the following line :
final Diagram diagramCopy = (Diagram)
EcoreUtil .copy(diagramDocument.getDiagram());

by something equivalent to get the diagram and the model, isn't it ? If
yes, does exist an util method to do that ?

Regards,
Jerome
Re: How to save both model and diagram in the same file from "File - Save as" menu [message #482844 is a reply to message #482703] Fri, 28 August 2009 10:25 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Jerome,

Did you try EcoreUtil.copyAll()?

-----------------
Alex Shatalin
Re: How to save both model and diagram in the same file from "File - Save as" menu [message #482898 is a reply to message #482844] Fri, 28 August 2009 13:27 Go to previous messageGo to next message
Jerome Correnoz is currently offline Jerome CorrenozFriend
Messages: 80
Registered: July 2009
Member
Hi Alex,

My problem is that in the "DocumentProvider.doSaveDocument", I only have
access to the DiagramDocument and it doesn't contain the domain data. So,
even the copyAll will return the diagram stuff.

Do you you know how to retrieve either the original file or the original
domain model ?

Jerome
Re: How to save both model and diagram in the same file from "File - Save as" menu [message #483140 is a reply to message #482898] Mon, 31 August 2009 10:22 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Jerome,

You can call diagram.getElement() to receive referenced domain model element.
-----------------
Alex Shatalin
Re: How to save both model and diagram in the same file from "File - Save as" menu [message #552662 is a reply to message #482613] Fri, 13 August 2010 05:39 Go to previous message
Eclipse UserFriend
Originally posted by: leomaggie365.163.com

On 2009-8-27 17:43, Alex Shatalin wrote:
> Hello Jerome,
>
> You need to modify ???DocumentProvider.doSaveDocument() [if (info ==
> null) branch].
>
> -----------------
> Alex Shatalin
>
>

Hi Jerome and Alex,

Just redirct your own domain model's root model to any Resource's
contents, then save that resource.
If a diagram refers to your domain root model myModelRoot, resource is
the target file you need to save you model(may be as the same as your
diagram file).
As your discussed, in DocumentProvider.doSaveDocument(), get myModelRoot
from diagram, and resource.getContents().add(myModelRoot),
resource.save(null).

That all, try it.
Previous Topic:Hide an attribute
Next Topic:Dividing root canvas into predefined compartments
Goto Forum:
  


Current Time: Fri Mar 29 13:43:27 GMT 2024

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

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

Back to the top