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;