Package com.nomagic.magicdraw.core
Class Application
- java.lang.Object
-
- com.nomagic.magicdraw.core.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Application.Environment
Contains application environment specific constants and utility methods.static class
Application.Runtime
Contains application runtime related constants and utility methods.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Application()
Constructor of Application.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addActivityAfterStartup(java.lang.Runnable activity)
Registered runnable is executed right after MagicDraw application startup.void
addNewDiagramType(DiagramDescriptor descriptor)
Registers new diagram type in the MagicDraw application.void
addProjectEventListener(ProjectEventListener listener)
Method adds new ProjectEventListener.void
addSaveParticipant(SaveParticipant participant)
Registers SaveParticipant for custom actions on project saving.static Application.Environment
environment()
Gets application environment.CookieSet
getCookieSet()
Returns cookie set of the application.EnvironmentOptions
getEnvironmentOptions()
Gets application environment options.GUILog
getGUILog()
Returns the interface to log window.static Application
getInstance()
Returns single instance of Application.MainFrame
getMainFrame()
Returns the mainFrame - main MagicDraw GUI component.Project
getProject()
Returns current active Project.ProjectsManager
getProjectsManager()
Returns the projectsManager.java.util.List<SaveParticipant>
getSaveParticipants()
List of registered SaveParticipants.boolean
isTryToLoadProject()
Checks if it is allowed to load project on startup.void
loadAliases()
Loads alias.properties file into memory.void
removeProjectEventListener(ProjectEventListener listener)
Method removes ProjectEventListener.void
removeSaveParticipant(SaveParticipant participant)
Unregister custom SaveParticipant.static Application.Runtime
runtime()
Gets application runtime.void
setApplicationName(java.lang.String name)
Set the name of the application.void
shutdown()
Shutdowns the application.void
start(boolean visible, boolean silentMode, boolean tryToLoadProject, java.lang.String[] args, StartupParticipant participant)
Starts the application.void
start(java.lang.String[] args)
Starts the application.
-
-
-
Method Detail
-
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
-
getEnvironmentOptions
@OpenApi public EnvironmentOptions getEnvironmentOptions()
Gets application environment options.- Returns:
- application environment options.
-
getInstance
@OpenApi public static Application getInstance()
Returns single instance of Application.- Returns:
- single instance of Application.
-
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
-
setApplicationName
@OpenApi public void setApplicationName(java.lang.String name)
Set the name of the application.- Parameters:
name
- application name
-
start
@OpenApi public void start(java.lang.String[] args) throws ApplicationExitedException
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, 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.
-
shutdown
@OpenApi public void shutdown() throws ApplicationExitedException
Shutdowns the application. User will be asked to save all opened projects before exiting the application.- Throws:
ApplicationExitedException
- in case of some error
-
getGUILog
@OpenApi public GUILog getGUILog()
Returns the interface to log window.- Returns:
- window for writing messages.
-
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.
-
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.
-
addNewDiagramType
@OpenApi public void addNewDiagramType(DiagramDescriptor descriptor)
Registers new diagram type in the MagicDraw application.- Parameters:
descriptor
- descriptor of the new diagram.
-
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.
-
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
@OpenApi public static Application.Runtime runtime()
Gets application runtime.- Returns:
- application runtime.
-
environment
@OpenApi public static Application.Environment environment()
Gets application environment.- Returns:
- application environment.
-
-