Package org.gwtoolbox.sample.widget.client.popup

Source Code of org.gwtoolbox.sample.widget.client.popup.MessageBoxSample

package org.gwtoolbox.sample.widget.client.popup;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import org.gwtoolbox.commons.ui.client.ggrowl.GGrowl;
import org.gwtoolbox.ioc.core.client.annotation.Component;
import org.gwtoolbox.sample.widget.client.SamplePanel;
import org.gwtoolbox.widget.client.button.SimpleButton;
import org.gwtoolbox.widget.client.notification.NotificationType;
import org.gwtoolbox.widget.client.popup.dialog.MessageBox;

/**
* @author Uri Boness
*/
@Component
@PopupSample
public class MessageBoxSample extends Composite implements SamplePanel {

    public MessageBoxSample() {
        HorizontalPanel buttons = new HorizontalPanel();
        buttons.setSpacing(4);

        SimpleButton button = new SimpleButton("Show Error");
        button.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                String title = "The Error";
                String message = "This is the content of the message and it's very long to see how it copes with it";
                MessageBox.show(NotificationType.ERROR, MessageBox.OptionType.OK, title, message, new MessageBox.OptionCallback() {
                    public void handle(MessageBox.Button button) {
                        GGrowl.showMessage("Continue Logic", "");
                    }
                });
            }
        });
        buttons.add(button);

        button = new SimpleButton("Show Warning");
        button.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                String title = "The Warning";
                String message = "This is the content of the message and it's very long to see how it copes with it";
                MessageBox.show(NotificationType.WARNING, MessageBox.OptionType.OK, title, message, new MessageBox.OptionCallback() {
                    public void handle(MessageBox.Button button) {
                        GGrowl.showMessage("Continue Logic", "");
                    }
                });
            }
        });
        buttons.add(button);

        button = new SimpleButton("Show Tip");
        button.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                String title = "The Tip";
                String message = "This is the content of the message and it's very long to see how it copes with it";
                MessageBox.show(NotificationType.TIP, MessageBox.OptionType.OK, title, message, new MessageBox.OptionCallback() {
                    public void handle(MessageBox.Button button) {
                        GGrowl.showMessage("Continue Logic", "");
                    }
                });
            }
        });
        buttons.add(button);

        button = new SimpleButton("Show Message");
        button.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                String title = "The Message";
                String message = "This is the content of the message and it's very long to see how it copes with it";
                MessageBox.show(NotificationType.MESSAGE, MessageBox.OptionType.OK, title, message, new MessageBox.OptionCallback() {
                    public void handle(MessageBox.Button button) {
                        GGrowl.showMessage("Continue Logic", "");
                    }
                });
            }
        });
        buttons.add(button);

        button = new SimpleButton("Confirm");
        button.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                String title = "Please Confirm";
                String message = "This is the content of the message and it's very long to see how it copes with it";
                MessageBox.show(NotificationType.MESSAGE, MessageBox.OptionType.OK_CANCEL, title, message, new MessageBox.OptionCallback() {
                    public void handle(MessageBox.Button button) {
                        String text = button == MessageBox.Button.OK ? "The user agreed" : "The user disagreed";
                        GGrowl.showMessage("Confirmation", text);
                    }
                });
            }
        });
        buttons.add(button);

        button = new SimpleButton("Yes/No/Cancel");
        button.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                String title = "Please Confirm";
                String message = "This is the content of the message and it's very long to see how it copes with it";
                MessageBox.show(NotificationType.MESSAGE, MessageBox.OptionType.YES_NO_CANCEL, title, message, new MessageBox.OptionCallback() {
                    public void handle(MessageBox.Button button) {
                        String text = button.name();
                        GGrowl.showMessage("Confirmation", text);
                    }
                });
            }
        });
        buttons.add(button);

        SimplePanel main = new SimplePanel();
        main.setWidget(buttons);

        initWidget(main);
    }

    public String getName() {
        return "Message Boxes";
    }

    public Widget getContentWidget() {
        return this;
    }

    public void reset() {
    }
}
TOP

Related Classes of org.gwtoolbox.sample.widget.client.popup.MessageBoxSample

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.