Hi all,

I am using the CellTree to add and remove nodes (on the same level,
only a list of nodes).
But I've encountered an exception when attempting to remove the last
node of the CellTree :

Uncaught JavaScript exception [uncaught exception:
java.lang.AssertionError: Child index out of bounds] in , line 0

Here is my code ;

public class Test extends Composite {
    private static TestUiBinder uiBinder =
GWT.create(TestUiBinder.class);

    interface TestUiBinder extends UiBinder<Widget, Test> {
    }

    @UiField(provided = true)
    CellTree rightTree;

    @UiField
    PushButton removeEntity;

    private SingleSelectionModel<EntiteDTO> rightTreeSelectionModel;
    private TreeViewModel rightTreeModel;
    private ListDataProvider<EntiteDTO> rightTreeProvider;

    public Test() {
        init();
    }

    public void init() {
        createRightTree();
        initWidget(uiBinder.createAndBindUi(this));
    }

    @UiHandler("removeEntity")
    public void onRemoveEntityClick(ClickEvent event) {
        EntiteDTO entSelected =
rightTreeSelectionModel.getSelectedObject();

        Iterator<EntiteDTO> ite =
rightTreeProvider.getList().iterator();
        while (ite.hasNext()) {
            EntiteDTO ent = ite.next();
            if (ent.getId().equals(entSelected.getId())) {
                ite.remove();
            }
        }
        rightTreeProvider.refresh();
    }

    private void createRightTree() {
        CellTree.Resources res =
GWT.create(CellTree.BasicResources.class);

        rightTreeSelectionModel = new
SingleSelectionModel<EntiteDTO>();

        rightTreeProvider = new ListDataProvider<EntiteDTO>();
        rightTreeModel = new TreeViewModel() {

            @Override
            public boolean isLeaf(Object value) {
                if (value == null) {
                    return false;
                }
                return true;
            }

            @Override
            public <T> NodeInfo<?> getNodeInfo(T value) {
                return new
DefaultNodeInfo<EntiteDTO>(rightTreeProvider, new FolderEntityCell(),
                        rightTreeSelectionModel, null);
            }
        };

        rightTree = new CellTree(rightTreeModel, null, res);
        rightTree.setAnimationEnabled(true);
    }


}

The FolderEntityCell is a cell with icon, and EntiteDTO just some
POJO.

So I added some nodes to the rightTree with
rightTreeProvider.getList().add(...) on the first level.

I can remove these nodes by clicking on the removeEntity PushButton,
but when I want to remove the last one, it is removed on the browser,
but a java.lang.AssertionError occur :

Uncaught JavaScript exception [uncaught exception:
java.lang.AssertionError: Child index out of bounds] in , line 0

So I'm wondering if I do something wrong in my removal process.

I hope you can help me on this point, and thank you in advance.

Cheers.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to