row = 0;
layout = new PFlexTable();
addLabel("Show a basic popup");
final PButton anchor2 = addButton("Open");
anchor2.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent clickEvent) {
final PPopupPanel popupPanel = new PPopupPanel();
final PVerticalPanel content = new PVerticalPanel();
final PButton closeButton = new PButton("Close");
closeButton.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent clickEvent) {
popupPanel.hide();
}
});
content.add(new PLabel("A popup displayed relatively to the mouse click"));
content.add(closeButton);
content.setWidth("200px");
content.setHeight("200px");
popupPanel.setWidget(content);
popupPanel.setPopupPosition(clickEvent.getClientX(), clickEvent.getClientY());
popupPanel.show();
}
});
addLabel("A draggable popup");
final PButton anchor3 = addButton("Open");
anchor3.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent clickEvent) {
final PClosableDialogBox dialogBox = new PClosableDialogBox("Custom caption");
dialogBox.setDraggable(true);
dialogBox.setContent(new PLabel("Content of a popup"));
dialogBox.center();
}
});
addLabel("A confirm dialog listenening on the close event");
final PButton anchor4 = addButton("Open");
anchor4.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent clickEvent) {
final POptionPane dialodBox = POptionPane.showConfirmDialog(new PActionHandler() {
@Override
public void onAction(final PDialogBox dialogBox, final String option) {
dialogBox.hide();
}
}, "Your custom text");
dialodBox.getDialogBox().addCloseHandler(new PCloseHandler() {
@Override
public void onClose(final PCloseEvent closeEvent) {
final DemoBusinessEvent event = new DemoBusinessEvent(this);
event.setBusinessMessage("Dialog box closed");
fireEvent(event);
}
});
}
});
addLabel("A confirm dialog listenening on the close event");
final PButton anchor5 = addButton("Open");
anchor5.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent clickEvent) {
POptionPane.showConfirmDialog(new PActionHandler() {
@Override
public void onAction(final PDialogBox dialogBox, final String option) {
dialogBox.hide();
final DemoBusinessEvent event = new DemoBusinessEvent(this);
event.setBusinessMessage("Option selected #" + option);
fireEvent(event);
}
}, "Your custom text", "Your title", POptionType.YES_NO_CANCEL_OPTION);
}
});
addLabel("PConfirmDialogBox");
final PButton anchor6 = addButton("Open");
anchor6.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent clickEvent) {
PConfirmDialog.show("Question ?", new PLabel("This is a confirm dialog box"));
}