public static PConfirmDialog buildPopup(final String windowCaption, final PWidget content, final String okCaption, final String cancelCaption, final PConfirmDialogHandler confirmDialogHandler) {
final PConfirmDialog confirmDialog = new PConfirmDialog();
confirmDialog.setStyleName(PonySDKTheme.DIALOGBOX);
confirmDialog.setAnimationEnabled(true);
confirmDialog.setGlassEnabled(true);
final PVerticalPanel dialogContent = new PVerticalPanel();
dialogContent.setWidth("100%");
dialogContent.add(content);
final PHorizontalPanel controlsPanel = new PHorizontalPanel();
controlsPanel.setStyleName(PonySDKTheme.DIALOGBOX_CONTROLS);
controlsPanel.setHorizontalAlignment(PHorizontalAlignment.ALIGN_CENTER);
controlsPanel.setWidth("100%");
if (cancelCaption != null) {
final PButton cancelButton = new PButton();
cancelButton.setText(cancelCaption);
cancelButton.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent clickEvent) {
if (confirmDialogHandler != null) {
confirmDialogHandler.onCancel();
}
confirmDialog.hide();
}
});
controlsPanel.add(cancelButton);
confirmDialog.setCancelButton(cancelButton);
}
if (okCaption != null) {
final PButton okButton = new PButton();
okButton.setText(okCaption);
okButton.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent clickEvent) {
if (confirmDialogHandler != null) {
if (confirmDialogHandler.onOK(confirmDialog)) confirmDialog.hide();
} else confirmDialog.hide();
}
});
controlsPanel.add(okButton);
confirmDialog.setOkButton(okButton);
}
dialogContent.add(controlsPanel);
dialogContent.setCellHorizontalAlignment(controlsPanel, PHorizontalAlignment.ALIGN_CENTER);
dialogContent.setCellHorizontalAlignment(content, PHorizontalAlignment.ALIGN_CENTER);
confirmDialog.setCaption(windowCaption);
confirmDialog.setWidget(dialogContent);
return confirmDialog;
}