java.lang.Object
io.github.palexdev.materialfx.notifications.base.AbstractMFXNotificationSystem
io.github.palexdev.materialfx.notifications.MFXNotificationSystem
- All Implemented Interfaces:
INotificationSystem
Simple implementation of an
AbstractMFXNotificationSystem which makes use of
a CircularQueue to keep a history of the shown notifications (by default max size is 100),
and a list to keep a reference to queued notifications that can't be shown at the moment of publish(INotification)
and that will be sent to scheduleReopen(INotification) instead.-
Field Summary
Fields inherited from class io.github.palexdev.materialfx.notifications.base.AbstractMFXNotificationSystem
animated, closeAfter, closeAfterTransition, closeAutomatically, closing, dummyStage, onClose, owner, popup, position, screen, showing, spacing -
Method Summary
Modifier and TypeMethodDescriptionprotected voidclose()Sets the closing property to true and hides the notification.protected TransitionPositionBeanComputes the position of the popup as aTransitionPositionBeanto be used in animations too.dispose()Closes and disposes the notification system if not needed anymore.history()Returns the list of shown notifications.protected voidinit()Initializes the popup's position for the specifiedNotificationPos.A notification system should be initialized to honor the behavior of a owner Window.static MFXNotificationSysteminstance()publish(INotification notification) If the notification system is showing/closing, exits andscheduleReopen(INotification)is called.protected voidscheduleReopen(INotification notification) Adds the notification to the queued notifications list, then adds a one-time listener to the closing property so that when it becomes false a notification is removed from the queue and then sent topublish(INotification)again.setHistoryLimit(int size) Delegate toCircularQueue.setSize(int).protected voidshow()Sets the showing property to true, computes the popup position as aTransitionPositionBean, then positions the popup (animated or not).Methods inherited from class io.github.palexdev.materialfx.notifications.base.AbstractMFXNotificationSystem
delaySetPosition, getCloseAfter, getPosition, getScreen, getSpacing, isAnimated, isCloseAutomatically, isClosing, isShowing, setAnimated, setCloseAfter, setCloseAutomatically, setPosition, setScreen, setSpacing
-
Method Details
-
instance
-
initOwner
A notification system should be initialized to honor the behavior of a owner Window. (for example if the owner closes that the notification system closes too) This method must be called before the notification system can be used.Also calls
dispose()before initializing. -
init
protected void init()Initializes the popup's position for the specifiedNotificationPos.- Overrides:
initin classAbstractMFXNotificationSystem
-
publish
If the notification system is showing/closing, exits andscheduleReopen(INotification)is called.Adds the notification to the notifications queue then if the notification system is set to close automatically starts the close
PauseTransition.Shows the popup (the content is still hidden tough so it's not really open), then forces the notification container to compute its bounds (should not be necessary though), shown the content and calls
show().- Throws:
IllegalStateException- if the notification system has not been initialized
-
show
protected void show()Sets the showing property to true, computes the popup position as aTransitionPositionBean, then positions the popup (animated or not).- Specified by:
showin classAbstractMFXNotificationSystem
-
close
protected void close()Sets the closing property to true and hides the notification. At the end always hides the popup, and resets the showing/closing properties.- Specified by:
closein classAbstractMFXNotificationSystem
-
scheduleReopen
Adds the notification to the queued notifications list, then adds a one-time listener to the closing property so that when it becomes false a notification is removed from the queue and then sent topublish(INotification)again.- Specified by:
scheduleReopenin classAbstractMFXNotificationSystem
-
computePosition
Computes the position of the popup as aTransitionPositionBeanto be used in animations too.- Specified by:
computePositionin classAbstractMFXNotificationSystem
-
dispose
Description copied from interface:INotificationSystemCloses and disposes the notification system if not needed anymore. -
history
Returns the list of shown notifications. -
setHistoryLimit
Delegate toCircularQueue.setSize(int).
-