Updating Only Visible Elements in JFace TreeViewer

I implemented an Eclipse plugin that displays data in a TreeViewer.

The tree structure is read at initialization and does not change at run time. A is LabelProviderused to display data for each item. This object does this by reading from our equipment. Reading the value may take some time (~ 0.5 sec). Values ​​are updated every time the debugger is paused and every time the user clicks the Refresh button.

I have many elements and subelements, so reading all the values ​​at once takes too much time. Therefore, I only want to read the data of the elements that are visible to the user.

I tried to use it ILazyTreeContentProvider, but it only saves time when loading the tree: After scrolling or expanding the TreeItem, visible elements are added to the list of elements to update instead of replacing invisible nodes.

How can i do this?

+3
source share
1 answer

Found it!

I am still using ILazyTreeContentProvider. Every time the debugger stops or the refresh button is clicked, instead of checking which item is being updated, I just delete all the items with tree.clearAll(true). Removing it will cause it ILazyTreeContentProviderto do its work again only for visible elements.

+1
source

Source: https://habr.com/ru/post/1784526/


All Articles