Many-valued references in EMF [message #1751069] |
Wed, 04 January 2017 04:48  |
Eclipse User |
|
|
|
In a model I have an object with a reference which is multiplicity-many and is not containment. And currently I'm struggling with some operations.
First, I need to override getParent() in ItemProvider for drag and drop operations. Default implementation returns actual container of the referenced object, but what I really need is to get somehow EObject which holds the list of references.
My structure is similar to this
Container1
-- MyObject1
Container2
-- MyObject2
Item1
-- Ref MyObject1
-- Ref MyObject2
Item2
-- Ref MyObject1
Item3
-- Ref MyObject2
so I have method in Item class EList<MyObject> getMyObjects(). In the UI I display only Items and references to MyObjects. And I'm struggling to get Item object for MyObject inside getParent()
|
|
|
Re: Many-valued references in EMF [message #1751077 is a reply to message #1751069] |
Wed, 04 January 2017 05:23   |
Eclipse User |
|
|
|
You can override org.eclipse.emf.edit.provider.ItemProviderAdapter.isWrappingNeeded(Object) to always return true. In that case, org.eclipse.emf.edit.provider.ItemProviderAdapter.createWrapper(EObject, EStructuralFeature, Object, int) will be called and will hit:
else if (!((EReference)feature).isContainment())
{
value = new DelegatingWrapperItemProvider(value, object, feature, index, adapterFactory);
} And that will ensure that the wrapper knows the parent, but otherwise delegates to the item provider of the value for labels, children, and properties. After all, such a referenced "child" could appear more than once in the tree, so the wrapper ensures each occurrence knows the parent under which it is being shown in the tree.
|
|
|
|
|
|
|
Re: Many-valued references in EMF [message #1751831 is a reply to message #1751826] |
Sun, 15 January 2017 13:43  |
Eclipse User |
|
|
|
Sorry, but I'm not sure how that relates to this thread. I assume there's no null pointer exception involved.
If there is a problem, I'll need to reproduce it. How might I reproduce the problem you're seeing?
|
|
|
Powered by
FUDForum. Page generated in 0.07655 seconds