Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » "Generate Diagram Code" - Programmatically
"Generate Diagram Code" - Programmatically [message #1717412] Sun, 13 December 2015 10:34 Go to next message
Florian Goenner is currently offline Florian GoennerFriend
Messages: 15
Registered: December 2015
Junior Member
Greetings!

I am currently working on an RCP Application for automatization of all the GMF codegeneration steps. Currently I am stuck with trying to find the correct functions and classes for programmatically generating the Diagram Code from a given .gmfgen File.

My first intuition lead me to
org.eclipse.gmf.codegen.util.Generator
but I have absolutely no clue how this is properly used. I'd really apprectiate any examples for use of this class.

Thanks in advance for any help!

Florian
Re: "Generate Diagram Code" - Programmatically [message #1717420 is a reply to message #1717412] Sun, 13 December 2015 11:51 Go to previous message
Florian Goenner is currently offline Florian GoennerFriend
Messages: 15
Registered: December 2015
Junior Member
I solved the problem myself. For all the people interested in this topic, here is my code snippet:

public void generateDiagramCodeFromGMFGen(String gmfGenLocation) throws InterruptedException{
		GMFFileHandler handler = new GMFFileHandler();
		CodegenEmitters emitters = new CodegenEmitters(true, null, false);
		org.eclipse.gmf.codegen.util.Generator gen = new org.eclipse.gmf.codegen.util.Generator(handler.loadGMFGenModel(gmfGenLocation), emitters);
		gen.run();
	}


function handler.loadGMFGenModel of GMFFileHandler:

GenEditorGenerator genModel = null;
		ResourceSet srcResSet = new ResourceSetImpl();
		srcResSet.getURIConverter().getURIMap().putAll(EcorePlugin.computePlatformURIMap(true));	
		ModelLoadHelper loadHelper = new ModelLoadHelper(srcResSet, URI.createFileURI(genModelLocation));
		Object root = loadHelper.getContentsRoot();
		if (root instanceof GenDiagram)
			genModel = ((GenDiagram) root).getEditorGen();
		else if (root instanceof GenEditorGenerator)
			genModel = (GenEditorGenerator) root;
		if (genModel != null && genModel.getDomainGenModel() != null)
			genModel.getDomainGenModel().reconcile();
		return genModel;
Previous Topic:missing GMF dashboard
Next Topic:Adding Menus when running an activity diagram
Goto Forum:
  


Current Time: Tue Dec 10 22:17:44 GMT 2024

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

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

Back to the top