Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Generate diagram instance from ecore-instance
Generate diagram instance from ecore-instance [message #642947] Fri, 03 December 2010 13:28 Go to next message
Kai Maschke is currently offline Kai MaschkeFriend
Messages: 16
Registered: October 2010
Junior Member
Hi,

how can I generate a diagram instance from an existing core-instance programatically ?
For example, I habe an instance called "test.model" and i want to generate programatically the "test.model_diagram" file.
Re: Generate diagram instance from ecore-instance [message #642954 is a reply to message #642947] Fri, 03 December 2010 13:56 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello,

You would have to reimplement a lot of the logic which is spread over the diagram code in both generated plugin and runtime plugins.

However, I don't really understand why do you need the component like that. If you just setup the Diagram instance (linking it to the correct semantic element), then the very first opening of the diagram by the user will create all inner structure automatically. You can test it by removing all but the diagram element from existing *.model_diagram file and reopening the editor.

If that does not help and if you are brave enough, you may try to write code around:

- manually creating the Diagram instance by calling the XXXDiagramEditorUtil#createDiagram()
- iteratively calling the XXXDiagramUpdater#getSemanticChildren(View) to create the nodes structure first,
- calling the ViewService for each XXXNodeDescriptor collected from diagram updater to invoke creation of the compartments, labels and other staff implicitly added in the XXXViewProvider
- finally calling the code similar to <Diagram>CanonicalEditPolicy#collectAllLinks(..), and again, wrapping the XXXLinkDescriptors into Edge's by calling the ViewService.

But I would not try to do that myself without a really good reason.

Regards,
Michael




Re: Generate diagram instance from ecore-instance [message #642980 is a reply to message #642954] Fri, 03 December 2010 15:11 Go to previous messageGo to next message
Kai Maschke is currently offline Kai MaschkeFriend
Messages: 16
Registered: October 2010
Junior Member
I didn't know that the diagram is initiated by itself. So, if I understood you correct, I just have to create an XML-file with the "..._diagram"-extension with content like this, right?
<?xml version="1.0" encoding="UTF-8"?>
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:model="http://model/1.0" xmi:id="_lRUcsdbzEd-qeowyZ4pk7Q" type="Model" name="default.model_diagram" measurementUnit="Pixel">
<element xmi:type="model:Model" href="test.model#/"/>
</notation:Diagram>
Re: Generate diagram instance from ecore-instance [message #642988 is a reply to message #642980] Fri, 03 December 2010 15:19 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello,

Yes, indeed, at least if your diagram us synchronized.

And the best way to create that initial contents is to call XXXDiagramEditorUtil#createDiagram and related methods called from the generated XXXCreationWizard#performFinish().

Regards,
Michael
Re: Generate diagram instance from ecore-instance [message #642998 is a reply to message #642988] Fri, 03 December 2010 15:54 Go to previous message
Kai Maschke is currently offline Kai MaschkeFriend
Messages: 16
Registered: October 2010
Junior Member
Ah ok, thanks a lot!
Previous Topic:Custom GMF mapping for links
Next Topic:Adding connections between nodes "automatically"
Goto Forum:
  


Current Time: Fri Apr 26 20:47:39 GMT 2024

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

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

Back to the top