View Full Version : Cannot really extend TreeTable

2 May 2008, 12:02 PM
I'm using 0.5.2, but from a quick glance at the beta 2 source, these issues still exist...

Basically, the way the class is structured makes it look extensible, but in reality it's not :(

Specifically in the TreeTable class:
* createRootItme() is protected, which is great! However, it creates a RootTreeTableItem, which is package local. This means that in order to tweak the root item, I have to copy the complete implementation into my own class.
* onRender() has a hard-coded cast of "root" to RootTreeTableItem. So, I can create my own root item, but since I cannot extend RootTreeTableItem, I get a ClassCastException here.I readily admit that I don't know if there are unintended consequences to what I'm going to propose, so please...if there are, I'm ready to be educated!

I'd like to recommend:
* RootTreeTableItem become an interface, which you are free to implement as you see fit, and I can too :).
* Rename the existing RootTreeTableItem class (obviously :) ) and make it public.
* Change the TreeTable::onRender root member to be of type RootTreeTableItem (the new interface).Now, there are a few other issues that prevent extending TreeTable... Specifically, there are a number of members which are private, rather than protected. This could be OK, if (for example) there are overridable methods for creating them and accessors for accessing them.

Thanks for your great work on this MUCH needed toolkit!


4 May 2008, 7:34 PM
You raise some valid points. TreeTable is one of the last remaining components that needs to be reworked a little. This will be happening soon and we will make sure your comments are addressed. The changes should go out in the next rev.

14 May 2008, 10:23 PM
I have made these changes:

1. RootTreeTableItem is now public
2. Most of the fields in TreeTable, TreeTableItem, and TreeTableViewer are now protected

You should be able to customize as needed. Let me know if you run into any other issues. Changes are in SVN.