Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Create a label in a node to describe an association
Create a label in a node to describe an association [message #154894] Thu, 11 October 2007 19:57 Go to next message
Eclipse UserFriend
Originally posted by: jdente.21technologies.com

Hi,
I am trying to figure out how to display the value of an Association in a
label inside a node. I have created an extremely simple ecore diagram to
demonstrate my problem. Here is a summary of my sample ecore diagram:

--------------------
| PatternNode |
| - name (EString) |
--------------------
|
| type (Association)
|
V
---------------------
| ClassType |
| - name (EString) |
---------------------

PatternNode and ClassType are both contained by a Canvas node that is not
drawn above. The 'type' relationship is a simple association. The idea, is
that the user places a PatternNode on the diagram and gives it the name
'P1'. The 'type' property will initially be blank. Now the user places a
ClassType on the diagram 'C1'. The user can now set the 'type' property on
'P1' to 'C1'. If the user adds another ClassType 'C2', 'P1' can now set its
'type' to 'C1' or 'C2'.

This ecore model works perfectly for the interaction stated above. Note
that graphically, the type associaton is not drawn, nor is it created by a
tool. Currently the type association is only created by accessing the drop
down list of ClassTypes located on the 'type' property of the PatternNode.
My problem, is that I cannot get the 'type' property to display as an
editable label on the PatternNode. It appears that I can only map labels to
features, and PatternNode's only feature is 'name'. I want to map a label
to 'type' and display that label in PatternNode. My longterm goal is to
combine 'name' and 'type' properties into a single label so that I can have
the user input something along the lines of "P1 : C2". Note that this
behavior is similar to the UML 2 diagram. I have spent a lot of time
looking at the UML 2 mapping and I cannot determine how their 'type' field
gets mapped to a label.

There are lots of other posts on the newsgroup asking for help with a
similar problem, but nobody has ever provided a solution. I'm sure other
people out there would appreciate a solution to this problem as they attempt
to mimic the UML 2 class attribute labels.

Thanks in advance,
Joe.
Re: Create a label in a node to describe an association [message #154978 is a reply to message #154894] Fri, 12 October 2007 06:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jan.herriger.gmx.de

Hi Joe,

sounds like https://bugs.eclipse.org/bugs/show_bug.cgi?id=138179

In the meantime, thread "how to display referenced feature in label"
might help.

Joe Dente schrieb:
> Hi,
> I am trying to figure out how to display the value of an Association in a
> label inside a node. I have created an extremely simple ecore diagram to
> demonstrate my problem. Here is a summary of my sample ecore diagram:
>
> --------------------
> | PatternNode |
> | - name (EString) |
> --------------------
> |
> | type (Association)
> |
> V
> ---------------------
> | ClassType |
> | - name (EString) |
> ---------------------
>
> PatternNode and ClassType are both contained by a Canvas node that is not
> drawn above. The 'type' relationship is a simple association. The idea, is
> that the user places a PatternNode on the diagram and gives it the name
> 'P1'. The 'type' property will initially be blank. Now the user places a
> ClassType on the diagram 'C1'. The user can now set the 'type' property on
> 'P1' to 'C1'. If the user adds another ClassType 'C2', 'P1' can now set its
> 'type' to 'C1' or 'C2'.
>
> This ecore model works perfectly for the interaction stated above. Note
> that graphically, the type associaton is not drawn, nor is it created by a
> tool. Currently the type association is only created by accessing the drop
> down list of ClassTypes located on the 'type' property of the PatternNode.
> My problem, is that I cannot get the 'type' property to display as an
> editable label on the PatternNode. It appears that I can only map labels to
> features, and PatternNode's only feature is 'name'. I want to map a label
> to 'type' and display that label in PatternNode. My longterm goal is to
> combine 'name' and 'type' properties into a single label so that I can have
> the user input something along the lines of "P1 : C2". Note that this
> behavior is similar to the UML 2 diagram. I have spent a lot of time
> looking at the UML 2 mapping and I cannot determine how their 'type' field
> gets mapped to a label.
>
> There are lots of other posts on the newsgroup asking for help with a
> similar problem, but nobody has ever provided a solution. I'm sure other
> people out there would appreciate a solution to this problem as they attempt
> to mimic the UML 2 class attribute labels.
>
> Thanks in advance,
> Joe.
>
>
Re: Create a label in a node to describe an association [message #155453 is a reply to message #154978] Mon, 15 October 2007 12:29 Go to previous message
Eclipse UserFriend
Originally posted by: jdente.21technologies.com

Thanks for the links.
For future reference and others who may be trying to solve a similar
problem, the final suggestion on the thread "how to display referenced
feature in label" worked well for me. I created a volitile String field
named "typeName" on PatternNode. Then I implemented the setTypeName and
getTypeName methods to basically retrieve and set the value of the "type"
association. Finally, I added a "typeName" notifier to the "setType" method
so that the "typeName" value is always synchronized with the current "type"
association. The volitile "typeName" attribute allows you to map a label to
the attribute, and since it's volitile, no storage is allocated for the
attribute.
-Joe

"Jan Herriger" <jan.herriger@gmx.de> wrote in message
news:feni64$d3q$1@build.eclipse.org...
> Hi Joe,
>
> sounds like https://bugs.eclipse.org/bugs/show_bug.cgi?id=138179
>
> In the meantime, thread "how to display referenced feature in label" might
> help.
>
> Joe Dente schrieb:
>> Hi,
>> I am trying to figure out how to display the value of an Association in a
>> label inside a node. I have created an extremely simple ecore diagram to
>> demonstrate my problem. Here is a summary of my sample ecore diagram:
>>
>> --------------------
>> | PatternNode |
>> | - name (EString) |
>> --------------------
>> |
>> | type (Association)
>> |
>> V
>> ---------------------
>> | ClassType |
>> | - name (EString) |
>> ---------------------
>>
>> PatternNode and ClassType are both contained by a Canvas node that is not
>> drawn above. The 'type' relationship is a simple association. The idea,
>> is that the user places a PatternNode on the diagram and gives it the
>> name 'P1'. The 'type' property will initially be blank. Now the user
>> places a ClassType on the diagram 'C1'. The user can now set the 'type'
>> property on 'P1' to 'C1'. If the user adds another ClassType 'C2', 'P1'
>> can now set its 'type' to 'C1' or 'C2'.
>>
>> This ecore model works perfectly for the interaction stated above. Note
>> that graphically, the type associaton is not drawn, nor is it created by
>> a tool. Currently the type association is only created by accessing the
>> drop down list of ClassTypes located on the 'type' property of the
>> PatternNode. My problem, is that I cannot get the 'type' property to
>> display as an editable label on the PatternNode. It appears that I can
>> only map labels to features, and PatternNode's only feature is 'name'. I
>> want to map a label to 'type' and display that label in PatternNode. My
>> longterm goal is to combine 'name' and 'type' properties into a single
>> label so that I can have the user input something along the lines of "P1
>> : C2". Note that this behavior is similar to the UML 2 diagram. I have
>> spent a lot of time looking at the UML 2 mapping and I cannot determine
>> how their 'type' field gets mapped to a label.
>>
>> There are lots of other posts on the newsgroup asking for help with a
>> similar problem, but nobody has ever provided a solution. I'm sure other
>> people out there would appreciate a solution to this problem as they
>> attempt to mimic the UML 2 class attribute labels.
>>
>> Thanks in advance,
>> Joe.
Previous Topic:contributionBar
Next Topic:changing icons in ecore editor example
Goto Forum:
  


Current Time: Thu May 29 15:05:07 EDT 2025

Powered by FUDForum. Page generated in 0.02862 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top