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);
}
});
}
});