| [news.eclipse.modeling.gmf] Re: Problems with the Mapping model |
This is a multi-part message in MIME format.
Hello Linda,
> We guess that you mean create only one link mapping. For example we
Right.
> create one like this:
> <Transition{Transition.sources:State->Transition.targets:State}/Transi
> tion>
> But then how do we get ONE link mapping to connect to the three kinds
> of nodes. If it is somewhere in the gmfmap, please specify where.
Well, AFAIR, you said me there is a common super-class for all States in your model â something like âAbstractStateâ. Mistakenly I supposed that Transition link in your model is a connection between two AbstractStates (or just two states if the common super-class is State).
BTW, taking into account this diagram I can not understand which particular element is mapped to the link connecting different states in your diagram? Is it Transition element? Then which features do you specify as source/target meta-features for the corresponding link mapping(s)?
I can suggest you to modify meta-model to make it similar to the .ecore diagram attached. In this case you can create LinkMapping associated with Transition domain model element always having one source/target element tepresented by source/target meta-features in link mapping. In addition you can create LinkConstraints below this LinkMapping containing following source/target end constraints:
Source: not self.oclIsKindOf(FinalState)
Target: not self.oclIsKinfOf(InitialState)
If you want to disable direct transitions from IitialState to Final one then:
Target: if self.oclIsKindOf(FinalState) then not oppositeEnd.oclIsKindOf(InitialState) else not self.oclIsKinfOf(InitialState) endif
If you still want to stay with your domain model then you have to describe me which domain model elements/features you want to represent as a links on a diagram and if same domain model element should be represented as different links (.gmfmap file contains several LinkMappings associated with same domain model element âTransitionâ) depending on itâs source/target elements then you have to add appropriate constraints to each of existing LinkMappings to show GMF how to represent each instance of âTransitionâ based on itâs source/target elements.
> We have never written any ocl and donÅt really understand how to write
> the constraints in it. We have looked at your example but we still
> donÅt understand how we should do it. (We added link constraints in
> the mapping model to the link Mapping and wrote some code snippets in
> the body part that didnÅt work.)Is there a way to set this in Java
> instead :-)
Sure. Set constraint language = java, write java code there, perform .gmfmap->.mgfgen transformation, find GenJavaExpressionProvider node inside created .gmfgen file , set injectExpressionBody property to true and re-generate code -> corresponding line of code will be injected into the generated ???VisualIdRegistry class.
-----------------
Alex Shatalin
P.S. BTW, you can find useful UML2Tools project implementing State Machine diagram based on GMF (http://wiki.eclipse.org/MDT-UML2Tools)
Attachment:
Statechart.PNG
Description: PNG image