Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Customize refresh of the editor based on EMF.Edit
Customize refresh of the editor based on EMF.Edit [message #1750914] Sun, 01 January 2017 16:13 Go to next message
Carsten Tsara is currently offline Carsten TsaraFriend
Messages: 11
Registered: March 2016
Junior Member
Hi all, I need some help with customizing an editor based on EMF.Edit
For one of my ItemProvider I override getChildren() so that it returns actual children along with "fake" children (which are EObject of the same type as real children, but are not contained in the resource). Now I want to customize my editor. I see in the tree actual children along with fake children, and that's exactly what I want.
The problem is with executing Add/Remove Commands. When I execute remove command, I want that removed item is still displayed in the tree, but as fake item. (Currently this item disappears on RemoveCommand). And for add command when it's executing for the fake item, I want it to be added to the container and displaying like actual child (no extra node should be inserted in the tree). How I can achieve this?

[Updated on: Sun, 01 January 2017 16:48]

Report message to a moderator

Re: Customize refresh of the editor based on EMF.Edit [message #1750924 is a reply to message #1750914] Mon, 02 January 2017 08:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
It's not so clear how you've implemented this so far. Where are the fake children actually contained? I.e., does a fake child have an eContainer or an eResource? I ask, because I wonder what the item provider for the fake child returns for getParent. This is important in terms of how org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain.createCommand(Class<? extends Command>, CommandParameter) behaves creating the RemoveCommand. You say it makes the item disappear. So that implies to me that getChildren is called again and this time you don't return the fake child, so I imagine somewhere some eContainer or the eResource is being modified to remove the object, which appears to be not what you really want. I need to understand this better to be able to answer your question.

The framework does support showing children of a non-containment reference, but there is quite a bit of logic associated with that. For example, org.eclipse.emf.edit.provider.ItemProviderAdapter.isWrappingNeeded(Object) will return true and then org.eclipse.emf.edit.provider.ItemProviderAdapter.createWrapper(EObject, EStructuralFeature, Object, int) will return wrappers. In this case, org.eclipse.emf.edit.provider.ItemProviderAdapter.getChildren(Object) manages a ChildStore that's updated when processed by org.eclipse.emf.edit.provider.ItemProviderAdapter.updateChildren(Notification) when processing a notification when the the referenced "children" are modified. But none of that can be directly reused because you don't have a derived non-containment reference for managing the fake children.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Customize refresh of the editor based on EMF.Edit [message #1750929 is a reply to message #1750924] Mon, 02 January 2017 11:00 Go to previous messageGo to next message
Carsten Tsara is currently offline Carsten TsaraFriend
Messages: 11
Registered: March 2016
Junior Member
Thanks for the answer.
Currently I managed to do what I want. On delete I create remove command like this new RemoveCommand(domain, container, child) and on add new AddCommand(domain, container, fakeChild)
My fake children haven't an eContainer or an eResource. On add I just put them to the container (and resource).
As I understand, in both cases I get content refresh notification on the container, getChildren() is called and I see my tree updated. Please correct me if I'm wrong, as I'm novice in EMF.
Re: Customize refresh of the editor based on EMF.Edit [message #1751049 is a reply to message #1750929] Tue, 03 January 2017 21:43 Go to previous message
Carsten Tsara is currently offline Carsten TsaraFriend
Messages: 11
Registered: March 2016
Junior Member
I have another problem not connected to the previous one, but also concerning refresh of the editor.
I added drag and drop support. To make it work I've override ItemProviderAdapter.getChildFeature(Object, Object) so that it returns the appropriate feature. So drag and drop works fine, but the editor doesn't refresh after drop operation.
UPD: I fixed this problem by also overriding notifyChanged()

[Updated on: Tue, 03 January 2017 22:07]

Report message to a moderator

Previous Topic:Cross-reference type?
Next Topic:[Xcore] EcorePackage version issue (in Xtext validator)
Goto Forum:
  


Current Time: Tue Apr 16 17:19:34 GMT 2024

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

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

Back to the top