Package it.tidalwave.util.ui
Class UserNotificationWithFeedback
java.lang.Object
it.tidalwave.util.ui.UserNotification
it.tidalwave.util.ui.UserNotificationWithFeedback
This class models a user notification where a feedback is expected (confirmation or cancellation).
- Author:
- Fabrizio Giudici
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class provides a few callback methods to notify a choice from the user. -
Field Summary
FieldsFields inherited from class it.tidalwave.util.ui.UserNotification
caption, text -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedUserNotificationWithFeedback(String text, String caption, UserNotificationWithFeedback.Feedback feedback) -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Notifies a cancellation to the user notification.voidconfirm()Notifies a confirmation to the user notification.feedback()Creates a newFeedbackthat does nothing.static UserNotificationWithFeedbackCreates a notification with empty caption and text.withCaption(Class<?> bundleClass, String resourceName, Object... params) Associates a caption to the notification, retrieved from a resource bundle.withCaption(String caption) Associates a caption to the notification.Associates aUserNotificationWithFeedback.Feedbackto the notification.Associates a text to the notification, retrieved from a resource bundle.Associates a text to the notification.Methods inherited from class it.tidalwave.util.ui.UserNotification
notification
-
Field Details
-
feedback
-
-
Constructor Details
-
UserNotificationWithFeedback
protected UserNotificationWithFeedback(@Nonnull String text, @Nonnull String caption, @Nonnull UserNotificationWithFeedback.Feedback feedback) - Parameters:
text- the notification textcaption- the notification captionfeedback- the feedback
-
-
Method Details
-
notificationWithFeedback
Creates a notification with empty caption and text.- Returns:
- the notification
-
withCaption
Associates a caption to the notification.- Overrides:
withCaptionin classUserNotification- Parameters:
caption- the caption- Returns:
- the notification
-
withCaption
@Nonnull public UserNotificationWithFeedback withCaption(@Nonnull Class<?> bundleClass, @Nonnull String resourceName, @Nonnull Object... params) Associates a caption to the notification, retrieved from a resource bundle.- Overrides:
withCaptionin classUserNotification- Parameters:
bundleClass- the class where to search the resource bundle fromresourceName- the resource name of the caption in the bundleparams- some (optional) parameters to the resource- Returns:
- the notification
-
withText
Associates a text to the notification.- Overrides:
withTextin classUserNotification- Parameters:
text- the text- Returns:
- the notification
-
withText
@Nonnull public UserNotificationWithFeedback withText(@Nonnull Class<?> bundleClass, @Nonnull String resourceName, @Nonnull Object... params) Associates a text to the notification, retrieved from a resource bundle.- Overrides:
withTextin classUserNotification- Parameters:
bundleClass- the class where to search the resource bundle fromresourceName- the resource name of the text in the bundleparams- some (optional) parameters to the resource- Returns:
- the notification
-
withFeedback
@Nonnull public UserNotificationWithFeedback withFeedback(@Nonnull UserNotificationWithFeedback.Feedback feedback) Associates aUserNotificationWithFeedback.Feedbackto the notification.- Parameters:
feedback- theFeedbackto associate- Returns:
- the notification
-
confirm
Notifies a confirmation to the user notification.- Throws:
Exception- in cases of error
-
cancel
Notifies a cancellation to the user notification.- Throws:
Exception- in cases of error
-
feedback
Creates a newFeedbackthat does nothing. This method should be chained withwithOnConfirm()and/orwithOnCancel(Callback)to specify the relative callbacks.feedback().withOnConfirm(this::doSomething).withOnCancel(this::doSomethingElse);
- Returns:
- a feedback that does nothing in any case
- Since:
- 3.2-ALPHA-1 (was previously on
Feedback8
-