Class 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.
    • Constructor Detail

      • NotificationManager

        protected NotificationManager()
        Creates new Notification manager instance. Constructor made protected to implement singleton pattern
    • 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 - notification
        openWindow - 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 show
        config - 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 show
        owner - 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 show
        owner - notification display container
        config - 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 - notification
        owner - notification owner
        config - notification display configuration
        openWindow - true if Notification window must be open
        type - notification type. Can be BALLOON, TEXT or HYPERLINK
        callbacks - 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.