|
Re: Programmatically access to the EAttributes [message #1730512 is a reply to message #1729298] |
Tue, 26 April 2016 13:15 |
|
Hi Alexander,
Le 12/04/2016 18:49, Alexander Schledewitz a écrit :
> Hello,
>
> with the following code I get access to the mapped class of my semantic model:
>
> IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
> if (editor instanceof DialectEditor) {
> DRepresentation activeRepresentation = ((DialectEditor) editor).getRepresentation();
> if (activeRepresentation instanceof DDiagram) {
>
> EList <DDiagramElement> diagram = (((DDiagram) activeRepresentation).getDiagramElements());
> String firstElementName = diagram.get(0).getMapping().getName();
>
> How do I get the access to the EAttributes of the Model?
From which model do you want to access the attributes ?
The Sirius model ?
The Viewpoint Specification Model ?
Your semantic model ?
From a DDiagram or a DDiagramElement, you can cast it to
org.eclipse.sirius.viewpoint.DSemanticDecorator and use the getTarget()
method to access to the semantic element
Calling DDiagram.getDescription() or DDiagramElement.getMapping() will
allow you to retrieve the description or the mapping from the VSM. Then
mapping.getName() is the id of the mapping, if you want its label, call
getLabel(), but for those element you should use
org.eclipse.sirius.business.api.query.IdentifiedElementQuery.getLabel().
It will be the same label as displayed in the VSM editor (for your
odesign file) and not the label computed from the VSM and your semantic
model and displayed in your diagram.
From where to you want to access this ? From a service in the VSM, from
a tool of your modeler, an action ? From an external view or component
outside of Sirius ?
>
> For example: I get the class Transition with the code above and now I want to access the EAttribute label of this Transition.
Is label and attribute of your metamodel or do you want to get the label
of a node of your modeler already computed by Sirius ?
>
> The Semantic Model is attached below.
>
> Thank you for your help!
>
>
Regards
--
Maxime - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Maxime Porhel - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
Powered by
FUDForum. Page generated in 0.03213 seconds