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

Difference between revisions of "Sirius/Tutorials/CompartmentsTutorial"

(Created page with "This tutorial, will guide you creating compartments into containers. Containers are diagram elements that contain sub-elements, displayed in a list or with shapes (squares, c...")
 
Line 1: Line 1:
 +
=Overview=
 
This tutorial, will guide you creating compartments into containers.
 
This tutorial, will guide you creating compartments into containers.
  
Line 4: Line 5:
  
 
Let's use compartments to create a diagram that displays the parental relationships of a person into a same container:
 
Let's use compartments to create a diagram that displays the parental relationships of a person into a same container:
his parents
+
* his parents
his siblings
+
* his siblings
his children
+
* his children
his grandchildren
+
* his grandchildren
  
 
[[File:Sirius_tuto3-1-1.png]]
 
[[File:Sirius_tuto3-1-1.png]]
 
 
 
 
 
 
 
 
  
 
'''Note:''' The screenshots have been updated with Obeo Designer 8.1 (based on Sirius 3.1)
 
'''Note:''' The screenshots have been updated with Obeo Designer 8.1 (based on Sirius 3.1)
Line 25: Line 18:
 
[[File:Sirius_4mtuto_02.png]]
 
[[File:Sirius_4mtuto_02.png]]
  
 
+
=Prepare the tutorial=
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
==Prepare the tutorial==
+
 
If you have already followed the Starter Tutorial or the Advanced Tutorial, you are ready! Directly go to next section: Start creating a diagram with compartments
 
If you have already followed the Starter Tutorial or the Advanced Tutorial, you are ready! Directly go to next section: Start creating a diagram with compartments
  
 
Otherwise, start by following the instructions to install the sample Domain Model:
 
Otherwise, start by following the instructions to install the sample Domain Model:
Import the projects containing the sample Domain Model
+
* Import the projects containing the sample Domain Model
Launch a new runtime from your Eclipse
+
* Launch a new runtime from your Eclipse
Select the Sirius perspective
+
* Select the Sirius perspective
Import a sample model
+
* Import a sample model
  
 
Now, you should have an Eclipse runtime (started from your first Eclipse) with a sample Family model installed in your workspace.
 
Now, you should have an Eclipse runtime (started from your first Eclipse) with a sample Family model installed in your workspace.
  
 +
Then, install the solution of the Starter Tutorial. It is implemented by a Viewpoint Specification Project that you need to import into your workspace.
  
Then, install the solution of the Starter Tutorial. It is implemented by a Viewpoint Specification Project that you need to import into your workspace.
 
 
This project can be easily installed from the provided examples (menu File > New > Example... : select Basic Family Sample Modeler Definition).
 
This project can be easily installed from the provided examples (menu File > New > Example... : select Basic Family Sample Modeler Definition).
 
  
 
Once the modeler imported in your workspace, activate the persons viewpoint by selecting the menu Viewpoint Selection.
 
Once the modeler imported in your workspace, activate the persons viewpoint by selecting the menu Viewpoint Selection.
 
  
 
You must activate the persons viewpoint to be able to create the representations which are defined by this viewpoint.
 
You must activate the persons viewpoint to be able to create the representations which are defined by this viewpoint.
  
 +
=Create a diagram with a compartment-ready container=
 +
Let's create a new kind of diagram that will display a ''Person'' as a container.
  
 
==Create a diagram with a compartment-ready container==
 
Let's create a new kind of diagram that will display a ''Person'' as a container.
 
 
[[File:Sirius_tuto3-2-1.png]]
 
[[File:Sirius_tuto3-2-1.png]]
  
 
To allow the user to create this new kind of diagram from any ''Person'' of a ''basicfamily'' model, you have to set <code>basicfamily.person</code> as the Domain Class.
 
To allow the user to create this new kind of diagram from any ''Person'' of a ''basicfamily'' model, you have to set <code>basicfamily.person</code> as the Domain Class.
 +
 
[[File:Sirius_tuto3-2-2.png]]
 
[[File:Sirius_tuto3-2-2.png]]
 
 
  
 
Use the expression <code>aql :'Details of '+self.name</code> to give a person-related name to the diagram (ex : « Details of Elias »).
 
Use the expression <code>aql :'Details of '+self.name</code> to give a person-related name to the diagram (ex : « Details of Elias »).
  
 
[[File:Sirius_tuto3-2-3.png]]
 
[[File:Sirius_tuto3-2-3.png]]
 
  
 
