Skip to main content



      Home
Home » Modeling » EMF » EMF and Java Templates(is any way?)
EMF and Java Templates [message #991789] Thu, 20 December 2012 02:53 Go to next message
Eclipse UserFriend
Hi,

Is any way to generate Java Templates with EMF?
some interfaces like:
 __________________                 ___________________
|    ITemplate<T>  |               |        <T>        |
|------------------|-------get---->|-------------------|
|                  |          0..* |                   |
|__________________|               |___________________|

to generate:
public interface ITemplate<T>{

  public List<T> get();
}

And when some class is inherited from this interface I should point a class name of T.
The reason is that in my EcorDiagram I have some repeated patterns of classes and it would be better collapse them to java templates.

Is any way to do this in current version of EMF? if no, is any futher plans for realising that?

Thanks,
Dmitriy.
Re: EMF and Java Templates [message #991922 is a reply to message #991789] Thu, 20 December 2012 08:34 Go to previous messageGo to next message
Eclipse UserFriend
Dmitriy,

The diagram editor doesn't have good support for specifying generics.
You'll have to edit the *.ecore directly with the Sample Ecore Editor
(or use Xcore). Be sure to enable Sample Ecore Editor -> Show
Generics. Then you'll be able to add type parameters to classifiers and
use them in generic types.


On 19/12/2012 11:53 PM, Dmitriy Shishkin wrote:
> Hi,
>
> Is any way to generate Java Templates with EMF?
> some interfaces like:
> __________________ ___________________
> | ITemplate<T> | | <T> |
> |------------------|-------get---->|-------------------|
> | | 0..* | |
> |__________________| |___________________|
> to generate:
> public interface ITemplate<T>{
>
> public List<T> get();
> }
> And when some class is inherited from this interface I should point a
> class name of T.
> The reason is that in my EcorDiagram I have some repeated patterns of
> classes and it would be better collapse them to java templates.
>
> Is any way to do this in current version of EMF? if no, is any futher
> plans for realising that?
>
> Thanks,
> Dmitriy.
Re: EMF and Java Templates [message #992218 is a reply to message #991922] Fri, 21 December 2012 01:01 Go to previous messageGo to next message
Eclipse UserFriend
Thank for quick answer, Ed
This is exactly what was needed.

Dmitriy.
Re: EMF and Java Templates [message #992241 is a reply to message #992218] Fri, 21 December 2012 02:28 Go to previous messageGo to next message
Eclipse UserFriend
With java generics the default editor behaves strangely.
Was it bad idea to encapsulate containment reference to generic?

index.php/fa/12757/0/
The containments of classes: RootClass -> ClassA -> ClassB
index.php/fa/12758/0/
Generated code seems to be correct, but the editor behaves strangely.

The main strange thing - RootClass has
protected EList<ClassA> containment;
but I can add ClassB to List.

Thanks,
Dmitriy
  • Attachment: 1.png
    (Size: 61.13KB, Downloaded 480 times)
  • Attachment: 2.png
    (Size: 20.49KB, Downloaded 473 times)

[Updated on: Fri, 21 December 2012 02:46] by Moderator

Re: EMF and Java Templates [message #992835 is a reply to message #992241] Sat, 22 December 2012 14:40 Go to previous message
Eclipse UserFriend
Dmitriy,

There are open bugzillas that we don't constrain the children in a way
that takes generics into account, i.e., this feature in the erased model
is of type EObject, so we allow any EObject, which in a RootClass
instance, isn't restricted enough. Sorry, I've not had time to address
this yet...


On 20/12/2012 11:28 PM, Dmitriy Shishkin wrote:
> With java generics the default editor behaves strangely.
> Was it bad idea to encapsulate containment reference to generic?
>
>
>
>
> Thanks,
> Dmitriy
Previous Topic:[Teneo] How to specify a Foreign Key name with a one to many relationship
Next Topic:eInvoke fails
Goto Forum:
  


Current Time: Tue Jul 22 21:06:17 EDT 2025

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

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

Back to the top