Wednesday, October 28, 2015

Re: CellTree only expands on clicking icon

W dniu poniedziałek, 26 października 2015 15:24:54 UTC+1 użytkownik Jaron Shulver napisał:

I want to have a CellTree which expands when you click anywhere on the cell, not just on the icon.

I've found this in my project, but I don't remember even how it works:).
Especially curious is why did I use package, probably  I needed to override some protect method.


import java.util.ArrayList;


public class MyCellTree extends CellTree {

    public MyCellTree(TreeViewModel model, Object object,
            Resources myresources, CellTreeMessages messages, int i) {
        super(model, object, myresources, messages, i);

    public void onBrowserEvent(Event event) {
        String eventType = event.getType();

        final boolean isMouseDown = BrowserEvents.MOUSEDOWN.equals(eventType);
        if (isMouseDown)
            final Element target = event.getEventTarget().cast();
            ArrayList<Element> chain = new ArrayList<Element>();
            collectElementChain2(chain, getElement(), target);
            CellTreeNodeView<?> nodeView = findItemByChain2(chain, 0, rootNode);
            if (nodeView != null)
                if (!nodeView.isRootNode() && ! nodeView.getImageElement().isOrHasChild(target))
                    nodeView.setOpen(!nodeView.isOpen(), true);


        private void collectElementChain2(ArrayList<Element> chain, Element hRoot,
                  Element hElem) {
                if ((hElem == null) || (hElem == hRoot)) {

                collectElementChain2(chain, hRoot, hElem.getParentElement());

        private CellTreeNodeView<?> findItemByChain2(ArrayList<Element> chain,
                  int idx, CellTreeNodeView<?> parent) {
                if (idx == chain.size()) {
                  return parent;

                Element hCurElem = chain.get(idx);
                for (int i = 0, n = parent.getChildCount(); i < n; ++i) {
                  CellTreeNodeView<?> child = parent.getChildNode(i);
                  if (child.getElement() == hCurElem) {
                    CellTreeNodeView<?> retItem = findItemByChain2(chain, idx + 1, child);
                    if (retItem == null) {
                      return child;
                    return retItem;

                return findItemByChain2(chain, idx + 1, parent);


You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment