Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Accessing enum outside Metamodel
Accessing enum outside Metamodel [message #1784797] Wed, 04 April 2018 09:33 Go to next message
Oliver Binns is currently offline Oliver BinnsFriend
Messages: 3
Registered: December 2017
Location: York, United Kingdom
Junior Member

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 #1784848 is a reply to message #1784797] Wed, 04 April 2018 18:29 Go to previous messageGo to next message
Ran Wei is currently offline Ran WeiFriend
Messages: 85
Registered: September 2012
Location: York, UK
Member
Hi,

Could you please try using the # operator (Discussed in Section 3.4.5) in the Epsilon book?

Example Operator#Equals

Cheers,
Will


Research Associate
Department of Computer Science
University of York
Re: Accessing enum outside Metamodel [message #1784862 is a reply to message #1784848] Wed, 04 April 2018 21:25 Go to previous messageGo to next message
Oliver Binns is currently offline Oliver BinnsFriend
Messages: 3
Registered: December 2017
Location: York, United Kingdom
Junior Member

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 #1784886 is a reply to message #1784862] Thu, 05 April 2018 08:11 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1589
Registered: July 2009
Location: York, UK
Senior Member

Hi Oliver,

A bit of a hack, but Operator#Equals.eEnum.eLiterals should do the trick.

Cheers,
Dimitris
Re: Accessing enum outside Metamodel [message #1785022 is a reply to message #1784886] Sat, 07 April 2018 18:03 Go to previous messageGo to next message
Oliver Binns is currently offline Oliver BinnsFriend
Messages: 3
Registered: December 2017
Location: York, United Kingdom
Junior Member

No luck still, unfortunately this gives the error:
Property 'eEnum' not found in object Equals
Re: Accessing enum outside Metamodel [message #1785081 is a reply to message #1785022] Mon, 09 April 2018 08:55 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 475
Registered: January 2010
Senior Member
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 Go to previous message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 475
Registered: January 2010
Senior Member
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, ]}
Previous Topic:Navigating a PlainXmlModel
Next Topic:Evl validation without GUI
Goto Forum:
  


Current Time: Tue Sep 25 09:02:03 GMT 2018

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

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

Back to the top