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.Events;
12: import net.mygwt.ui.client.Style;
13: import net.mygwt.ui.client.event.BaseEvent;
14: import net.mygwt.ui.client.event.Listener;
15: import net.mygwt.ui.client.fx.Draggable;
16: import net.mygwt.ui.client.widget.ContentPanel;
17: import net.mygwt.ui.client.widget.Info;
18: import net.mygwt.ui.client.widget.WidgetContainer;
19: import net.mygwt.ui.client.widget.layout.FlowLayout;
20:
21: import com.google.gwt.user.client.ui.HorizontalPanel;
22:
23: public class ContentPanelPage extends Page {
24:
25: protected void createWidget(WidgetContainer container) {
26: Listener listener = new Listener() {
27: public void handleEvent(BaseEvent be) {
28: ContentPanel cp = (ContentPanel) be.widget;
29: String n = cp.getText();
30: if (be.type == Events.Expand) {
31: Info.show("Panel Change",
32: "The '{0}' panel was expanded", n);
33: } else {
34: Info.show("Panel Change",
35: "The '{0}' panel was collapsed", n);
36: }
37: }
38: };
39:
40: final HorizontalPanel vp = new HorizontalPanel();
41: vp.setSpacing(10);
42:
43: ContentPanel cp = new ContentPanel(Style.HEADER,
44: "my-cpanel-small");
45: cp.setWidth(200);
46: cp.setText("With Icon");
47: cp.setIconStyle("icon-text");
48: cp.addText(TestData.DUMMY_TEXT_SHORT);
49: cp.addListener(Events.Expand, listener);
50: cp.addListener(Events.Collapse, listener);
51: vp.add(cp);
52:
53: cp = new ContentPanel(Style.HEADER | Style.COLLAPSE,
54: "my-cpanel-small");
55: cp.setWidth(200);
56: cp.setText("Collapsible");
57: cp.addText(TestData.DUMMY_TEXT_SHORT);
58: cp.addListener(Events.Expand, listener);
59: cp.addListener(Events.Collapse, listener);
60: vp.add(cp);
61:
62: cp = new ContentPanel(Style.HEADER, "my-cpanel-small");
63: cp.setWidth(200);
64:
65: cp.getHeader().setStyleAttribute("cursor", "move");
66: cp.setText("Draggable");
67: cp.addText(TestData.DUMMY_TEXT_SHORT);
68: cp.disableTextSelection(true);
69: vp.add(cp);
70:
71: Draggable d = new Draggable(cp);
72: d.useProxy = false;
73: d.container = container;
74:
75: container.setLayout(new FlowLayout());
76: container.setScrollEnabled(true);
77: container.add(vp);
78: }
79:
80: }
|