|
|
|
Re: setValue() of a stereotype attribute of custom type [message #925238 is a reply to message #925156] |
Thu, 27 September 2012 14:17 |
|
Hi, Mauro,
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: setValue() of a stereotype attribute of custom type [message #939133 is a reply to message #933811] |
Wed, 10 October 2012 13:05 |
|
Hi, Mauro,
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>
|
|
|
Powered by
FUDForum. Page generated in 0.05064 seconds