Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » save as. How can I make a copy from the model and diagram file?
save as. How can I make a copy from the model and diagram file? [message #237342] Thu, 23 July 2009 13:48 Go to next message
Urs Frei is currently offline Urs FreiFriend
Messages: 27
Registered: July 2009
Junior Member
Hello

I try to implement the save as functionality. What I have to do now?

I would like to have the possibility to save the current diagram und model
state in a new file.

I know following: I have to override the method isSaveAsAllowed and doSaveAs
from the class DiagramDocumentEditor.

My problem is: I don't know what I have to do now.

I can not copy both files an save it under a new name, because the diagram
file have a relationship to the modelfile.

Thank you for your help



Urs
Re: save as. How can I make a copy from the model and diagram file? [message #237367 is a reply to message #237342] Fri, 24 July 2009 07:29 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Urs,

See generated ???DocumentProvider.doSaveDocument() - saveAs is implemented
there (only diagram file model is copied now, so you can extend it to copy
domain model as well).

-----------------
Alex Shatalin
Re: save as. How can I make a copy from the model and diagram file? [message #237433 is a reply to message #237367] Fri, 24 July 2009 14:09 Go to previous messageGo to next message
Urs Frei is currently offline Urs FreiFriend
Messages: 27
Registered: July 2009
Junior Member
Hello Alex

Thank you for your answer

Ok, I can now copy the two files. My problem is actual the relationship
between the two files. If I only copy the files, the diagram file have the
relationship to the original modelfile. Have you a idea, how to bring the
two new files together?

Have a good weekend

Urs


"Alex Shatalin" <vano@borland.com> schrieb im Newsbeitrag
news:3c3172e62eef08cbda58514449f6@news.eclipse.org...

> See generated ???DocumentProvider.doSaveDocument() - saveAs is implemented
> there (only diagram file model is copied now, so you can extend it to copy
> domain model as well).
Re: save as. How can I make a copy from the model and diagram file? [message #237592 is a reply to message #237433] Mon, 27 July 2009 13:15 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Urs,

As a simple solution you can just assign existing model content to new resource
and then save only this new resource (without saving original one model information
will not be removed from there) like:

Resource newModelResource = diagramDocument.getEditingDomain().getResourceSet().createRe source(newModelResoruceURI);
newModelResource.getContents().addAll(diagramDocument.getDia gram().getElement().eResource().getContents())
newModelResource.save(EcoreDiagramEditorUtil.getSaveOptions( ));

-----------------
Alex Shatalin
Re: save as. How can I make a copy from the model and diagram file? [message #237604 is a reply to message #237592] Mon, 27 July 2009 13:55 Go to previous messageGo to next message
Urs Frei is currently offline Urs FreiFriend
Messages: 27
Registered: July 2009
Junior Member
Hello Alex

Thank you for your answer

No, that is not my problem. I can copy the model and diagram file.
The situation:
Model file origModel
Diagram file origDiag

Now I copy the two and I have now two new file:
Model file copyModel
Diagram file copyDiag

The Problem is now. The file copyDiag has a reference to origModel.

<element xmi:type="model.model:AuxVariable"
href="origModel#//@allAuxVariable.0"/>

I make the copy from the model and diagram by using the methode
EcoreUtil.copy
After that I add the EObject to a resource and the Diagram to a resource and
save it.

Now, I found no way to replace this href with the correct copyModel ref.
Have you any idea.

Thank you for your help.

Urs
Re: save as. How can I make a copy from the model and diagram file? [message #237616 is a reply to message #237604] Mon, 27 July 2009 14:05 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Urs,

> The Problem is now. The file copyDiag has a reference to origModel.
Right. This is because original diagram was referencing old model.. If you
MOVE domain model from original resource to new one then the all references
in loaded diagram (or even diagram copy) should be updated automatically.
Try using the code sniped I posted above before saving diagram resource copy.

-----------------
Alex Shatalin
Re: save as. How can I make a copy from the model and diagram file? [message #237645 is a reply to message #237616] Mon, 27 July 2009 15:12 Go to previous message
Urs Frei is currently offline Urs FreiFriend
Messages: 27
Registered: July 2009
Junior Member
Hello Alex

You are the best!!

Thank you

Have a good time

Urs

"Alex Shatalin" <vano@borland.com> schrieb im Newsbeitrag
news:3c3172e62efd78cbdceb3fd79ac1@news.eclipse.org...
> Hello Urs,
>
>> The Problem is now. The file copyDiag has a reference to origModel.
> Right. This is because original diagram was referencing old model.. If you
> MOVE domain model from original resource to new one then the all
> references in loaded diagram (or even diagram copy) should be updated
> automatically. Try using the code sniped I posted above before saving
> diagram resource copy.
>
> -----------------
> Alex Shatalin
>
>
Previous Topic:Fill/Font/Line styles added on View creation
Next Topic:Derived attribute without adding extra attr in metamodel
Goto Forum:
  


Current Time: Thu Mar 28 14:15:11 GMT 2024

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

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

Back to the top