Home » Modeling » EMF » EMF notification missing for removeAll on reference which is part of a FeatureMap(EMF notification missing for removeAll on reference which is part of a FeatureMap)
EMF notification missing for removeAll on reference which is part of a FeatureMap [message #1757856] |
Mon, 20 March 2017 18:33 |
Daniel Wille Messages: 1 Registered: March 2017 |
Junior Member |
|
|
I've run into a situation that I think may be an EMF bug, and I'd appreciate any insights from the group. I've tried to reproduce my issue with a simple scenario. The EMF model is:
* Class Bar
* Class Foo
** Attribute parent : EFeatureMapEntry
** Reference child_a : Bar
** Reference child_b : Bar
Both child_a and child_b have no upper bound, are marked volatile, and belong to the feature map group called parent.
In the genmodel, I've specified children=false for parent and child_b, but children=true for child_a. That is, only child_a contributes children to Foo. In the item provider, this generates code like so:
public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(Foo.class)) {
case TestemfPackage.FOO__CHILD_A:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
return;
}
super.notifyChanged(notification);
}
As expected, the code fires a notification to the viewer if the child_a reference list is modified. However, if I write some test code like so:
List<Bar> references = new ArrayList<>();
references.add(TestemfFactory.eINSTANCE.createBar());
references.add(TestemfFactory.eINSTANCE.createBar());
getFixture().getChild_a().addAll(references);
getFixture().getChild_a().removeAll(references);
and I watch the notifications that get generated, I see only 3:
FeatureMapUtil$FeatureENotificationImpl (eventType: ADD_MANY, feature: EReferenceImpl (name: child_a), oldValue: null, newValue: [BarImpl, BarImpl], isTouch: false, wasSet: true)
ENotificationImpl (eventType: ADD_MANY, feature: EAttributeImpl (name: parent), oldValue: null, newValue: [child_a=BarImpl, child_a=BarImpl], isTouch: false, wasSet: false)
ENotificationImpl (eventType: REMOVE_MANY, feature: EAttributeImpl (name: parent), oldValue: [child_a=BarImpl, child_a=BarImpl], newValue: [0, 1], isTouch: false, wasSet: true)
It seems that addAll(Collection) triggers a notification from both child_a and parent, but removeAll(Collection) only triggers a notification from parent. This means that the item provider doesn't know that its children have changed, and continues to show the removed children in the UI.
Any thoughts? The ecore and genmodel files are attached for reference.
|
|
| |
Goto Forum:
Current Time: Tue Apr 23 12:49:01 GMT 2024
Powered by FUDForum. Page generated in 0.02977 seconds
|