Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 354539

Summary: Navigator does not correctly check for createable child objects
Product: [Modeling] ECP Reporter: Mike Haney <txmikester>
Component: NavigatorAssignee: Franziska Haunolder <franziska.haunolder>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: corrmage, eclipse, jhelming, mkoegel
Version: unspecified   
Target Milestone: 0.8.9   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Preliminary patch to fix the bug. none

Description Mike Haney CLA 2011-08-11 14:55:02 EDT
Build Identifier: I20110613-1736

When suppressing child objects in a model (using the genmodel Children and Create Child properties), the navigator is ignoring the changes to collectNewChildDescriptors() in the affected item provider.

The item provider IS being consulted for populating the navigator, as the suppressed children no longer displayed in the hierarchy, but right clicking on the parent node still gives a menu item to create the hidden child object.

Reproducible: Always

Steps to Reproduce:
1.  Create a model with 3 objects - Parent, Child A, Child B
2.  Add containment references to Parent for both Child A and Child B
3.  Create a genmodel, expand the tree and select the reference to Child A under the Parent object.
4.  In the Properties view, set Children and Create Child to false.
5.  Generate the model and model.edit plugins
6.  Add the model to an ECP app (or use the EMFStore perspective)
7.  Add an instance of Parent
8.  Right click on the PArent node and you sill see options to create both Child A and Child B objects.  This is wrong behavior, according to the provider settings!
9.  Create an instance of each child.  Child B should be the only one displayed under Parent in the navigator view (this works correctly).
Comment 1 Maximilian Koegel CLA 2011-08-12 06:03:51 EDT
Thanks for this detailed report, this is indeed a bug and must be fixed.
Comment 2 Franziska Haunolder CLA 2011-09-01 04:17:56 EDT
Created attachment 202593 [details]
Preliminary patch to fix the bug.

Preliminary patch to fix the bug.
Comment 3 Franziska Haunolder CLA 2011-09-01 04:19:03 EDT
Preliminary fixed the bug with a patch.
Comment 4 Nikolay Kasyanov CLA 2011-09-01 14:38:25 EDT
As far as i can see patch solved problem described in this bug, but it doesn't allow following usecase:

abstract InheritedItem with EReference subclasses [1..*] : InheritedItem;
Product -> InheritedItem
Type -> InheritedItem
Reference -> InheritedItem

with default generated code one can add Types to Product's subclasses, for example, which is wrong in my domain model. So, I edited collectNewChildDescriptors method of (Product | Type | Reference)ItemProvider to return only corresponding child descriptors.

But DynamicContainmentCommands collects new child descriptors only for containment detection. In createCommands method it calls to addCommandForSubTypes, because EReference type is abstract.

Maybe addcommandForSubTypes should take child descriptors into account in some way?
Comment 5 Nikolay Kasyanov CLA 2011-09-14 08:00:41 EDT
looks like current implementation has another problem. I'll use domain model from previous comment.
In getContributionItems method of DynamicContainmentCommands all child descriptors considered as different containments, event if all of them are child descriptors for one EReference.

So, in example domain model it leads to duplication (actually triplication) of creation menu items, because addCommandForSubtypes called for every child descriptor and returns 3 menus for every child descriptor, so we would get 9 menu items.
Comment 6 Jonas Helming CLA 2012-01-24 12:55:38 EST
ok