I try to display a tree with BaseTreeModel

==================================================
In my entry point :

RootPanel.get().add(new TreeTestModel());

==================================================
My TreeTestModel :

public class TreeTestModel extends LayoutContainer {

        @Override
        protected void onRender(Element parent, int pos) {
                super.onRender(parent, pos);

                myClass model = TreeTestData.getTreeModel();

                TreeStore<ModelData> store = new TreeStore<ModelData>();
                store.add(model.getChildren(), true);

                final TreePanel<ModelData> tree = new 
TreePanel<ModelData>(store);
                tree.setWidth(300);
                tree.setDisplayProperty("name");

                ButtonBar buttonBar = new ButtonBar();

                buttonBar.add(new Button("Expand All", new
SelectionListener<ButtonEvent>() {
                        public void componentSelected(ButtonEvent ce) {
                                tree.expandAll();
                        }
                }));

                buttonBar.add(new Button("Collapse All", new
SelectionListener<ButtonEvent>() {
                        public void componentSelected(ButtonEvent ce) {
                                tree.collapseAll();
                        }
                }));

                add(buttonBar, new FlowData(10));
                add(tree, new FlowData(10));
        }
}

==================================================
My model :

public class myClass extends BaseTreeModel implements Serializable {

        private static final long serialVersionUID = 1L;

        private static int ID = 0;

        public myClass() {
                set("id", ID++);
        }

        public myClass(String name) {
                set("id", ID++);
                set("name", name);
        }

        public myClass(String name, BaseTreeModel[] children) {
                this(name);
                for (int i = 0; i < children.length; i++) {
                        add(children[i]);
                }
        }

        public Integer getId() {
                return (Integer) get("id");
        }

        public String getName() {
                return (String) get("name");
        }

        public String toString() {
                return getName();
        }
}

==================================================
And the implementation :

public class TreeTestData {

        public static myClass getTreeModel() {
                myClass[] datas = new myClass[] {
                        new myClass("ClassA"),
                        new myClass("ClassB"),
                        new myClass("ClassC")
                };

                OntoClass root = new OntoClass("root", datas);

            return root;
        }
}

==================================================
When I test my page, only buttons are displayed but none tree.
If I click on buttons, nothing happens. Can somebody help me please ?
Thanks.

-- 
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-tool...@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