Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » GMF/xtext diagram/model creation problem
GMF/xtext diagram/model creation problem [message #1106028] Tue, 10 September 2013 15:31 Go to next message
Thomas Högg is currently offline Thomas HöggFriend
Messages: 3
Registered: September 2013
Junior Member
Hello,

we are currently working on some UML like gmf editors using xtext and gmf as basis. The dsl is working well but now we are facing on a problem in the diagram creation:

	public static Resource createDiagram(URI diagramURI, URI modelURI,
			IProgressMonitor progressMonitor) {
		TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE
				.createEditingDomain();
		progressMonitor
				.beginTask(
						christ.xtext.modelingframework.cmfdsl.cmfDsl.diagram.part.Messages.CmfDslDiagramEditorUtil_CreateDiagramProgressTask,
						3);
	
		final Resource diagramResource = editingDomain.getResourceSet()
				.createResource(diagramURI);
		final Resource modelResource = editingDomain.getResourceSet()
				.createResource(modelURI); //THIS LINE!!!!!


The last line returns in the current project a LazyLinkingResource, in a older project it returns a XMIResourceImpl. The LazyLinkingResource results the things described in http://www.eclipse.org/forums/index.php/t/521338/. Do you have any idea how to fix it or what we did wrong or how we can force it to create a XMIResourceImpl -resource?

Thanks.
Thomas
Re: GMF/xtext diagram/model creation problem [message #1106718 is a reply to message #1106028] Wed, 11 September 2013 12:55 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 658
Registered: July 2009
Senior Member
Xtext models must be read in a LazyLinkingResource, as it encapsulates
the parser and the serializer.

XMIResource only works for models serialized as XMI.

If your error is really the same as the described link, it is due to the
fact that you're trying to create an Xtext resource with an invalid root
element. Make sure the model conforms to the grammar, e.g. starts with
an element that could be returned by the entry rule.

Am 10.09.13 21:45, schrieb Thomas Högg:
> Hello,
>
> we are currently working on some UML like gmf editors using xtext and
> gmf as basis. The dsl is working well but now we are facing on a problem
> in the diagram creation:
>
> public static Resource createDiagram(URI diagramURI, URI modelURI,
> IProgressMonitor progressMonitor) {
> TransactionalEditingDomain editingDomain =
> GMFEditingDomainFactory.INSTANCE
> .createEditingDomain();
> progressMonitor
> .beginTask(
>
> christ.xtext.modelingframework.cmfdsl.cmfDsl.diagram.part.Messages.CmfDslDiagramEditorUtil_CreateDiagramProgressTask,
>
> 3);
>
> final Resource diagramResource = editingDomain.getResourceSet()
> .createResource(diagramURI);
> final Resource modelResource = editingDomain.getResourceSet()
> .createResource(modelURI); //THIS LINE!!!!!
>
> The last line returns in the current project a LazyLinkingResource, in a
> older project it returns a XMIResourceImpl. The LazyLinkingResource
> results the things described in
> http://www.eclipse.org/forums/index.php/t/521338/. Do you have any idea
> how to fix it or what we did wrong or how we can force it to create a
> XMIResourceImpl -resource?
>
> Thanks.
> Thomas


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: GMF/xtext diagram/model creation problem [message #1109606 is a reply to message #1106718] Sun, 15 September 2013 17:52 Go to previous messageGo to next message
Thomas Högg is currently offline Thomas HöggFriend
Messages: 3
Registered: September 2013
Junior Member
Thanks for the answer and sorry for the late reply. We changed the grammar now, accordingly to your suggestion. But now, it is not as we wanted to have it. To get it work we changed the grammar like this:

Modeling:
ClassDiagram | ObjectDiagram | ComponentDiagram | .....;

But this allows one diagram per file only not as in the first version where multiple diagrams have been possible:

Modeling:

diagtype+=DiagramTypes*;

DiagramTypes:
(StructureDiagram | BehaviorDiagram);

StructureDiagram:
(ClassDiagram | ObjectDiagram | ComponentDiagram | ComponentInstanceDiagram);

BehaviorDiagram:
(StateMachineDiagram | ActivityDiagram);

Is it possible to go somehow back to the original version of the grammar?
The problem is the serializer and the ContextFinder. It always returns root object (in this case Modeling) as context what is not allowed in the sequencer (only DiagramTypes, BehaviorDiagram and StateMachineDiagram). Is it the whished behavior of the ContextFinder that it must return the root object or is it a bug?

Thanks.
Thomas
Re: GMF/xtext diagram/model creation problem [message #1110012 is a reply to message #1109606] Mon, 16 September 2013 08:34 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 658
Registered: July 2009
Senior Member
To be honest, this rather sounds like GMF is configured such that it
assumes the semantic element of the diagram to be a root element in the
semantic resource. Does it work with an XMI resource?


Am 15.09.13 19:52, schrieb Thomas Högg:
> Thanks for the answer and sorry for the late reply. We changed the
> grammar now, accordingly to your suggestion. But now, it is not as we
> wanted to have it. To get it work we changed the grammar like this:
>
> Modeling:
> ClassDiagram | ObjectDiagram | ComponentDiagram | .....;
>
> But this allows one diagram per file only not as in the first version
> where multiple diagrams have been possible:
> Modeling:
>
> diagtype+=DiagramTypes*;
>
> DiagramTypes:
> (StructureDiagram | BehaviorDiagram);
>
> StructureDiagram:
> (ClassDiagram | ObjectDiagram | ComponentDiagram |
> ComponentInstanceDiagram);
>
> BehaviorDiagram:
> (StateMachineDiagram | ActivityDiagram);
>
> Is it possible to go somehow back to the original version of the grammar?
> The problem is the serializer and the ContextFinder. It always returns
> root object (in this case Modeling) as context what is not allowed in
> the sequencer (only DiagramTypes, BehaviorDiagram and
> StateMachineDiagram). Is it the whished behavior of the ContextFinder
> that it must return the root object or is it a bug?
>
> Thanks.
> Thomas


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: GMF/xtext diagram/model creation problem [message #1110994 is a reply to message #1110012] Tue, 17 September 2013 16:08 Go to previous messageGo to next message
Thomas Högg is currently offline Thomas HöggFriend
Messages: 3
Registered: September 2013
Junior Member
Yes, the XMI resource works well. Maybe to clarify what we want to model:

The xtext file should allow to define multiple diagrams/objects what works very well with the first structure while for the gmf editor we planned that there is one diagram per file only. So we started the diagram creation with state-diagram as entry point. As long as we don't make the StateMachineDiagram placeable we have the here addressed behavior.

So for the moment we solved the problem allowing it to place all the diagrams using a node and fill them with content. This fits to the xtext dsl now and works with the serializer.

Thanks.
Re: GMF/xtext diagram/model creation problem [message #1111388 is a reply to message #1110994] Wed, 18 September 2013 06:26 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 658
Registered: July 2009
Senior Member
The this sounds a bit like a serializer bug.
Would you file a bugzilla to ensure this is not the case?

Am 17.09.13 18:08, schrieb Thomas Högg:
> Yes, the XMI resource works well. Maybe to clarify what we want to model:
>
> The xtext file should allow to define multiple diagrams/objects what
> works very well with the first structure while for the gmf editor we
> planned that there is one diagram per file only. So we started the
> diagram creation with state-diagram as entry point. As long as we don't
> make the StateMachineDiagram placeable we have the here addressed behavior.
>
> So for the moment we solved the problem allowing it to place all the
> diagrams using a node and fill them with content. This fits to the xtext
> dsl now and works with the serializer.
>
> Thanks.


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Previous Topic:uniqueness check restricted to certain (model) resources
Next Topic:Grammar
Goto Forum:
  


Current Time: Sun Dec 21 00:32:11 GMT 2014

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

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