Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
Daniel Wille is currently offline Daniel WilleFriend
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.
Re: EMF notification missing for removeAll on reference which is part of a FeatureMap [message #1757926 is a reply to message #1757856] Tue, 21 March 2017 22:03 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 29539
Registered: July 2009
Senior Member
Please open a Bugzilla and I'll have a look at this after I get back from Devoxx US.
Previous Topic:[xcore] cannot create build.properties
Next Topic:How can access eStructuralFeatures any of EClassifier?
Goto Forum:
  


Current Time: Fri Sep 21 02:21:55 GMT 2018

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

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

Back to the top