Hi,

I have serveral classes that extend from a baseclass. I display them in a 
CellTree.
Now, if a specific class (Cat) is displayed, I want this class to have 
subentries. Similar to:

Dog1
Dog2
Cat1
 - Age Cat1
Dog3
Dog4


How can I achieve this??

class Animal {
    //every animal gets a name
    String name;
}

class Dog extends Animal {}

class cat extends Animal {
    //only cat shall have an age
    int age;
}

//data provider will be set in onLoadModule()
private final ListDataProvider<Animal> animals = new 
ListDataProvider<Animal>();

//the view model
class AnimalModel implements TreeViewModel {

    @Override
    public <T> NodeInfo<?> getNodeInfo(T value) {
        List<HasCell<Animal, ?>> hasCells = new ArrayList<HasCell<Animal, 
?>>();

        hasCells.add(new HasCell<Animal, Animal>() {
            private AnimalCell cell = new AnimalCell();
        
        }


        if (value instanceOf Cat) {
            //what do I have to do in order to display subentries only for 
cats??
        }

        return new DefaultNodeInfo<Animal>(animals, new 
CompositeCell<Animal>(hasCells));
    }
}


//renderer for parent items like "Dog1", "Cat1"...
class AnimalCell extends AbstractCell<Port> {

    @Override
    public void render(Context context, Animal animal, SafeHtmlBuilder sb) {
        sb.appendEscaped(animal.getName());
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/QG468QIvJpQJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to