On the default layer of this diagram, create a container to represent the current person.
 
On the default layer of this diagram, create a container to represent the current person.
Line 81: Line 57:
  
 
[[File:Sirius_tuto3-2-5.png]]
 
[[File:Sirius_tuto3-2-5.png]]
 
 
 
 
 
 
 
 
  
 
The other option (<code>Vertical Stack</code>) is used to display all the sub-containers within a single column.
 
The other option (<code>Vertical Stack</code>) is used to display all the sub-containers within a single column.
Line 94: Line 62:
  
 
Set a ''Gradient'' style to this main container.
 
Set a ''Gradient'' style to this main container.
 +
 
[[File:Sirius_tuto3-2-6.png]]
 
[[File:Sirius_tuto3-2-6.png]]
 
 
 
 
 
 
 
  
 
Set the label properties of the ''Gradient'' :
 
Set the label properties of the ''Gradient'' :
Line 119: Line 81:
 
This is the container that we are going to fill with compartments.
 
This is the container that we are going to fill with compartments.
  
==Create a first compartment for the parents==
+
=Create a first compartment for the parents=
 
The first compartment that we are going to create will display the parents of the person.
 
The first compartment that we are going to create will display the parents of the person.
 
Right-click on the ''PersonContainer'' and add a new container.
 
Right-click on the ''PersonContainer'' and add a new container.
Line 134: Line 96:
  
 
[[File:Sirius_tuto3-3-4.png]]
 
[[File:Sirius_tuto3-3-4.png]]
 
  
 
The label of this compartment will be fixed (''Parents'') and displayed with a smaller font (''12'') in bold.
 
The label of this compartment will be fixed (''Parents'') and displayed with a smaller font (''12'') in bold.
Line 147: Line 108:
  
 
[[File:Sirius_tuto3-3-7.png]]
 
[[File:Sirius_tuto3-3-7.png]]
 
 
 
  
 
In order to specify the label of the parents, we need to add a style to this node. We can choose any kind of style (its shape will not be taken into account as the ''Children Presentation'' feature selected for the ''ParentsContainer'' is ''List''). Let's use a ''Square''.
 
In order to specify the label of the parents, we need to add a style to this node. We can choose any kind of style (its shape will not be taken into account as the ''Children Presentation'' feature selected for the ''ParentsContainer'' is ''List''). Let's use a ''Square''.
Line 163: Line 121:
 
[[File:Sirius_tuto3-3-10.png]]
 
[[File:Sirius_tuto3-3-10.png]]
  
 
+
=Add two other compartments for siblings and children=
 
+
==Add two other compartments for siblings and children==
+
 
Now, let's create two other compartments to display the siblings and the children of a person.
 
Now, let's create two other compartments to display the siblings and the children of a person.
 +
 
Just copy and paste the ''ParentsContainer'' twice and changes the names and labels.
 
Just copy and paste the ''ParentsContainer'' twice and changes the names and labels.
 +
 
[[File:Sirius_tuto3-4-1.png]]
 
[[File:Sirius_tuto3-4-1.png]]
 +
 
Under the ''SiblingsContainer'', rename the node to <code>SiblingNode</code> and replace the ''Semantic Candidate Expression'' by <code>aql:self.parents.children->asSet()->excluding(self)</code>
 
Under the ''SiblingsContainer'', rename the node to <code>SiblingNode</code> and replace the ''Semantic Candidate Expression'' by <code>aql:self.parents.children->asSet()->excluding(self)</code>
  
Line 181: Line 140:
 
[[File:Sirius_tuto3-4-4.png]]
 
[[File:Sirius_tuto3-4-4.png]]
  
 
+
=For each children, add a compartment containing the grandchildren=
==For each children, add a compartment containing the grandchildren==
+
 
The three compartments defined previously were « fixed » : each one is created only once within the container. This is due to the expression <code>var:self</code>.
 
The three compartments defined previously were « fixed » : each one is created only once within the container. This is due to the expression <code>var:self</code>.
 +
 
In some cases, you need « dynamic » compartments: their number can vary depending on the model. For example, here we want to display grandchildren grouped by their parents. So we need as many compartments as the number of children.
 
In some cases, you need « dynamic » compartments: their number can vary depending on the model. For example, here we want to display grandchildren grouped by their parents. So we need as many compartments as the number of children.
 +
 
