Class Application


  • @OpenApi
    public class Application
    extends java.lang.Object
    Main class which connects main parts of MagicDraw. This class is singleton, only one instance of this class can exist.
    • Field Detail

      • cookieSet

        private final CookieSet cookieSet
      • instance

        private static Application instance
        Single instance of Application.
      • projectsManager

        private ProjectsManager projectsManager
        Manages projects.
      • mainFrame

        private MainFrame mainFrame
        GUI Frame.
      • actionsManager

        private com.nomagic.magicdraw.actions.ActionsManager actionsManager
        Manages main Actions.
      • tipsManager

        private com.nomagic.magicdraw.core.TipsManager tipsManager
        Tips manager instance.
      • pluginsManager

        private com.nomagic.magicdraw.plugins.PluginsManager pluginsManager
        Manager manages plugins.
      • propertyResourceManager

        private com.nomagic.magicdraw.properties.PropertyResourceManager propertyResourceManager
        Manager of property resources.
      • guiLog

        private GUILog guiLog
        Log for displaying messages.
      • recentFilesManager

        private com.nomagic.magicdraw.ui.RecentFilesManager recentFilesManager
        Manager manages recent files.
      • activitiesAfterStartup

        @CheckForNull
        private java.util.List<java.lang.Runnable> activitiesAfterStartup
        List of Runnable to be run after startup.
      • activitiesOnUICreation

        @CheckForNull
        private java.util.List<java.lang.Runnable> activitiesOnUICreation
        List of Runnable to be run on UI creation.
      • saveParticipants

        private final java.util.List<SaveParticipant> saveParticipants
        List of Save Participants.
      • applicationEventListeners

        private final java.util.Collection<com.nomagic.magicdraw.core.ApplicationEventListener> applicationEventListeners
        Holds application event listeners.
      • canCreateNewProject

        private boolean canCreateNewProject
      • showFirstStartupDlg

        private java.util.function.Supplier<java.lang.Boolean> showFirstStartupDlg
        Indicates if first startup dialog should be shown.
      • integratorsManager

        private final com.nomagic.magicdraw.integrations.IntegratorsManager integratorsManager
      • tryToLoadProject

        private java.util.function.Supplier<java.lang.Boolean> tryToLoadProject
      • isPluginsInitialized

        private boolean isPluginsInitialized
        Flag which shows if plug-ins already initialized.
      • alias

        private final com.nomagic.magicdraw.core.Alias alias
      • runtimeInternal

        private static com.nomagic.magicdraw.core.Application.RuntimeInternal runtimeInternal
      • environmentInternal

        private static final com.nomagic.magicdraw.core.Application.EnvironmentInternal environmentInternal
      • webInternal

        private static final com.nomagic.magicdraw.core.Application.WebInternal webInternal
      • applicationTitleConfigurator

        @CheckForNull
        private static java.util.function.Function<java.lang.String,​java.lang.String> applicationTitleConfigurator
    • Constructor Detail

      • Application

        @OpenApi
        protected Application()
        Constructor of Application.
    • Method Detail

      • resolveAlias

        public java.lang.String resolveAlias​(java.lang.String type,
                                             java.lang.String name)
      • loadAliases

        @OpenApi
        public void loadAliases()
                         throws java.lang.Exception
        Loads alias.properties file into memory. If alias were already loaded reload it.
        Throws:
        java.lang.Exception - in case of some error
      • addAlias

        public void addAlias​(java.lang.String type,
                             java.lang.String alias,
                             java.lang.String value)
      • setApplicationTitleConfigurator

        public void setApplicationTitleConfigurator​(java.util.function.Function<java.lang.String,​java.lang.String> configurator)
      • getEnvironmentOptions

        @OpenApi
        public EnvironmentOptions getEnvironmentOptions()
        Gets application environment options.
        Returns:
        application environment options.
      • saveEnvironmentOptions

        public void saveEnvironmentOptions()
        Saves environment options to file.
      • getInstance

        @OpenApi
        public static Application getInstance()
        Returns single instance of Application.
        Returns:
        single instance of Application.
      • getPluginManager

        public com.nomagic.magicdraw.plugins.PluginsManager getPluginManager()
        Method getPluginManager.
        Returns:
        PluginsManager manager for loading, starting stopping plugins.
      • getPropertyResourceManager

        public com.nomagic.magicdraw.properties.PropertyResourceManager getPropertyResourceManager()
        Returns propertyResourceManager for managing property resources.
        Returns:
        manager for providing custom property resources.
      • getFLManager

        public com.nomagic.rcpf.product.lic.floating.client.internal.FLManager getFLManager()
        Method getFLManager.
        Returns:
        PluginsManager manager for loading, starting stopping plugins.
      • getProject

        @CheckForNull
        @OpenApi
        public Project getProject()
        Returns current active Project.
        Returns:
        current project, null if there is no current project.
      • getProjectsManager

        @OpenApi
        public ProjectsManager getProjectsManager()
        Returns the projectsManager.
        Returns:
        ProjectsManager
      • getMainFrame

        @OpenApi
        public MainFrame getMainFrame()
        Returns the mainFrame - main MagicDraw GUI component.
        Returns:
        MainFrame
      • setMainFrame

        void setMainFrame​(MainFrame mainFrame)
      • setApplicationName

        @OpenApi
        public void setApplicationName​(java.lang.String name)
        Set the name of the application.
        Parameters:
        name - application name
      • getActionsManager

        public com.nomagic.magicdraw.actions.ActionsManager getActionsManager()
        Returns the actionsManager.
        Returns:
        ActionsManager
      • getTipsManager

        public com.nomagic.magicdraw.core.TipsManager getTipsManager()
        Returns the tipsManager.
        Returns:
        TipsManager
      • start

        @OpenApi
        public void start​(boolean visible,
                          boolean silentMode,
                          boolean tryToLoadProject,
                          java.lang.String[] args,
                          @CheckForNull
                          StartupParticipant participant)
                   throws ApplicationExitedException
        Starts the application.
        Parameters:
        visible - start MagicDraw as visible frame?
        silentMode - true if GUI must be in silent mode(batch mode).
        tryToLoadProject - true if application should try to load file passed as argument.
        args - command line arguments passed to MagicDraw.
        participant - the participant of startup process. May be null.
        Throws:
        ApplicationExitedException - if application exists during the startup.
      • checkFilePassedWithSpaces

        private static java.lang.String[] checkFilePassedWithSpaces​(java.lang.String[] args)
      • setInitialLF

        public void setInitialLF()
        Set initial L&F
      • provideProperAppNameForLinux

        private static void provideProperAppNameForLinux()
        Oracle bug JDK-6528430 official workaround.
      • internalStart

        public byte internalStart​(com.nomagic.magicdraw.core.Application.MainFrameController mfController,
                                  boolean silentMode,
                                  boolean tryToLoadProject,
                                  @CheckForNull
                                  StartupParticipant participant)
        Starts the application.
        Parameters:
        mfController - the controller for controlling the main window appearance.
        silentMode - true if GUI must be in silent mode.
        tryToLoadProject - true if application should try to load file passed as argument.
        participant - the participant of startup process. May be null.
        Returns:
        STARTUP_SUCCESSFUL if starting was without fatal errors, STARTUP_CANCELED - canceled by the user on dialogs, STARTUP_ERROR - on any error
      • executeActivitiesAfterStartup

        void executeActivitiesAfterStartup()
        Executes activities
      • executeActivitiesOnUICreation

        public final void executeActivitiesOnUICreation()
        Executes registered UI activities.
      • executeActivities

        static void executeActivities​(java.util.Collection<java.lang.Runnable> activities)
        Execute given activities. During the execution new activities can be added into a source collection, so repeat execution until all activities are executed
        Parameters:
        activities - activities
      • shutdown

        public void shutdown​(boolean force)
        Shutdowns the application. User will be asked to save all opened projects before exiting the application.
        Parameters:
        force - exit the application in any case (ignore if project is not saved if plugin is not closed).
      • shutdown

        public void shutdown​(byte exitStatus,
                             boolean force)
      • getGUILog

        @OpenApi
        public GUILog getGUILog()
        Returns the interface to log window.
        Returns:
        window for writing messages.
      • setGUILog

        public void setGUILog​(GUILog log)
      • getOpenAPIVersion

        public java.lang.String getOpenAPIVersion()
        Version of OpenAPI
        Returns:
        version of OpenAPI.
      • getRecentFilesManager

        public com.nomagic.magicdraw.ui.RecentFilesManager getRecentFilesManager()
        Returns the recentFilesManager.
        Returns:
        RecentFilesManager
      • addProjectEventListener

        @OpenApi
        public final void addProjectEventListener​(ProjectEventListener listener)
        Method adds new ProjectEventListener.
        Parameters:
        listener - listener to be added.
      • removeProjectEventListener

        @OpenApi
        public void removeProjectEventListener​(ProjectEventListener listener)
        Method removes ProjectEventListener.
        Parameters:
        listener - to be removed.
      • addActivityAfterStartup

        @OpenApi
        public void addActivityAfterStartup​(java.lang.Runnable activity)
        Registered runnable is executed right after MagicDraw application startup.
        Parameters:
        activity - runnable to execute.
      • addActivityOnUICreation

        public void addActivityOnUICreation​(java.lang.Runnable activity)
        Runnable which will be run on UI creation.
        Parameters:
        activity - instance of Runnable
      • insertActivityAfterStartup

        public void insertActivityAfterStartup​(java.lang.Runnable activity)
      • getActivitiesAfterStartup

        private java.util.List<java.lang.Runnable> getActivitiesAfterStartup()
        Returns the activitiesAfterStartup.
        Returns:
        List
      • getActivitiesOnUICreation

        private java.util.List<java.lang.Runnable> getActivitiesOnUICreation()
        Returns list for UI creation activities.
        Returns:
        list of Runnable
      • getCookieSet

        @OpenApi
        public final CookieSet getCookieSet()
        Returns cookie set of the application.
        This cookie set may be used for example to replace standard application CloseCookie with some other.
        The example:
        CookieSet set = application.getCookieSet();
        CloseCookie newCloseCookie = ...;
        CloseCookie close = (CloseCookie) set.getCookie(CloseCookie.class);
        set.remove(close);
        set.add(newCloseCookie);
        Returns:
        cookie set of the application.
      • exit

        public void exit​(byte exitStatus)
        Exits the application. Calls close method for registered CloseCookie.
        Parameters:
        exitStatus - exit code
      • exit

        public void exit()
        Exits the application with Application.STARTUP_ERROR exit code. Calls close method for registered CloseCookie.
      • addNewDiagramType

        @OpenApi
        public void addNewDiagramType​(DiagramDescriptor descriptor)
        Registers new diagram type in the MagicDraw application.
        Parameters:
        descriptor - descriptor of the new diagram.
      • getAlias

        public com.nomagic.magicdraw.core.Alias getAlias()
      • getSaveParticipants

        @OpenApi
        public java.util.List<SaveParticipant> getSaveParticipants()
        List of registered SaveParticipants.
        Returns:
        list of registered Save Participants.
      • addSaveParticipant

        @OpenApi
        public void addSaveParticipant​(SaveParticipant participant)
        Registers SaveParticipant for custom actions on project saving.
        Parameters:
        participant - the custom SaveParticipant.
      • removeSaveParticipant

        @OpenApi
        public void removeSaveParticipant​(SaveParticipant participant)
        Unregister custom SaveParticipant.
        Parameters:
        participant - the custom SaveParticipant.
      • getVersionManager

        public com.nomagic.magicdraw.lic.MDVersionManager getVersionManager()
      • initMacFeatures

        private static void initMacFeatures()
      • isCanCreateNewProject

        public boolean isCanCreateNewProject()
      • setCanCreateNewProject

        public void setCanCreateNewProject​(boolean canCreateNewProject)
      • getDiagramDescriptor

        @CheckForNull
        public DiagramDescriptor getDiagramDescriptor​(java.lang.String diagramType)
        Parameters:
        diagramType - diagram type to get its descriptor.
        Returns:
        DiagramDescriptor for given type. If type is unknown return null.
      • getIntegrationsManager

        public com.nomagic.magicdraw.integrations.IntegratorsManager getIntegrationsManager()
        Returns:
        an integrations manager.
      • addApplicationEventListener

        public void addApplicationEventListener​(com.nomagic.magicdraw.core.ApplicationEventListener listener)
        Adds application event listener to application listeners.
        Parameters:
        listener - listener to add.
      • notifyPluginsInitialized

        public void notifyPluginsInitialized()
        Notifies application event listeners that plugins were initialized.
      • isTryToLoadProject

        @OpenApi
        public boolean isTryToLoadProject()
        Checks if it is allowed to load project on startup. Under integrations loading may cause deadlock and is disabled.
        Returns:
        true if project may be loaded on application startup.
      • setTryToLoadProject

        public void setTryToLoadProject​(java.util.function.Supplier<java.lang.Boolean> tryToLoadProject)
        Sets flag which indicates if it is allowed to load project on startup.
        Parameters:
        tryToLoadProject - flag which indicates if it is allowed to load project on startup
      • isShowFirstStartupDlg

        public boolean isShowFirstStartupDlg()
        Checks if first startup dialog should be shown.
        Returns:
        true if first startup dialog should be shown.
      • setShowFirstStartupDlg

        public void setShowFirstStartupDlg​(java.util.function.Supplier<java.lang.Boolean> showFirstStartupDlg)
        Sets flag which indicates if first startup dialog should be shown.
        Parameters:
        showFirstStartupDlg - flag which indicates if first startup dialog should be shown.
      • isPluginsInitialized

        public boolean isPluginsInitialized()
        Checks if plug-ins already initialized.
        Returns:
        true if plug-ins already initialized.
      • runtimeInternal

        public static com.nomagic.magicdraw.core.Application.RuntimeInternal runtimeInternal()
      • runtime

        @OpenApi
        public static Application.Runtime runtime()
        Gets application runtime.
        Returns:
        application runtime.
      • environmentInternal

        public static com.nomagic.magicdraw.core.Application.EnvironmentInternal environmentInternal()
      • environment

        @OpenApi
        public static Application.Environment environment()
        Gets application environment.
        Returns:
        application environment.
      • webInternal

        public static com.nomagic.magicdraw.core.Application.WebInternal webInternal()