Forbid to set both Attributes [message #1743659] |
Sun, 18 September 2016 12:27 |
Xi Ng Messages: 26 Registered: June 2016 |
Junior Member |
|
|
Hello,
I would like to model the following situation:
An Element has an Enum Attribute "Name" and a String Attribute "Custom Name"
The user can set any of these two attributes, but not both.
Then the same Element has a Double and a Boolean Attribute. The user can set any of these two attributes, but not both.
Is there an elegant way, how to model this in EMF - or do I have to get into code writing? Or should this not even be a matter of EMF, so I should implement this function better in Sirius?
Does anybody experienced, have advice regarding this?
Thank you in advance
Xing
[Updated on: Sun, 18 September 2016 12:28] Report message to a moderator
|
|
|
|
|
|
Re: Forbid to set both Attributes [message #1743838 is a reply to message #1743749] |
Tue, 20 September 2016 08:17 |
Xi Ng Messages: 26 Registered: June 2016 |
Junior Member |
|
|
Hello,
I tried now to model my problem, with just introducing one value (so no double, no boolean).
Then I tried to model the data type of this value as a UNION TYPE, which should then contain Double and Boolean.
I tried to model it exaclty as it is described in the official EMF Book, Second Edition.
EClass
name = Indicator
> EAttribute value : IndicatorValueType
EData Type
instance type name = java.lang.Object
name= IndicatorValueType
> EAnnotation
> source = http:///org/eclipse/emf/ecore/util/ExtendedMetaData
>> Details Entry
>> key = name, value = IndicatorValueType
>> key = memberTypes, value = Boolean Double
Now in the book, it also says, that when I have a EJavaObject, the serializable is false. So I assumed, I have to switched it from true to false. But then Eclipse tells me to also change my attribute's transiable to true.
But it does not work, neither with changing serializable/transiable, nor without.
Did I completely misunderstand the idea of a Union Type?
Xing
|
|
|
|
Re: Forbid to set both Attributes [message #1743870 is a reply to message #1743848] |
Tue, 20 September 2016 10:18 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
You'll need it to be serializeable, so don't set that to false otherwise you can only use it on transient attribute, and of course then it won't serialize, which I assume defeats the purpose.
One thing that looks wrong is "Boolean Double". Such references will expect to find an EDataType with that name in the same Ecore model, but I doubt you have that. To refer to a data type in another package, you must prefix it with the nsURI of that package, e.g., http://www.eclipse.org/emf/2003/XMLType#boolean .
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04142 seconds