Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Create edge End Label from a target element property
Create edge End Label from a target element property [message #1460379] Mon, 03 November 2014 14:03 Go to next message
Vladimir D is currently offline Vladimir DFriend
Messages: 22
Registered: January 2013
Junior Member
Hi,

I have specified a basic diagram for my DSL and I have one problem so far. I have three classes in my meta-model:

1. Entity (name : String)
2. RegularEntity (entity : Entity, min : SomeEnum, max: SomeEnum)
3. Relationship (entities : RegularEntities[0..*])

Based on this meta-model I have created a Sirius diagram where Entity and Relationship are nodes and there is a link between each relationship and its entities. I get connected entities by using an expression ([self.entities -> collect(e | e.entity)/]).

Now the tricky part (at least for me)... I want to create a label at the end of the edge (connecting relationship to entity, on entity side) which prints out min and max values from a regular entity which is in fact a wrapper around the connected entity. The problem is that in the label definition property, I can get only all relationship entities (as the self returns relationship), and I cannot get the current one connected by a specific Edge. I've tried a lot of different OCL expressions with no result.

Thank you in advance.
Best regards,
Vladimir
Re: Create edge End Label from a target element property [message #1462150 is a reply to message #1460379] Wed, 05 November 2014 08:58 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,

Le 03/11/2014 15:03, Vladimir D a écrit :
> Hi,
>
> I have specified a basic diagram for my DSL and I have one problem so
> far. I have three classes in my meta-model:
>
> 1. Entity (name : String)
> 2. RegularEntity (entity : Entity, min : SomeEnum, max: SomeEnum)
> 3. Relationship (entities : RegularEntities[0..*])
>
> Based on this meta-model I have created a Sirius diagram where Entity
> and Relationship are nodes and there is a link between each relationship
> and its entities. I get connected entities by using an expression
> ([self.entities -> collect(e | e.entity)/]).
>
> Now the tricky part (at least for me)... I want to create a label at the
> end of the edge (connecting relationship to entity, on entity side)
> which prints out min and max values from a regular entity which is in
> fact a wrapper around the connected entity. The problem is that in the
> label definition property, I can get only all relationship entities (as
> the self returns relationship), and I cannot get the current one
> connected by a specific Edge. I've tried a lot of different OCL
> expressions with no result.
> Thank you in advance.
> Best regards,
> Vladimir

In your case, you should use the Sirius model to retrieve the
Entity/RegularEntity connected to your current link.

In your expression you have access to the view variable which is in your
case a DEdge. The DEdge is the Sirius internal model element created
from your EdgeMapping. It has relations named sourceNode/targetNode to
retrieve its ends. DSemanticDecorator.target is the reference which
allow to retrieve the semantic model from the Sirius model and the
diagram elements are DSemanticDecorators (they are subtypes of
DDiagramElements which inherits from DSemanticDecorator).

I would write
[view.oclAsType(DEdge).targetNode.oclAsType(DSemanticDecorator).target/]
to retrieve the linked entity.

Here I would recommend to use a Java Service [1][2] to compute the label.
You could use service:view.computeLabel in your label expression and
complete the attached service snippet.

Note that you have to define a JavaExtension as child of your Viewpoint
in your VSM to declare the service class, and you will have to add
org.eclipse.sirius and org.eclipse.sirius.diagram in your plugin
dependencies to have access to the Sirius model concepts.

Regards

--
Maxime - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius

--
[1]
https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html#service_methods
[2]
https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html#specialized

/**
* Copyright (c) 2014 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Obeo - initial API and implementation
*/
package fr.obeo.dsl.arduino.design.services;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.sirius.diagram.DDiagramElement;
import org.eclipse.sirius.diagram.DEdge;
import org.eclipse.sirius.diagram.EdgeTarget;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;

public class SampleService {

public String computeLabel(DDiagramElement dde) {
String label = "";
if (dde instanceof DEdge) {
EdgeTarget et = ((DEdge) dde).getTargetNode();
if (et instanceof DSemanticDecorator) {
EObject semanticTarget = ((DSemanticDecorator) et).getTarget();

// Your label computation from the semantic element of the edge
// target node.

}

}
return label;
}

}


Maxime Porhel - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Create edge End Label from a target element property [message #1462249 is a reply to message #1462150] Wed, 05 November 2014 11:16 Go to previous message
Vladimir D is currently offline Vladimir DFriend
Messages: 22
Registered: January 2013
Junior Member
Thank you very much. I'll give it a try.

Best regards.
Vladimir
Previous Topic:Installing Sirius 2.0.0 on Eclipse Modeling
Next Topic:[Feature] Navigate between model explorer & diagram elements
Goto Forum:
  


Current Time: Thu Mar 28 17:24:38 GMT 2024

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

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

Back to the top