Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Implement a third-party interface in EMF
Implement a third-party interface in EMF [message #428652] Wed, 25 March 2009 17:58 Go to next message
Rashmy A is currently offline Rashmy A
Messages: 149
Registered: July 2009
Senior Member
Hello,
This post is to figure out implementing a third-party interface within EMF
ecore file.

There is a ecore file that I created with the below setup:
testmodel/
-University (inherits from EObject)
--name:EString
--description:EString

Next I generate code using the EMF genmodel file.
Everything good so far.

Next, I open the UniversityImpl class and make it implement a
third-party interface. Say the interface is named Deployable
So the code looks like this:
public abstract class UniversityImpl extends EObjectImpl implements
University, Deployable
{
........
}

Now, if I go back to the ecore file and add more attributes to Univeristy
and regenerate the code, the interface Deployable is lost. The "generated
NOT" tag can be used in the UniversityElement class. But then by doing this
I will not have EMF generate code for this class anymore.

Could you let me know if there is a way to define this interface as part of
the ecore file so that I can take advantage of the EMF code generation
capability too? Is there some article that I can read?

Thanks,
Rashmy
Re: Implement a third-party interface in EMF [message #428658 is a reply to message #428652] Wed, 25 March 2009 19:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25946
Registered: July 2009
Senior Member
Rashmy,

You can use @implements or @extends in the use-doc section to specify
additional interfaces that will be mixed in during merge. You can also
define an EClass with a given instanceClassName, set it to be abstract
and an interface, and then extend that...


Rashmy wrote:
> Hello,
> This post is to figure out implementing a third-party interface within EMF
> ecore file.
>
> There is a ecore file that I created with the below setup:
> testmodel/
> -University (inherits from EObject)
> --name:EString
> --description:EString
>
> Next I generate code using the EMF genmodel file.
> Everything good so far.
>
> Next, I open the UniversityImpl class and make it implement a
> third-party interface. Say the interface is named Deployable
> So the code looks like this:
> public abstract class UniversityImpl extends EObjectImpl implements
> University, Deployable
> {
> ........
> }
>
> Now, if I go back to the ecore file and add more attributes to Univeristy
> and regenerate the code, the interface Deployable is lost. The "generated
> NOT" tag can be used in the UniversityElement class. But then by doing this
> I will not have EMF generate code for this class anymore.
>
> Could you let me know if there is a way to define this interface as part of
> the ecore file so that I can take advantage of the EMF code generation
> capability too? Is there some article that I can read?
>
> Thanks,
> Rashmy
>
>
>
Re: Implement a third-party interface in EMF [message #428674 is a reply to message #428658] Thu, 26 March 2009 10:45 Go to previous messageGo to next message
Rashmy A is currently offline Rashmy A
Messages: 149
Registered: July 2009
Senior Member
Ed,
Thanks for replying.

Yesterday, I got hold of an EMF book where I found the below notes:
"The user section of the Javadoc comment associated with an interface may
also contain a special control directive used during merging: the @extends
tag, followed by a comma-separated list of interfaces. The generated
interface's extends clause will be merged with this list. This allows you to
add non-generated super-interface, without removing the @generated tag."

I tried the following option but after code generation the addtional
interface is not available in the implementation class.
Option 1:

/**
* @model abstract="true"
* @generated
* @extends com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

After reading your mail today, I even tried the below @implements option and
it did not work.
Option 2:
/**
* @model abstract="true"
* @generated
* @implements com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

Could you point me to some example available either in the EMF book or
online article?
My Eclipse EMF version is 2.3.0.

Thanks!


"Ed Merks" <Ed.Merks@gmail.com> wrote in message
news:gqefhg$a3u$3@build.eclipse.org...
> Rashmy,
>
> You can use @implements or @extends in the use-doc section to specify
> additional interfaces that will be mixed in during merge. You can also
> define an EClass with a given instanceClassName, set it to be abstract and
> an interface, and then extend that...
>
>
> Rashmy wrote:
>> Hello,
>> This post is to figure out implementing a third-party interface within
>> EMF ecore file.
>>
>> There is a ecore file that I created with the below setup:
>> testmodel/
>> -University (inherits from EObject)
>> --name:EString
>> --description:EString
>>
>> Next I generate code using the EMF genmodel file.
>> Everything good so far.
>>
>> Next, I open the UniversityImpl class and make it implement a
>> third-party interface. Say the interface is named Deployable
>> So the code looks like this:
>> public abstract class UniversityImpl extends EObjectImpl implements
>> University, Deployable
>> {
>> ........
>> }
>>
>> Now, if I go back to the ecore file and add more attributes to Univeristy
>> and regenerate the code, the interface Deployable is lost. The "generated
>> NOT" tag can be used in the UniversityElement class. But then by doing
>> this I will not have EMF generate code for this class anymore.
>>
>> Could you let me know if there is a way to define this interface as part
>> of the ecore file so that I can take advantage of the EMF code generation
>> capability too? Is there some article that I can read?
>>
>> Thanks,
>> Rashmy
>>
>>
Re: Implement a third-party interface in EMF [message #428678 is a reply to message #428674] Thu, 26 March 2009 11:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25946
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090604030804090701060007
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Rashmy,

I tried this with the library example code and it works fine.

/**
* @model extendedMetaData="name='Book' kind='elementOnly'"
* @generated
* @extends java.io.Serializable
*/
public interface Book extends EObject, java.io.Serializable
{

Are you saying if you do this, *and *you add it to the actual Java, that
when you regenerate, it gets removed?


Rashmy wrote:
> Ed,
> Thanks for replying.
>
> Yesterday, I got hold of an EMF book where I found the below notes:
> "The user section of the Javadoc comment associated with an interface may
> also contain a special control directive used during merging: the @extends
> tag, followed by a comma-separated list of interfaces. The generated
> interface's extends clause will be merged with this list. This allows you to
> add non-generated super-interface, without removing the @generated tag."
>
> I tried the following option but after code generation the addtional
> interface is not available in the implementation class.
> Option 1:
>
> /**
> * @model abstract="true"
> * @generated
> * @extends com.partner.install.Deployable
> */
> public interface University extends EObject
> {
> ........
> }
>
> After reading your mail today, I even tried the below @implements option and
> it did not work.
> Option 2:
> /**
> * @model abstract="true"
> * @generated
> * @implements com.partner.install.Deployable
> */
> public interface University extends EObject
> {
> ........
> }
>
> Could you point me to some example available either in the EMF book or
> online article?
> My Eclipse EMF version is 2.3.0.
>
> Thanks!
>
>
> "Ed Merks" <Ed.Merks@gmail.com> wrote in message
> news:gqefhg$a3u$3@build.eclipse.org...
>
>> Rashmy,
>>
>> You can use @implements or @extends in the use-doc section to specify
>> additional interfaces that will be mixed in during merge. You can also
>> define an EClass with a given instanceClassName, set it to be abstract and
>> an interface, and then extend that...
>>
>>
>> Rashmy wrote:
>>
>>> Hello,
>>> This post is to figure out implementing a third-party interface within
>>> EMF ecore file.
>>>
>>> There is a ecore file that I created with the below setup:
>>> testmodel/
>>> -University (inherits from EObject)
>>> --name:EString
>>> --description:EString
>>>
>>> Next I generate code using the EMF genmodel file.
>>> Everything good so far.
>>>
>>> Next, I open the UniversityImpl class and make it implement a
>>> third-party interface. Say the interface is named Deployable
>>> So the code looks like this:
>>> public abstract class UniversityImpl extends EObjectImpl implements
>>> University, Deployable
>>> {
>>> ........
>>> }
>>>
>>> Now, if I go back to the ecore file and add more attributes to Univeristy
>>> and regenerate the code, the interface Deployable is lost. The "generated
>>> NOT" tag can be used in the UniversityElement class. But then by doing
>>> this I will not have EMF generate code for this class anymore.
>>>
>>> Could you let me know if there is a way to define this interface as part
>>> of the ecore file so that I can take advantage of the EMF code generation
>>> capability too? Is there some article that I can read?
>>>
>>> Thanks,
>>> Rashmy
>>>
>>>
>>>
>
>
>

--------------090604030804090701060007
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Rashmy,<br>
<br>
I tried this with the library example code and it works fine.<br>
<blockquote>/**<br>
&nbsp;* @model extendedMetaData="name='Book' kind='elementOnly'"<br>
&nbsp;* @generated<br>
&nbsp;* @extends java.io.Serializable<br>
&nbsp;*/<br>
public interface Book extends EObject, java.io.Serializable<br>
{<br>
</blockquote>
Are you saying if you do this, <b>and </b>you add it to the actual
Java, that when you regenerate, it gets removed?<br>
<br>
<br>
Rashmy wrote:
<blockquote cite="mid:gqg4dl$m0c$1@build.eclipse.org" type="cite">
<pre wrap="">Ed,
Thanks for replying.

Yesterday, I got hold of an EMF book where I found the below notes:
"The user section of the Javadoc comment associated with an interface may
also contain a special control directive used during merging: the @extends
tag, followed by a comma-separated list of interfaces. The generated
interface's extends clause will be merged with this list. This allows you to
add non-generated super-interface, without removing the @generated tag."

I tried the following option but after code generation the addtional
interface is not available in the implementation class.
Option 1:

/**
* @model abstract="true"
* @generated
* @extends com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

After reading your mail today, I even tried the below @implements option and
it did not work.
Option 2:
/**
* @model abstract="true"
* @generated
* @implements com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

Could you point me to some example available either in the EMF book or
online article?
My Eclipse EMF version is 2.3.0.

Thanks!


"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:Ed.Merks@gmail.com">&lt;Ed.Merks@gmail.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:gqefhg$a3u$3@build.eclipse.org">news:gqefhg$a3u$3@build.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Rashmy,

You can use @implements or @extends in the use-doc section to specify
additional interfaces that will be mixed in during merge. You can also
define an EClass with a given instanceClassName, set it to be abstract and
an interface, and then extend that...


Rashmy wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hello,
This post is to figure out implementing a third-party interface within
EMF ecore file.

There is a ecore file that I created with the below setup:
testmodel/
-University (inherits from EObject)
--name:EString
--description:EString

Next I generate code using the EMF genmodel file.
Everything good so far.

Next, I open the UniversityImpl class and make it implement a
third-party interface. Say the interface is named Deployable
So the code looks like this:
public abstract class UniversityImpl extends EObjectImpl implements
University, Deployable
{
........
}

Now, if I go back to the ecore file and add more attributes to Univeristy
and regenerate the code, the interface Deployable is lost. The "generated
NOT" tag can be used in the UniversityElement class. But then by doing
this I will not have EMF generate code for this class anymore.

Could you let me know if there is a way to define this interface as part
of the ecore file so that I can take advantage of the EMF code generation
capability too? Is there some article that I can read?

Thanks,
Rashmy


</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
</body>
</html>

--------------090604030804090701060007--
Re: Implement a third-party interface in EMF [message #428682 is a reply to message #428678] Thu, 26 March 2009 11:16 Go to previous messageGo to next message
Rashmy A is currently offline Rashmy A
Messages: 149
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_003E_01C9ADFB.F087ADB0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Ed,
That is correct.

Here are the steps that were followed. Let me know if I'm missing =
something.
1)Add @extends to interface University as below
/**
* @model abstract=3D"true"
* @generated
* @extends com.partner.install.Deployable
*/
public interface University extends EObject, =
com.partner.install.Deployable
{
........
}

2)Add Deployable interface to the implementation class as below
public abstract class UniversityImpl extends EObjectImpl implements =
Univeristy, com.partner.install.Deployable
{
...
}

3)Open the ecore file and add a new attribute to University element.

4)Open the genmodel file and select "Generate Model code".

5)The entires for Deployable interface is removed from the Univeristy =
interface and implementation class.


Thanks.


"Ed Merks" <Ed.Merks@gmail.com> wrote in message =
news:gqg5ag$q9u$1@build.eclipse.org...
Rashmy,

I tried this with the library example code and it works fine.

/**
* @model extendedMetaData=3D"name=3D'Book' kind=3D'elementOnly'"
* @generated
* @extends java.io.Serializable
*/
public interface Book extends EObject, java.io.Serializable
{

Are you saying if you do this, and you add it to the actual Java, that =
when you regenerate, it gets removed?


Rashmy wrote:=20
Ed,
Thanks for replying.

Yesterday, I got hold of an EMF book where I found the below notes:
"The user section of the Javadoc comment associated with an interface =
may=20
also contain a special control directive used during merging: the =
@extends=20
tag, followed by a comma-separated list of interfaces. The generated=20
interface's extends clause will be merged with this list. This allows =
you to=20
add non-generated super-interface, without removing the @generated tag."

I tried the following option but after code generation the addtional=20
interface is not available in the implementation class.
Option 1:

/**
* @model abstract=3D"true"
* @generated
* @extends com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

After reading your mail today, I even tried the below @implements option =
and=20
it did not work.
Option 2:
/**
* @model abstract=3D"true"
* @generated
* @implements com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

Could you point me to some example available either in the EMF book or=20
online article?
My Eclipse EMF version is 2.3.0.

Thanks!


"Ed Merks" <Ed.Merks@gmail.com> wrote in message=20
news:gqefhg$a3u$3@build.eclipse.org...
Rashmy,

You can use @implements or @extends in the use-doc section to specify=20
additional interfaces that will be mixed in during merge. You can also=20
define an EClass with a given instanceClassName, set it to be abstract =
and=20
an interface, and then extend that...


Rashmy wrote:
Hello,
This post is to figure out implementing a third-party interface within=20
EMF ecore file.

There is a ecore file that I created with the below setup:
testmodel/
-University (inherits from EObject)
--name:EString
--description:EString

Next I generate code using the EMF genmodel file.
Everything good so far.

Next, I open the UniversityImpl class and make it implement a
third-party interface. Say the interface is named Deployable
So the code looks like this:
public abstract class UniversityImpl extends EObjectImpl implements=20
University, Deployable
{
........
}

Now, if I go back to the ecore file and add more attributes to =
Univeristy=20
and regenerate the code, the interface Deployable is lost. The =
"generated=20
NOT" tag can be used in the UniversityElement class. But then by doing=20
this I will not have EMF generate code for this class anymore.

Could you let me know if there is a way to define this interface as part =

of the ecore file so that I can take advantage of the EMF code =
generation=20
capability too? Is there some article that I can read?

Thanks,
Rashmy


=20


------=_NextPart_000_003E_01C9ADFB.F087ADB0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.3492" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV>Ed,</DIV>
<DIV>That is correct.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Here are the steps that were followed. Let me know if I'm missing=20
something.</DIV>
<DIV>1)Add @extends to interface University as below</DIV>
<DIV>/**<BR> * @model abstract=3D"true"<BR> * @generated<BR> * @extends=20
com.partner.install.Deployable<BR> */<BR>public interface University =
extends=20
EObject, com.partner.install.Deployable<BR>{<BR>&nbsp; =
.........<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>2)Add Deployable interface to the implementation class as =
below<BR>public=20
abstract class UniversityImpl extends EObjectImpl implements Univeristy, =

com.partner.install.Deployable</DIV>
<DIV>{</DIV>
<DIV>..</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>3)Open the ecore file and add a new attribute to University =
element.</DIV>
<DIV>&nbsp;</DIV>
<DIV>4)Open the genmodel file and select "Generate Model code".</DIV>
<DIV>&nbsp;</DIV>
<DIV>5)The entires for Deployable interface is removed from the =
Univeristy=20
interface and implementation class.</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>Thanks.</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:Ed.Merks@gmail.com">Ed.Merks@gmail.com</A>&gt; wrote in =
message=20
<A=20
=
href=3D"news:gqg5ag$q9u$1@build.eclipse.org">news:gqg5ag$q9u$1@build.ecli=
pse.org</A>...</DIV>Rashmy,<BR><BR>I=20
tried this with the library example code and it works fine.<BR>
<BLOCKQUOTE>/**<BR>&nbsp;* @model extendedMetaData=3D"name=3D'Book'=20
kind=3D'elementOnly'"<BR>&nbsp;* @generated<BR>&nbsp;* @extends=20
java.io.Serializable<BR>&nbsp;*/<BR>public interface Book extends =
EObject,=20
java.io.Serializable<BR>{<BR></BLOCKQUOTE>Are you saying if you do =
this,=20
<B>and </B>you add it to the actual Java, that when you regenerate, it =
gets=20
removed?<BR><BR><BR>Rashmy wrote:=20
<BLOCKQUOTE cite=3Dmid:gqg4dl$m0c$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Ed,
Thanks for replying.

Yesterday, I got hold of an EMF book where I found the below notes:
"The user section of the Javadoc comment associated with an interface =
may=20
also contain a special control directive used during merging: the =
@extends=20
tag, followed by a comma-separated list of interfaces. The generated=20
interface's extends clause will be merged with this list. This allows =
you to=20
add non-generated super-interface, without removing the @generated tag."

I tried the following option but after code generation the addtional=20
interface is not available in the implementation class.
Option 1:

/**
* @model abstract=3D"true"
* @generated
* @extends com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

After reading your mail today, I even tried the below @implements option =
and=20
it did not work.
Option 2:
/**
* @model abstract=3D"true"
* @generated
* @implements com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

Could you point me to some example available either in the EMF book or=20
online article?
My Eclipse EMF version is 2.3.0.

Thanks!


"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:Ed.Merks@gmail.com">&lt;Ed.Merks@gmail.com&gt;</A> wrote =
in message=20
<A class=3Dmoz-txt-link-freetext =
href=3D"news:gqefhg$a3u$3@build.eclipse.org">news:gqefhg$a3u$3@build.ecli=
pse.org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Rashmy,

You can use @implements or @extends in the use-doc section to specify=20
additional interfaces that will be mixed in during merge. You can also=20
define an EClass with a given instanceClassName, set it to be abstract =
and=20
an interface, and then extend that...


Rashmy wrote:
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hello,
This post is to figure out implementing a third-party interface within=20
EMF ecore file.

There is a ecore file that I created with the below setup:
testmodel/
-University (inherits from EObject)
--name:EString
--description:EString

Next I generate code using the EMF genmodel file.
Everything good so far.

Next, I open the UniversityImpl class and make it implement a
third-party interface. Say the interface is named Deployable
So the code looks like this:
public abstract class UniversityImpl extends EObjectImpl implements=20
University, Deployable
{
........
}

Now, if I go back to the ecore file and add more attributes to =
Univeristy=20
and regenerate the code, the interface Deployable is lost. The =
"generated=20
NOT" tag can be used in the UniversityElement class. But then by doing=20
this I will not have EMF generate code for this class anymore.

Could you let me know if there is a way to define this interface as part =

of the ecore file so that I can take advantage of the EMF code =
generation=20
capability too? Is there some article that I can read?

Thanks,
Rashmy


</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->

</PRE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_003E_01C9ADFB.F087ADB0--
Re: Implement a third-party interface in EMF [message #428687 is a reply to message #428682] Thu, 26 March 2009 11:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25946
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040405090004060304090006
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Rashmy,

I am unable to duplicate this. I know we've been using this in Ecore
itself for a long time without a problem, e.g.,

/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>EEnum Literal</b></em>'.
* @extends Enumerator
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link org.eclipse.emf.ecore.EEnumLiteral#getValue
<em>Value</em>}</li>
* <li>{@link org.eclipse.emf.ecore.EEnumLiteral#getInstance
<em>Instance</em>}</li>
* <li>{@link org.eclipse.emf.ecore.EEnumLiteral#getLiteral
<em>Literal</em>}</li>
* <li>{@link org.eclipse.emf.ecore.EEnumLiteral#getEEnum
<em>EEnum</em>}</li>
* </ul>
* </p>
*
* @see org.eclipse.emf.ecore.EcorePackage#getEEnumLiteral()
* @model
* @generated
*/
public interface EEnumLiteral extends ENamedElement, Enumerator

Are you able to duplicate your problem with the library example? I.e.,
does what I show work for that example or not?

Rashmy wrote:
> Ed,
> That is correct.
>
> Here are the steps that were followed. Let me know if I'm missing
> something.
> 1)Add @extends to interface University as below
> /**
> * @model abstract="true"
> * @generated
> * @extends com.partner.install.Deployable
> */
> public interface University extends EObject,
> com.partner.install.Deployable
> {
> ........
> }
>
> 2)Add Deployable interface to the implementation class as below
> public abstract class UniversityImpl extends EObjectImpl implements
> Univeristy, com.partner.install.Deployable
> {
> ..
> }
>
> 3)Open the ecore file and add a new attribute to University element.
>
> 4)Open the genmodel file and select "Generate Model code".
>
> 5)The entires for Deployable interface is removed from the Univeristy
> interface and implementation class.
>
>
> Thanks.
>
>
>
> "Ed Merks" <Ed.Merks@gmail.com <mailto:Ed.Merks@gmail.com>> wrote
> in message news:gqg5ag$q9u$1@build.eclipse.org...
> Rashmy,
>
> I tried this with the library example code and it works fine.
>
> /**
> * @model extendedMetaData="name='Book' kind='elementOnly'"
> * @generated
> * @extends java.io.Serializable
> */
> public interface Book extends EObject, java.io.Serializable
> {
>
> Are you saying if you do this, *and *you add it to the actual
> Java, that when you regenerate, it gets removed?
>
>
> Rashmy wrote:
>> Ed,
>> Thanks for replying.
>>
>> Yesterday, I got hold of an EMF book where I found the below notes:
>> "The user section of the Javadoc comment associated with an interface may
>> also contain a special control directive used during merging: the @extends
>> tag, followed by a comma-separated list of interfaces. The generated
>> interface's extends clause will be merged with this list. This allows you to
>> add non-generated super-interface, without removing the @generated tag."
>>
>> I tried the following option but after code generation the addtional
>> interface is not available in the implementation class.
>> Option 1:
>>
>> /**
>> * @model abstract="true"
>> * @generated
>> * @extends com.partner.install.Deployable
>> */
>> public interface University extends EObject
>> {
>> ........
>> }
>>
>> After reading your mail today, I even tried the below @implements option and
>> it did not work.
>> Option 2:
>> /**
>> * @model abstract="true"
>> * @generated
>> * @implements com.partner.install.Deployable
>> */
>> public interface University extends EObject
>> {
>> ........
>> }
>>
>> Could you point me to some example available either in the EMF book or
>> online article?
>> My Eclipse EMF version is 2.3.0.
>>
>> Thanks!
>>
>>
>> "Ed Merks" <Ed.Merks@gmail.com> wrote in message
>> news:gqefhg$a3u$3@build.eclipse.org...
>>
>>> Rashmy,
>>>
>>> You can use @implements or @extends in the use-doc section to specify
>>> additional interfaces that will be mixed in during merge. You can also
>>> define an EClass with a given instanceClassName, set it to be abstract and
>>> an interface, and then extend that...
>>>
>>>
>>> Rashmy wrote:
>>>
>>>> Hello,
>>>> This post is to figure out implementing a third-party interface within
>>>> EMF ecore file.
>>>>
>>>> There is a ecore file that I created with the below setup:
>>>> testmodel/
>>>> -University (inherits from EObject)
>>>> --name:EString
>>>> --description:EString
>>>>
>>>> Next I generate code using the EMF genmodel file.
>>>> Everything good so far.
>>>>
>>>> Next, I open the UniversityImpl class and make it implement a
>>>> third-party interface. Say the interface is named Deployable
>>>> So the code looks like this:
>>>> public abstract class UniversityImpl extends EObjectImpl implements
>>>> University, Deployable
>>>> {
>>>> ........
>>>> }
>>>>
>>>> Now, if I go back to the ecore file and add more attributes to Univeristy
>>>> and regenerate the code, the interface Deployable is lost. The "generated
>>>> NOT" tag can be used in the UniversityElement class. But then by doing
>>>> this I will not have EMF generate code for this class anymore.
>>>>
>>>> Could you let me know if there is a way to define this interface as part
>>>> of the ecore file so that I can take advantage of the EMF code generation
>>>> capability too? Is there some article that I can read?
>>>>
>>>> Thanks,
>>>> Rashmy
>>>>
>>>>
>>>>
>>
>>
>>
>

--------------040405090004060304090006
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Rashmy,<br>
<br>
I am unable to duplicate this.&nbsp;&nbsp; I know we've been using this in Ecore
itself for a long time without a problem, e.g., <small><br>
</small>
<blockquote><small>/**</small><br>
<small>&nbsp;* &lt;!-- begin-user-doc --&gt;</small><br>
<small>&nbsp;* A representation of the model object
'&lt;em&gt;&lt;b&gt;EEnum Literal&lt;/b&gt;&lt;/em&gt;'.</small><br>
<small>&nbsp;* @extends Enumerator</small><br>
<small>&nbsp;* &lt;!-- end-user-doc --&gt;</small><br>
<small>&nbsp;*</small><br>
<small>&nbsp;* &lt;p&gt;</small><br>
<small>&nbsp;* The following features are supported:</small><br>
<small>&nbsp;* &lt;ul&gt;</small><br>
<small>&nbsp;*&nbsp;&nbsp; &lt;li&gt;{@link
org.eclipse.emf.ecore.EEnumLiteral#getValue
&lt;em&gt;Value&lt;/em&gt;}&lt;/li&g t; </small><br>
<small>&nbsp;*&nbsp;&nbsp; &lt;li&gt;{@link
org.eclipse.emf.ecore.EEnumLiteral#getInstance
&lt;em&gt;Instance&lt;/em&gt;}&lt;/li&am p;gt; </small><br>
<small>&nbsp;*&nbsp;&nbsp; &lt;li&gt;{@link
org.eclipse.emf.ecore.EEnumLiteral#getLiteral
&lt;em&gt;Literal&lt;/em&gt;}&lt;/li& ;gt; </small><br>
<small>&nbsp;*&nbsp;&nbsp; &lt;li&gt;{@link
org.eclipse.emf.ecore.EEnumLiteral#getEEnum
&lt;em&gt;EEnum&lt;/em&gt;}&lt;/li&g t; </small><br>
<small>&nbsp;* &lt;/ul&gt;</small><br>
<small>&nbsp;* &lt;/p&gt;</small><br>
<small>&nbsp;*</small><br>
<small>&nbsp;* @see org.eclipse.emf.ecore.EcorePackage#getEEnumLiteral()</small ><br>
<small>&nbsp;* @model</small><br>
<small>&nbsp;* @generated</small><br>
<small>&nbsp;*/</small><br>
<small>public interface EEnumLiteral extends ENamedElement, Enumerator</small><br>
</blockquote>
Are you able to duplicate your problem with the library example?&nbsp;&nbsp;
I.e., does what I show work for that example or not?<br>
<br>
Rashmy wrote:
<blockquote cite="mid:gqg68p$k75$1@build.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.3492" name="GENERATOR">
<style></style>
<div>Ed,</div>
<div>That is correct.</div>
<div>&nbsp;</div>
<div>Here are the steps that were followed. Let me know if I'm
missing something.</div>
<div>1)Add @extends to interface University as below</div>
<div>/**<br>
* @model abstract="true"<br>
* @generated<br>
* @extends com.partner.install.Deployable<br>
*/<br>
public interface University extends EObject,
com.partner.install.Deployable<br>
{<br>
&nbsp; ........<br>
}</div>
<div>&nbsp;</div>
<div>2)Add Deployable interface to the implementation class as below<br>
public abstract class UniversityImpl extends EObjectImpl implements
Univeristy, com.partner.install.Deployable</div>
<div>{</div>
<div>..</div>
<div>}</div>
<div>&nbsp;</div>
<div>3)Open the ecore file and add a new attribute to University
element.</div>
<div>&nbsp;</div>
<div>4)Open the genmodel file and select "Generate Model code".</div>
<div>&nbsp;</div>
<div>5)The entires for Deployable interface is removed from the
Univeristy interface and implementation class.</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>Thanks.</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<blockquote dir="ltr"
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a moz-do-not-send="true"
href="mailto:Ed.Merks@gmail.com">Ed.Merks@gmail.com</a>&gt; wrote in
message <a moz-do-not-send="true"
href="news:gqg5ag$q9u$1@build.eclipse.org">news:gqg5ag$q9u$1@build.eclipse.org</a>...</div>
Rashmy,<br>
<br>
I tried this with the library example code and it works fine.<br>
<blockquote>/**<br>
&nbsp;* @model extendedMetaData="name='Book' kind='elementOnly'"<br>
&nbsp;* @generated<br>
&nbsp;* @extends java.io.Serializable<br>
&nbsp;*/<br>
public interface Book extends EObject, java.io.Serializable<br>
{<br>
</blockquote>
Are you saying if you do this, <b>and </b>you add it to the actual
Java, that when you regenerate, it gets removed?<br>
<br>
<br>
Rashmy wrote:
<blockquote cite="mid:gqg4dl$m0c$1@build.eclipse.org" type="cite">
<pre wrap="">Ed,
Thanks for replying.

Yesterday, I got hold of an EMF book where I found the below notes:
"The user section of the Javadoc comment associated with an interface may
also contain a special control directive used during merging: the @extends
tag, followed by a comma-separated list of interfaces. The generated
interface's extends clause will be merged with this list. This allows you to
add non-generated super-interface, without removing the @generated tag."

I tried the following option but after code generation the addtional
interface is not available in the implementation class.
Option 1:

/**
* @model abstract="true"
* @generated
* @extends com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

After reading your mail today, I even tried the below @implements option and
it did not work.
Option 2:
/**
* @model abstract="true"
* @generated
* @implements com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

Could you point me to some example available either in the EMF book or
online article?
My Eclipse EMF version is 2.3.0.

Thanks!


"Ed Merks" <a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:Ed.Merks@gmail.com">&lt;Ed.Merks@gmail.com&gt;</a> wrote in message
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="news:gqefhg$a3u$3@build.eclipse.org">news:gqefhg$a3u$3@build.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Rashmy,

You can use @implements or @extends in the use-doc section to specify
additional interfaces that will be mixed in during merge. You can also
define an EClass with a given instanceClassName, set it to be abstract and
an interface, and then extend that...


Rashmy wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hello,
This post is to figure out implementing a third-party interface within
EMF ecore file.

There is a ecore file that I created with the below setup:
testmodel/
-University (inherits from EObject)
--name:EString
--description:EString

Next I generate code using the EMF genmodel file.
Everything good so far.

Next, I open the UniversityImpl class and make it implement a
third-party interface. Say the interface is named Deployable
So the code looks like this:
public abstract class UniversityImpl extends EObjectImpl implements
University, Deployable
{
........
}

Now, if I go back to the ecore file and add more attributes to Univeristy
and regenerate the code, the interface Deployable is lost. The "generated
NOT" tag can be used in the UniversityElement class. But then by doing
this I will not have EMF generate code for this class anymore.

Could you let me know if there is a way to define this interface as part
of the ecore file so that I can take advantage of the EMF code generation
capability too? Is there some article that I can read?

Thanks,
Rashmy


</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
</blockquote>
</blockquote>
</body>
</html>

--------------040405090004060304090006--
Re: Implement a third-party interface in EMF [message #428688 is a reply to message #428687] Thu, 26 March 2009 12:00 Go to previous messageGo to next message
Rashmy A is currently offline Rashmy A
Messages: 149
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_008E_01C9AE02.20105A40
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Ed,
I could reproduce the same issue with Library example too.
But the issue got resolved by adding @extends tag between the below =
tags.=20
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>EEnum Literal</b></em>'.
* @extends Enumerator
* <!-- end-user-doc -->

I did this based on the code snippet you sent below for EEnumListeral.
Thus far I was adding the @extends tag outside of the begin and end =
user-doc tag.

Thanks for helping me out.

Rashmy

"Ed Merks" <Ed.Merks@gmail.com> wrote in message =
news:gqg7io$sj8$1@build.eclipse.org...
Rashmy,

I am unable to duplicate this. I know we've been using this in Ecore =
itself for a long time without a problem, e.g.,=20

/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>EEnum =
Literal</b></em>'.
* @extends Enumerator
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link org.eclipse.emf.ecore.EEnumLiteral#getValue =
<em>Value</em>}</li>
* <li>{@link org.eclipse.emf.ecore.EEnumLiteral#getInstance =
<em>Instance</em>}</li>
* <li>{@link org.eclipse.emf.ecore.EEnumLiteral#getLiteral =
<em>Literal</em>}</li>
* <li>{@link org.eclipse.emf.ecore.EEnumLiteral#getEEnum =
<em>EEnum</em>}</li>
* </ul>
* </p>
*
* @see org.eclipse.emf.ecore.EcorePackage#getEEnumLiteral()
* @model
* @generated
*/
public interface EEnumLiteral extends ENamedElement, Enumerator

Are you able to duplicate your problem with the library example? =
I.e., does what I show work for that example or not?

Rashmy wrote:=20
Ed,
That is correct.

Here are the steps that were followed. Let me know if I'm missing =
something.
1)Add @extends to interface University as below
/**
* @model abstract=3D"true"
* @generated
* @extends com.partner.install.Deployable
*/
public interface University extends EObject, =
com.partner.install.Deployable
{
........
}

