Palladio Workflow Engine/XText

Aus SDQ-Wiki

Xtext Generator Example

Example code for using the Xtext Generator:

	String targetDir = "../example/src-gen/";
	String registerGeneratedEPackage = "org.example";
	String slot = "model";
		
		Class<MyTextGenerator> clazz = MyTextGenerator.class; //Generated using xtend2
		XTextGeneratorConfiguration config = new XTextGeneratorConfiguration(clazz, "Example Language", "example", registerGeneratedEPackage);

		String modelPath = "/path/to/model.xmi";
		ModelLocation sourceModel = new ModelLocation(slot, URI.createFileURI(modelPath));
		
		config.setSourceSlot(slot);
		config.setBlackboardModelLocation(sourceModel);
		config.setTargetDir(targetDir);
		
		NullProgressMonitor monitor = new NullProgressMonitor();
		MDSDBlackboard blackboard = new MDSDBlackboard();
		
		XTextGeneratorBlackboardCompositeJob job = new XTextGeneratorBlackboardCompositeJob(config);
		job.setBlackboard(blackboard);
			
		job.execute(monitor);