javaeclipseswtjfacetreeviewer

How do you get a TreeViewer in SWT to refresh properly?


I have an app that uses a JFace TreeViewer. I have it hooked up to a ContentProvider. Mostly, it works great. However, for some actions, like adding a Node in the middle of a list of Nodes or changing a value which should change the label for a Node, the refresh() call doesn't work. I've tried including the parent Node, say "true" for label update. Nothing works all the time.

I have seen that if I leave a collapsible Node closed and add and then expand, the added Node is shown. But if it's already expanded, no change is shown. If I save my tree info to disk and look, the change is made. It's just the TreeViewer refresh that is not working.

I looked at the inputChanged method in my ContentProvider, but it is only called at the beginning and end of my app execution.

Can anyone help? I've read all the web pages that even hint at an answer and nothing has worked.


Solution

  • Unfortunately, nothing I could find resolved this. I ended up closing the file and reopening it to force a "refresh/update". Thanks all for the advice.