2)Add Deployable interface to the implementation class as below
public abstract class UniversityImpl extends EObjectImpl implements =
Univeristy, com.partner.install.Deployable
{
..
}

3)Open the ecore file and add a new attribute to University element.

4)Open the genmodel file and select "Generate Model code".

5)The entires for Deployable interface is removed from the =
Univeristy interface and implementation class.


Thanks.


"Ed Merks" <Ed.Merks@gmail.com> wrote in message =
news:gqg5ag$q9u$1@build.eclipse.org...
Rashmy,

I tried this with the library example code and it works fine.

/**
* @model extendedMetaData=3D"name=3D'Book' =
kind=3D'elementOnly'"
* @generated
* @extends java.io.Serializable
*/
public interface Book extends EObject, java.io.Serializable
{

Are you saying if you do this, and you add it to the actual Java, =
that when you regenerate, it gets removed?


Rashmy wrote:=20
Ed,
Thanks for replying.

Yesterday, I got hold of an EMF book where I found the below notes:
"The user section of the Javadoc comment associated with an interface =
may=20
also contain a special control directive used during merging: the =
@extends=20
tag, followed by a comma-separated list of interfaces. The generated=20
interface's extends clause will be merged with this list. This allows =
you to=20
add non-generated super-interface, without removing the @generated tag."

I tried the following option but after code generation the addtional=20
interface is not available in the implementation class.
Option 1:

/**
* @model abstract=3D"true"
* @generated
* @extends com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

After reading your mail today, I even tried the below @implements option =
and=20
it did not work.
Option 2:
/**
* @model abstract=3D"true"
* @generated
* @implements com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

Could you point me to some example available either in the EMF book or=20
online article?
My Eclipse EMF version is 2.3.0.

Thanks!


"Ed Merks" <Ed.Merks@gmail.com> wrote in message=20
news:gqefhg$a3u$3@build.eclipse.org...
Rashmy,

You can use @implements or @extends in the use-doc section to specify=20
additional interfaces that will be mixed in during merge. You can also=20
define an EClass with a given instanceClassName, set it to be abstract =
and=20
an interface, and then extend that...


Rashmy wrote:
Hello,
This post is to figure out implementing a third-party interface within=20
EMF ecore file.

There is a ecore file that I created with the below setup:
testmodel/
-University (inherits from EObject)
--name:EString
--description:EString

Next I generate code using the EMF genmodel file.
Everything good so far.

Next, I open the UniversityImpl class and make it implement a
third-party interface. Say the interface is named Deployable
So the code looks like this:
public abstract class UniversityImpl extends EObjectImpl implements=20
University, Deployable
{
........
}

Now, if I go back to the ecore file and add more attributes to =
Univeristy=20
and regenerate the code, the interface Deployable is lost. The =
"generated=20
NOT" tag can be used in the UniversityElement class. But then by doing=20
this I will not have EMF generate code for this class anymore.

Could you let me know if there is a way to define this interface as part =

of the ecore file so that I can take advantage of the EMF code =
generation=20
capability too? Is there some article that I can read?

Thanks,
Rashmy


=20


------=_NextPart_000_008E_01C9AE02.20105A40
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.3492" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV>
<DIV><SMALL><FONT size=3D3>Ed,<BR>I could reproduce the same issue with =
Library=20
example too.<BR>But the issue got resolved by adding @extends tag =
between the=20
below tags. <BR>* &lt;!-- begin-user-doc --&gt;<BR>&nbsp;* A =
representation of=20
the model object '&lt;em&gt;&lt;b&gt;EEnum=20
Literal&lt;/b&gt;&lt;/em&gt;'.<BR>&nbsp;* @extends Enumerator<BR>&nbsp;* =
&lt;!--=20
end-user-doc --&gt;</FONT></SMALL></DIV>
<DIV>&nbsp;</DIV>
<DIV><SMALL><FONT size=3D3>I did this based on the code snippet you sent =
below for=20
EEnumListeral.<BR>Thus far I was adding the @extends tag outside of the =
begin=20
and end user-doc tag.</FONT></SMALL></DIV>
<DIV>&nbsp;</DIV>
<DIV><SMALL><FONT size=3D3>Thanks for helping me =
out.</FONT></SMALL></DIV>
<DIV>&nbsp;</DIV>
<DIV><SMALL><FONT size=3D3>Rashmy</FONT></SMALL></DIV></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:Ed.Merks@gmail.com">Ed.Merks@gmail.com</A>&gt; wrote in =
message=20
<A=20
=
href=3D"news:gqg7io$sj8$1@build.eclipse.org">news:gqg7io$sj8$1@build.ecli=
pse.org</A>...</DIV>Rashmy,<BR><BR>I=20
am unable to duplicate this.&nbsp;&nbsp; I know we've been using this =
in Ecore=20
itself for a long time without a problem, e.g., <SMALL><BR></SMALL>
<BLOCKQUOTE><SMALL>/**</SMALL><BR><SMALL>&nbsp;* &lt;!-- =
begin-user-doc=20
--&gt;</SMALL><BR><SMALL>&nbsp;* A representation of the model =
object=20
'&lt;em&gt;&lt;b&gt;EEnum=20
Literal&lt;/b&gt;&lt;/em&gt;'.</SMALL><BR> <SMALL>&nbsp;* @extends=20
Enumerator</SMALL><BR><SMALL>&nbsp;* &lt;!-- end-user-doc=20
--&gt;</SMALL><BR><SMALL>&nbsp;*</SMALL><BR><SMALL >&nbsp;*=20
&lt;p&gt;</SMALL><BR><SMALL>&nbsp;* The following features are=20
supported:</SMALL><BR><SMALL>&nbsp;*=20
&lt;ul&gt;</SMALL><BR><SMALL>&nbsp;*&nbsp;&nbsp; &lt;li&gt;{@link=20
org.eclipse.emf.ecore.EEnumLiteral#getValue=20
=
&lt;em&gt;Value&lt;/em&gt;}&lt;/li&g t; </SMALL><BR><SMALL>&nbsp;*&nbsp;&nb=
sp;=20
&lt;li&gt;{@link org.eclipse.emf.ecore.EEnumLiteral#getInstance=20
=
&lt;em&gt;Instance&lt;/em&gt;}&lt;/li&am p;gt; </SMALL><BR><SMALL>&nbsp;*&nbsp;=
&nbsp;=20
&lt;li&gt;{@link org.eclipse.emf.ecore.EEnumLiteral#getLiteral=20
=
&lt;em&gt;Literal&lt;/em&gt;}&lt;/li& ;gt; </SMALL><BR><SMALL>&nbsp;*&nbsp;&=
nbsp;=20
&lt;li&gt;{@link org.eclipse.emf.ecore.EEnumLiteral#getEEnum=20
&lt;em&gt;EEnum&lt;/em&gt;}&lt;/li&g t; </SMALL><BR><SMALL>&nbsp;*=20
&lt;/ul&gt;</SMALL><BR><SMALL>&nbsp;*=20
&lt;/p&gt;</SMALL><BR><SMALL>&nbsp;*</SMALL ><BR><SMALL>&nbsp;* @see=20
=
org.eclipse.emf.ecore.EcorePackage#getEEnumLiteral()</SMALL ><BR><SMALL>&n=
bsp;*=20
@model</SMALL><BR><SMALL>&nbsp;*=20
@generated</SMALL><BR><SMALL>&nbsp;*/</SMALL><BR><SMALL >public =
interface=20
EEnumLiteral extends ENamedElement, =
Enumerator</SMALL><BR></BLOCKQUOTE>Are you=20
able to duplicate your problem with the library example?&nbsp;&nbsp; =
I.e.,=20
does what I show work for that example or not?<BR><BR>Rashmy wrote:=20
<BLOCKQUOTE cite=3Dmid:gqg68p$k75$1@build.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.3492" name=3DGENERATOR>
<STYLE></STYLE>

<DIV>Ed,</DIV>
<DIV>That is correct.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Here are the steps that were followed. Let me know if I'm =
missing=20
something.</DIV>
<DIV>1)Add @extends to interface University as below</DIV>
<DIV>/**<BR>* @model abstract=3D"true"<BR>* @generated<BR>* @extends =

com.partner.install.Deployable<BR>*/<BR>public interface University =
extends=20
EObject, com.partner.install.Deployable<BR>{<BR>&nbsp; =
.........<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>2)Add Deployable interface to the implementation class as=20
below<BR>public abstract class UniversityImpl extends EObjectImpl =
implements=20
Univeristy, com.partner.install.Deployable</DIV>
<DIV>{</DIV>
<DIV>..</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>3)Open the ecore file and add a new attribute to University=20
element.</DIV>
<DIV>&nbsp;</DIV>
<DIV>4)Open the genmodel file and select "Generate Model =
code".</DIV>
<DIV>&nbsp;</DIV>
<DIV>5)The entires for Deployable interface is removed from the =
Univeristy=20
interface and implementation class.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A href=3D"mailto:Ed.Merks@gmail.com"=20
moz-do-not-send=3D"true">Ed.Merks@gmail.com</A>&gt; wrote in =
message <A=20
href=3D"news:gqg5ag$q9u$1@build.eclipse.org"=20
=
moz-do-not-send=3D"true">news:gqg5ag$q9u$1@build.eclipse.org</A>...</DIV>=
Rashmy,<BR><BR>I=20
tried this with the library example code and it works fine.<BR>
<BLOCKQUOTE>/**<BR>&nbsp;* @model =
extendedMetaData=3D"name=3D'Book'=20
kind=3D'elementOnly'"<BR>&nbsp;* @generated<BR>&nbsp;* @extends=20
java.io.Serializable<BR>&nbsp;*/<BR>public interface Book =
extends=20
EObject, java.io.Serializable<BR>{<BR></BLOCKQUOTE>Are you =
saying if you=20
do this, <B>and </B>you add it to the actual Java, that when you=20
regenerate, it gets removed?<BR><BR><BR>Rashmy wrote:=20
<BLOCKQUOTE cite=3Dmid:gqg4dl$m0c$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Ed,
Thanks for replying.

Yesterday, I got hold of an EMF book where I found the below notes:
"The user section of the Javadoc comment associated with an interface =
may=20
also contain a special control directive used during merging: the =
@extends=20
tag, followed by a comma-separated list of interfaces. The generated=20
interface's extends clause will be merged with this list. This allows =
you to=20
add non-generated super-interface, without removing the @generated tag."

I tried the following option but after code generation the addtional=20
interface is not available in the implementation class.
Option 1:

/**
* @model abstract=3D"true"
* @generated
* @extends com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

After reading your mail today, I even tried the below @implements option =
and=20
it did not work.
Option 2:
/**
* @model abstract=3D"true"
* @generated
* @implements com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

Could you point me to some example available either in the EMF book or=20
online article?
My Eclipse EMF version is 2.3.0.

Thanks!


"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:Ed.Merks@gmail.com" =
moz-do-not-send=3D"true">&lt;Ed.Merks@gmail.com&gt;</A> wrote in message =

<A class=3Dmoz-txt-link-freetext =
href=3D"news:gqefhg$a3u$3@build.eclipse.org" =
moz-do-not-send=3D"true">news:gqefhg$a3u$3@build.eclipse.org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Rashmy,

You can use @implements or @extends in the use-doc section to specify=20
additional interfaces that will be mixed in during merge. You can also=20
define an EClass with a given instanceClassName, set it to be abstract =
and=20
an interface, and then extend that...


Rashmy wrote:
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hello,
This post is to figure out implementing a third-party interface within=20
EMF ecore file.

There is a ecore file that I created with the below setup:
testmodel/
-University (inherits from EObject)
--name:EString
--description:EString

Next I generate code using the EMF genmodel file.
Everything good so far.

Next, I open the UniversityImpl class and make it implement a
third-party interface. Say the interface is named Deployable
So the code looks like this:
public abstract class UniversityImpl extends EObjectImpl implements=20
University, Deployable
{
........
}

Now, if I go back to the ecore file and add more attributes to =
Univeristy=20
and regenerate the code, the interface Deployable is lost. The =
"generated=20
NOT" tag can be used in the UniversityElement class. But then by doing=20
this I will not have EMF generate code for this class anymore.

Could you let me know if there is a way to define this interface as part =

of the ecore file so that I can take advantage of the EMF code =
generation=20
capability too? Is there some article that I can read?

Thanks,
Rashmy


</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->

=
</PRE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE ></BODY></HTML>

------=_NextPart_000_008E_01C9AE02.20105A40--
Re: Implement a third-party interface in EMF [message #428690 is a reply to message #428688] Thu, 26 March 2009 12:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25946
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080307000000060907010604
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Rashmy,

Hence my reason for explicitly mentioning the user-doc section right in
my first note... :-P


Rashmy wrote:
> Ed,
> I could reproduce the same issue with Library example too.
> But the issue got resolved by adding @extends tag between the below tags.
> * <!-- begin-user-doc -->
> * A representation of the model object '<em><b>EEnum Literal</b></em>'.
> * @extends Enumerator
> * <!-- end-user-doc -->
>
> I did this based on the code snippet you sent below for EEnumListeral.
> Thus far I was adding the @extends tag outside of the begin and end
> user-doc tag.
>
> Thanks for helping me out.
>
> Rashmy
>
>
> "Ed Merks" <Ed.Merks@gmail.com <mailto:Ed.Merks@gmail.com>> wrote
> in message news:gqg7io$sj8$1@build.eclipse.org...
> Rashmy,
>
> I am unable to duplicate this. I know we've been using this in
> Ecore itself for a long time without a problem, e.g.,
>
> /**
> * <!-- begin-user-doc -->
> * A representation of the model object '<em><b>EEnum
> Literal</b></em>'.
> * @extends Enumerator
> * <!-- end-user-doc -->
> *
> * <p>
> * The following features are supported:
> * <ul>
> * <li>{@link org.eclipse.emf.ecore.EEnumLiteral#getValue
> <em>Value</em>}</li>
> * <li>{@link org.eclipse.emf.ecore.EEnumLiteral#getInstance
> <em>Instance</em>}</li>
> * <li>{@link org.eclipse.emf.ecore.EEnumLiteral#getLiteral
> <em>Literal</em>}</li>
> * <li>{@link org.eclipse.emf.ecore.EEnumLiteral#getEEnum
> <em>EEnum</em>}</li>
> * </ul>
> * </p>
> *
> * @see org.eclipse.emf.ecore.EcorePackage#getEEnumLiteral()
> * @model
> * @generated
> */
> public interface EEnumLiteral extends ENamedElement, Enumerator
>
> Are you able to duplicate your problem with the library example?
> I.e., does what I show work for that example or not?
>
> Rashmy wrote:
>> Ed,
>> That is correct.
>>
>> Here are the steps that were followed. Let me know if I'm missing
>> something.
>> 1)Add @extends to interface University as below
>> /**
>> * @model abstract="true"
>> * @generated
>> * @extends com.partner.install.Deployable
>> */
>> public interface University extends EObject,
>> com.partner.install.Deployable
>> {
>> ........
>> }
>>
>> 2)Add Deployable interface to the implementation class as below
>> public abstract class UniversityImpl extends EObjectImpl
>> implements Univeristy, com.partner.install.Deployable
>> {
>> ..
>> }
>>
>> 3)Open the ecore file and add a new attribute to University element.
>>
>> 4)Open the genmodel file and select "Generate Model code".
>>
>> 5)The entires for Deployable interface is removed from the
>> Univeristy interface and implementation class.
>>
>>
>> Thanks.
>>
>>
>>
>> "Ed Merks" <Ed.Merks@gmail.com <mailto:Ed.Merks@gmail.com>>
>> wrote in message news:gqg5ag$q9u$1@build.eclipse.org...
>> Rashmy,
>>
>> I tried this with the library example code and it works fine.
>>
>> /**
>> * @model extendedMetaData="name='Book' kind='elementOnly'"
>> * @generated
>> * @extends java.io.Serializable
>> */
>> public interface Book extends EObject, java.io.Serializable
>> {
>>
>> Are you saying if you do this, *and *you add it to the actual
>> Java, that when you regenerate, it gets removed?
>>
>>
>> Rashmy wrote:
>>> Ed,
>>> Thanks for replying.
>>>
>>> Yesterday, I got hold of an EMF book where I found the below notes:
>>> "The user section of the Javadoc comment associated with an interface may
>>> also contain a special control directive used during merging: the @extends
>>> tag, followed by a comma-separated list of interfaces. The generated
>>> interface's extends clause will be merged with this list. This allows you to
>>> add non-generated super-interface, without removing the @generated tag."
>>>
>>> I tried the following option but after code generation the addtional
>>> interface is not available in the implementation class.
>>> Option 1:
>>>
>>> /**
>>> * @model abstract="true"
>>> * @generated
>>> * @extends com.partner.install.Deployable
>>> */
>>> public interface University extends EObject
>>> {
>>> ........
>>> }
>>>
>>> After reading your mail today, I even tried the below @implements option and
>>> it did not work.
>>> Option 2:
>>> /**
>>> * @model abstract="true"
>>> * @generated
>>> * @implements com.partner.install.Deployable
>>> */
>>> public interface University extends EObject
>>> {
>>> ........
>>> }
>>>
>>> Could you point me to some example available either in the EMF book or
>>> online article?
>>> My Eclipse EMF version is 2.3.0.
>>>
>>> Thanks!
>>>
>>>
>>> "Ed Merks" <Ed.Merks@gmail.com> wrote in message
>>> news:gqefhg$a3u$3@build.eclipse.org...
>>>
>>>> Rashmy,
>>>>
>>>> You can use @implements or @extends in the use-doc section to specify
>>>> additional interfaces that will be mixed in during merge. You can also
>>>> define an EClass with a given instanceClassName, set it to be abstract and
>>>> an interface, and then extend that...
>>>>
>>>>
>>>> Rashmy wrote:
>>>>
>>>>> Hello,
>>>>> This post is to figure out implementing a third-party interface within
>>>>> EMF ecore file.
>>>>>
>>>>> There is a ecore file that I created with the below setup:
>>>>> testmodel/
>>>>> -University (inherits from EObject)
>>>>> --name:EString
>>>>> --description:EString
>>>>>
>>>>> Next I generate code using the EMF genmodel file.
>>>>> Everything good so far.
>>>>>
>>>>> Next, I open the UniversityImpl class and make it implement a
>>>>> third-party interface. Say the interface is named Deployable
>>>>> So the code looks like this:
>>>>> public abstract class UniversityImpl extends EObjectImpl implements
>>>>> University, Deployable
>>>>> {
>>>>> ........
>>>>> }
>>>>>
>>>>> Now, if I go back to the ecore file and add more attributes to Univeristy
>>>>> and regenerate the code, the interface Deployable is lost. The "generated
>>>>> NOT" tag can be used in the UniversityElement class. But then by doing
>>>>> this I will not have EMF generate code for this class anymore.
>>>>>
>>>>> Could you let me know if there is a way to define this interface as part
>>>>> of the ecore file so that I can take advantage of the EMF code generation
>>>>> capability too? Is there some article that I can read?
>>>>>
>>>>> Thanks,
>>>>> Rashmy
>>>>>
>>>>>
>>>>>
>>>
>>>
>>>
>>

--------------080307000000060907010604
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Rashmy,<br>
<br>
Hence my reason for explicitly mentioning the user-doc section right in
my first note... :-P<br>
<br>
<br>
Rashmy wrote:
<blockquote cite="mid:gqg8rj$475$1@build.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.3492" name="GENERATOR">
<div>
<div><small><font size="3">Ed,<br>
I could reproduce the same issue with Library example too.<br>
But the issue got resolved by adding @extends tag between the below
tags. <br>
* &lt;!-- begin-user-doc --&gt;<br>
&nbsp;* A representation of the model object '&lt;em&gt;&lt;b&gt;EEnum
Literal&lt;/b&gt;&lt;/em&gt;'.<br>
&nbsp;* @extends Enumerator<br>
&nbsp;* &lt;!-- end-user-doc --&gt;</font></small></div>
<div>&nbsp;</div>
<div><small><font size="3">I did this based on the code snippet you
sent below for EEnumListeral.<br>
Thus far I was adding the @extends tag outside of the begin and end
user-doc tag.</font></small></div>
<div>&nbsp;</div>
<div><small><font size="3">Thanks for helping me out.</font></small></div>
<div>&nbsp;</div>
<div><small><font size="3">Rashmy</font></small></div>
</div>
<blockquote dir="ltr"
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>&nbsp;</div>
<div>"Ed Merks" &lt;<a moz-do-not-send="true"
href="mailto:Ed.Merks@gmail.com">Ed.Merks@gmail.com</a>&gt; wrote in
message <a moz-do-not-send="true"
href="news:gqg7io$sj8$1@build.eclipse.org">news:gqg7io$sj8$1@build.eclipse.org</a>...</div>
Rashmy,<br>
<br>
I am unable to duplicate this.&nbsp;&nbsp; I know we've been using this in Ecore
itself for a long time without a problem, e.g., <small><br>
</small>
<blockquote><small>/**</small><br>
<small>&nbsp;* &lt;!-- begin-user-doc --&gt;</small><br>
<small>&nbsp;* A representation of the model object
'&lt;em&gt;&lt;b&gt;EEnum Literal&lt;/b&gt;&lt;/em&gt;'.</small><br>
<small>&nbsp;* @extends Enumerator</small><br>
<small>&nbsp;* &lt;!-- end-user-doc --&gt;</small><br>
<small>&nbsp;*</small><br>
<small>&nbsp;* &lt;p&gt;</small><br>
<small>&nbsp;* The following features are supported:</small><br>
<small>&nbsp;* &lt;ul&gt;</small><br>
<small>&nbsp;*&nbsp;&nbsp; &lt;li&gt;{@link
org.eclipse.emf.ecore.EEnumLiteral#getValue
&lt;em&gt;Value&lt;/em&gt;}&lt;/li&g t; </small><br>
<small>&nbsp;*&nbsp;&nbsp; &lt;li&gt;{@link
org.eclipse.emf.ecore.EEnumLiteral#getInstance
&lt;em&gt;Instance&lt;/em&gt;}&lt;/li&am p;gt; </small><br>
<small>&nbsp;*&nbsp;&nbsp; &lt;li&gt;{@link
org.eclipse.emf.ecore.EEnumLiteral#getLiteral
&lt;em&gt;Literal&lt;/em&gt;}&lt;/li& ;gt; </small><br>
<small>&nbsp;*&nbsp;&nbsp; &lt;li&gt;{@link
org.eclipse.emf.ecore.EEnumLiteral#getEEnum
&lt;em&gt;EEnum&lt;/em&gt;}&lt;/li&g t; </small><br>
<small>&nbsp;* &lt;/ul&gt;</small><br>
<small>&nbsp;* &lt;/p&gt;</small><br>
<small>&nbsp;*</small><br>
<small>&nbsp;* @see
org.eclipse.emf.ecore.EcorePackage#getEEnumLiteral()</small ><br>
<small>&nbsp;* @model</small><br>
<small>&nbsp;* @generated</small><br>
<small>&nbsp;*/</small><br>
<small>public interface EEnumLiteral extends ENamedElement,
Enumerator</small><br>
</blockquote>
Are you able to duplicate your problem with the library example?&nbsp;&nbsp;
I.e., does what I show work for that example or not?<br>
<br>
Rashmy wrote:
<blockquote cite="mid:gqg68p$k75$1@build.eclipse.org" type="cite">
<meta content="MSHTML 6.00.2900.3492" name="GENERATOR">
<style></style>
<div>Ed,</div>
<div>That is correct.</div>
<div>&nbsp;</div>
<div>Here are the steps that were followed. Let me know if I'm
missing something.</div>
<div>1)Add @extends to interface University as below</div>
<div>/**<br>
* @model abstract="true"<br>
* @generated<br>
* @extends com.partner.install.Deployable<br>
*/<br>
public interface University extends EObject,
com.partner.install.Deployable<br>
{<br>
&nbsp; ........<br>
}</div>
<div>&nbsp;</div>
<div>2)Add Deployable interface to the implementation class as
below<br>
public abstract class UniversityImpl extends EObjectImpl implements
Univeristy, com.partner.install.Deployable</div>
<div>{</div>
<div>..</div>
<div>}</div>
<div>&nbsp;</div>
<div>3)Open the ecore file and add a new attribute to University
element.</div>
<div>&nbsp;</div>
<div>4)Open the genmodel file and select "Generate Model code".</div>
<div>&nbsp;</div>
<div>5)The entires for Deployable interface is removed from the
Univeristy interface and implementation class.</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>Thanks.</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<blockquote dir="ltr"
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:Ed.Merks@gmail.com"
moz-do-not-send="true">Ed.Merks@gmail.com</a>&gt; wrote in message <a
href="news:gqg5ag$q9u$1@build.eclipse.org" moz-do-not-send="true">news:gqg5ag$q9u$1@build.eclipse.org</a>...</div>
Rashmy,<br>
<br>
I tried this with the library example code and it works fine.<br>
<blockquote>/**<br>
&nbsp;* @model extendedMetaData="name='Book' kind='elementOnly'"<br>
&nbsp;* @generated<br>
&nbsp;* @extends java.io.Serializable<br>
&nbsp;*/<br>
public interface Book extends EObject, java.io.Serializable<br>
{<br>
</blockquote>
Are you saying if you do this, <b>and </b>you add it to the actual
Java, that when you regenerate, it gets removed?<br>
<br>
<br>
Rashmy wrote:
<blockquote cite="mid:gqg4dl$m0c$1@build.eclipse.org"
type="cite">
<pre wrap="">Ed,
Thanks for replying.

Yesterday, I got hold of an EMF book where I found the below notes:
"The user section of the Javadoc comment associated with an interface may
also contain a special control directive used during merging: the @extends
tag, followed by a comma-separated list of interfaces. The generated
interface's extends clause will be merged with this list. This allows you to
add non-generated super-interface, without removing the @generated tag."

I tried the following option but after code generation the addtional
interface is not available in the implementation class.
Option 1:

/**
* @model abstract="true"
* @generated
* @extends com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

After reading your mail today, I even tried the below @implements option and
it did not work.
Option 2:
/**
* @model abstract="true"
* @generated
* @implements com.partner.install.Deployable
*/
public interface University extends EObject
{
........
}

Could you point me to some example available either in the EMF book or
online article?
My Eclipse EMF version is 2.3.0.

Thanks!


"Ed Merks" <a class="moz-txt-link-rfc2396E"
href="mailto:Ed.Merks@gmail.com" moz-do-not-send="true">&lt;Ed.Merks@gmail.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext"
href="news:gqefhg$a3u$3@build.eclipse.org" moz-do-not-send="true">news:gqefhg$a3u$3@build.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Rashmy,

You can use @implements or @extends in the use-doc section to specify
additional interfaces that will be mixed in during merge. You can also
define an EClass with a given instanceClassName, set it to be abstract and
an interface, and then extend that...


Rashmy wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hello,
This post is to figure out implementing a third-party interface within
EMF ecore file.

There is a ecore file that I created with the below setup:
testmodel/
-University (inherits from EObject)
--name:EString
--description:EString

Next I generate code using the EMF genmodel file.
Everything good so far.

Next, I open the UniversityImpl class and make it implement a
third-party interface. Say the interface is named Deployable
So the code looks like this:
public abstract class UniversityImpl extends EObjectImpl implements
University, Deployable
{
........
}

Now, if I go back to the ecore file and add more attributes to Univeristy
and regenerate the code, the interface Deployable is lost. The "generated
NOT" tag can be used in the UniversityElement class. But then by doing
this I will not have EMF generate code for this class anymore.

Could you let me know if there is a way to define this interface as part
of the ecore file so that I can take advantage of the EMF code generation
capability too? Is there some article that I can read?

Thanks,
Rashmy


</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</body>
</html>

--------------080307000000060907010604--
Re: Implement a third-party interface in EMF [message #990109 is a reply to message #428690] Mon, 10 December 2012 17:34 Go to previous messageGo to next message
Vincenzo Caselli is currently offline Vincenzo Caselli
Messages: 100
Registered: January 2012
Senior Member
Hi Ed,
is there also some way to do this on the Ecore file, e.g. with EAnnotations, so to have the implements/extends at first generation?
Thank you
Vincenzo
Re: Implement a third-party interface in EMF [message #990180 is a reply to message #990109] Tue, 11 December 2012 05:05 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25946
Registered: July 2009
Senior Member
Vincenzo,

You can always define a wrapper EClass (an EClass with the instance type
name set to some existing Java interface) and use that in the
eSuperTypes of some other EClass.


On 10/12/2012 11:34 PM, Vincenzo Caselli wrote:
> Hi Ed,
> is there also some way to do this on the Ecore file, e.g. with
> EAnnotations, so to have the implements/extends at first generation?
> Thank you
> Vincenzo
Previous Topic:[CDO/db4o store] Multi session/transaction problems
Next Topic:[xcore] generated package not compiling
Goto Forum:
  


Current Time: Wed Jul 30 21:34:58 EDT 2014

Powered by FUDForum. Page generated in 0.07223 seconds