Skip to main content



      Home
Home » Eclipse Projects » Sirius » objects from the model
objects from the model [message #1775101] Tue, 24 October 2017 10:51 Go to next message
Eclipse UserFriend
Hi,

I'd like to access the objects from the model in memory to use in another method. For this, i have to use a extension with External Java Action, like this https://www.eclipse.org/sirius/doc/specifier/general/Model_Operations.html#extensions

in the code bellow, i can access the information about style, but it's not what I want.
@Override
	public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
		for(EObject obj : selections) {
			TreeIterator<EObject> eAllContents = obj.eAllContents();
			while(eAllContents.hasNext()) {
				EObject next = eAllContents.next();
				EList<EAttribute> nameElement = next.eClass().getEAllAttributes();
			}
		}
	}


I want information about the packages, classes, attributes, etc of the model.
How can I do this? It's possible? Sorry, I'm a beginner in sirius.

Thanks
Re: objects from the model [message #1775140 is a reply to message #1775101] Wed, 25 October 2017 04:58 Go to previous messageGo to next message
Eclipse UserFriend
Maybe you must a change context Model Operations https://www.eclipse.org/sirius/doc/specifier/general/Model_Operations.html#goto before you call you extensions.

change context expression:
var:self

Re: objects from the model [message #1775142 is a reply to message #1775101] Wed, 25 October 2017 05:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Can you be more specific about the context?
From where your action is called?


Also external actions are not recommended. Prefer using services: https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html#service_methods


Regards,

Pierre
Re: objects from the model [message #1775150 is a reply to message #1775142] Wed, 25 October 2017 08:18 Go to previous messageGo to next message
Eclipse UserFriend
I'm using a popup menu to call a Java Action, in the method called I've got to access all the contents of the model to generate code.
Re: objects from the model [message #1775223 is a reply to message #1775150] Thu, 26 October 2017 09:26 Go to previous messageGo to next message
Eclipse UserFriend
You have to get the semantic elements from the representation element you get with:
((DRepresentationElement)obj).getTarget()


Regards,

Pierre
Re: objects from the model [message #1775309 is a reply to message #1775223] Fri, 27 October 2017 09:08 Go to previous message
Eclipse UserFriend
Pierre Guilet wrote on Thu, 26 October 2017 13:26
You have to get the semantic elements from the representation element you get with:
((DRepresentationElement)obj).getTarget()


Regards,

Pierre


This worked. Thank you!
Previous Topic:[Sirius] generate the representations.aird in XML file
Next Topic:Tools for Tables
Goto Forum:
  


Current Time: Thu May 15 15:25:40 EDT 2025

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

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

Back to the top