Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Custom DSL with Sirius(Few questions about Sirius)
Custom DSL with Sirius [message #1181335] Mon, 11 November 2013 14:36 Go to next message
sninja sninja is currently offline sninja sninjaFriend
Messages: 31
Registered: October 2013
Member
Hi,

I've finished basicFamily tutorial and I think that Sirius is pretty much what I need to create diagram representation of some bussines model using my DSL.

I just want to ask a few questions, before I go too far and then realize that I can't do something:

1. Can I use Ecore model generated from XSD file for my modeling project Ecore model?

2. Can I create nodes to graphically look like UML diagram classes with attributes, where attributes have their types (and is there some tutorial for best way to do it)? For example, in basicFamily persons have birthDate, but it is not seen on the diagram, only in properties.

3. Can I save final diagram and everything on it (elements and relations and their properties) like XML file which will corespond to the starting XSD file?

Thank's
Re: Custom DSL with Sirius [message #1182576 is a reply to message #1181335] Tue, 12 November 2013 09:25 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 701
Registered: July 2009
Senior Member
Le 11/11/2013 15:36, sninja sninja a écrit :
> Hi,

Hello.

> 1. Can I use Ecore model generated from XSD file for my modeling project
> Ecore model?

The basic stuff should work, but this is not a case we have tested a
lot. Off the top of my head I don't see any reason why it wouldn't work
as long as it is an EMF model, but I know that Ecore models generated
from XSD use various EMF mechanisms (like feature maps) which make them
more cumbersome to deal with, and thus are not used very often in
"native" Ecore models, so they are less tested.

We would certainly like feedback (positive or negative) on this use case.

> 2. Can I create nodes to graphically look like UML diagram classes with
> attributes, where attributes have their types (and is there some
> tutorial for best way to do it)? For example, in basicFamily persons
> have birthDate, but it is not seen on the diagram, only in properties.

It is certainly possible. The mapping structure you need for this (in
your .odesign file) looks like this:
- a Container Mapping for the top-level element (what would be the Class
in a UML diagram), with the "Children Presentation" property set to "List";
- one Node Mapping inside the Container Mapping for each different kind
of element you want in the list, with the appropriate labelExpression in
its style configuration.

When used inside a list container, most attributes of a node's style
(e.g. shape, color) are ignored [2], but the label's text is used.

The expression used to compute the label's text can be arbitrarily
complex, so if you wanted to show the birthDate for a person, you simply
need to change the labelExpression of the corresponding element (i.e.
instead of something like [firstName/], the expression would be
[firstName + ' (' + birthDate + ')'/]).

The principle is the same if you need to show the type of an attribute
instead of just its name; use something like [name + ' : ' + type.name/].

You can have a look at how UML Designer [1] does it in its class diagram.

> 3. Can I save final diagram and everything on it (elements and relations
> and their properties) like XML file which will corespond to the starting
> XSD file?

Sirius stores the graphical data separately from the semantic data:
- the representations.aird file is specific to Sirius and contains only
"graphical" data, like which diagrams have bee created, the layout of
the various shapes on it etc.
- your semantic model (e.g. .uml file if using UML) is stored
separately. Sirius does not change the way it is serialized, the
standard EMF mechanisms are used. If you use an Ecore metamodel
generated from an XSD, the standard EMF mechanisms should ensure the
model is saved in a way that is compatible with the XSD schema.

Hope this helps, and don't hesitate if you need more details.

[1] https://github.com/ObeoNetwork/UML-Modeling
[2]
http://www.eclipse.org/sirius/doc/specifier/diagrams/Diagrams.html#containers


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom DSL with Sirius [message #1199484 is a reply to message #1182576] Wed, 20 November 2013 21:44 Go to previous messageGo to next message
sninja sninja is currently offline sninja sninjaFriend
Messages: 31
Registered: October 2013
Member
Alright, once again, Sirius is great.

I've managed to do almost everything that I wanted and even more.

Generation from XSD schema to ecore model didn't quite worked out, I simply didn't get what I expected. So, I created ecore model from scratch. Everything else was fine.

Now, I have two questions:

1. Is it possible for relations to have properties? Containers have them, nodes have them, but relations no. I assume that I should add properties in ecore model, but right now, I don't know how.

2. Is there some documentation about all standard Acceleo 3.4 expressions used in Sirius? I saw if statements in tutorial. I really never heard of Acceleo till Sirius, but now I would like to know more. I found this page http://www.obeonetwork.com/page/the-acceleo-language-elements, but is there some summary for Sirius?

Thanks.



Re: Custom DSL with Sirius [message #1200593 is a reply to message #1199484] Thu, 21 November 2013 10:09 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 701
Registered: July 2009
Senior Member
Le 20/11/2013 22:44, sninja sninja a écrit :
> Alright, once again, Sirius is great.

Thanks :-)

> 1. Is it possible for relations to have properties? Containers have
> them, nodes have them, but relations no. I assume that I should add
> properties in ecore model, but right now, I don't know how.

I see two possible interpretations to your question:

1. If by "relations" you mean the EReferences between EClasses you
defined in you Ecore, then no. If you want to model more than just a
reference (with the standard Ecore properties like cardinality), you
have to "reify" you relation by creating a full-blown EClass to model
it. So instead of having an EClass named "A" with an ERefence "r" to
another EClass "B", you would have A.r pointing to an intermediate
concept/EClass, say "Ref". Ref can then have a reference to "B" and any
other properties and references you need to model the relation. Note
that this issue has nothing to do with Sirius itself and is only about
how to use Ecore to represent your domain. If you have more questions
about this, the eclipse.tools.emf forum is probably the right place.

2. If by "relations" you mean the graphical edges on a Sirius diagram,
then Sirius supports both cases described above. For the first case
above (A.r directly referencing B), you would need to define a "Relation
Based Edge" in your VSM (the .odesign file). For the second case above
(A.r points to an instance of Ref, which can have its own properties and
a reference to B), you would need to define an "Element Based Edge". See
the doc at [1] or the corresponding section in the Eclipse Help.

> 2. Is there some documentation about all standard Acceleo 3.4
> expressions used in Sirius? I saw if statements in tutorial. I really
> never heard of Acceleo till Sirius, but now I would like to know more. I
> found this page
> http://www.obeonetwork.com/page/the-acceleo-language-elements, but is
> there some summary for Sirius?

Acceleo is an implementation of the MTL standard, which extends OCL to
define "Model To Text" generators. It is an completely independent
project and you can get the complete documentation from [2].

Sirius supports Acceleo as a "query language" (among others) by reusing
the part of the language which allows navigation inside EMF models and
computation of simple strings. You can get more details about how Sirius
uses Acceleo and how to write queries for Sirius in general at [3].

Regards,
Pierre-Charles David

[1] http://www.eclipse.org/sirius/doc/specifier/diagrams/Diagrams.html#edges
[2]
http://www.eclipse.org/acceleo/http://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html
[3]


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom DSL with Sirius [message #1200746 is a reply to message #1200593] Thu, 21 November 2013 11:44 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 701
Registered: July 2009
Senior Member
The links at the bottom should be:

[1] http://eclipse.org/sirius/doc/specifier/diagrams/Diagrams.html#edges
[2] http://eclipse.org/acceleo/
[3] http://eclipse.org/sirius/doc/specifier/general/Writing_Queries.html


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom DSL with Sirius [message #1208007 is a reply to message #1200746] Sun, 24 November 2013 22:06 Go to previous messageGo to next message
sninja sninja is currently offline sninja sninjaFriend
Messages: 31
Registered: October 2013
Member
Hi,

I don't know how to fill general properties for element based edge. In ecore model I have class A, then composition ref1 to classB, then reference ref2 back to class A. It works great in model editor, but I can't get relationship to show on graphical designer. I've tried all sorts of combination, but no luck, and I can't find on net some instructions.

What is the right way to do it?

Thanks.
Re: Custom DSL with Sirius [message #1208968 is a reply to message #1208007] Mon, 25 November 2013 09:15 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 701
Registered: July 2009
Senior Member
Le 24/11/2013 23:06, sninja sninja a écrit :
> Hi,

Hi.

> I don't know how to fill general properties for element based edge. In
> ecore model I have class A, then composition ref1 to classB, then
> reference ref2 back to class A.

If I understand you correctly, your metamodel looks like this:

+------+ +-----+
| | ref1 | |
| |------------->+ |
| A | | B |
| | | |
| +<-------------+ |
+------+ ref2 +-----+


Assuming that in your diagram you want to show an edge between instances
of A and instances of B, this is a case where you need a "Relation Based
Edge", as the graphical edge on your diagram will represent a direct
reference from an instance of A to an instance of B through ref1.

Element Based Edges are used to represent cases where the metamodel
looks like this:

+-------+ +-------+ +------+
| | r | | b | |
| A +-------->+ Ref +------->+ B |
| | | | | |
+-------+ +-------+ +------+

and on the diagram you want to represent a graphical edge between an
instance of A and an instance of B when when there is an actual element
in the model (here an instance of Ref) instead of a direct reference to
model the relationship.

Hope this is more clear.


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom DSL with Sirius [message #1209040 is a reply to message #1208968] Mon, 25 November 2013 09:57 Go to previous messageGo to next message
sninja sninja is currently offline sninja sninjaFriend
Messages: 31
Registered: October 2013
Member
Hi,

It's like this:

classX ---someRef---> classA ---ref1---> classB ---ref2---> classA

In words, I want to self reference classA, but that self reference has to have some properties, so I have classB to define that properties.

So, in graphical designer I want classB to manifest as relation with properties. I don't want classB to show like class. I want it to be line, and when I click on that line, I want to see properties from classB. I've managed that in model editor, but I don't know how to visually present it in the designer.

That's why I use element based edge for classB and in general properties it should go something like this:

source mapping: classA
target mapping: classA
source finder expression: [someRef/]
target finder expression: [ref2/]
domain class: classB
semantic candidate expression: [ref1/]

But I'm not sure about these general properties. I need help with that.

Thanks. Your help really means to me.
Re: Custom DSL with Sirius [message #1209104 is a reply to message #1209040] Mon, 25 November 2013 10:36 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 701
Registered: July 2009
Senior Member
Le 25/11/2013 10:57, sninja sninja a écrit :
> Hi,
>
> It's like this:
>
> classX ---someRef---> classA ---ref1---> classB ---ref2---> classA

OK, I see better.

> In words, I want to self reference classA, but that self reference has
> to have some properties, so I have classB to define that properties.
>
> So, in graphical designer I want classB to manifest as relation with
> properties. I don't want classB to show like class. I want it to be
> line, and when I click on that line, I want to see properties from
> classB. I've managed that in model editor, but I don't know how to
> visually present it in the designer.
>
> That's why I use element based edge for classB

Then this is correct.

> and in general properties it should go something like this:
>
> source mapping: classA
> target mapping: classA

Correct: the graphical edges will go from an element representing an
instance of "classA" to an element representing an instance of "classA"
(possibly the same instance and thus the same graphical shape).

> domain class: classB

Correct: the graphical edge will represent an instance of "classB", and
when selecting it on the diagram, the Eclipse "Properties" view will
show the the properties the "classB" instance.

> semantic candidate expression: [ref1/]

Here I don't have enough information about your metamodel, but this is
probably wrong. For an Element Based Edge, this expression works the
same as for a Node Mapping or Container Mapping: it is evaluated in the
parent context (probably the semantic element of the diagram itself) and
should return all the instances of the domain class ("classB") which may
be represented on the diagram.

For a first iteration you can probably leave it empty, which has a
special meaning: "consider all the instances of classB in my model (in
any of the resources) as candidates". This can have a negative impact on
performances on large models, but you can go back to this later to
refine it once the rest works.

> source finder expression: [someRef/]
> target finder expression: [ref2/]

Both will be evaluated in the context of the candidates returned by
"semantic candidate epxression", so you start on an instance of "classB".

Given you schema, [ref2/] for target finder seems correct.

For the source finder you need the inverse reference of ref1. If you do
not directly have an eOpposite of ref1 in your model, you can use an
expression like this:

[eInverse()->selectByKind(classA)->filter(a : classA | a.ref1 = self/].

This will return all the instances of classA which have ref1 pointing to
the instance of classB.


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom DSL with Sirius [message #1209292 is a reply to message #1209104] Mon, 25 November 2013 12:39 Go to previous messageGo to next message
sninja sninja is currently offline sninja sninjaFriend
Messages: 31
Registered: October 2013
Member
Hi,

Thanks. It makes sense that invert instance thing.

Now, you wrote
[eInverse()->selectByKind(classA)->filter(a : classA | a.ref1 = self/]

It seems to me that one bracket is missing, so I wrote
[eInverse()->selectByKind(classA)->filter(a : classA | a.ref1 = self)/]

Now, I have error:
Incomplete iterator expression: (self."<null>"()->"<null>"("<null>"))->filter(a:"<null>" | a."<null>"->"<null>"(self)))

Help?
Re: Custom DSL with Sirius [message #1209346 is a reply to message #1209292] Mon, 25 November 2013 13:13 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 701
Registered: July 2009
Senior Member
Le 25/11/2013 13:39, sninja sninja a écrit :
> Hi,
>
> Thanks. It makes sense that invert instance thing.
>
> Now, you wrote [eInverse()->selectByKind(classA)->filter(a : classA |
> a.ref1 = self/]
>
> It seems to me that one bracket is missing, so I wrote
> [eInverse()->selectByKind(classA)->filter(a : classA | a.ref1 = self)/]

It looks like an error message from OCL (used underneath). Can you try
with this syntax instead?

[self.eInverse()->filter(classA)->select(a: classA | a.ref1 = self)/]


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom DSL with Sirius [message #1210242 is a reply to message #1209346] Mon, 25 November 2013 23:08 Go to previous messageGo to next message
sninja sninja is currently offline sninja sninjaFriend
Messages: 31
Registered: October 2013
Member
It worked.

But to be honest, I've used just [self.eInverse()]. That alone was enough. I couldn't get it to work with whole expression.

Now, my, I hope so, final question is:

How to set up palette tool Edge Creation Description?

It isn't covered in tutorial, so I've tried same as "basic" case:

- Edge Creation Description Ref1
----Id: Ref1
----Edge Mappings: classB
- Change context
----General: [source/]
- Set Value ref1
----Feature name: ref1
----Value Expression: [ref1->including(target)/]

but it didn't work.

Thanks.
Re: Custom DSL with Sirius [message #1211115 is a reply to message #1210242] Tue, 26 November 2013 09:11 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 701
Registered: July 2009
Senior Member
Le 26/11/2013 00:08, sninja sninja a écrit :
> It worked.
>
> But to be honest, I've used just [self.eInverse()]. That alone was
> enough.

OK, you just have to be aware that if your metamodel evolves and other
kinds of references than ref1 are added between classA and classB, such
a generic expression may return elements you do not want/need in this
context.

> Now, my, I hope so, final question is:
>
> How to set up palette tool Edge Creation Description?

See the documentation at
http://www.eclipse.org/sirius/doc/specifier/diagrams/Diagrams.html#edge_tools
(you should also have it installed in the Eclipse Help if you installed
Sirius).

> It isn't covered in tutorial, so I've tried same as "basic" case:
>
> - Edge Creation Description Ref1
> ----Id: Ref1
> ----Edge Mappings: classB
> - Change context
> ----General: [source/]
> - Set Value ref1
> ----Feature name: ref1
> ----Value Expression: [ref1->including(target)/]

See
http://www.eclipse.org/sirius/doc/specifier/general/Model_Operations.html for
how to specify the operations inside the body of a tool.


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom DSL with Sirius [message #1212571 is a reply to message #1211115] Tue, 26 November 2013 23:58 Go to previous messageGo to next message
sninja sninja is currently offline sninja sninjaFriend
Messages: 31
Registered: October 2013
Member
Hi,

I've tried lots of expressions and combinations, but can't get it to work. I simply don't know what to put inside/under change context to make my edge creation palette tool for element based edge work.

I've tried to set value just for ref1, then just for ref2, then for both references, but no luck. Even tried create instance, set object, but nothing. I think that the right way is to set values for both references (cause unseting both references made the delete tool to work), but I don't know how to write that.

I tried obeos full family example, didn't find such case there. I don't have elswhere to look and I don't have so much experience in this area. I went through documentation, but no examples for this case.

Help?
Re: Custom DSL with Sirius [message #1214119 is a reply to message #1212571] Wed, 27 November 2013 14:54 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 701
Registered: July 2009
Senior Member
Le 27/11/2013 00:58, sninja sninja a écrit :
> Hi,

Hi.

> I've tried lots of expressions and combinations, but can't get it to
> work. I simply don't know what to put inside/under change context to
> make my edge creation palette tool for element based edge work.
>
> I've tried to set value just for ref1, then just for ref2, then for both
> references, but no luck. Even tried create instance, set object, but
> nothing. I think that the right way is to set values for both references
> (cause unseting both references made the delete tool to work), but I
> don't know how to write that.
>
> I tried obeos full family example, didn't find such case there. I don't
> have elswhere to look and I don't have so much experience in this area.
> I went through documentation, but no examples for this case.
>
> Help?

I think I would need to see your projects to help you further. There is
too much room for misinterpretation with just exchanges on the forum.
Can you send your project here? Or more privately by email at
pierre-charles.david@xxxxxxxx if you prefer.


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom DSL with Sirius [message #1214727 is a reply to message #1214119] Wed, 27 November 2013 20:45 Go to previous messageGo to next message
sninja sninja is currently offline sninja sninjaFriend
Messages: 31
Registered: October 2013
Member
Hi,

I did it Very Happy

I got the idea from http://www.obeonetwork.com/group/obeo-designer/forum/topics/disappearing-when-i-create-new-connections

Now everything works and, for me, Sirius is truly fantastic project for creating eclipse plugins.

Thank you team Sirius.

Thank you Pierre-Charles David, you have been a really big help.
Re: Custom DSL with Sirius [message #1406254 is a reply to message #1214727] Sat, 09 August 2014 13:30 Go to previous message
Kristian Beckers is currently offline Kristian BeckersFriend
Messages: 1
Registered: August 2014
Junior Member
Do you mind sharing a small example? I am struggeling also with creating an edge for the palette. Thanks.
Previous Topic:Style of selected item in tree editor
Next Topic:Hiding synchronized edges programmatically
Goto Forum:
  


Current Time: Thu Mar 28 18:48:02 GMT 2024

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

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

Back to the top