Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Sirius/Cookbook

< Sirius
Revision as of 09:53, 21 March 2016 by Pierre-charles.david.obeo.fr (Talk | contribs) (Created page with "This page gathers code snippets which can be useful when using and extending Sirius programmatically. === Retrieve a <code>DNode</code> (or another Sirius representation elem...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This page gathers code snippets which can be useful when using and extending Sirius programmatically.

Retrieve a DNode (or another Sirius representation elements) from given semantic element

Sirius maintains an session-scoped inverse cross-referencer which can be used to find "who references who" even in the absence of explicit navigable references in the model. Sirius representation elements have a reference to the semantic model they represents, so you can use it for this kind of task. The most convenient way is to use the org.eclipse.sirius.business.api.query.EObjectQuery:

 Collection<EObject> result = new EObjectQuery(mySemanticElement).getInverseReferences(ViewpointPackage.Literals.DSEMANTIC_DECORATOR__TARGET);

Note that this will find all the DSemanticDecorators which represent mySemanticElement in the whole session (all representations included), which may or may not be what you want. If you need more precision, you will have to filter the result (using EObjectQuery#getRepresentation(DRepresentation) for example to restrict to a specific diagram).

Copyright © Eclipse Foundation, Inc. All Rights Reserved.