Difference between pages "Extending the Rodin database (How to extend Rodin Tutorial)" and "File:Steve Wright Quite Big Model Presentation.pdf"

From Event-B
(Difference between pages)
Jump to navigationJump to search
imported>Tommy
m
 
 
Line 1: Line 1:
{{Navigation|Previous= [[Extend_Rodin_database_(How_to_extend_Rodin_Tutorial)|Extend the database]]|Next=[[Extend_Rodin_Structured_Editor_(How_to_extend_Rodin_Tutorial)|Extend the structured editor]] | Up= [[Plug-in_Tutorial|How to extend Rodin Tutorial (Index)]]}}
+
Slides from Steve Wright's presentation "Experiences with a Quite Big Event-b Model", given at the Rodin workshop, Southampton, July 16th 2009.
 
 
=== In this part ===
 
We will explain how to add a new attribute to events elements and add a new element in the database.
 
Here are the steps we will detail :
 
# add dependencies to the plugins providing the extension services and interfaces we want to use,
 
# add the extensions point we will use, and define our extensions,
 
# implement required classes to specify newly added elements,
 
# create an interface using Eclipse content assist
 
For more information about the database extension, please refer to :  [[Extending_the_Rodin_Database| Extending the Rodin Database]]
 
 
 
=== Step 1 ===
 
When one wants to use extension points provided by a plugin, one has to add a dependency to this plugin.
 
We will use 2 extension points to extend the database, so we need to add a dependency to the plugin <tt>org.rodinp.core</tt> which defines them.
 
Moreover, as we want to manipulate event-b elements, we will manipulate interfaces and public classes provided by the event-B plugin.
 
We will then add a dependency to the plugin <tt>org.eventb.core</tt>
 
To do this, open the MANIFEST.MF file in the forlder META-INF of our plugin to get the following:
 
 
 
[[Image:Extend_Rodin_Tuto_1_5_Manifest_dependencies.png|500px]]
 
 
 
1. Click on the "Dependencies" Tab, <br>
 
2. Click on the Add button.<br>
 
A dialog appears, start to enter <tt>org.rodinp.core</tt> and select this plugin, press "OK" to add it to the dependencies.<br>
 
The dependency to <tt>org.rodinp.core</tt> has been added.
 
Re-do the above operations to add <tt>org.eventb.core</tt>.
 
 
 
You should now have the following dependencies added to the plugin :
 
 
 
[[Image:Extend_Rodin_Tuto_1_5_Added_Dependencies.png|200px]]
 
 
 
=== Step 2 ===
 
We will add now the Extensions Points that we want to use, and define extensions using them.
 
 
 
[[Image:Extend_Rodin_Tuto_1_6_Add_Extension_Point.png|400px]]
 
 
 
1. Click on the "Extensions" Tab, <br>
 
2. and click on the "Add" button.
 
 
 
[[Image:Extend_Rodin_Tuto_1_6_Extension_Point_Selection.png|440px]]
 
 
 
As we will start by extending the database by adding the attribute "probabilistic", we will create an extension for <tt>org.rodinp.core.attributeTypes</tt> extension point. Hence, we need to add this extension point first before creating an extension with it.
 
To do so... on the wizard that appeared (see picture above):<br>
 
1. start to type the extension point name <tt>org.rodinp.core.attributeTypes</tt>, to reveal it in the list of available extension points,<br>
 
2. select it in the list, and click on "Finish" to add it.
 
 
 
The extension point <tt>org.rodinp.core.attributeTypes</tt> now appears in the list on the "Extensions" page of the MANIFEST.MF of our plugin.
 
 
 
=== Step 3 ===
 
We will now add the attribute "probabilistic" in the database, creating an extension for <tt>org.rodinp.core.attributeTypes</tt>.
 
Right click on the extension point, select <tt>New > attributeType</tt> as in the picture below :
 
 
 
[[Image:Extend_Rodin_Tuto_1_7_Add_Attibute_Extension.png|440px]]
 
 
 
A new extension <tt>attributeType</tt> has been added. We will edit it to add our "probabilistic" attribute.<br>
 
As an event can be probabilistic or not, we set the kind of this attribute to <tt>boolean</tt>.
 
Give a unique ID to this attribute (here <tt>probabilistic</tt>) and a name (here <tt>Event-B Probabilistic Attribute</tt>).
 
You should now have something similar to what appears in the picture below :
 
 
 
[[Image:Extend_Rodin_Tuto_1_7_Add_Attibute_Extension2.png]]
 
 
 
=== Step 4 ===
 
 
 
