Module MaterialFX
Class MFXNotificationCenterSystem
java.lang.Object
io.github.palexdev.materialfx.notifications.base.AbstractMFXNotificationSystem
io.github.palexdev.materialfx.notifications.MFXNotificationCenterSystem
- All Implemented Interfaces:
INotificationSystem
Implementation of an
AbstractMFXNotificationSystem
which makes use of a MFXNotificationCenter
to show the notifications.-
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 void
close()
Sets the closing property to true, immediately closes the notification center, computes the popup's position as aTransitionPositionBean
and then sets the popup's coordinates (animated or not).protected TransitionPositionBean
Computes the position of the popup as aTransitionPositionBean
to be used in animations too.dispose()
Closes and disposes the notification system if not needed anymore.Returns the instance of the notification center used by this notification system.protected void
init()
Initializes the popup's position for the specifiedNotificationPos
.A notification system should be initialized to honor the behavior of a owner Window.static MFXNotificationCenterSystem
instance()
boolean
Specifies if the notification center should be opened when a new notification is sent.publish
(INotification notification) If the notification system is closing, exits andscheduleReopen(INotification)
is called.protected void
scheduleReopen
(INotification notification) Adds a one-time listener to the closing property so that when it becomes false the notification that could not be shown will be sent topublish(INotification)
again.setAnimated
(boolean animated) Enables/Disables animations.setOpenOnNew
(boolean openOnNew) protected void
show()
Sets the showing property to true, computes the popup position as aTransitionPositionBean
, then positions the popup (animated or not), and tells the notification center to open.Methods inherited from class io.github.palexdev.materialfx.notifications.base.AbstractMFXNotificationSystem
delaySetPosition, getCloseAfter, getPosition, getScreen, getSpacing, isAnimated, isCloseAutomatically, isClosing, isShowing, 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:
init
in classAbstractMFXNotificationSystem
-
publish
If the notification system is closing, exits andscheduleReopen(INotification)
is called.Adds the notification to the
MFXNotificationCenter
then if the notification system is set to close automatically starts the closePauseTransition
.If the notification center is in "Do not disturb mode" exits immediately otherwise shows the popup (the content is still hidden tough so it's not really open), then shown the bell icon and if
isOpenOnNew()
is true,show()
is called.- 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), and tells the notification center to open.- Specified by:
show
in classAbstractMFXNotificationSystem
-
close
protected void close()Sets the closing property to true, immediately closes the notification center, computes the popup's position as aTransitionPositionBean
and then sets the popup's coordinates (animated or not). At the end always hides the popup, and resets the showing/closing properties.- Specified by:
close
in classAbstractMFXNotificationSystem
-
scheduleReopen
Adds a one-time listener to the closing property so that when it becomes false the notification that could not be shown will be sent topublish(INotification)
again.- Specified by:
scheduleReopen
in classAbstractMFXNotificationSystem
-
computePosition
Computes the position of the popup as aTransitionPositionBean
to be used in animations too.- Specified by:
computePosition
in classAbstractMFXNotificationSystem
-
dispose
Description copied from interface:INotificationSystem
Closes and disposes the notification system if not needed anymore. -
getCenter
Returns the instance of the notification center used by this notification system. WARN: do not mess around too much with it since the notification system is highly dependent on the notification center. For this reason I also warn you that this method could be deprecated and removed in the future, maybe replaced by delegates methods to expose only a few features. -
setAnimated
Enables/Disables animations. Overridden to also enable/disable the notification center's animations.- Overrides:
setAnimated
in classAbstractMFXNotificationSystem
-
isOpenOnNew
public boolean isOpenOnNew()Specifies if the notification center should be opened when a new notification is sent. -
setOpenOnNew
-