Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to use Xtext(M2M with Xtend) and GMF to create diagramm? (Beginner)
How to use Xtext(M2M with Xtend) and GMF to create diagramm? (Beginner) [message #942410] Sat, 13 October 2012 13:20
J Sommer is currently offline J SommerFriend
Messages: 28
Registered: October 2012
Location: Germany
Junior Member
I have started to work with Eclipse and I'm still a beginner. So I want to get some help from here.
I use Xtext to read my DSL. And then I want to show the instance with a diagram, which I have already defined with GMF. But the ecore(MFilesystem) in Xtext and the ecore(Filesystem) in GMF are different. So I use the Xtend to change the model and create an EObject(Filesystem). But i don't know, how the GMF use the resource from Xtent to create a diagram. I show my problem here:

1. I have defined the ecore in xtext(Grammmar)
grammar org.xtext.Filesystem with org.eclipse.xtext.common.Terminals

generate filesystem ""

	(mfiles+=MFile | mfolder+=MFolder)* ;
	'myfile' name=ID ';'
	'myfolder' name = ID ';'

2. I have defined the ecore in GMF

3. I try to run the runtime for Xtext

and create the diagramm from my DSL file (test.filesystem).

4. Then I have this problem

5. So I try to use Xtend to change my model in Xtext
package org.xtext.generator

import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.xtext.generator.IFileSystemAccess
import org.eclipse.xtext.generator.IGenerator
import org.gmf.filesystem.filesystem.Filesystem
import org.gmf.filesystem.filesystem.FilesystemFactory
import org.gmf.filesystem.filesystem.impl.FilesystemFactoryImpl
import org.xtext.filesystem.MFile
import org.xtext.filesystem.MFolder

class FilesystemGenerator implements IGenerator  {
	Filesystem myfilesystem
	FilesystemFactory myfilesystemFactory
	override void doGenerate(Resource resource, IFileSystemAccess fsa) {
		//TODO implement me
		val ast = resource.contents.get(0)
		myfilesystemFactory = new FilesystemFactoryImpl()
		myfilesystem = myfilesystemFactory.createFilesystem()
		val fi = myfilesystemFactory.createFile()
		var astFi = (ast.eContents.get(0)) as MFile =

		val fo = myfilesystemFactory.createFolder()
		var astFo = (ast.eContents.get(1)) as MFolder =


6. But it does not work. I think, I have done something wrong. So I want to know, how I can do so that the GMF uses
to create a diagram.


[Updated on: Sat, 13 October 2012 19:31]

Report message to a moderator

Previous Topic:Changing shape on property change
Next Topic:Place a custom figure into a compartment
Goto Forum:

Current Time: Thu Nov 26 18:11:02 GMT 2015

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

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