CellList with cells of CellTree

368 Views Asked by At

I used the gwt CellList example to implement a cell-based listbox. It used TextCell cells to represent the data, as it was just text, and worked perfectly.

Now I have to extend this list to include elements of type "tree" (I mean that you can click on some element of the list, and if it's not a leaf, it is opened and displays the information of its children). So I've implemented a CellTree-based widget. (CellTree)

My problem is that I don't know how to insert items of type "tree", which are really CellTrees, into my CellList.

The only approach I could imagine was to create a new type of cell that represents the CellTree, extending "AbstractCell", and use it as the CellList items.

My implementation is:

private class TreeCell extends AbstractCell<CellTreeListBox> {

    public TreeCell() {}

    @Override
    public void render(Context context, CellTreeListBox value,
        SafeHtmlBuilder sb)
    {
      sb.appendEscaped(value.getElement().getInnerHTML());
    }
}

This, once included in a CellList, displays only the root nodes, but when I click on them they don't get opened! so this approach doesn't keep the events neither the functionality of the selectionModel...

So I don't know if it's possible to implement a cell that represents a whole CellTree, and keeps its events and functionalities (if you click, the node is opened and information of its children is displayed, etc...).

I'd really appreciate any information about this!

1

There are 1 best solutions below

3
On BEST ANSWER

You should replace your CellList with a CellTree.

Either that or replacing the CellList with some container panel (FlowPanel, VerticalPanel) in which you'd (manually) put widgets (Labels, or possibly CellWidget with a TextCell), and insert your CellTree in between them to show it. You'd then lose the other features of cell widgets though: SelectionModel, paging, etc.

In any case, ditch your CellList. You cannot embed widgets inside cell widgets.