Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF and Java Templates(is any way?)
EMF and Java Templates [message #991789] Thu, 20 December 2012 07:53 Go to next message
Dmitriy Shishkin is currently offline Dmitriy ShishkinFriend
Messages: 20
Registered: May 2012
Junior Member
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 13:34 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26226
Registered: July 2009
Senior Member
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 06:01 Go to previous messageGo to next message
Dmitriy Shishkin is currently offline Dmitriy ShishkinFriend
Messages: 20
Registered: May 2012
Junior Member
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 07:28 Go to previous messageGo to next message
Dmitriy Shishkin is currently offline Dmitriy ShishkinFriend
Messages: 20
Registered: May 2012
Junior Member
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 186 times)
  • Attachment: 2.png
    (Size: 20.49KB, Downloaded 193 times)

[Updated on: Fri, 21 December 2012 07:46]

Report message to a moderator

Re: EMF and Java Templates [message #992835 is a reply to message #992241] Sat, 22 December 2012 19:40 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26226
Registered: July 2009
Senior Member
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: Thu Nov 27 01:42:09 GMT 2014

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

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