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.ui.client.Events;
011: import net.mygwt.ui.client.Style;
012: import net.mygwt.ui.client.event.BaseEvent;
013: import net.mygwt.ui.client.event.Listener;
014: import net.mygwt.ui.client.event.SelectionListener;
015: import net.mygwt.ui.client.widget.Button;
016: import net.mygwt.ui.client.widget.ContentPanel;
017: import net.mygwt.ui.client.widget.Dialog;
018: import net.mygwt.ui.client.widget.Info;
019: import net.mygwt.ui.client.widget.WidgetContainer;
020: import net.mygwt.ui.client.widget.layout.BorderLayout;
021: import net.mygwt.ui.client.widget.layout.BorderLayoutData;
022:
023: import com.google.gwt.user.client.ui.HorizontalPanel;
024:
025: public class DialogPage extends Page {
026:
027: protected void createWidget(WidgetContainer container) {
028: final Dialog dialog = new Dialog(Style.YES_NO | Style.CLOSE);
029: dialog.setCloseOnButtonClick(true);
030: dialog.setText("Dialog");
031: dialog.addListener(Events.Close, new Listener() {
032:
033: public void handleEvent(BaseEvent be) {
034: Button btn = dialog.getButtonPressed();
035: if (btn != null) {
036: Info.show("Button Pressed", "The {0} was pressed.",
037: btn.getText());
038: }
039: }
040:
041: });
042: dialog.getContent().setHeight(50);
043: dialog.getContent()
044: .addText("This is the dialogs content area.");
045:
046: final Dialog complex = new Dialog(Style.OK | Style.CLOSE
047: | Style.RESIZE);
048: complex.setMinimumSize(300, 200);
049: complex.addStyleName("my-shell-plain");
050: complex.setText("Nested BorderLayout");
051: complex.addListener(Events.Close, new Listener() {
052:
053: public void handleEvent(BaseEvent be) {
054: Button btn = complex.getButtonPressed();
055: if (btn != null) {
056: Info.show("Button Pressed", "The {0} was pressed.",
057: btn.getText());
058: }
059: }
060:
061: });
062:
063: BorderLayout layout = new BorderLayout();
064: layout.setMargin(0);
065:
066: WidgetContainer c = complex.getContent();
067: c.setBorders(false);
068: c.setLayout(layout);
069:
070: ContentPanel west = new ContentPanel(Style.HEADER);
071: west.setText("West");
072:
073: ContentPanel center = new ContentPanel(Style.HEADER);
074: center.setText("Center");
075:
076: c.add(west, new BorderLayoutData(Style.WEST, 125, 100, 300));
077: c.add(center, new BorderLayoutData(Style.CENTER));
078:
079: complex.setSize(375, 250);
080:
081: HorizontalPanel hp = new HorizontalPanel();
082: hp.setSpacing(10);
083:
084: hp.add(new Button("Basic", new SelectionListener() {
085: public void widgetSelected(BaseEvent be) {
086: dialog.open();
087: }
088: }));
089:
090: hp.add(new Button("Complex", new SelectionListener() {
091: public void widgetSelected(BaseEvent be) {
092: complex.open();
093: }
094: }));
095:
096: container.add(hp);
097:
098: }
099:
100: }
|