0

how to refresh 2 nodes at different level in JFaceTree viewer in one go

If we assume, A is one root and B another root, then somewhere down under A, we have C and the same C gets listed somewhere down under B.

Now I want to refresh node C at both places in one go

user1328572
  • 599
  • 1
  • 7
  • 12

1 Answers1

0

Just call TreeViewer.refresh(Object) on each of the C nodes. The tree is not actually refreshed until the next time the main dispatch loop is run so these updates will appear in one go.

Note: If the C objects appear to TreeViewer to be the same object (equals returns true and the hashCode is the same) you may have trouble with the refresh. Don't use the same object in different places in the tree or if this is unavoidable use an IElementComparer to let the tree viewer distinguish between the objects.

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • I have tried refresh(item), however issue is, I get only one item from the structured selection and i can take refresh on that item only. How do we get all the instances of C objects ?, I tried _IElementComparer_ however it did not help.Could you give any example link of IElementComparer – user1328572 Jun 15 '16 at 09:46
  • I can't tell you how to find all the C objects since I don't know what your data model is like. You are providing all these objects in your content provider so you should be able to do something there. IElementComparer does not help with finding objects. – greg-449 Jun 15 '16 at 09:50