Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Programmatically access to the EAttributes
Programmatically access to the EAttributes [message #1729298] Tue, 12 April 2016 16:49 Go to next message
Alexander Schledewitz is currently offline Alexander SchledewitzFriend
Messages: 10
Registered: March 2015
Junior Member
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?

For example: I get the class Transition with the code above and now I want to access the EAttribute label of this Transition.

The Semantic Model is attached below.

Thank you for your help!

  • Attachment: Unbenannt.PNG
    (Size: 11.62KB, Downloaded 409 times)
Re: Programmatically access to the EAttributes [message #1730512 is a reply to message #1729298] Tue, 26 April 2016 13:15 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
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
Re: Programmatically access to the EAttributes [message #1730548 is a reply to message #1730512] Tue, 26 April 2016 15:29 Go to previous message
Alexander Schledewitz is currently offline Alexander SchledewitzFriend
Messages: 10
Registered: March 2015
Junior Member
Hey Maxime,

thanks for your answer. I attached an Screenshot of my use case. I need the marked labels.

I also added a button to the menu bar. With that button I want to start a database Query and the Parameters are the labels (from the semantic model) of my diagram elements.

Regards

Alex
Previous Topic:Custom routing edges (position)
Next Topic:Automatically trigger "Diagram Validation" or adding a button on a tabbar for diagram vali
Goto Forum:
  


Current Time: Fri Apr 26 09:16:17 GMT 2024

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

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

Back to the top