How to display the referenced element of a connection as a label in GMF [message #1720303] |
Sat, 16 January 2016 13:52  |
Eclipse User |
|
|
|
Hi,
I would like to clarify my question with the small metamodel shown in the attached image.
I am trying to create a graphical editor for something like this.
I intend to represent the states as nodes and the transitions as connections between the state nodes.
My problem is how to display the computations (Expressions) as labels on the transition connections. Normally, if the expressions were attributes of the Transition class, I know how to do it as it is explicitly supported in the GMF workflow; however, since the expressions are described in a separate Class that is merely referenced by the Transition class.
Could someone help me out?
Thanks in advance.

|
|
|
Re: How to display the referenced element of a connection as a label in GMF [message #1721164 is a reply to message #1720303] |
Mon, 25 January 2016 11:39   |
Eclipse User |
|
|
|
Hi AHOT,
In complex cases as it, I usually modify the underlying Java code of the Connection EditPart implied in the problem (in your case, the Transition EClass).
From your Java code you can access to the underliying model and modify the text of the Label associated with the Transition Connection, in base of the info associated with the Expression EObject instances.
To do this task, in your Transition EditPart, inside of your createContents() method or other one method, you can access to your underliying model using this lines of code.
EObject _eobject = ((View) this.getModel()).getElement();
if (_eobject instanceof Transition)
{
Transition transitionEObject = (Transition) _eobject;
List<Expression> computationsList = transitionEObject.getComputations();
// TO-DO. Modify the code and text of the Label associated with the connection
}
Maybe, other posible solution it's using the OCL language, to predefine the label text in base of the Transition Expression EObjects, but I can't offer a correct solution in this way.
Regards,
Ángel M.
[Updated on: Mon, 25 January 2016 11:40] by Moderator Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03870 seconds