Bug 146535 - Provide solution for intermediate container w/o graphical node
Summary: Provide solution for intermediate container w/o graphical node
Status: NEW
Alias: None
Product: GMF-Tooling (ARCHIVED)
Classification: Modeling
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 enhancement with 2 votes (vote)
Target Milestone: 2.2   Edit
Assignee: Artem Tikhomirov CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 221542 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-06-12 06:24 EDT by Fedor Isakov CLA
Modified: 2010-07-19 22:18 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fedor Isakov CLA 2006-06-12 06:24:29 EDT
http://www.eclipse.org/newsportal/article.php?id=3081&group=eclipse.technology.gmf#3081

Suppose I have a model similar to...

<Node>
 <Name>Here goes the name</Name>
 <Subnode>
   <SubnodeContent>Here goes the content</SubnodeContent>
   <Params>
     <Param>Some arbitrary content here</Param>
     <Param>Some more content</Param>
   </Params>
  </Subnode>
</Node>

What I want is to have a top-level figure for Node element, with a compartment for Name and another compartment for Subnodes (which can be many). Each Subnode figure in its turn can have zero or more Param children, which should be displayed as labels.

What I don't want, is to have a figure for Params container. 

I'm forced to either create additional (otherwise unnecessary) mapping for Params element in gmfmap model, or provide a "fake" IElementType for it, so that I could reuse CreateElementCommand.

On creating a top node it has no structure. Children (and grand-children) are added on user's request, and this is when the structure needs to be initialized. I can prepend CreateElementCommand to create container for new element in the *ItemSemanticEditPolicy. That's why I need IElementType.
Comment 1 Alex Shatalin CLA 2006-06-12 06:29:30 EDT
Here is a reference for newsreaders: news://news.eclipse.org/e6bad9$q6l$1@utils.eclipse.org

This is a feature for next version.
Comment 2 Artem Tikhomirov CLA 2006-06-27 14:29:13 EDT
With mapping like this:
NodeMapping - Node
 ChildReference - containmentFeatureParam
   NodeMapping - Param

you'll need to (a) ignore validation, (b) fix compilation issues. As long as you need some additional code to handle container creation, this should not be a problem. 

We'll definitely address these to some extent (perhaps, some sort of markers pointing to exact place inside code that requires attention, instead of validation errors). 

Though, I doubt out-of-the-box solution for such usecase could be reasonably simple. In general, one needs to distinguish 'children' *selector* from 'containment' (which is the theme of this bugzilla) - e.g. imagine Subnode has non-cont. reference to Param to display inside Node (thus, ChildReference's childrenFeature may look like subnode/referencedParam), while creation should take place in subnode/params/param feature. In addition, 'containment' selector might have need to specify whether to create intermediate containers or not (and what if containers feature is multiple - should we use existing value - which one? - or just add another one?). To me, it sounds like a really complex syntax and I'd be grateful for ideas how to make it reasonable while keeping it useful.
Comment 3 Fedor Isakov CLA 2006-06-28 06:43:03 EDT
The solution you describe is exactly how I currently approach this issue. Nothing is terribly wrong with it, only when I face the necessity to actually create "Params" container with CreateElementCommand I must introduce a IElementType for it. I don't know, there may be other ways to create a container without the IElementType, in which case this is no longer an issue. 

Please, don't exaggerate the problem discussed here. The XML structure I described is a very simple idea, and is a quite common pattern indeeed. Basically, "Params"  serves *only* the purpose to group together "Param" elements. They could have just been moved to "Subnode", in which case Subnode.params feature would be sufficient. EMF could probably have built-in support for this scenario (and it might have actually, I just don't know; I'm using the ecore model generated from XSD). 

So, in case there is an alternative approach, I would be more than willing to switch to it and withdraw this request altogether. Otherwise, I would suggest to use a very simple strategy here: create new "Params" container for any "Param" elements created and (optionally) destroy an empty "Params" after its last child has been destroyed. 
Comment 4 Linda Damus CLA 2006-12-14 09:39:34 EST
I'm experiencing a similar problem. However, in 2.0 I find that the proposed workaround (ignore errors in gmfmap and gmfgen and fix resulting compile errors) no longer works.  The code generation throws exceptions and does not complete.

I have had some success with tweaking the jet templates to tolerate the lack of Children Feature and/or Containment Feature in a Child Reference.  In such cases I've been generating a stub method that I can fill in later to do the creation (or selection of existing element) the way I want.  There are also some changes to the generation of code to delete such elements.

What would you think of making the ChildrenFeature and ContainmentFeature optional, and when they are not specified the toolsmith names his own commands to create, delete, move that kind of element instead?
Comment 5 Artem Tikhomirov CLA 2007-04-10 10:58:58 EDT
(In reply to comment #4)
Templates should tolerate absence of these features. I've submitted bug #181771 to cover codeneration aspect of the problem.
Comment 6 Artem Tikhomirov CLA 2007-05-24 07:36:18 EDT
Updated target milestone
Comment 7 Artem Tikhomirov CLA 2008-03-06 08:17:25 EST
*** Bug 221542 has been marked as a duplicate of this bug. ***
Comment 8 Artem Tikhomirov CLA 2008-06-02 08:49:00 EDT
Bulk update, target milestone 2.2
Comment 9 Eclipse Webmaster CLA 2010-07-19 22:18:40 EDT
[GMF Restructure] Bug 319140 : product GMF and component
Generation was the original product and component for this bug