We will now add a new element "'''Bound'''" to set the upper bound of the probabilistic variant.<br>
 
Repeat the step 2, to add the extension point : <tt>org.rodinp.core.internalElementTypes</tt>.<br>
 
Create an extension to specify our new element "'''Bound'''" using the right click as previously.<br>
 
You shall now specify the details for this new extension element :
 
 
 
[[Image:Extend_Rodin_Tuto_1_7_Bound_Extension.png]]
 
 
 
As in the picture above :<br>
 
1. give the element a unique ID (here <tt>bound</tt>)<br>
 
2. give a name to this element (here Event-B Bound Element)<br>
 
3. now things differ, as this extension point (<tt>org.rodinp.core.internalElementTypes</tt>) requires us to provide a class describing the element.<br>
 
Click on the "class*:" link to open a wizard that will help us to create this class.
 
 
 
The following wizard appears :
 
 
 
[[Image:Extend_Rodin_Tuto_1_7_Bound_Extension_New_Java_Class_Bound.png|400px]]
 
 
 
1. First specify a package where you want this class to be stored. As we want to organise a bit the project, we will say that all elements that we add will be part of a new package called <tt>fr.systerel.rodinextension.sample.basis</tt>,<br>
 
2. Give the name of the class : "Bound",<br>
 
3. We see that the superclass of this element is <tt>org.rodinp.core.basis.InternalElement</tt> but we know that we will implement an element specific to Event-B, so we put here <tt>org.eventb.core.basis.EventBElement</tt>,<br>
 
4. You can optionnaly add comments automatically to the created class, if you set them in "Preferences > Java > Code Style > Code Templates",<br>
 
5. Click on "Finish" to create the class.
 
 
 
The class ''Bound.java'' has now been created. We can open it and review its contents that we anyway shall modify now.
 
 
 
=== Step 5 ===
 
We now opened the class ''Bound.java'' and see that we need to implement the method <tt>getElementType()</tt> inherited from the superclass.<br>
 
As the type of element might be needed from outside, and is common to all Bound element, we will create a constanst in a new interface IBound that we have to create.<br>
 
Enter in the method body the following code :
 
return IBound.ELEMENT_TYPE;
 
 
 
[[Image:Extend_Rodin_Tuto_1_7_Create_Interface_Menu.png|400px]]
 
 
 
Then use the quick assist (while you go over IBound underlined in red), to create the interface IBound.
 
The following wizard appears :
 
 
[[Image:Extend_Rodin_Tuto_1_7_Create_Interface_Wizard.png|400px]]
 
 
 
Use here the "Extended Interfaces" field to specify that the element '''Bound''' should be commented (thus shall implement ICommentedElement) and will carry an expression (thus shall implement IExpressionElement) for the value of the bound.
 
 
 
public interface IBound extends ICommentedElement, IExpressionElement {
 
IInternalElementType<IBound> ELEMENT_TYPE = RodinCore
 
.getInternalElementType(QualProbPlugin.PLUGIN_ID + ".bound");
 
}
 
 
 
Modify the class <tt>Bound.java</tt> to add <tt>implements IBound</tt>.<br>
 
At this point of the development, you should have the following extensions :
 
 
 
[[Image:Extend_Rodin_Tuto_1_7_Used_Extensions.png]]
 
 
 
and you should have the following contents in your plugin :
 
 
 
[[Image:Extend_Rodin_Tuto_1_7_ProjectExplorer2.png.png]]
 
 
 
The sources of the plugin at this point can be downloaded here : // FIXME attach sources here.
 
 
 
=== In Brief ===
 
 
 
We saw how to use Eclipse to add extension points that will be used in our plugin and created our extensions using some helpful Eclipse automatic actions (wizard, content assist...).
 
As we had a detailed view (captures) of all the actions further needed, the next parts of this tutorial will focus only on the extensions.
 
 
{{Navigation|Previous= [[Extend_Rodin_database_(How_to_extend_Rodin_Tutorial)|Extend the database]]|Next= [[Extend_Rodin_Structured_Editor_(How_to_extend_Rodin_Tutorial)|Extend the structured editor]] | Up= [[Plug-in_Tutorial|How to extend Rodin Tutorial (Index)]]}}
 
 
 
[[Category:Developer documentation|*Index]]
 
[[Category:Rodin Platform|*Index]]
 
[[Category:Tutorial|*Index]]
 

Latest revision as of 20:49, 30 April 2020

Slides from Steve Wright's presentation "Experiences with a Quite Big Event-b Model", given at the Rodin workshop, Southampton, July 16th 2009.