Showing alerts

Alert

Alerts are modal messages that show up in the context the user is currently working in. You can use alerts to confirm that an action should be executed, inform the user of harmful consequences, or report the progress of a long-running action. Since alerts are modal they block the user interface.

Use AlertBuilder to build various alerts.

Usage examples:

// Show an ERROR alert.
void openErrorAlert(String message, Runnable confirmationHandler) {
   AlertBuilder.alert("Error")
                .withLevel(Notification.Type.ERROR_MESSAGE)
                .withBody(message)
                .withConfirmationHandler(confirmationHandler)
                .withOkButtonCaption("OK")
                .buildAndOpen();
}

// Confirm deletion with a WARNING alert.
void openConfirmationWarning(String message, Runnable confirmationHandler) {
    AlertBuilder.confirmDialog("Delete node?")
                .withLevel(Notification.Type.WARNING_MESSAGE)
                .withBody("This action cannot be undone.")
                .withConfirmationHandler(confirmationHandler)
                .withConfirmButtonCaption("Yes, Delete")
                .withDeclineButtonCaption("No")
                .buildAndOpen();
}
Feedback