Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] how to inject manual model
[Acceleo] how to inject manual model [message #1258883] Thu, 27 February 2014 16:32 Go to next message
duke vah is currently offline duke vah
Messages: 17
Registered: December 2013
Junior Member
Hi,
I wonder if there is a way to use a Java object in Acceleo generator?
This is my code. I registered a metamodel which is exactly the same as my java class. I know that generator accepts EObject. I wonder if there is a way to pass this limitation?
I user "(EObject)fixture" but it didn't worked.
Thanks in advance.

public class MainClass {

public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("This is the beginning of the program.");
DukeModel fixture = null;
fixture = new DukeModel();
fixture.setName("DukeModel");
File folder = new File("c:\\");
List<String> propertiesFiles = new ArrayList<String>();
try {
Generate gen = new Generate((EObject)fixture, folder, propertiesFiles);
gen.doGenerate(new BasicMonitor());
} catch (IOException e) {
// TODO Auto-generated catch block

e.printStackTrace();
}
System.out.println("It's done.");
}
}
Re: [Acceleo] how to inject manual model [message #1264426 is a reply to message #1258883] Wed, 05 March 2014 03:07 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1623
Registered: July 2009
Senior Member
Hi,

Acceleo is built upon and only operates on EMF models, so unless you are willing to create a whole sub-class of EObejct by hand, you should create and generate a metamodel before trying to use Acceleo. Trying to pass it a random object that is not an EObject will simply fail in ClassCastException. Please look at Java tutorials for that, particularly on inheritance such as this one.

Laurent Goubet
Obeo
Re: [Acceleo] how to inject manual model [message #1267854 is a reply to message #1264426] Sun, 09 March 2014 13:45 Go to previous message
duke vah is currently offline duke vah
Messages: 17
Registered: December 2013
Junior Member
Thanks for response.
I hope I understood correctly.
You first mentioned Acceleo is based on EMF and then mentioned if I don't want to use EMF I should create my own metamodel.

I have my own metamodel and it is not based on EMF. So, how can I let Acceleo understand my metamodel which is not based n EMF.
Thnaks
Previous Topic:[Acceleo] how to get the type of UML attribute/property ?
Next Topic:Acceleo how to change the value of a variable of type String
Goto Forum:
  


Current Time: Thu Aug 21 06:30:27 EDT 2014

Powered by FUDForum. Page generated in 0.02516 seconds