blob: c7fb35a34a502c3d43dbf88e093b60f3bae24cf7 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta content="text/html; charset=windows-1252" http-equiv="content-type">
<title>Table generation</title>
<link rel="stylesheet" type="text/css" href="userguide.css">
</head>
<body>
<h2>Papyrus And Sirius Tables</h2>
<p>As tables exist in Papyrus and Sirius we want to provide a way to
integrate them as Word tables or LibreOffice tables.</p>
<p>Gendoc tag already exists, so the solution proposed is to have a pivot
generic Table object, offered by a dedicated Gendoc metamodel, in order to
generate all kinds of table the same way. Dedicated acceleo bundles,
already existing for Papyrus and Sirius, have a new service to transform
their table to the Gendoc generic table. </p>
<p>An overview of the Gendoc table very simple metamodel is shown in the
picture below.</p>
<p><img alt="" src="img/Gendoc_table_metamodel.png"></p>
<h3>Papyrus table generation (with manual configuration of the table columns
in the template)</h3>
<p>From a Papyrus model containing this table:</p>
<p><img alt="" src="img/Papyrus_table_sample.png"></p>
<p>Gendoc template fragment :</p>
<div class="codeBox cbBg code">
<p class="code">&lt;config&gt; &lt;drop/&gt;<br>
&nbsp;&nbsp; &lt;param key='modelPath' value='${project_loc}/...'/&gt;<br>
&nbsp;&nbsp; &lt;output path='...'/&gt;<br>
&lt;/config&gt; &lt;drop/&gt;</p>
&lt;context model='${modelPath}' element='RootElement/Requirements'
importedBundle='gmf;papyrus' searchMetamodel='true'/&gt;<br>
&lt;gendoc id='requirements'&gt; &lt;drop/&gt;<br>
&nbsp;&nbsp; [for (table: table::Table | self.getPapyrusTables())]
&lt;drop/&gt;<br>
&nbsp;&nbsp; &lt;table&gt; &lt;drop/&gt;
<div style="text-align: center;">[table.name/]:</div>
<br>
<table style="border-collapse:collapse;width: 929px; height: 44px;" border="1">
<tbody>
<tr>
<td><b>[table.tableheader.cells -&gt; at(1).label/]</b></td>
<td><b>[table.tableheader.cells -&gt; at(2).label/]</b></td>
<td><b>[table.tableheader.cells -&gt; at(3).label/]</b></td>
</tr>
</tbody>
</table>
&nbsp;&nbsp; [for (row: table::Row | table.rows)] &lt;drop/&gt;
<table style="border-collapse:collapse;" border="1" width="100%">
<tbody>
<tr>
<td>[row.cells-&gt;at(1).label/]</td>
<td>[row.cells-&gt;at(1).label/]</td>
<td>[row.cells-&gt;at(1).label/]</td>
</tr>
</tbody>
</table>
&nbsp;&nbsp; [/for] &lt;drop/&gt;<br>
&nbsp;&nbsp; &lt;/table&gt; &lt;drop/&gt;<br>
&lt;/gendoc&gt; &lt;drop/&gt;<br>
</div>
<p>In this example the service "getPapyrusTables()" will return the list of
tables contained in the context element.</p>
<p>It is possible to navigate in a table using relations “tableheader” and
“row”. The first relation returns the headers of a table and the latter a
list of row. From each of these objects we use the relation “cells” to
access to the list of cells composing a row or the table header. </p>
<p>Result in the word document produced by Gendoc :</p>
<table style="border-collapse: collapse;width: 929px; height: 28px;" border="1">
<tbody>
<tr>
<td style="width: 307.517px;"><b>id</b></td>
<td style="width: 309.85px;"><b>name</b></td>
<td style="width: 289.633px;"><b>text</b></td>
</tr>
<tr>
<td style="width: 307.733px;">REQ_001</td>
<td style="width: 308.633px;">Automated alarm clock</td>
<td style="width: 290.633px;">The alarm clock radio shall wake up the
user automatically at the right time, through radio or buzzer</td>
</tr>
<tr>
<td>REQ_0012</td>
<td>Radio management</td>
<td>The user shall be able to modify easily the radio station and the
volume.</td>
</tr>
<tr>
<td>REQ_003</td>
<td>Clock management</td>
<td>The user shall be able to update easily the time displayed by the
clock or the alarm. </td>
</tr>
<tr>
<td>...</td>
<td><br>
</td>
<td><br>
</td>
</tr>
</tbody>
</table>
<h3>Sirius table generation (with manual configuration of the table columns
in the template)</h3>
<p>From a Sirius model containing this table:</p>
<p><img alt="" src="img/Sirius_table_sample.png"> </p>
<p>Gendoc template fragment:</p>
<p> </p>
<div class="codeBox cbBg code">
<p class="code">&lt;config&gt; &lt;drop/&gt;<br>
&nbsp;&nbsp; &lt;param key='modelPath' value='${project_loc}/...'/&gt;<br>
&nbsp;&nbsp; &lt;output path='...'/&gt;<br>
&lt;/config&gt; &lt;drop/&gt;</p>
&lt;context model='${modelPath}' element='RootElement/Requirements'
importedBundle='gmf;sirius' searchMetamodel='true'/&gt;<br>
&lt;gendoc id='requirements'&gt; &lt;drop/&gt;<br>
&nbsp;&nbsp; [for (table: table::Table | self.getSiriusTables())]
&lt;drop/&gt;<br>
&nbsp;&nbsp; &lt;table&gt; &lt;drop/&gt;<br>
<div style="text-align: center;">[table.name/]:</div>
<br>
<table style="border-collapse:collapse;width: 929px; height: 44px;" border="1">
<tbody>
<tr>
<td><b>[table.tableheader.cells -&gt; at(1).label/]</b></td>
<td><b>[table.tableheader.cells -&gt; at(2).label/]</b></td>
<td><b>[table.tableheader.cells -&gt; at(3).label/]</b></td>
</tr>
</tbody>
</table>
&nbsp;&nbsp; [for (row: table::Row | table.rows)] &lt;drop/&gt;
<table style="border-collapse:collapse;" border="1" width="100%">
<tbody>
<tr>
<td>[row.cells-&gt;at(1).label/]</td>
<td>[row.cells-&gt;at(1).label/]</td>
<td>[row.cells-&gt;at(1).label/]</td>
</tr>
</tbody>
</table>
&nbsp;&nbsp; [/for] &lt;drop/&gt;<br>
&nbsp;&nbsp; &lt;/table&gt; &lt;drop/&gt;<br>
&lt;/gendoc&gt; &lt;drop/&gt;<br>
</div>
<p>This example is very similar to the precedent. The only notable
difference is how we access to the list of tables. In this case as we are
in a Sirius model, we use the “getSiriusTables()” service.</p>
<p>Result in the word document produced by Gendoc :</p>
<table style="border-collapse: collapse; width: 918px; height: 28px;" border="1">
<tbody>
<tr>
<td style="width: 307.517px;"><br>
</td>
<td style="width: 309.85px"><b>Father</b></td>
<td style="width: 289.633px;"><b>Mother</b></td>
</tr>
<tr>
<td style="width: 307.517px;">Man Paul</td>
<td style="width: 308.633px;"><br>
</td>
<td style="width: 290.633px;"><br>
</td>
</tr>
<tr>
<td>Woman Isa</td>
<td><br>
</td>
<td><br>
</td>
</tr>
<tr>
<td>Man Elias</td>
<td>Paul</td>
<td>Isa</td>
</tr>
<tr>
<td>Woman Lea</td>
<td>Paul<br>
</td>
<td>Isa<br>
</td>
</tr>
<tr>
<td>Man Dave</td>
<td>Elias</td>
<td><br>
</td>
</tr>
<tr>
<td>Man Alain</td>
<td>Dave</td>
<td>Katell</td>
</tr>
<tr>
<td>...</td>
<td><br>
</td>
<td><br>
</td>
</tr>
</tbody>
</table>
<h3>Example of an automated table generation from a Papyrus table</h3>
<p>From a Papyrus model containing several tables on a package the following
gendoc fragment allows a full table generation.</p>
<p><u><strong>Note</strong></u>: Automated mode also works with Sirius</p>
<p>Gendoc code:</p>
<div class="codeBox cbBg code">
<p class="code">&lt;config&gt; &lt;drop/&gt;<br>
&nbsp;&nbsp; &lt;param key='modelPath' value='${project_loc}/...'/&gt;<br>
&nbsp;&nbsp; &lt;output path='...'/&gt;<br>
&lt;/config&gt; &lt;drop/&gt;</p>
&lt;context model='${modelPath}' element='RootElement/Requirements'
importedBundle='gmf;papyrus' searchMetamodel='true'/&gt;<br>
&lt;gendoc id='requirements'&gt; &lt;drop/&gt;<br>
&nbsp;&nbsp; [for (table: table::Table | self.getPapyrusTables())]
&lt;drop/&gt;
<div style="text-align: center;">[table.name/]:[t.type/] <br>
<div style="text-align: left;"> &nbsp;&nbsp; &lt;table
object='[t.getTableId()/]'&gt; &lt;drop/&gt;</div>
</div>
<table style="border-collapse:collapse;" border="1" width="100%">
<tbody>
<tr>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
&nbsp;&nbsp; &lt;/table&gt; &lt;drop/&gt;<br>
&lt;/gendoc&gt; &lt;drop/&gt;<br>
</div>
<p></p>
<p>The table tag has a new attribute “object” for the automatic generation.
This attribute has to be set to the identifier of the table. The service
“getTableId()” is used to retrieve this identifier.</p>
<p><u><strong>Note</strong></u>: in this mode all cells will have the same
style.</p>
<p>Gendoc result :</p>
<p style="text-align: center;"><strong>RequirementTable0 : PapyrusSysMLRequirementTable</strong></p>
<table style="border-collapse: collapse;width: 929px; height: 28px;" border="1">
<tbody>
<tr>
<td style="width: 307.517px; text-align: center;"><b>id : String [1]<br>
</b></td>
<td style="width: 309.85px; text-align: center;"><b>name : String
[0..1]<br>
</b></td>
<td style="width: 289.633px; text-align: center;"><b>text : String [1]<br>
</b></td>
</tr>
<tr align="center">
<td style="width: 307.733px;">REQ_001</td>
<td style="width: 308.633px;">Automated alarm clock</td>
<td style="width: 290.633px;">The alarm clock radio shall wake up the
user automatically at the right time, through radio or buzzer</td>
</tr>
<tr align="center">
<td>REQ_0012</td>
<td>Radio management</td>
<td>The user shall be able to modify easily the radio station and the
volume.</td>
</tr>
<tr align="center">
<td>REQ_003</td>
<td>Clock management</td>
<td>The user shall be able to update easily the time displayed by the
clock or the alarm. </td>
</tr>
<tr>
<td>...</td>
<td><br>
</td>
<td><br>
</td>
</tr>
</tbody>
</table>
<p></p>
<p style="text-align: center;"><strong>AllocationTable0 :
PapyrusSysMLAllocationTable</strong></p>
<p style="text-align: center;"><strong></strong></p>
<table style="text-align: left; margin-left: auto; margin-right: auto;" border="1"
width="100%">
<tbody>
<tr align="center">
<td><strong>name : String [0..1]</strong></td>
</tr>
<tr align="center">
<td>Allocate1</td>
</tr>
<tr align="center">
<td>Allocate2</td>
</tr>
<tr align="center">
<td>Allocate3</td>
</tr>
<tr align="center">
<td>Allocate4</td>
</tr>
<tr align="center">
<td>Allocate5</td>
</tr>
</tbody>
</table>
</body>
</html>