Package com.nomagic.magicdraw.core
Class Application
java.lang.Object
com.nomagic.magicdraw.core.Application
Main class which connects main parts of MagicDraw.
This class is singleton, only one instance of this class can exist.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Contains application environment specific constants and utility methods.static class
Contains application runtime related constants and utility methods. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addActivityAfterStartup
(Runnable activity) Registered runnable is executed right after MagicDraw application startup.void
addNewDiagramType
(DiagramDescriptor descriptor) Registers new diagram type in the MagicDraw application.final void
addProjectEventListener
(ProjectEventListener listener) Method adds new ProjectEventListener.void
addSaveParticipant
(SaveParticipant participant) Registers SaveParticipant for custom actions on project saving.static Application.Environment
Gets application environment.final CookieSet
Returns cookie set of the application.Gets application environment options.Returns the interface to log window.static Application
Returns single instance of Application.Returns the mainFrame - main MagicDraw GUI component.Returns current active Project.Returns the projectsManager.List of registered SaveParticipants.boolean
Checks if it is allowed to load project on startup.void
Loads alias.properties file into memory.void
Method removes ProjectEventListener.void
removeSaveParticipant
(SaveParticipant participant) Unregister custom SaveParticipant.static Application.Runtime
runtime()
Gets application runtime.void
setApplicationName
(String name) Set the name of the application.void
shutdown()
Shutdowns the application.void
start
(boolean visible, boolean silentMode, boolean tryToLoadProject, String[] args, StartupParticipant participant) Starts the application.void
Starts the application.
-
Constructor Details
-
Application
@OpenApi protected Application()Constructor of Application.
-
-
Method Details
-
loadAliases
Loads alias.properties file into memory. If alias were already loaded reload it.- Throws:
Exception
- in case of some error
-
getEnvironmentOptions
Gets application environment options.- Returns:
- application environment options.
-
getInstance
Returns single instance of Application.- Returns:
- single instance of Application.
-
getProject
Returns current active Project.- Returns:
- current project, null if there is no current project.
-
getProjectsManager
Returns the projectsManager.- Returns:
- ProjectsManager
-
getMainFrame
Returns the mainFrame - main MagicDraw GUI component.- Returns:
- MainFrame
-
setApplicationName
Set the name of the application.- Parameters:
name
- application name
-
start
Starts the application.- Parameters:
args
- command line arguments passed to MagicDraw.- Throws:
ApplicationExitedException
- in case of some error
-
start
@OpenApi public void start(boolean visible, boolean silentMode, boolean tryToLoadProject, 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.
-
shutdown
Shutdowns the application. User will be asked to save all opened projects before exiting the application.- Throws:
ApplicationExitedException
- in case of some error
-
getGUILog
Returns the interface to log window.- Returns:
- window for writing messages.
-
addProjectEventListener
Method adds new ProjectEventListener.- Parameters:
listener
- listener to be added.
-
removeProjectEventListener
Method removes ProjectEventListener.- Parameters:
listener
- to be removed.
-
addActivityAfterStartup
Registered runnable is executed right after MagicDraw application startup.- Parameters:
activity
- runnable to execute.
-
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.
-
addNewDiagramType
Registers new diagram type in the MagicDraw application.- Parameters:
descriptor
- descriptor of the new diagram.
-
getSaveParticipants
List of registered SaveParticipants.- Returns:
- list of registered Save Participants.
-
addSaveParticipant
Registers SaveParticipant for custom actions on project saving.- Parameters:
participant
- the custom SaveParticipant.
-
removeSaveParticipant
Unregister custom SaveParticipant.- Parameters:
participant
- the custom SaveParticipant.
-
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.
-
runtime
Gets application runtime.- Returns:
- application runtime.
-
environment
Gets application environment.- Returns:
- application environment.
-