Class NotificationManager
- java.lang.Object
-
- com.nomagic.magicdraw.ui.notification.NotificationManager
-
@OpenApiAll public class NotificationManager extends java.lang.ObjectEntry 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 classNotificationManager.QueuedNotificationHelper 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 classNotificationManager.QueuedNotificationTypeTypes of de-referred notification messages
-
Field Summary
Fields Modifier and Type Field Description private NotificationViewBuilderapplicationNotificationsBuilderprivate EnvironmentOptions.EnvironmentChangeListenerchangeListenerprivate NotificationViewBuildercontainerNotificationsBuilderprivate NotificationViewConfigerrorConfigprivate NotificationViewConfiginfoConfigprivate static NotificationManagerinstanceprivate java.util.Queue<NotificationManager.QueuedNotification>messageQueueprivate java.util.Collection<java.util.function.Predicate<Notification>>notificationShowingConfiguratorsprivate NotificationViewConfigwarningConfig
-
Constructor Summary
Constructors Modifier Constructor Description protectedNotificationManager()Creates new Notification manager instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNotificationShowingConfigurator(java.util.function.Predicate<Notification> notificationShowingConfigurator)Adds custom logic configurator in order to limit shown notifications.private voidaddNotificationToQueue(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.NotificationViewBuildergetApplicationNotificationsBuilder()Returns builder that creates and displays application notificationsNotificationViewConfiggetConfig(Notification notification)Helper method that returns predefined display parameters determined by notification severity level.NotificationViewBuildergetContainerNotificationsBuilder()Returns builder that creates and displays container notificationsNotificationViewConfiggetErrorConfig()Returns display parameters for notification with severity errorNotificationViewConfiggetInfoConfig()Returns display parameters for notification with severity infostatic NotificationManagergetInstance()Returns single Notification manger instanceNotificationViewConfiggetWarningConfig()Returns display parameters for notification with severity warningvoidhideNotifications(java.awt.Component owner)Hides all notifications for component.voidhideNotifications(java.lang.String notificationID)Hides notifications with specified idprivate static booleanisMainFrame()booleanisNotificationVisible(java.lang.String notificationID)Returns true if notification with specified id is shownvoidlogHyperlinkedTextNotifications(java.lang.String text, java.util.Map<java.lang.String,java.lang.Runnable> callbacks)Logs hyperlinked text to Notification window without displaying balloon message.voidopenNotificationWindow(Notification notification, boolean openWindow)Shows notification in notification windowvoidsetApplicationNotificationsBuilder(NotificationViewBuilder applicationNotificationsBuilder)Sets builder that creates and displays application notificationsvoidsetContainerNotificationsBuilder(NotificationViewBuilder containerNotificationsBuilder)Sets builder that creates and displays container notificationsvoidshowNotification(Notification notification)Shows application level notification in right bottom corner with default display parameters.voidshowNotification(Notification notification, NotificationViewConfig config)Shows application level notification in right bottom corner with display parameters specified in config object.voidshowNotification(Notification notification, java.awt.Component owner)Shows application or container level notification with default display parameters.voidshowNotification(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.
-
-