Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [XPand] Generate from Graphitis .diagram file
[XPand] Generate from Graphitis .diagram file [message #1236371] Mon, 27 January 2014 03:17 Go to next message
Klaus Meiner is currently offline Klaus MeinerFriend
Messages: 6
Registered: January 2014
Junior Member
Hi,

I have a problem when I try to generate code from a graphiti .diagram file. I have a working Xpand setup for basic .ecore metamodels and I thought running that with the .diagram file give me the correct result. But I get errors like
Package with uri 'http://eclipse.org/graphiti/mm/pictograms not found
. I have one plugin project for the metamodel, one project for the xpand generator and one for graphiti and I copied the .diagram file to the directory descriped in my workflow, which looks like this:

<?xml version="1.0"?>
<workflow>
	<property name="model" value="de.tu_bs.cs.isf.mbse.raytracerscenefile/Model/TestPhong.diagram" />
	<property name="ecore" value="de.tu_bs.cs.isf.mbse.raytracerscenefile/Model/RaytracerSceneFile.ecore" />
	<property name="src-gen" value="output" />

	<!-- set up EMF for standalone execution -->
	<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" >
		<platformUri value=".."/>
		<registerEcoreFile value="platform:/resource/${ecore}" />
	</bean>

	<!-- instantiate metamodel -->
	<bean id="mm_emf" class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>

	<!-- load model and store it in slot 'model' -->
	<component class="org.eclipse.emf.mwe.utils.Reader">
		<uri value="platform:/resource/${model}" />
		<modelSlot value="model" />
	</component>

    <!-- Clear output directory -->
    <!--
	<component class="org.eclipse.emf.mwe.utils.DirectoryCleaner">
			<directory value="${src-gen}"/>
	</component>-->

	<!-- check model -->
	<component class="org.eclipse.xtend.check.CheckComponent">
		<metaModel idRef="mm_emf"/>
		<checkFile value="metamodel::Checks" />
		<emfAllChildrenSlot value="model" />
	</component>

	<!--  generate code -->
	<component class="org.eclipse.xpand2.Generator">
		<metaModel idRef="mm_emf"/>
		<expand
			value="template::Template::main FOR model" />
		<outlet path="${src-gen}" >
			<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
		</outlet>
		<resourceManager class ="org.eclipse.xtend.expression.ResourceManagerDefaultImpl">
			<fileEncoding value="ISO-8859-1"/>
		</resourceManager>
	</component>
</workflow>


What do I have to do to get the generation working?


Meiner
Re: [XPand] Generate from Graphitis .diagram file [message #1236452 is a reply to message #1236371] Mon, 27 January 2014 08:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Did you try to register additional generated epackages (those from
grphiti) in the stand alone set up?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [XPand] Generate from Graphitis .diagram file [message #1236453 is a reply to message #1236371] Mon, 27 January 2014 08:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Did you try to register additional generated epackages (those from
grphiti) in the stand alone set up?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [XPand] Generate from Graphitis .diagram file [message #1236502 is a reply to message #1236453] Mon, 27 January 2014 11:07 Go to previous messageGo to next message
Klaus Meiner is currently offline Klaus MeinerFriend
Messages: 6
Registered: January 2014
Junior Member
I tried something like that, but I dont know which packages I have to register there. I tried to register something like org.eclipse.graphiti etc. but I only get errors like "Couldn't find an interface......".
Re: [XPand] Generate from Graphitis .diagram file [message #1236505 is a reply to message #1236502] Mon, 27 January 2014 11:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi have a look for classes that are EPackages (XXXPackage) in the
graphiti bundles

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [XPand] Generate from Graphitis .diagram file [message #1236566 is a reply to message #1236505] Mon, 27 January 2014 14:54 Go to previous messageGo to next message
Klaus Meiner is currently offline Klaus MeinerFriend
Messages: 6
Registered: January 2014
Junior Member
Ok, with that hint I bring it to work (thanks for that). But now I have the problem, that XPand tries to expand not only the emf-model but also the diagram model which comes at 1. in the .diagram file from graphiti. How can I achieve that Xpand only uses the emf model?

My worklow looks like this now:

<?xml version="1.0"?>
<workflow>
	<property name="model" value="de.tu_bs.cs.isf.mbse.raytracerscenefile/Model/TestPhong.diagram" />
	<property name="ecore" value="de.tu_bs.cs.isf.mbse.raytracerscenefile/Model/RaytracerSceneFile.ecore" />
	<property name="src-gen" value="output" />

	<!-- set up EMF for standalone execution -->
	<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" >
		<platformUri value=".."/>
		<!--<registerEcoreFile value="platform:/resource/${ecore}" />-->
		<registerGeneratedEPackage value="de.tu_bs.cs.isf.mbse.RaytracerSceneFile.RaytracerSceneFilePackage"/>
		<registerGeneratedEPackage value="org.eclipse.graphiti.mm.MmPackage"/>
	</bean>

	<!-- instantiate metamodel -->
	<bean id="mm_emf" class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>

	<!-- load model and store it in slot 'model' -->
	<component class="org.eclipse.emf.mwe.utils.Reader">
		<!--<uri value="platform:/resource/${model}" />
		<modelSlot value="model" />-->
		<uri value="platform:/resource/${model}" />
		<modelSlot value="model" />
		<firstElementOnly value ="false" />
	</component>

    <!-- Clear output directory -->
    <!--
	<component class="org.eclipse.emf.mwe.utils.DirectoryCleaner">
			<directory value="${src-gen}"/>
	</component>-->

	<!-- check model -->
	<component class="org.eclipse.xtend.check.CheckComponent">
		<metaModel idRef="mm_emf"/>
		<checkFile value="metamodel::Checks" />
		<emfAllChildrenSlot value="model" />
	</component>

	<!--  generate code -->
	<component class="org.eclipse.xpand2.Generator">
		<metaModel idRef="mm_emf"/>
		<expand
			value="template::Template::main FOR model" />
		<outlet path="${src-gen}" >
			<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
		</outlet>
		<resourceManager class ="org.eclipse.xtend.expression.ResourceManagerDefaultImpl">
			<fileEncoding value="ISO-8859-1"/>
		</resourceManager>
	</component>
</workflow>



The .diagramm file looks like this (I want the part with RaytracerSceneFile):

  <pi:Diagram visible="true" gridUnit="10" diagramTypeId="RT Scene" name="TestPhong" 
..
..
..
</pi:Diagram>
  <RaytracerSceneFile:Scene name="TestPhong">
    <primitive xsi:type="RaytracerSceneFile:Triangle" name="Triangle1" shader="Phong1">
      <pointA>-2.0</pointA>
      <pointA>3.0</pointA>
      <pointA>1.0</pointA>
      <pointB>1.0</pointB>
      <pointB>2.0</pointB>
      <pointB>1.0</pointB>
..
..
..
    </globalShader>
  </RaytracerSceneFile:Scene>
</xmi:XMI>



Because there are links to non eclipse.org sites (I have <5 Posts) I attached the full file.

My Template looks like this:

«IMPORT RaytracerSceneFile»

«DEFINE main FOR Scene»
«FILE "test.json"-»
..
..



And now the error is: "No Definition 'template::Template::main for List' found!"
Re: [XPand] Generate from Graphitis .diagram file [message #1236594 is a reply to message #1236566] Mon, 27 January 2014 16:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi have a look the the reader maybe it is adjustable regarding what
to take. Or you simply ignore the stuff in the template by
introducing a dummy define that does nothing

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [XPand] Generate from Graphitis .diagram file [message #1236630 is a reply to message #1236594] Mon, 27 January 2014 17:54 Go to previous message
Klaus Meiner is currently offline Klaus MeinerFriend
Messages: 6
Registered: January 2014
Junior Member
So, I finally got it. The solution was the following line in the workflow:

<expand value="template::Template::main FOR model.last()" />


Thats because model contains a list of two different models, where the last element is my desired ecore model. With that method I do not have to make dummy defines or so, because I access only the right element.
Previous Topic:[Acceleo 3.4.x] How to import template / modul?
Next Topic:[Acceleo] Can't create new projects in Eclipse 4.3
Goto Forum:
  


Current Time: Tue Apr 16 19:21:29 GMT 2024

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

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

Back to the top