Before to modify the modeler, we have to complete the sample model and create grandchildren for ''Elias'' (otherwise, my example won't display enough grandchildren).
 
Before to modify the modeler, we have to complete the sample model and create grandchildren for ''Elias'' (otherwise, my example won't display enough grandchildren).
[[File:Sirius_tuto3-5-0.png]]
 
  
 +
[[File:Sirius_tuto3-5-0.png]]
  
 
Now, let's create a new container ''GrandchildrenContainer''.
 
Now, let's create a new container ''GrandchildrenContainer''.
Line 200: Line 160:
  
 
[[File:Sirius_tuto3-5-3.png]]
 
[[File:Sirius_tuto3-5-3.png]]
 
  
 
We can also define a specific border for this compartment : let's use the ''dash '' style.
 
We can also define a specific border for this compartment : let's use the ''dash '' style.
Line 209: Line 168:
  
 
[[File:Sirius_tuto3-5-5.png]]
 
[[File:Sirius_tuto3-5-5.png]]
 +
 
To display the grandchildren, let's create two sub-nodes (one for the sons and one for the daughters), with ''Workspace Images'' (you can use the SVG images provided with the [[Sirius/Tutorials/AdvancedTutorial | Advanced Tutorial]] or the PNG ones provided with the [[Sirius/Tutorials/StarterTutorial | Starter Tutorial]]).
 
To display the grandchildren, let's create two sub-nodes (one for the sons and one for the daughters), with ''Workspace Images'' (you can use the SVG images provided with the [[Sirius/Tutorials/AdvancedTutorial | Advanced Tutorial]] or the PNG ones provided with the [[Sirius/Tutorials/StarterTutorial | Starter Tutorial]]).
  
 
[[File:Sirius_tuto3-5-6.png]]
 
[[File:Sirius_tuto3-5-6.png]]
 
  
 
[[File:Sirius_tuto3-5-7.png]]
 
[[File:Sirius_tuto3-5-7.png]]
 
If you use the PNG images, set the size to <code>3</code>.
 
If you use the PNG images, set the size to <code>3</code>.
 
  
 
[[File:Sirius_tuto3-1-1.png]]
 
[[File:Sirius_tuto3-1-1.png]]
 +
 
And now you can see the grandchildren within each children container.
 
And now you can see the grandchildren within each children container.

Revision as of 11:08, 23 October 2015

Overview

This tutorial, will guide you creating compartments into containers.

Containers are diagram elements that contain sub-elements, displayed in a list or with shapes (squares, circle, images, etc) arranged according to user needs. Compartments can be used to group these sub-elements into predefined regions within the container.

Let's use compartments to create a diagram that displays the parental relationships of a person into a same container:

  • his parents
  • his siblings
  • his children
  • his grandchildren

Sirius tuto3-1-1.png

Note: The screenshots have been updated with Obeo Designer 8.1 (based on Sirius 3.1)

This tutorial is based on a simple Domain Model which describes basic concepts about families.

Sirius 4mtuto 02.png

Prepare the tutorial

If you have already followed the Starter Tutorial or the Advanced Tutorial, you are ready! Directly go to next section: Start creating a diagram with compartments

Otherwise, start by following the instructions to install the sample Domain Model:

  • Import the projects containing the sample Domain Model
  • Launch a new runtime from your Eclipse
  • Select the Sirius perspective
  • Import a sample model

Now, you should have an Eclipse runtime (started from your first Eclipse) with a sample Family model installed in your workspace.

Then, install the solution of the Starter Tutorial. It is implemented by a Viewpoint Specification Project that you need to import into your workspace.

This project can be easily installed from the provided examples (menu File > New > Example... : select Basic Family Sample Modeler Definition).

Once the modeler imported in your workspace, activate the persons viewpoint by selecting the menu Viewpoint Selection.

You must activate the persons viewpoint to be able to create the representations which are defined by this viewpoint.

Create a diagram with a compartment-ready container

Let's create a new kind of diagram that will display a Person as a container.

Sirius tuto3-2-1.png

To allow the user to create this new kind of diagram from any Person of a basicfamily model, you have to set basicfamily.person as the Domain Class.

Sirius tuto3-2-2.png

Use the expression aql :'Details of '+self.name to give a person-related name to the diagram (ex : « Details of Elias »).

Sirius tuto3-2-3.png

On the default layer of this diagram, create a container to represent the current person.

Sirius tuto3-2-4.png

As we want the container to display the compartments horizontaly, select Horizontal Stack as value of the Children Presentation option. This means that all the sub-containers defined within this main container will be displayed within a single row.

Sirius tuto3-2-5.png

The other option (Vertical Stack) is used to display all the sub-containers within a single column. Note that the Sirius editor disables these options if the container contains sub-nodes (only sub-containers can be used for a stack).

Set a Gradient style to this main container.

Sirius tuto3-2-6.png

Set the label properties of the Gradient :

  • Label Size : 14
  • Label Format : Bold

Sirius tuto3-2-7.png

Now, before going further, you can already test this new kind of diagram : save the .odesign file then right-click on Elias in the Model Explorer. You should see a menu New Representation and a sub-menu Details of Elias.

Sirius tuto3-2-8.png

If you select this sub-menu, Sirius creates and opens a new diagram containing a box named Elias.

Sirius tuto3-2-9.png

This is the container that we are going to fill with compartments.

Create a first compartment for the parents

The first compartment that we are going to create will display the parents of the person. Right-click on the PersonContainer and add a new container. Sirius tuto3-3-1.png

This new container will display the parents of the current person as a list.

Sirius tuto3-3-2.png

Set a gradient style to the ParentsContainer. Sirius tuto3-3-3.png

Set a specific Foreground Color to this Gradient (light_blue). You can also select a lighter border color for all the compartments (gray).

Sirius tuto3-3-4.png

The label of this compartment will be fixed (Parents) and displayed with a smaller font (12) in bold.

Sirius tuto3-3-5.png

Now let's add the sub-node which will display each parent.

Sirius tuto3-3-6.png

This node will display all the persons (basicfamily.Person instances) that Sirius will retrieve by executing the expression feature:parents.

Sirius tuto3-3-7.png

In order to specify the label of the parents, we need to add a style to this node. We can choose any kind of style (its shape will not be taken into account as the Children Presentation feature selected for the ParentsContainer is List). Let's use a Square.

Sirius tuto3-3-8.png

The default values of the Label properties are exactly what we need. So we can let them as is. Note that it is possible to hide the label (option  Hide Labl By Default) if you don't want to display a label for a compartment.

Sirius tuto3-3-9.png

Save the .odesign file and have a look at the diagram previously created for Elias : you should see a blue compartment named Parents containing Isa and Paul.

Sirius tuto3-3-10.png

Add two other compartments for siblings and children

Now, let's create two other compartments to display the siblings and the children of a person.

Just copy and paste the ParentsContainer twice and changes the names and labels.

Sirius tuto3-4-1.png

Under the SiblingsContainer, rename the node to SiblingNode and replace the Semantic Candidate Expression by aql:self.parents.children->asSet()->excluding(self)

Sirius tuto3-4-2.png

Under the ChildrenContainer, rename the node to ChildrenNode and replace the Semantic Candidate Expression by feature:children

Sirius tuto3-4-3.png

On the diagram, now you can see three compartments.

Sirius tuto3-4-4.png

For each children, add a compartment containing the grandchildren

The three compartments defined previously were « fixed » : each one is created only once within the container. This is due to the expression var:self.

In some cases, you need « dynamic » compartments: their number can vary depending on the model. For example, here we want to display grandchildren grouped by their parents. So we need as many compartments as the number of children.

Before to modify the modeler, we have to complete the sample model and create grandchildren for Elias (otherwise, my example won't display enough grandchildren).

Sirius tuto3-5-0.png

Now, let's create a new container GrandchildrenContainer.

As we want a compartment for each children who has children (in order to display the grandchildren), use this expression for the Semantic Candidate Expression : aql:self.children->select(c:c.children->size()>0).

Unlike the previous containers that display the persons in a list, let's use the Free Form option.

Sirius tuto3-5-1.png

Create a Gradient for this container with a label computed from the name of the person (one of the main person's children) aql:self.name+'\'s children'.

Sirius tuto3-5-3.png

We can also define a specific border for this compartment : let's use the dash  style.

Sirius tuto3-5-4.png

Now you can see three new compartments : one for each children having children.

Sirius tuto3-5-5.png

To display the grandchildren, let's create two sub-nodes (one for the sons and one for the daughters), with Workspace Images (you can use the SVG images provided with the Advanced Tutorial or the PNG ones provided with the Starter Tutorial).

Sirius tuto3-5-6.png

Sirius tuto3-5-7.png If you use the PNG images, set the size to 3.

Sirius tuto3-1-1.png

And now you can see the grandchildren within each children container.

Back to the top