Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to set NAME_EDEFAULT
How to set NAME_EDEFAULT [message #792648] Tue, 07 February 2012 08:22 Go to next message
Hugo A. Garcia is currently offline Hugo A. GarciaFriend
Messages: 258
Registered: July 2009
Senior Member
Hi

Is it possible to set NAME_EDEFAULT for an EClass somewhere in the model
generator or in the model itself, maybe using the Ecore diagram editor?

Currently we are doing this to set the default name for each impl class
generated:

public class LongImpl extends SimpleTypeImpl implements
org.best_of_robotics.bride.datatypes.Long {
/**
* @generated NOT
*/
protected LongImpl() {
super();
name = "long";
}
....

since SimpleTypeImpl has:

public abstract class DataTypeImpl extends EObjectImpl implements DataType {

protected static final String NAME_EDEFAULT = null;
protected String name = NAME_EDEFAULT;
....

Thanks

-H
Re: How to set NAME_EDEFAULT [message #792673 is a reply to message #792648] Tue, 07 February 2012 09:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Hugo,

Comments below.

On 07/02/2012 9:22 AM, Hugo Garcia wrote:
> Hi
>
> Is it possible to set NAME_EDEFAULT for an EClass somewhere in the
> model generator or in the model itself, maybe using the Ecore diagram
> editor?
You'll need to use the properties view to set the default value literal
property of the attribute.
>
> Currently we are doing this to set the default name for each impl
> class generated:
>
> public class LongImpl extends SimpleTypeImpl implements
> org.best_of_robotics.bride.datatypes.Long {
> /**
> * @generated NOT
> */
> protected LongImpl() {
> super();
> name = "long";
Is the name feature defined in LongImpl or in a base class?
> }
> ...
>
> since SimpleTypeImpl has:
>
> public abstract class DataTypeImpl extends EObjectImpl implements
> DataType {
>
> protected static final String NAME_EDEFAULT = null;
If you had to force it (which you don't) why wouldn't you change the
value of this declaration? After all, you'll notice that this value is
used to determine the result of eIsSet...
> protected String name = NAME_EDEFAULT;
> ...
>
> Thanks
>
> -H


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to set NAME_EDEFAULT [message #793060 is a reply to message #792673] Tue, 07 February 2012 18:17 Go to previous messageGo to next message
Hugo A. Garcia is currently offline Hugo A. GarciaFriend
Messages: 258
Registered: July 2009
Senior Member
On 02/07/2012 10:09 AM, Ed Merks wrote:
> Hugo,
>
> Comments below.
>
> On 07/02/2012 9:22 AM, Hugo Garcia wrote:
>> Hi
>>
>> Is it possible to set NAME_EDEFAULT for an EClass somewhere in the
>> model generator or in the model itself, maybe using the Ecore diagram
>> editor?
> You'll need to use the properties view to set the default value literal
> property of the attribute.
>>
>> Currently we are doing this to set the default name for each impl
>> class generated:
>>
>> public class LongImpl extends SimpleTypeImpl implements
>> org.best_of_robotics.bride.datatypes.Long {
>> /**
>> * @generated NOT
>> */
>> protected LongImpl() {
>> super();
>> name = "long";
> Is the name feature defined in LongImpl or in a base class?
>> }

A base class. Guess we have to do a push down refactoring and add the
name attribute to each subclass and then set a default value for it?

>> ...
>>
>> since SimpleTypeImpl has:
>>
>> public abstract class DataTypeImpl extends EObjectImpl implements
>> DataType {
>>
>> protected static final String NAME_EDEFAULT = null;
> If you had to force it (which you don't) why wouldn't you change the
> value of this declaration? After all, you'll notice that this value is
> used to determine the result of eIsSet...
>> protected String name = NAME_EDEFAULT;
>> ...

or set this in each subclass in the code and use @generated NOT?

What would be best practice?

-H
Re: How to set NAME_EDEFAULT [message #797314 is a reply to message #793060] Mon, 13 February 2012 10:10 Go to previous message
Hugo A. Garcia is currently offline Hugo A. GarciaFriend
Messages: 258
Registered: July 2009
Senior Member
On 02/07/2012 07:17 PM, Hugo Garcia wrote:
> On 02/07/2012 10:09 AM, Ed Merks wrote:
>> Hugo,
>>
>> Comments below.
>>
>> On 07/02/2012 9:22 AM, Hugo Garcia wrote:
>>> Hi
>>>
>>> Is it possible to set NAME_EDEFAULT for an EClass somewhere in the
>>> model generator or in the model itself, maybe using the Ecore diagram
>>> editor?
>> You'll need to use the properties view to set the default value literal
>> property of the attribute.
>>>
>>> Currently we are doing this to set the default name for each impl
>>> class generated:
>>>
>>> public class LongImpl extends SimpleTypeImpl implements
>>> org.best_of_robotics.bride.datatypes.Long {
>>> /**
>>> * @generated NOT
>>> */
>>> protected LongImpl() {
>>> super();
>>> name = "long";
>> Is the name feature defined in LongImpl or in a base class?
>>> }
>
> A base class. Guess we have to do a push down refactoring and add the
> name attribute to each subclass and then set a default value for it?
>

Ok, so the solution is to use Interfaces as super types and thus the
generator will produce an implementation code for each field declared in
the interface.

-H
Previous Topic:3rd Biannual Eclipse/OMG Workshop on March 25
Next Topic:[CDO] Undo/Redo with CDO
Goto Forum:
  


Current Time: Fri Apr 19 01:16:52 GMT 2024

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

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

Back to the top