[DataBinding] Deletion in model not shown in Treeviewer when bound [message #312928] |
Mon, 26 February 2007 04:56  |
Eclipse User |
|
|
|
Problem:
--------
I am binding to a TreeViewer using the UnorderedTreeContentProvider and
when I delete a child in the model, this isn't shown in the bounded
TreeViewer. I am using the source code that is currently in cvs for
databinding.
Investigation:
------------
After investigation, I think that the UnorderedTreeContentProvider.remove
method is calling the wrong remove method in TreeViewer. This is what
brought me to that conclusion.
This is the signature of the UnorderedTreeContentProvider.remove method
void remove(Object element, Set removals, boolean lastElement)
it is called from the class UnorderedTreeNode class in 3 places, in each
place the first parameter is a TreePath object.
(1) handleStateChanged(StaleEvent) contentProvider.remove(treePath,
removals, children.isEmpty() && !hasPendingNode);
(2) handleStale(StaleEvent): contentProvider.remove(treePath,
Collections.singleton(contentProvider.getPendingNode()), true);
(3) dispose(): contentProvider.remove(treePath, children, true);
The first parameter in UnorderedTreeContentProvider.remove method (the
TreePath object) is then used as the "parent" parameter for the
TreeViewer.remove method with this signature
public void remove(final Object parent, final Object[] elements)
However, that method should not have the TreePath as the parent, it should
have the actual parent object. There is another "remove" method in
TreeViewer that should be used for TreePaths:
public void remove(Object elementsOrTreePaths).
Conclusion:
-----------
Solution could be found by
(a) change the object being passed as the first parameter to the
UnorderedTreeContentProvider.remove method in (1), (2) (3)
(b) call the other TreeViewer remove method for TreePaths in the
UnorderedTreeContentProvider.remove method
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04005 seconds