01: /*
02: * MyGWT Widget Library
03: * Copyright(c) 2007, MyGWT.
04: * licensing@mygwt.net
05: *
06: * http://mygwt.net/license
07: */
08: package net.mygwt.samples.explorer.client;
09:
10: import net.mygwt.samples.resources.client.TestData;
11: import net.mygwt.ui.client.Style;
12: import net.mygwt.ui.client.event.BaseEvent;
13: import net.mygwt.ui.client.event.SelectionListener;
14: import net.mygwt.ui.client.util.TreeBuilder;
15: import net.mygwt.ui.client.widget.Button;
16: import net.mygwt.ui.client.widget.ButtonBar;
17: import net.mygwt.ui.client.widget.WidgetContainer;
18: import net.mygwt.ui.client.widget.layout.FlowLayout;
19: import net.mygwt.ui.client.widget.tree.Tree;
20:
21: import com.google.gwt.user.client.ui.VerticalPanel;
22:
23: public class TreePage extends Page {
24:
25: protected void createWidget(WidgetContainer container) {
26: final Tree tree = new Tree(Style.SINGLE);
27: tree.setItemImageStyle("icon-music");
28:
29: // quick way to build tree from Model instances.
30: TreeBuilder.buildTree(tree, TestData.getTreeModel());
31:
32: ButtonBar buttonBar = new ButtonBar(Style.LEFT);
33: buttonBar.add(new Button("Expand All", new SelectionListener() {
34: public void widgetSelected(BaseEvent be) {
35: tree.expandAll();
36: }
37: }));
38: buttonBar.add(new Button("Collapse All",
39: new SelectionListener() {
40: public void widgetSelected(BaseEvent be) {
41: tree.collapseAll();
42: }
43: }));
44:
45: VerticalPanel vp = new VerticalPanel();
46: vp.setSpacing(10);
47:
48: vp.add(buttonBar);
49: vp.add(tree);
50:
51: container.setLayout(new FlowLayout());
52: container.add(vp);
53:
54: }
55: }
|