Home » Modeling » Epsilon » Accessing enum outside Metamodel
Accessing enum outside Metamodel [message #1784797] |
Wed, 04 April 2018 09:33 |
|
I am defining an enumeration in my Emfatic metamodel.
enum Operator{
Equals;
LessThan;
LessThanOrEqualTo;
GreaterThan;
GreaterThanOrEqualTo;
Plus;
Subtract;
Multiply;
Divide;
}
I am attempting to implement an EVL quick fix (Line 111) that allows the user to select an option from this enumeration.
I am also attempting to use it in my XML generation (EGL, Line 152-170)
However when attempting to run the code, I am getting an error message that my enum is an Undefined variable, type or model.
I have tried referring to the enum with it's name: Operator, and also using it's package address: FLAME.Operator, but no luck!
Are enumerations defined in my metamodel unavailable in EVL/EGL?
If not, how can I allow the user to select from the possible values?
|
|
| |
Re: Accessing enum outside Metamodel [message #1784862 is a reply to message #1784848] |
Wed, 04 April 2018 21:25 |
|
Great! I must have missed this, have managed to fix the code generation!
Is there also a way for retrieving a list/sequence of all available enum values, for example:
var operator = System.user.choose("Select an operator:", Operator);
|
|
| | |
Re: Accessing enum outside Metamodel [message #1785081 is a reply to message #1785022] |
Mon, 09 April 2018 08:55 |
|
I just tried creating a minimal working example with your enum and a simple EOL program, and it worked fine (see attachment). I was using the latest interim release of Epsilon, if it helps.
Could you perhaps try this out and see if it works, or if it fails as well?
|
|
|
Re: Accessing enum outside Metamodel [message #1785082 is a reply to message #1785081] |
Mon, 09 April 2018 08:59 |
|
Just to add to this. Running this program:
Operator#Equals.eEnum.eLiterals.print('options: ');
gave me this output:
options: Sequence {EEnumLiteral [name=Equals, value=0, instance=Equals, literal=Equals, ], EEnumLiteral [name=LessThan, value=1, instance=LessThan, literal=LessThan, ], EEnumLiteral [name=LessThanOrEqualTo, value=2, instance=LessThanOrEqualTo, literal=LessThanOrEqualTo, ], EEnumLiteral [name=GreaterThan, value=3, instance=GreaterThan, literal=GreaterThan, ], EEnumLiteral [name=GreaterThanOrEqualTo, value=4, instance=GreaterThanOrEqualTo, literal=GreaterThanOrEqualTo, ], EEnumLiteral [name=Plus, value=5, instance=Plus, literal=Plus, ], EEnumLiteral [name=Subtract, value=6, instance=Subtract, literal=Subtract, ], EEnumLiteral [name=Multiply, value=7, instance=Multiply, literal=Multiply, ], EEnumLiteral [name=Divide, value=8, instance=Divide, literal=Divide, ]}
|
|
|
Goto Forum:
Current Time: Mon Sep 23 10:21:42 GMT 2024
Powered by FUDForum. Page generated in 0.03391 seconds
|