|
|
|
Re: Generation gap pattern and EcoreGenerator [message #758704 is a reply to message #758652] |
Thu, 24 November 2011 10:28 |
Moritz Eysholdt Messages: 161 Registered: July 2009 Location: Kiel, Germany |
Senior Member |
|
|
Hi Xavier,
(answers inline)
> Since I prefer writing custom in separated classes rather than in the
> EMF model code, I'm trying the method described there :
> http://www.eclipsecon.org/2011/sessions/?page=sessions&id=2253
nice!
> But I have some questions : - I tried the sample on github and it seems
> that the directory cleaner is not executed ? (see the mwe2 log there :
> https://gist.github.com/1390741)
hm, could it be that the directory cleaner is configures for the wrong
directory?
What you might try is to set a breakpoint in
org.eclipse.emf.mwe.utils.DirectoryCleaner.invokeInternal(...) and
org.eclipse.emf.mwe.utils.DirectoryCleaner.checkConfigurationInternal(...)
Then launch the MWE2-Workflow via "Debug As...".
> - What if I want to customize the name of the custom classes? (I don't
> like the suffixed ones by Custom)
You'll have to subclass org.eclipse.emf.mwe2.ecore.EcoreGenerator and
override getTypeMapper(). getTypeMapper() returns an object that is
responsible for mapping EMF-names (e.g. FooBarImpl) to names of "custom"
classes (e.g. FooBarImplCustom). You can implement any mapping logic you
want. In your MWE2-Workflow, your subclass replaces the EcoreGenerator.
> - In my own project custom code is not generated? (here is my mwe2 file
> : https://gist.github.com/1390746)
true ;) It's not generated by default because we assume that not every
class from an EMF model will have a Custom-Class. Therefore, generating
stubs for all classes would kinda pollute the project. You can have
custom classes generated when you set
EcoreGenerator { generateCustomClasses = true }
in your workflow.
> Still, it seems a good approach when you deal with some custom code.
> And is there any drawbacks we should be aware of?
Yes, there is one thing you should have in mind when overriding Methods:
Since EMF supports multiple inheritance and Java does not, not all
super-classes declared on the EMF side will be actual super-classes on
the Java-Class-Side (only on the Java-Interface side).
regards,
Moritz
|
|
|
Powered by
FUDForum. Page generated in 0.04136 seconds