jabal
jabal

Reputation: 12367

How to access the object hierarchy shown by a GWT CellTree from a custom SelectionEventManager?

I'd like to make a custom CellTree that would use checkbox based cells (I would like to use tristate checkboxes so will have to write a custom cell). I would like to make the parent node selection to select all its children and also if all children is selected then the parent node's checkbox should become selected too. If not all children are selected only some of them, then the parent checkbox should be in the so called "third state".

To achieve this I made a custom public class TriStateSelectionEventManager extends DefaultSelectionEventManager<TopologyNodeRep> and wanted to override its

public void doMultiSelection(MultiSelectionModel<? super TopologyNodeRep> selectionModel,
                                 HasData<TopologyNodeRep> display,
                                 int row,
                                 TopologyNodeRep rowValue,
                                 DefaultSelectionEventManager.SelectAction action,
                                 boolean selectRange,
                                 boolean clearOthers)

method. I thought this is the most appropriate way to implement this requirement. My problem is that from this method I cannot access the tree data. The received display object contains all the necessary information, but it cannot be accessed as it is a CellTreeNodeView.NodeCellList instance that is a private inner class of a package access class.. :-(

Do you have any idea how to implement this requirement in GWT?

Upvotes: 1

Views: 295

Answers (1)

&#220;mit
&#220;mit

Reputation: 17499

Does your TopologyNodeRep class have references to its childs and parents respectively? In case it does you could retrieve the childs of a specific selected TopologyNodeRep instance and also select its childs automatically. Something like this:

List<TopologyNodeRep> childs = rowValue.getChilds();
for (TopologyNodeRep child: childs) {
    selectionModel.setSelected(child,true);
}

Upvotes: 1

Related Questions