Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [XCORE] How to make feature readonly with xcore
[XCORE] How to make feature readonly with xcore [message #1253545] Sat, 22 February 2014 11:34 Go to next message
Roger Gilliar is currently offline Roger GilliarFriend
Messages: 40
Registered: March 2010
Member
I just started to use EMF and xcore and I would like to know how to make a feature readonly.

Example:

class Facility extends Parent
{
String name
String nodeName = "Facility"
}

I would like to make nodeName readonly. I tried to set Changeable to false, Unsettable to true ad so on. But the setter for nodeName is still present in the generated source code and at least Changeable is changed back to true after a save.

[Updated on: Sat, 22 February 2014 15:28]

Report message to a moderator

Re: How to make feature readonly with xcore [message #1253651 is a reply to message #1253545] Sat, 22 February 2014 14:18 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 295
Registered: March 2012
Senior Member
On 22/02/2014 12:34, Roger Gilliar wrote:
> I would like to make nodeName readonly. I tried to set Changeable to
> false, Unsettable to true ad so on. But the setter for nodeName is still
> present in the generated source code and at least Changeable is changed
> back to true after a save.
>

Try derived, non-changeable, transient (and maybe volatile).
Re: How to make feature readonly with xcore [message #1253701 is a reply to message #1253651] Sat, 22 February 2014 15:31 Go to previous messageGo to next message
Roger Gilliar is currently offline Roger GilliarFriend
Messages: 40
Registered: March 2010
Member
The strange thing is that the changes I make in the properties view are gone after I save the xcore model.
Re: How to make feature readonly with xcore [message #1254395 is a reply to message #1253701] Sun, 23 February 2014 10:15 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Roger,

The Ecore model's properties should really be displayed as read-only in
the Properties view, because the Ecore model is derived from the Xcore
model so will always be overwritten by what's specified in Xcore; please
open a bugzilla. The same goes for the GenModel, but changes to it in
the properties view are converted to @GenModel annotations so that the
subsequently derived GenModel will have the desired settings.

So to achieve your goal, you need to make use of the keywords that are
allowed to qualify a feature declarations. You can see that from these
excerpts the grammar (and Ctrl-space will suggest these, although very
low down on the long list of type completions):

XAttribute:
{XAttribute}
(annotations+=XAnnotation)*
(
(unordered?='unordered')? &
(unique?='unique')? &
(readonly?='readonly')? &
(transient?='transient')? &
(volatile?='volatile')? &
(unsettable?='unsettable')? &
(derived?='derived')? &
(iD?='id')?
)

XReference:
{XReference}
(annotations+=XAnnotation)*
((containment?='contains' resolveProxies?='resolving'?) |
(resolveProxies?='resolving' containment?='contains') |
(container?='container' resolveProxies?='resolving'?) |
(resolveProxies?='resolving' container?='container') |
('refers' local?='local'?) |
(local?='local' 'refers'))
(
(unordered?='unordered')? &
(unique?='unique')? &
(readonly?='readonly')? &
(transient?='transient')? &
(volatile?='volatile')? &
(unsettable?='unsettable')? &
(derived?='derived')?
)



On 22/02/2014 4:31 PM, Roger Gilliar wrote:
> The strange thing is that the changes I make in the properties view
> are gone after I save the xcore model.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to make feature readonly with xcore [message #1255775 is a reply to message #1254395] Mon, 24 February 2014 20:20 Go to previous message
Roger Gilliar is currently offline Roger GilliarFriend
Messages: 40
Registered: March 2010
Member
Hi Ed,

thanks for the explanation. That was very helpful.

BTW: Where can I find the grammar ?

Previous Topic:[Oomph] Adding support for Nebula
Next Topic:How to check if my object state has changed ?
Goto Forum:
  


Current Time: Fri Mar 29 07:27:20 GMT 2024

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

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

Back to the top