Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » How to set Values of attributes programmatically(setting values of M1 level instances(*.xmi) programmatically without using tree editor)
How to set Values of attributes programmatically [message #1817376] Thu, 21 November 2019 11:38 Go to next message
yawar rasheed is currently offline yawar rasheedFriend
Messages: 8
Registered: September 2019
Junior Member
Hi Every One...
I have loaded a meta model i.e trip.ecore Programmatically (using resourse set, Resourse etc). Thereafter, I created instances of the Meta-Model Classes using EFactory. Instances are successfully created and i have stored them in xmi model.
Now Iam facing issues in setting values of these attributes, programmatically. and setting links among these instances programmatically.
like i have created an instance Trip, now i want to set the value of its attruibute name of type estring as "London Trip" How will i do that programmatically and not using xmi editor.

EObject Trip = tripFactory.create((EClass) tripPackage.getEClassifiers().get(1));

Object is made how will i access its attributes and references....

Thanks in advance
Re: How to set Values of attributes programmatically [message #1818111 is a reply to message #1817376] Fri, 06 December 2019 07:57 Go to previous message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 499
Registered: July 2009
Location: Nantes, France
Senior Member
Hi Yawar,

Did you generate the code(model, edit, editor) from your trip.genmodel ?
After deployment of the resulting plugins (or in a runtime), you would have the possibility to use:
Trip myTrip = TripFactory.eINSTANCE.createTrip();
myTrip.setName("London Trip");

For the moment I assume you have dynamic instances, you might try : trip.eSet(EStructuralFeature feature, Object newValue);

For those general question on Ecore and not related to Sirius, I invite you to post on the EMF forum:

You might also find resources on the following page:


Maxime Porhel - Obeo

Need training or professional services for Sirius?
Previous Topic:How to add SessionWrapper/ViewHelper extensions to handle custom tree elements
Next Topic:Unable to add a viewpoint programmatically
Goto Forum:

Current Time: Wed Dec 02 22:50:33 GMT 2020

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

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

Back to the top