Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » set a stereotype property value
set a stereotype property value [message #476930] Wed, 13 February 2008 09:50 Go to next message
Emilien Perico is currently offline Emilien PericoFriend
Messages: 36
Registered: July 2009
Member
Hi all,

I've defined a profile with several sterotypes. I need to set a property
value of a stereotype manually in Java.

I know that it can be done with the followings lines:
namedElement.setValue(stereotype, property.getName(), value);

It's OK when I set a property with a primitive type like String.
Now I need to set a property which reference another Stereotype.

Example:

Profile myProfile
- Stereotype s1
- Stereotype s2
- Property name:String
- Property s1_reference: s1

I would like to set the "s1_reference" but I have problems with type.

Thanks for help,
Re: set a stereotype property value [message #476931 is a reply to message #476930] Wed, 13 February 2008 15:40 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Emilien,

I'm not sure what you mean by "I have problems with type". Could you
elaborate? Do you mean that you are not sure what to set as the type of
the property? or do you have an issue with setValue() not working?

Cheers,
- James.


"Emilien Perico" <emilien.perico@atosorigin.com> wrote in message
news:91254c76c8c107bdcd2b1d78cba82c7c$1@www.eclipse.org...
> Hi all,
>
> I've defined a profile with several sterotypes. I need to set a property
> value of a stereotype manually in Java.
>
> I know that it can be done with the followings lines:
> namedElement.setValue(stereotype, property.getName(), value);
>
> It's OK when I set a property with a primitive type like String.
> Now I need to set a property which reference another Stereotype.
>
> Example:
>
> Profile myProfile
> - Stereotype s1
> - Stereotype s2
> - Property name:String
> - Property s1_reference: s1
>
> I would like to set the "s1_reference" but I have problems with type.
>
> Thanks for help,
Re: set a stereotype property value [message #476932 is a reply to message #476931] Wed, 13 February 2008 16:32 Go to previous messageGo to next message
Emilien Perico is currently offline Emilien PericoFriend
Messages: 36
Registered: July 2009
Member
Thanks for reply James,

I mean I don't succed to set the value for a referenced stereotype.
I don't know what to set as the type of the property when this one
references another stereotype.

When I get a same type, previously added from the modeller, I get a
DynamicEObjectImpl.

Do I have to build an object with the same type ? How ?
Re: set a stereotype property value [message #476934 is a reply to message #476932] Thu, 14 February 2008 13:57 Go to previous message
Emilien Perico is currently offline Emilien PericoFriend
Messages: 36
Registered: July 2009
Member
Here the good way,

Profile myProfile
- Stereotype s1
- Stereotype s2
- Property name:String
- Property s1_reference: s1

To set the value "s1" to the property "s1_reference". You have to do this:

EObject s1Reference = classWithS1.getStereotypeApplication(s1);
Property s1RefProp = s2.getAttribute("s1_reference", null);
classWithS2.setValue(s2, s1RefProp.getName(), s1Reference);

Here the reference to help
http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.u ml2/msg01630.html

Emilien.
Re: set a stereotype property value [message #626030 is a reply to message #476930] Wed, 13 February 2008 15:40 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Emilien,

I'm not sure what you mean by "I have problems with type". Could you
elaborate? Do you mean that you are not sure what to set as the type of
the property? or do you have an issue with setValue() not working?

Cheers,
- James.


"Emilien Perico" <emilien.perico@atosorigin.com> wrote in message
news:91254c76c8c107bdcd2b1d78cba82c7c$1@www.eclipse.org...
> Hi all,
>
> I've defined a profile with several sterotypes. I need to set a property
> value of a stereotype manually in Java.
>
> I know that it can be done with the followings lines:
> namedElement.setValue(stereotype, property.getName(), value);
>
> It's OK when I set a property with a primitive type like String.
> Now I need to set a property which reference another Stereotype.
>
> Example:
>
> Profile myProfile
> - Stereotype s1
> - Stereotype s2
> - Property name:String
> - Property s1_reference: s1
>
> I would like to set the "s1_reference" but I have problems with type.
>
> Thanks for help,
Re: set a stereotype property value [message #626031 is a reply to message #476931] Wed, 13 February 2008 16:32 Go to previous message
Emilien Perico is currently offline Emilien PericoFriend
Messages: 36
Registered: July 2009
Member
Thanks for reply James,

I mean I don't succed to set the value for a referenced stereotype.
I don't know what to set as the type of the property when this one
references another stereotype.

When I get a same type, previously added from the modeller, I get a
DynamicEObjectImpl.

Do I have to build an object with the same type ? How ?
Re: set a stereotype property value [message #626033 is a reply to message #476932] Thu, 14 February 2008 13:57 Go to previous message
Emilien Perico is currently offline Emilien PericoFriend
Messages: 36
Registered: July 2009
Member
Here the good way,

Profile myProfile
- Stereotype s1
- Stereotype s2
- Property name:String
- Property s1_reference: s1

To set the value "s1" to the property "s1_reference". You have to do this:

EObject s1Reference = classWithS1.getStereotypeApplication(s1);
Property s1RefProp = s2.getAttribute("s1_reference", null);
classWithS2.setValue(s2, s1RefProp.getName(), s1Reference);

Here the reference to help
http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.u ml2/msg01630.html

Emilien.
Previous Topic:how to find out the type of element in a package
Next Topic:Re: unknown protocol: pathmap
Goto Forum:
  


Current Time: Sat Aug 20 06:07:51 GMT 2022

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

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

Back to the top