Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumssetValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/925156/#msg_925156
I need some help for a standalone application that uses UML2 and EMF API.
Starting point is that I have a custom UML2Profile with a stereotype that has a required attribute. It is custom type defined in the Profile, e.g.:
MyType is an interface defined into the UML2Profile that owns "MyStereotype".
I created a new UML model programmatically and I applied MyStereotype to an element but I also need to value "attr".
It can be done by the following method of org.eclipse.uml2.uml.Element:
Now my question is:
How can I instantiate Object of right type? Do I need java code of the UML2Profile (e.g.: generated by genmodel)? I mean like L2Profile or L3Profile API?
I'm using a uml class with an InterfaceRealization relationship with MyType, but it doesn't work.
Thanks in advance for any help]]>Mauro Faella2012-09-27T12:38:37-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/925210/#msg_925210
The UML2 Java API is both powerful and confusing, many apparently
visible methods should not be used and many methods should be used in
appropriate combinations.
I recommend using Papyrus or the UML Model editor to create something
similar to what you want and then recreate it with Java code.
Regards
Ed Willink
On 27/09/2012 13:38, Mauro Faella wrote:
> Hi all,
> I need some help for a standalone application that uses UML2 and EMF API.
>
> Starting point is that I have a custom UML2Profile with a stereotype
> that has a required attribute. It is custom type defined in the
> Profile, e.g.:
>
> +---------------+
> | <Stereotype> | | MyStereotype |
> |---------------|
> |- attr: MyType |
> +---------------+
>
> MyType is an interface defined into the UML2Profile that owns
> "MyStereotype".
> I created a new UML model programmatically and I applied MyStereotype
> to an element but I also need to value "attr". It can be done by the
> following method of org.eclipse.uml2.uml.Element:
>
> setValue(Stereotype stereotype, String propertyName, Object newValue)
>
> Now my question is:
> How can I instantiate Object of right type? Do I need java code of the
> UML2Profile (e.g.: generated by genmodel)? I mean like L2Profile or
> L3Profile API?
> I'm using a uml class with an InterfaceRealization relationship with
> MyType, but it doesn't work.
>
> Thanks in advance for any help]]>Ed Willink2012-09-27T13:47:55-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/925219/#msg_925219
Ed Willink wrote on Thu, 27 September 2012 09:47
Hi
The UML2 Java API is both powerful and confusing, many apparently
visible methods should not be used and many methods should be used in
appropriate combinations.
I recommend using Papyrus or the UML Model editor to create something
similar to what you want and then recreate it with Java code.
Regards
Ed Willink
Thanks for advice.
But even in UML Editor and Papyrus I can't do what I want with a custom type attribute. In the Properties view I have no choice for "attr" so I guess that it depends on the fact that there isn't the right element in my model.]]>Mauro Faella2012-09-27T13:59:48-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/925238/#msg_925238
You say that 'MyType' is an interface. Do you mean, literally, an
instance of the UML Interface metaclass? If so, then be aware that
interfaces aren't really used in metamodels (profiles are metamodel
extensions). At best, UML2 can generate an EClass that has
isInterface=true, which maps to a Java interface. Interfaces aren't
instantiable, so the editor wouldn't have any idea of what to do.
Why is 'MyType' not a UML Class? If it is a class, then UML2 can
generate an EClass that you can instantiate. Note that it will also
have to be contained (perhaps indirectly) in some stereotype somewhere,
otherwise you won't be able to create it in a UML model.
HTH,
Christian
On 2012-09-27 12:38:38 +0000, Mauro Faella said:
> Hi all,
> I need some help for a standalone application that uses UML2 and EMF API.
>
> Starting point is that I have a custom UML2Profile with a stereotype
> that has a required attribute. It is custom type defined in the
> Profile, e.g.:
>
> +---------------+
> | <Stereotype> | | MyStereotype |
> |---------------|
> |- attr: MyType |
> +---------------+
>
> MyType is an interface defined into the UML2Profile that owns "MyStereotype".
> I created a new UML model programmatically and I applied MyStereotype
> to an element but I also need to value "attr". It can be done by the
> following method of org.eclipse.uml2.uml.Element:
>
> setValue(Stereotype stereotype, String propertyName, Object newValue)
>
> Now my question is:
> How can I instantiate Object of right type? Do I need java code of the
> UML2Profile (e.g.: generated by genmodel)? I mean like L2Profile or
> L3Profile API?
> I'm using a uml class with an InterfaceRealization relationship with
> MyType, but it doesn't work.
>
> Thanks in advance for any help]]>Christian Damus2012-09-27T14:17:47-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/926029/#msg_926029
thank you for reply.
I'd got the profile from external source and it is developed in that way, but I understood what are you saying and I agree.
I will try to modify the Interface into a Class.]]>Mauro Faella2012-09-28T08:34:47-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/932895/#msg_932895
I tried to modify the profile changing the Interface into a Class without success.
Even so if I add a 'MyType' class to my UML model I can't choice an element to 'attr'. I tried also to add a property of type MyType to stereotyped element but it doesn't work.
]]>Mauro Faella2012-10-04T14:46:09-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/933624/#msg_933624
Try posting an example. It's unlikely that any can accurately guess at
what your doing from your vague overview.
Regards
ed Willink
On 04/10/2012 16:46, Mauro Faella wrote:
> Hi,
> I tried to modify the profile changing the Interface into a Class
> without success. Even so if I add a 'MyType' class to my UML model I
> can't choice an element to 'attr'. I tried also to add a property of
> type MyType to stereotyped elemend but it doesn't work.
>]]>Ed Willink2012-10-05T07:18:51-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/933772/#msg_933772
I attach an example, I hope that it explains better then me
As you can see I can't choice element for the required attribute of the Stereotype applied. I tried to create a class (MyTypeDerived) that implements the interface specified into the Profile and even two properties (one of type MyType and other of type MyTypeDerived) into the stereotyped class, but it didn't work.
Thanks for replying,
m]]>Mauro Faella2012-10-05T10:26:19-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/933782/#msg_933782
Without the *.uml to play with it is unclear whether
a) You have no instances of MyType to be offered
b) the offered instances have no name and so appear blank
Regards
Ed Willink
On 05/10/2012 12:26, Mauro Faella wrote:
> Hi Ed,
> I attach an example, I hope that it explains better then me :p
>
> As you can see I can't choice element for the required attribute of the Stereotype applied. I tried to create a class (MyTypeDerived) that implements the interface specified into the Profile and even two properties (one of type MyType and other of type MyTypeDerived) into the stereotyped class, but it didn't work.
>
> Thanks for replying,
> m]]>Ed Willink2012-10-05T10:34:09-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/933811/#msg_933811
Anyway I don't follow you about instance... What do I wrong? Isn't a property enough?]]>Mauro Faella2012-10-05T11:13:08-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/934795/#msg_934795
Ok. I can see the models now. They look ok.
The two blank lines in your PNG look unhelpful but not wrong.
What is it that you cannot do?
Regards
Ed Willink
On 05/10/2012 13:13, Mauro Faella wrote:
> You're right, here are the .uml files
>
> Anyway I don't follow you about instance... What do I wrong? Isn't a property enough?]]>Ed Willink2012-10-06T09:53:14-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/937738/#msg_937738
I cannot assign a value to the 'Attr', the two blank lines aren't selectable.
I also tried programmatically with uml2 API, as I described in the first post, and I get the same problem.]]>Mauro Faella2012-10-09T08:11:53-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/937808/#msg_937808
Without reproducible details, I cannot give you any further help.
Regards
Ed Willink
On 09/10/2012 09:11, Mauro Faella wrote:
> Hi
>
> I cannot assign a value to the 'Attr'. I also tried programmatically
> with uml2 API, as I described in the first post, and I get the same
> problem.]]>Ed Willink2012-10-09T09:23:59-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/937867/#msg_937867
You try to assign a value to 'Attr' in Properties view... simply you can't]]>Mauro Faella2012-10-09T10:36:16-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/937880/#msg_937880
If I spent an hour trying to reproduce your code, I might be able to
reproduce it, but I might not reproduce your bugs and I have better
things to do with my time.
If you want free help, you need to make it easy to help you.
Provide a zipped project with a launch configuration that just runs and
shows and error.
Regards
Ed Willink
On 09/10/2012 11:36, Mauro Faella wrote:
> With the two uml that I attached previously you can reproduce the
> problem.
> You try to assign a value to 'Attr' in Properties view... simply you
> can't]]>Ed Willink2012-10-09T10:43:04-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/937967/#msg_937967
You can reproduce the problem into uml editor of Eclipse Modeling (I'm using Juno). The programmatically part cames later in simple way (I hope).
Anyway I thank you for any help that you are providing me.
What should be assigned to Attr? The Interface MyType?
Then the Datatype of Attr must be set to the "Metaclass" Interface from
the UML.metamodel.uml file.
Greetings
Am 09.10.2012 10:11, schrieb Mauro Faella:
> Hi
>
> I cannot assign a value to the 'Attr'. I also tried programmatically
> with uml2 API, as I described in the first post, and I get the same
> problem.]]>Peter Mising name2012-10-09T14:03:58-00:00Re: setValue() of a stereotype attribute of custom type
https://www.eclipse.org/forums/index.php/mv/msg/386026/939133/#msg_939133
I see in the profile that the 'attr' property of type MyType is not a
composite aggregation, which in Ecore terms is a containment reference.
So, in Ecore terms, an instance of MyStereotype has a cross-reference
named 'attr' to an instance of MyType.
The editor requires you to have an instance of MyType available to
assign to the 'attr' reference. That's why the Properties view
provides a drop-down list to pick from. The problem that you have is
that there isn't any place to create an instance of MyType because
* there is no containment reference of type MyType or some concrete
subtype of it
that can hold a MyType instance
* there is no concrete subtype of the MyType interface in the
profile, so you wouldn't
be able to create any instances of it, anyways
HTH,
Christian
On 2012-10-05 11:13:08 +0000, Mauro Faella said:
> You're right, here are the .uml files
>
> Anyway I don't follow you about instance... What do I wrong? Isn't a
> property enough?
> <image><image>]]>Christian Damus2012-10-10T13:05:01-00:00