Reputation: 2440
I don't know if I understand the Viewer framework exactly. This is an image I think that describes the framework :
.
In my understanding, when we setInput on an object for a Tree, this object is feeded to the ContentProvider. The elements come out from the ContentProvider will be filtered by various filters. After that, the remaining elements will be sorted. Finally, the tree widget will take these elements and display them. Is it correct ?
Upvotes: 1
Views: 186
Reputation: 13984
In my understanding, when we setInput on an object for a Tree, this object is feeded to the ContentProvider. The elements come out from the ContentProvider will be filtered by various filters. After that, the remaining elements will be sorted. Finally, the tree widget will take these elements and display them. Is it correct ?
Yes it is correct.
Explanation
A viewer never directly talks to the data/domain objects. For example, the TreeViewer doesn't talk to the domain objects directly. Instead, it uses another object called a ContentProvider, and this object uses your domain objects.
Just as there is a content provider object that gets the children of the tree nodes, when it comes to actually displaying the nodes, the tree viewer has another helper object: the label provider.
Similarly in order to handle tables, JFace has a TableViewer. Just like the TreeViewer, it has an input (a root object), a content provider, and a label provider. It's simpler than the tree viewer since it doesn't need to deal with trees.
Now if you look at the default TreeViwer implementation then you will find that in the createChildren()
method (which is called on expansion of a node) there is a call to getSortedChildren()
, which basically applies all the filters on the provided input (and on demand i.e. when the node is expanded) and finally applies the sorter that you have provided. Once all this is done the label provider will come into picture.
Links:
Upvotes: 1