Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Import all elements from an existing diagram file
Import all elements from an existing diagram file [message #468324] Wed, 05 August 2009 05:46 Go to next message
Peter Lang is currently offline Peter LangFriend
Messages: 153
Registered: July 2009
Senior Member
I'd like to have some sort of import functionality, where user can choose
an existing diagram file in filesystem and all nodes and links defined in
that file will be copied into the current diagram (if possible preserving
layout, but just copying the model would be a great start).

Any hints on where to start?
Thanks!
Re: Import all elements from an existing diagram file [message #468376 is a reply to message #468324] Wed, 05 August 2009 10:21 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Peter,

You can load corresponding diagram file with EMF and browse/copy/tranform
diagram/domain model contet using EMF api.

-----------------
Alex Shatalin
Re: Import all elements from an existing diagram file [message #468432 is a reply to message #468376] Wed, 05 August 2009 14:00 Go to previous messageGo to next message
Peter Lang is currently offline Peter LangFriend
Messages: 153
Registered: July 2009
Senior Member
> You can load corresponding diagram file with EMF and browse/copy/tranform
> diagram/domain model contet using EMF api.
Hi Alex,
I've got split Diagram/Model files, so do you mean to open the diagram
file using editingDomain.getResourceSet().getResource, or do I need both?

How would I continue then?
Re: Import all elements from an existing diagram file [message #471903 is a reply to message #468432] Wed, 05 August 2009 19:02 Go to previous messageGo to next message
Seweryn Niemiec is currently offline Seweryn NiemiecFriend
Messages: 80
Registered: July 2009
Member
Peter Lang wrote:
>> You can load corresponding diagram file with EMF and
>> browse/copy/tranform diagram/domain model contet using EMF api.
> Hi Alex,
> I've got split Diagram/Model files, so do you mean to open the diagram
> file using editingDomain.getResourceSet().getResource, or do I need both?

Booth

> How would I continue then?

IMHO just add elements (from booth models) to appropriate new
containers. You have to do it under the control of a
TransactionalEditingDomain.

--
Greetings,
Seweryn
Re: Import all elements from an existing diagram file [message #478270 is a reply to message #468432] Thu, 06 August 2009 09:01 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Peter,

I mean:
- reate new EMF ResourceSet and load diagram resource using its URI there.
- get root element of the resource - this is a Diagram instance
- if you need to access underlying domain model you can simply call diagram.getElement().
This EObject will be located in another resource (domain model one) but for
you it will be transparent.

-----------------
Alex Shatalin
Re: Import all elements from an existing diagram file [message #479215 is a reply to message #478270] Mon, 10 August 2009 09:54 Go to previous messageGo to next message
Peter Lang is currently offline Peter LangFriend
Messages: 153
Registered: July 2009
Senior Member
Hi Alex,

Quite easy until here :)
But how am I going to continue once I've got the diagram?

Do I have to loop over persistedChildren and persistedEdges and copy them
to my own diagram somehow?

How would I do this, and can it be done in one transaction to allow undo?

Thanks a lot,
Peter


> - reate new EMF ResourceSet and load diagram resource using its URI there.
> - get root element of the resource - this is a Diagram instance
> - if you need to access underlying domain model you can simply call
diagram.getElement().
> This EObject will be located in another resource (domain model one) but for
> you it will be transparent.
Re: Import all elements from an existing diagram file [message #480535 is a reply to message #479215] Mon, 17 August 2009 14:46 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Peter,

> Do I have to loop over persistedChildren and persistedEdges and copy
> them to my own diagram somehow?
Yes. or you can write QVT transformation for it..

> How would I do this, and can it be done in one transaction to allow
> undo?
Do you need to undo copying diagram elements to the new resource?
Then you have to use TransactionalEditingDomain and corresponding ResourceSet
to load EMF reosurces there.

-----------------
Alex Shatalin
Previous Topic:GMF link (Relationship) between two nodes
Next Topic:Traingle Figure
Goto Forum:
  


Current Time: Wed Apr 24 18:56:20 GMT 2024

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

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

Back to the top