John Doe
John Doe

Reputation: 867

CellTree suggestion - AsyncDataProvider add/remove/update

I have issues with GWT CellTree and at this point, I'm wondering if it's really ready for prime time. Maybe I'm not getting the default use-cases??

Most questions that have seen over the Web so far are related to CRUD operations with a CellTree but using a simple ListDataProvider such as GWT - Add and remove nodes in celltree.

In my case, I'm populating the nodes of a CellTree using an AsyncDataProvider. The nodes are fetched on-demand using a RequestFactory service.

Given a selection, I would like to add child nodes, remove/update the current selection. The GWT TreeViewModel interface is way too basic in my opinion.

From my current understanding, the way to go would be to use a map of DataProviders, keep a reference of the underlying list returned by the remote call and likely a reference to the parent NodeInfo object.

For example to delete the current selection I'd probably do the following:

TreeViewModel model = cellTree.getTreeViewModel();
TreeViewModel.NodeInfo nodeInfo = model.getNodeInfo(selectionFromChangeListener);
CustomNodeInfo parent = ((CustomNodeInfo) nodeInfo).getParent();
parent.getUnderLyingNodeListFromDataProvider().remove(selectionFromChangeListener);
// maybe force refresh using dataProvider???
parent.getDataProvider().refreshDisplayAsInRepopulateData()

Any better suggestion? It looks like it's going to be a challenging task, unless I'm mistaken... It seems a bit overkill though. In Swing it would be very easy to achieve or even in most other Web Frameworks providing Tree widgets.

Would using the default Tree widget and replacing myself the icons with the "loading" image be a more straightforward thing? It looks like the basic Tree allows way more manipulations of nodes as TreeItems.

Upvotes: 2

Views: 1095

Answers (1)

John Doe
John Doe

Reputation: 867

The CellTree widget seems to be based on the original code of FastTree.

The FastTree already have more or less what I need, without some kind of setUserObject method as in a Swing DefaultMutableTreeNode

For spinning icons, someone already investigated it in the past.

I guess that for now, I'll switch from CellTree to a customized version of FastTree and FastTreeItem.

Out of the box ability to have methods such as getParentItem, remove(current node or specific child node)?? Thank you very much sir...

Upvotes: 1

Related Questions