001: /*
002: * MyGWT Widget Library
003: * Copyright(c) 2007, MyGWT.
004: * licensing@mygwt.net
005: *
006: * http://mygwt.net/license
007: */
008: package net.mygwt.samples.explorer.client;
009:
010: import net.mygwt.samples.resources.client.TestData;
011: import net.mygwt.ui.client.Style;
012: import net.mygwt.ui.client.event.BaseEvent;
013: import net.mygwt.ui.client.event.SelectionListener;
014: import net.mygwt.ui.client.event.ShellListener;
015: import net.mygwt.ui.client.widget.Button;
016: import net.mygwt.ui.client.widget.ButtonBar;
017: import net.mygwt.ui.client.widget.Info;
018: import net.mygwt.ui.client.widget.Shell;
019: import net.mygwt.ui.client.widget.ShellManager;
020: import net.mygwt.ui.client.widget.TabFolder;
021: import net.mygwt.ui.client.widget.TabItem;
022: import net.mygwt.ui.client.widget.WidgetContainer;
023: import net.mygwt.ui.client.widget.layout.FillLayout;
024: import net.mygwt.ui.client.widget.layout.FlowLayout;
025:
026: import com.google.gwt.user.client.ui.TextBox;
027: import com.google.gwt.user.client.ui.VerticalPanel;
028:
029: public class ShellPage extends Page {
030:
031: protected void createWidget(WidgetContainer container) {
032: ShellListener listener = new ShellListener() {
033:
034: public void shellDeactivated(BaseEvent be) {
035: Shell s = (Shell) be.widget;
036: Info.show("Shell Event",
037: "The '{0}' shell was deativated", s.getText());
038: }
039:
040: public void shellClosed(BaseEvent be) {
041: Shell s = (Shell) be.widget;
042: Info.show("Shell Event", "The '{0}' shell was closed",
043: s.getText());
044: }
045:
046: public void shellActivated(BaseEvent be) {
047: Shell s = (Shell) be.widget;
048: Info.show("Shell Event",
049: "The '{0}' shell was activated", s.getText());
050: }
051:
052: };
053:
054: final Shell shell = new Shell(Style.CLOSE);
055: shell.setText("Basic");
056: // need to give explicit height so content will scroll
057: shell.setHeight(125);
058: shell.addShellListener(listener);
059: WidgetContainer content = shell.getContent();
060: content.setLayout(new FlowLayout());
061: content.setScrollEnabled(true);
062: content.addText(TestData.DUMMY_TEXT_LONG);
063:
064: final Shell close = new Shell(Style.CLOSE | Style.RESIZE);
065: close.setPagePosition(50, 50);
066: close.setText("Resize");
067: close.addShellListener(listener);
068:
069: WidgetContainer wc = close.getContent();
070: VerticalPanel vp = new VerticalPanel();
071: vp.setSpacing(8);
072: vp.add(new TextBox());
073: wc.add(vp);
074:
075: final Shell modal = new Shell(Style.CLOSE | Style.MODAL);
076: modal.setText("Modal Shell");
077: modal.addShellListener(listener);
078:
079: final Shell tabShell = new Shell(Style.RESIZE | Style.CLOSE);
080: tabShell.setSize(400, 300);
081: tabShell.setIconStyle("icon-text");
082: tabShell.setText("Nested TabFolder");
083: tabShell.addShellListener(listener);
084:
085: TabFolder tabFolder = new TabFolder(Style.NONE);
086: tabFolder.setBorders(false);
087: TabItem item = new TabItem(Style.NONE);
088: item.setText("Tab Item 1");
089: item.getContainer().setScrollEnabled(true);
090: item.getContainer().addText(TestData.DUMMY_TEXT_LONG);
091: tabFolder.add(item);
092:
093: tabFolder.setSelection(item);
094:
095: item = new TabItem(Style.NONE);
096: item.setText("Tab Item 2");
097: tabFolder.add(item);
098:
099: WidgetContainer c = tabShell.getContent();
100: c.setLayout(new FillLayout());
101: c.add(tabFolder);
102:
103: ButtonBar buttons = new ButtonBar();
104: buttons.add(new Button("Basic", new SelectionListener() {
105: public void widgetSelected(BaseEvent be) {
106: shell.open();
107: }
108: }));
109: buttons.add(new Button("Resize", new SelectionListener() {
110: public void widgetSelected(BaseEvent be) {
111: close.open();
112: }
113: }));
114: buttons.add(new Button("Modal", new SelectionListener() {
115: public void widgetSelected(BaseEvent be) {
116: modal.open();
117: // you can alter the size when visible
118: modal.setHeight(200);
119: modal.center();
120: }
121: }));
122: buttons.add(new Button("Complex", new SelectionListener() {
123: public void widgetSelected(BaseEvent be) {
124: tabShell.open();
125: }
126: }));
127:
128: buttons.add(new Button("Close Open", new SelectionListener() {
129: public void widgetSelected(BaseEvent be) {
130: ShellManager.get().closeAll();
131: }
132: }));
133:
134: container.setLayout(new FlowLayout(10));
135: container.add(buttons);
136: }
137:
138: }
|