Bug 138179 - Allow to define labels based on attributes of referenced objects
Summary: Allow to define labels based on attributes of referenced objects
Status: RESOLVED FIXED
Alias: None
Product: GMF-Tooling (ARCHIVED)
Classification: Modeling
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P1 enhancement with 16 votes (vote)
Target Milestone: 2.3   Edit
Assignee: Artem Tikhomirov CLA
QA Contact:
URL:
Whiteboard: Usability
Keywords: plan
Depends on:
Blocks:
 
Reported: 2006-04-24 09:20 EDT by Dmitry Stadnik CLA
Modified: 2010-07-19 22:23 EDT (History)
11 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Stadnik CLA 2006-04-24 09:20:34 EDT
Consider node A that has reference to node B with attribute C; user wants to 
create node mapping for A and child label mapping for attribute C; label 
mapping should allow to specify a way (query using ocl expression?) to navigate 
from A instance to B instance to obtain C value.


Post in newsgroup by Marco Mosconi:

Currently, only EAttributes can be selected, that are direct members of domain 
elements. But I need to get Label values also from EOperations or by navigating 
EReferences and accessing EAttributes of referenced domain elements. Can I 
achieve this in .gmfmap/.gmfgen or do I have to extend/customize the generated 
Java code? I tried to edit the gmfmap directly with something like <features 
href="//A/ref/b"/> to select feature 'b' from the domain element that is 
referenced by A through an association 'ref'. I had no luck so far ...
Comment 1 Christian Vogt CLA 2006-04-25 17:39:02 EDT
The display string pattern should allow for very complex labels. Consider the following.

For the GMF Ecore editor, it would be nice to be able to display the following string for an EOperation with EParameters inside the EClass containment list. For example:
"myOperation(p1 : Type1, p) : Type"

A solution would be to allow the user to write an OCL expression to define the display string. The following is such an OCL expression which could create the above display string:

let str : String = self.name.concat('(') in
 let length : Integer = str.size() in
  self.eParameters->iterate(
   p : EParameter; s : String = str |
    (if s.size() = length then s else s.concat(', ') endif)
     .concat(p.name).concat(
      (if p.eType <> null
       then ' : '.concat(p.eType.name)
       else '' endif)
     )
    ).concat(')')
    .concat(
     (if self.eType <> null
      then ' : '.concat(self.eType.name)
      else '' endif)
    )

The IParser has a method, isAffectingEvent(), which returns true if the parser should refresh the display string. By using OCL a simple visitor can be created to visit the OCL exression and determine all EStructuralFeatures used in the expression. The resulting list of EStructuralFeatures could then be included in the isAffectingEvent() check.

OCL is great for allowing the user to express the label display string.
Comment 2 Artem Tikhomirov CLA 2006-05-15 08:10:02 EDT
(In reply to comment #1)
> OCL is great for allowing the user to express the label display string.

Sounds really good, OMG guys should love this :)

It's a huge topic how to provide means for complex/non-direct-attribute labels, and OCL (or any language/script) comes as first choice, though it's not best fit, IMO. Text is not a model, and we can't validate/check it easily. Plus, evaluation in runtime seems bit expensive, provided you'd merely like to concatenate few values.
Comment 3 Artem Tikhomirov CLA 2006-05-31 10:10:05 EDT
Version updated - not 1.0 release
Comment 4 Steffen Becker CLA 2007-05-24 07:37:43 EDT
I also somehow like the OCL idea, however it is cumbersome. Would it be possible to attach sth. more MDD like? Like for example a Xpand Script from oAW which perfectly supports Model-2-Text...
Comment 5 Artem Tikhomirov CLA 2007-05-25 16:36:20 EDT
not 2.0
Comment 6 Richard Gronback CLA 2007-10-22 08:53:11 EDT
Increasing priority and adding as plan item for 2.1
Comment 7 Artem Tikhomirov CLA 2008-06-02 08:48:56 EDT
Bulk update, target milestone 2.2
Comment 8 Alessander Botti Benevides CLA 2008-06-13 00:43:06 EDT
I really need this functionality. What I need is a little more specific:

"Consider node A that has reference to node B with attribute C; user wants to 
create node mapping for A and child label mapping for attribute C; label 
mapping should allow to specify a way (query using ocl expression?) to navigate 
from A instance to B instance to obtain C value."

In my case, the EClass A has a containment EReference to EClass B. I need to automatically create an instance of B when I create an instance of A (using "Reference New Element Spec" in the definition of Node A, for example) and add EAttribute C of the EClass B as a "Feature Label Mapping" of the Node A. Then, in the generated editor, when someone creates an instance of A and selects it's label, the properties of the automatically created instance of B should be shown in the Properties View. I don't need B as a Node, only it's properties have to be acessible in the Properties View, when selecting the label of A.

I'm almost two years waiting for this GMF enhancement and trying to alter the generated Java code to implement this behaviour (any ideas of how can I do it?).

Please try to release this functionality, it would be VERY nice on GMF 2.1.

Sorry for the bad english and thanks for the great work on GMF!
Comment 9 Artem Tikhomirov CLA 2010-03-10 14:28:30 EST
GMFMap got ExpressionLabelMapping where one can specify expressions to represent labels. Still, parting user input and model update should be coded manually (#updateValues in the generated code) - I don't have any idea how to accomplish that with anything else, and I'd be grateful for any suggestions.

In GMFGen, ExpressionLabelParser is counterpart of this new Label Mapping.

Short description: http://wiki.eclipse.org/GMF_2.3_New_and_Noteworthy#2.3_M6

Tests: ParsersTest#testExpressionLabelParser
Comment 10 Eclipse Webmaster CLA 2010-07-16 23:38:29 EDT
[target cleanup] 2.3 M6 was the original target milestone for this
bug
Comment 11 Eclipse Webmaster CLA 2010-07-19 22:23:14 EDT
[GMF Restructure] Bug 319140 : product GMF and component
Models was the original product and component for this bug