fUML support in Papyrus
Alf support in Papyrus
Alf is the textual surface notation for fUML.
This notation makes easier to the user the specification of a behavior (activity) in the context of an fUML model. Indeed, instead of graphically (using actions nodes) defining this latter, the behavior can be expressed textually (example below) as it might be using any other programming languages.
Mapping between Alf and fUML
In order to make a behavior written in Alf executable, it needs to be mapped/transformed into pure fUML (i.e. a set of action nodes). The mapping between Alf notation and the fUML syntactic subset is clearly formalized in this specification  from section 16.
Considering the previous example, the picture below shows an equivalent activity generated from the Alf specification.
As you can see parameters of the function multiply are mapped into ActivityParameterNode and the body which consists in a return statement is mapped into a call to the behavior * taking x and y as parameters. The return output pin of this CallBehavior is connected to the Return activity parameter node thanks to an ObjectFlow.
Papyrus offers an editor to enable the user to specify an existing activity in Alf.
How to specifiy a behavior in Alf
At the left-hand side of the Papyrus editor you can find the model explorer which is a tree representation of your model. To specify an activity in Alf, make right click on this latter in the model explorer and click on Open Alf Editor.
This provokes the opening of the Alf editor in the context of the target activity.
Syntactic validation of the specification
The Alf editor automatically performs a syntactic validation of the content of your specification.
In the case the specification is incorrect, the error location is highlighted by a specific marker and a description message.
Semantic validation of the specification
At any step of the development of your specification you can check wether it is semantically cohesive in the context of your model.
As an example, it is semantically invalid to write an accept statement outside the classifier behavior of an active class.
Requesting the editor to perform a semantic validation can be made by simultaneously pressing keys Alt+Entry.
In the case where the specification is not semantically valid, errors will be shown in the console.
Mapping the specification on fUML
The last step of specifying an activity with Alf is to map the written specification into an equivalent representation in fUML.
This can be done by simultaneously pressing keys Ctrl+Alt+Entry.
Such request provokes both a semantic validation and the mapping. As a result you will see a popup telling you if the mapping terminated on a success or not.
In the case the mapping is successful, you can explore the action nodes that have been generated by unfolding your activity in the model explorer.
In the case where the mapping failed, errors will be shown in the console.