Skip to main content



      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 06:34 Go to next message
Eclipse UserFriend
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 10:28] by Moderator

Re: How to make feature readonly with xcore [message #1253651 is a reply to message #1253545] Sat, 22 February 2014 09:18 Go to previous messageGo to next message
Eclipse UserFriend
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 10:31 Go to previous messageGo to next message
Eclipse UserFriend
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 05:15 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: How to make feature readonly with xcore [message #1255775 is a reply to message #1254395] Mon, 24 February 2014 15:20 Go to previous message
Eclipse UserFriend
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: Tue Jul 01 06:13:32 EDT 2025

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

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

Back to the top