You have two options, but first its important to point out that "leaf" is not the same as "empty". If you have a folder that may or may not have children, TreeViewModel#isLeaf() should return false, meaning that the node is not a leaf. When the user opens thenode, one of the following can happen.
- You return a DataProvider with some data, in which case the children are rendered
- You return a DataProvider without data, in which case the node "opens", but a message is displayed that the node is empty
- You return a null NodeInfo, in which case the node is treated as a leaf
In the second option, you can still push data (such as the first child) to the node, and it will render them. For example, if you return an empty ListDataProvider, then add items to the underlying list, the nodes will show up. If you use the other two options, you need to rerender the parent nodes so that the Tree will call TreeViewModel#isLeaf() again.
There is no correct answer; its just a matter of user interaction. You can consider a folder to be a leaf, in which case it cannot be opened (no open icon). Or, you can consider a folder to be a non-leaf even if it is empty. Note that at the moment, the "no data" message is fixed, but we can probably make that a Cell so you could add a button such as "Create New Folder".
Thanks,
John LaBanca
jlab...@google.com