Class NotificationManager
- java.lang.Object
-
- com.nomagic.magicdraw.ui.notification.NotificationManager
-
@OpenApiAll public class NotificationManager extends java.lang.Object
Entry point to display notifications in MagicDraw. Two types of notifications can be displayed: application level and container level. Container lever notifications are displayed in special container that implements NotificationsContainer interface. When show notification method is called component owner parameter should point to notification container. If application level notification must be displayed, null parameter should be passed as component owner.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
NotificationManager.QueuedNotification
Helper class that contains needed information about Notification while it is de-referred for later display (due MD main frame is not yet created)(package private) static class
NotificationManager.QueuedNotificationType
Types of de-referred notification messages
-
Field Summary
Fields Modifier and Type Field Description private NotificationViewBuilder
applicationNotificationsBuilder
private EnvironmentOptions.EnvironmentChangeListener
changeListener
private NotificationViewBuilder
containerNotificationsBuilder
private NotificationViewConfig
errorConfig
private NotificationViewConfig
infoConfig
private static NotificationManager
instance
private java.util.Queue<NotificationManager.QueuedNotification>
messageQueue
private java.util.Collection<java.util.function.Predicate<Notification>>
notificationShowingConfigurators
private NotificationViewConfig
warningConfig
-
Constructor Summary
Constructors Modifier Constructor Description protected
NotificationManager()
Creates new Notification manager instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNotificationShowingConfigurator(java.util.function.Predicate<Notification> notificationShowingConfigurator)
Adds custom logic configurator in order to limit shown notifications.private void
addNotificationToQueue(Notification notification, java.awt.Component owner, NotificationViewConfig config, boolean openWindow, NotificationManager.QueuedNotificationType type, java.util.Map<java.lang.String,java.lang.Runnable> callbacks)
Adds notification to message queue.NotificationViewBuilder
getApplicationNotificationsBuilder()
Returns builder that creates and displays application notificationsNotificationViewConfig
getConfig(Notification notification)
Helper method that returns predefined display parameters determined by notification severity level.NotificationViewBuilder
getContainerNotificationsBuilder()
Returns builder that creates and displays container notificationsNotificationViewConfig
getErrorConfig()
Returns display parameters for notification with severity errorNotificationViewConfig
getInfoConfig()
Returns display parameters for notification with severity infostatic NotificationManager
getInstance()
Returns single Notification manger instanceNotificationViewConfig
getWarningConfig()
Returns display parameters for notification with severity warningvoid
hideNotifications(java.awt.Component owner)
Hides all notifications for component.void
hideNotifications(java.lang.String notificationID)
Hides notifications with specified idprivate static boolean
isMainFrame()
boolean
isNotificationVisible(java.lang.String notificationID)
Returns true if notification with specified id is shownvoid
logHyperlinkedTextNotifications(java.lang.String text, java.util.Map<java.lang.String,java.lang.Runnable> callbacks)
Logs hyperlinked text to Notification window without displaying balloon message.void
openNotificationWindow(Notification notification, boolean openWindow)
Shows notification in notification windowvoid
setApplicationNotificationsBuilder(NotificationViewBuilder applicationNotificationsBuilder)
Sets builder that creates and displays application notificationsvoid
setContainerNotificationsBuilder(NotificationViewBuilder containerNotificationsBuilder)
Sets builder that creates and displays container notificationsvoid
showNotification(Notification notification)
Shows application level notification in right bottom corner with default display parameters.void
showNotification(Notification notification, NotificationViewConfig config)
Shows application level notification in right bottom corner with display parameters specified in config object.void
showNotification(Notification notification, java.awt.Component owner)
Shows application or container level notification with default display parameters.void
showNotification(Notification notification, java.awt.Component owner, NotificationViewConfig config)
Shows application or container level notification with specified display parameters.
-
-
-
Field Detail
-
instance
private static NotificationManager instance
-
applicationNotificationsBuilder
private NotificationViewBuilder applicationNotificationsBuilder
-
containerNotificationsBuilder
private NotificationViewBuilder containerNotificationsBuilder
-
infoConfig
private final NotificationViewConfig infoConfig
-
errorConfig
private final NotificationViewConfig errorConfig
-
warningConfig
private final NotificationViewConfig warningConfig
-
messageQueue
private final java.util.Queue<NotificationManager.QueuedNotification> messageQueue
-
notificationShowingConfigurators
private final java.util.Collection<java.util.function.Predicate<Notification>> notificationShowingConfigurators
-
changeListener
private final EnvironmentOptions.EnvironmentChangeListener changeListener
-
-
Method Detail
-
getInstance
public static NotificationManager getInstance()
Returns single Notification manger instance- Returns:
- Notification manager instance
-
openNotificationWindow
public void openNotificationWindow(Notification notification, boolean openWindow)
Shows notification in notification window- Parameters:
notification
- notificationopenWindow
- flag, if true opens notification window
-
showNotification
public void showNotification(Notification notification)
Shows application level notification in right bottom corner with default display parameters.- Parameters:
notification
- notification to show
-
showNotification
public void showNotification(Notification notification, NotificationViewConfig config)
Shows application level notification in right bottom corner with display parameters specified in config object.- Parameters:
notification
- notification to showconfig
- notification display parameters
-
showNotification
public void showNotification(Notification notification, @CheckForNull java.awt.Component owner)
Shows application or container level notification with default display parameters. If owner is not null and implements NotificationsContainer interface, the notification is displayed in owner's specific display area.- Parameters:
notification
- notification to showowner
- notification display container
-
showNotification
public void showNotification(Notification notification, @CheckForNull java.awt.Component owner, NotificationViewConfig config)
Shows application or container level notification with specified display parameters. If owner is not null and implements NotificationsContainer interface, the notification is displayed in owner's specific display area.- Parameters:
notification
- notification to showowner
- notification display containerconfig
- notification display parameters
-
hideNotifications
public void hideNotifications(java.lang.String notificationID)
Hides notifications with specified id- Parameters:
notificationID
- notification id
-
hideNotifications
public void hideNotifications(@CheckForNull java.awt.Component owner)
Hides all notifications for component.
-
isNotificationVisible
public boolean isNotificationVisible(java.lang.String notificationID)
Returns true if notification with specified id is shown- Parameters:
notificationID
- notification id
-
logHyperlinkedTextNotifications
public void logHyperlinkedTextNotifications(java.lang.String text, java.util.Map<java.lang.String,java.lang.Runnable> callbacks)
Logs hyperlinked text to Notification window without displaying balloon message.- Parameters:
text
- text with hyper links.callbacks
- callbacks that will be executed when link in text is selected
-
isMainFrame
private static boolean isMainFrame()
-
getApplicationNotificationsBuilder
public NotificationViewBuilder getApplicationNotificationsBuilder()
Returns builder that creates and displays application notifications- Returns:
- builder that creates and displays application notifications
-
setApplicationNotificationsBuilder
public void setApplicationNotificationsBuilder(NotificationViewBuilder applicationNotificationsBuilder)
Sets builder that creates and displays application notifications- Parameters:
applicationNotificationsBuilder
- builder that creates and displays application notifications
-
getContainerNotificationsBuilder
public NotificationViewBuilder getContainerNotificationsBuilder()
Returns builder that creates and displays container notifications- Returns:
- builder that creates and displays container notifications
-
setContainerNotificationsBuilder
public void setContainerNotificationsBuilder(NotificationViewBuilder containerNotificationsBuilder)
Sets builder that creates and displays container notifications- Parameters:
containerNotificationsBuilder
- builder that creates and displays container notifications
-
getErrorConfig
public NotificationViewConfig getErrorConfig()
Returns display parameters for notification with severity error- Returns:
- display parameters for notification with severity error
-
getWarningConfig
public NotificationViewConfig getWarningConfig()
Returns display parameters for notification with severity warning- Returns:
- display parameters for notification with severity warning
-
getInfoConfig
public NotificationViewConfig getInfoConfig()
Returns display parameters for notification with severity info- Returns:
- display parameters for notification with severity info
-
getConfig
public NotificationViewConfig getConfig(Notification notification)
Helper method that returns predefined display parameters determined by notification severity level.- Parameters:
notification
- notification for which display parameters should be returned- Returns:
- notification display parameters specific to its severity
-
addNotificationToQueue
private void addNotificationToQueue(@Nonnull Notification notification, @CheckForNull java.awt.Component owner, @CheckForNull NotificationViewConfig config, boolean openWindow, @Nonnull NotificationManager.QueuedNotificationType type, @CheckForNull java.util.Map<java.lang.String,java.lang.Runnable> callbacks)
Adds notification to message queue.- Parameters:
notification
- notificationowner
- notification ownerconfig
- notification display configurationopenWindow
- true if Notification window must be opentype
- notification type. Can be BALLOON, TEXT or HYPERLINKcallbacks
- list of callbacks for hyperlinked notification
-
addNotificationShowingConfigurator
public void addNotificationShowingConfigurator(java.util.function.Predicate<Notification> notificationShowingConfigurator)
Adds custom logic configurator in order to limit shown notifications.- Parameters:
notificationShowingConfigurator
- configurator which limits shown notifications. Should return true if notification should be shown.
-
-