Create diagram programmatically from uml file [message #1795266] |
Wed, 19 September 2018 09:15  |
Eclipse User |
|
|
|
First of all, I'm sorry if this question is already answered somewhere, but I searched a lot and didn't found anything about that.
I want to know if there's any way to create a diagram programmatically (and be able to save it aftewards in a notation file) being that I already have an uml file with the description of the model.
In regard to the context of the question, I want to generate the graphical description of a model that was transformed with QVTo to UML2 from another model generated through Xtext. I have a Resource object from which I can get the model EObject (with the getContents function).
Thanks for your time.
|
|
|
Re: Create diagram programmatically from uml file [message #1795666 is a reply to message #1795266] |
Wed, 26 September 2018 10:03  |
Eclipse User |
|
|
|
Hi Ignacio,
Sorry for the delay.
If you want to create it via papyrus, what you will need is, afaik, fairly complex but here are the pointers I can give you:
0- First of you will need to have a Papyrus editor opened
1- get the type of diagram you want to create and its associated ViewPrototype
2- create a ModelSet from the Papyrus MultiDiagramEditor through the service Registry
3- then create your diagram through a CreationCommandDescriptor.getComand().createDiagram(modelset, root, diagramName)
4- from there you will need to get from the editor its associated ServiceRegistry, TransactionalEditingDomain and Diagram page.
5- open the created diagram in it so as to be able to drop your elements in it through OpenDiagramCommand
6- drop your elements in the now active part through a drop request
command
you will then have your diagram created and populated. Although you won't have its elements organized so you might have to do a little cleanup by hand. Unless you want to use an automatic tool like ELK.
You can look at an example of this in the DiagramTemplate tool [1]. There should be a second release shortly but I have no time frame on it yet.
HTH,
Quentin
[1] http://git.eclipse.org/c/papyrus/org.eclipse.papyrus.incubation.git/
|
|
|
Powered by
FUDForum. Page generated in 0.03744 seconds