Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » 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 #942406] Sat, 13 October 2012 13:17 Go to next message
J Sommer is currently offline J SommerFriend
Messages: 28
Registered: October 2012
Location: Germany
Junior Member
Hi,
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 "http://www.xtext.org/Filesystem"

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

http://farm9.staticflickr.com/8327/8082261415_65a69aa38c.jpg

2. I have defined the ecore in GMF
http://farm9.staticflickr.com/8048/8082263442_149b8e8b0f.jpghttp://farm9.staticflickr.com/8336/8082305888_824c467570.jpg

3. I try to run the runtime for Xtext
http://farm9.staticflickr.com/8475/8082313936_d06206d838.jpg

and create the diagramm from my DSL file (test.filesystem).
http://farm9.staticflickr.com/8323/8082338379_f35894ba57_z.jpg

4. Then I have this problem
http://farm9.staticflickr.com/8332/8082347529_3ca68fd520.jpg

5. So I try to use Xtend to change my model in Xtext
http://farm9.staticflickr.com/8476/8082347146_dc220f9ca9.jpg
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
		fi.name = astFi.name
		myfilesystem.files.add(fi)

		val fo = myfilesystemFactory.createFolder()
		var astFo = (ast.eContents.get(1)) as MFolder
		fo.name = astFo.name
		myfilesystem.folders.add(fo)
	}
}


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
myfilesystem
to create a diagram.

Thanks.

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

Report message to a moderator

Re: How to use Xtext(M2M with Xtend) and GMF to create diagramm? (Beginner) [message #942667 is a reply to message #942406] Sat, 13 October 2012 19:23 Go to previous message
J Sommer is currently offline J SommerFriend
Messages: 28
Registered: October 2012
Location: Germany
Junior Member
No Message Body

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

Report message to a moderator

Previous Topic:NMToken Terminal
Next Topic:articles in the newsgroup are out of wack...
Goto Forum:
  


Current Time: Fri Apr 19 05:09:40 GMT 2024

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

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

Back to the top