Customize refresh of the editor based on EMF.Edit [message #1750914] |
Sun, 01 January 2017 16:13 |
Carsten Tsara 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 |
Ed Merks Messages: 33142 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 #1751049 is a reply to message #1750929] |
Tue, 03 January 2017 21:43 |
Carsten Tsara 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
|
|
|
Powered by
FUDForum. Page generated in 0.03107 seconds