Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Polarsys » Capella Studio » Accessing elements from different EMF (libraries)(Link between Component (in EMF) and representation (in aird))
Accessing elements from different EMF (libraries) [message #1831861] Tue, 01 September 2020 09:39 Go to next message
Antonin Messioux is currently offline Antonin MessiouxFriend
Messages: 5
Registered: June 2020
Junior Member
Greetings,

I have developed a viewpoint that, on a click event on any Capella component (the_component), triggers an OpenAction(the_component) that is able to navigate in the EMF of the project thanks to the_component parameter, and sort all those elements into lists that I can use later on.
However, I am working with a Capella project that is referencing one library. Of course, those elements contained in the library are not parsed by my viewpoint as they belong to another EMF. After a week of struggling, my question is : how can I retrieve at least one component from the library so that I can parse it fully as the main project ?

Note that if I run the OpenAction by clicking on an element on a diagram that belongs to the library, the viewpoint is parsing correctly the EMF of the library, but not the EMF of the project.

I have tried to access the libraries from their graphical elements using https://wiki.eclipse.org/Capella/Tutorials/Extensibility/Edit.
Using the given code, I have been able to access all graphical elements in a diagram. Nonetheless, I have not found how to access a component from its representation, I guess its DDiagramElement. This solution would be the best for me as I would like to sort the elements later, according to the diagram they are displayed on.

I hope my problem is clear, thanks in advance for your help,
Have a great day,
Antonin

Re: Accessing elements from different EMF (libraries) [message #1832054 is a reply to message #1831861] Mon, 07 September 2020 13:12 Go to previous messageGo to next message
Antonin Messioux is currently offline Antonin MessiouxFriend
Messages: 5
Registered: June 2020
Junior Member
Hello,

I have been able to retrieve a TreeIterator of my library's melodymodeller with :
        URI URI1 = URI.createFileURI("C:/path/myLibrary.melodymodeller");  
        ResourceSet resourceSet = new ResourceSetImpl();
        Resource resource = resourceSet.getResource(URI1, true);
        TreeIterator<EObject> myTreeIterator = ((CapellamodellerResourceImpl) resource).getContents().get(0).eAllContents();

with of course after :
while(myTreeIterator.hasNext())
	{
	node = myTreeIterator.next();
	if (node instanceof LogicalFunction)
	       {
			LogicalFunction lf = (LogicalFunction) node;
			ListCapellaElement.add(lf);
                        ...
	       }
               ...
        }

This URI I am accessing could have been another project or a library, it doesn't matter. So this problem is solved.

Nonetheless, if someone has an idea about how can I link a graphical element with the EObject it is describing (ie. accessing an EObject from its representation on a diagram), I am still interested.

Regards,
Antonin
Re: Accessing elements from different EMF (libraries) [message #1832134 is a reply to message #1832054] Wed, 09 September 2020 21:32 Go to previous messageGo to next message
Philippe Dul is currently offline Philippe DulFriend
Messages: 25
Registered: November 2013
Junior Member
Hi,

From the OpenAction(component)
If the model references some libraries, you can use something like
_component.eResource().getResourceSet().getResources()

to retrieve the list of all loaded resources, and among other, the melodymodellers files.
or
 Session session = SessionManager.INSTANCE.getSession(_component)
 session.getSemanticResources()


if (resource.getUri().xxx == "Library.melodymodeller") 
xxx
}




Re: Accessing elements from different EMF (libraries) [message #1832136 is a reply to message #1832134] Wed, 09 September 2020 21:43 Go to previous messageGo to next message
Philippe Dul is currently offline Philippe DulFriend
Messages: 25
Registered: November 2013
Junior Member
For diagrams elements,

a diagram is composed by diagram elements, (diagram.getDiagramElements) which are referencing "semantic elements" such as the component.
for (DDiagramElement e: diagram.getDiagramElements()) {
  if (e instanceof DSemanticDecorator) {
     if (((DSemanticDecorator)e.getTarget()) instanceof Component) {
      //xxxx
     }
  }
}


DDiagramElement sub types can be DNode (not decomposable, ex port, function in architecture blank), DEdge, DNodeContainer (decomposable, ex components in Architecture Blank) or DNodeList (like classes in class diagram blank)


[Updated on: Wed, 09 September 2020 21:45]

Report message to a moderator

Re: Accessing elements from different EMF (libraries) [message #1832588 is a reply to message #1832136] Mon, 21 September 2020 12:58 Go to previous message
Antonin Messioux is currently offline Antonin MessiouxFriend
Messages: 5
Registered: June 2020
Junior Member
Hello,

First thank you for your answers,

It works well. I had been stuck while trying to reach the instance of the LogicalFunction from the instance of its DDiagramElement, but the method .getTarget() allowed me to achieve that.
Thanks again,

Regards,
Antonin
Previous Topic:Viewpoint creation using ECore tools
Next Topic:Understanding the code behind viewpoint creation
Goto Forum:
  


Current Time: Sat Oct 12 05:41:30 GMT 2024

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

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

Back to the top