Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Automatically set the value of a property
Automatically set the value of a property [message #1848337] Sun, 28 November 2021 21:29 Go to next message
Jan Crkvic is currently offline Jan CrkvicFriend
Messages: 18
Registered: November 2021
Junior Member
Hi all,

I was wondering if it is possible to automatically fill in the value of a property by using two other properties .

For example if I have the following Class with the following attributes/ references:

Element
- name
- firstelement
- secondelement

Upon filling in the value of the first element and second element (or saving them it is not really important), I want those values to be concatenated and put as value to the name attribute. Is that possible and if so, what would be the way to do it? Maybe customising the ItemProvider? Are there any examples on something similar?

Thank you!
Re: Automatically set the value of a property [message #1848341 is a reply to message #1848337] Mon, 29 November 2021 05:45 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You are describing a derived attribute; an automated computation (nothing to do with inheritance).

Just set the Derived=true in your Ecore model, and probably transient and volatile and not-changeable too.

When you genmodel your code will have a TODO and a throw UnsupportedOperationException, in the Java which you can manually replace with your algorithm in Java and an @Generated NOT.

If you use Xcore you can define your algorithm in Xbase.

If you use OCLinEore you can define your algorithm in OCL.

See the EMF book [1] to learn about the power of Ecore.

Regards

Ed Willink

[1] https://www.amazon.co.uk/EMF-Eclipse-Modeling-Framework-ebook/dp/B004YW6M52

Previous Topic:Access EMF object in Xtend
Next Topic:Generate Tests for Non-plugin Projects
Goto Forum:
  


Current Time: Fri Apr 26 13:45:16 GMT 2024

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

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

Back to the top